Tuesday 30 July 2013

YOCTO - my understanding

Yocto - Its all Open source... oh wow!! That is what people exclaimed about.
To me... Yocto?? What is that??

Later I started building my understanding in the yocto and now it is my dream to establish career in or towards yocto.

In embedded OS, building image and packaging them is very important and different companies use their own build frame work to do the same. Being a part of such a team, I would admit I had some knowledge in packaging concepts. Then I was opened up to yocto.

Yocto is end to end frame work to create such images for Embedded devices. Mind it, I did not mention it as Build frame work but just mentioned it  as a framework. Of course It also has a build framework in it(which is called POKY) but that is not all.

Yocto comprises of build framework, packaging features and many more advanced features. All leading companies starting from Intel and Windriver, feel proud to be elusive members of yocto community.

Yocto has also started delivering kernel. In addition it also has virtual deployment utility - qemu. Yocto also has some test frameworks inside it. If you want anything more, it is very simple to plugin your utility with yocto and start using it. And hence in a nut-shell, it can be claimed as yocto has it all.

This is the best place for anyone new to start with
http://www.youtube.com/watch?v=zNLYanJAQ3s

Other references about yocto can be found at
https://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-project-qs.html
http://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html
http://en.wikipedia.org/wiki/Yocto_Project

Bugs in yocto can be looked at
https://bugzilla.yoctoproject.org/

This post is just to make the name "yocto" familiar.
I will post detailed findings in upcoming posts.

Thanks,
Gomathi

Thursday 25 July 2013

Writing a linux system call

WHAT IS A SYSTEM CALL?

System call is an interface (the only interface) between user space and the kernel. It is more than a normal function. It creates a trap (soft interrupt) to make the kernel perform a specific task.

Examples of System call

The applications we use might use many system calls. But as a person with limited experience we might not be aware of this fact.
Some examples include - open, chown, seek etc.

Can I write my own system call?

Of course, we can. This is the beauty of it and the same can be stated as "kernel programming":)

How do I write a system call?

It is quite simple in latest Linux kernels, unlike the older ones (2.6 and older).
The steps are elaborated below.

1. Get the source of your kernel tree.
2. There is a syscall table in the kernel, which is specific to architecture.
<kernel>/arch/<architecture>/syscalls/syscall_32.tbl
This table contains the ID of system call, its name and its function name. Add your system call entry in this file. Please make sure that you give a unique ID number to your system call based on the current number of system calls.
3. Add the prototype of the system call in include/Linux/syscalls.h file.
4. Add the system call definition in any file (new or can be appended in existing file). In case of a new file. Make necessary modification in the Makefile of parent directories recursively, until this file is treated for compilation.
NOTE : in steps 3 and 4, asmlinkage is to be done.
5. Once these modifications are done, Compile this kernel and deploy the image
a) make menuconfig
b) make
c) make modules
d) make modules_install
e) make install

6. make install will take care of copying kernel image to /boot directory and to update grub configuration.
7. reboot. Select your kernel image during board bring up.
8. Write an application that will invoke your system  all and verify that your system call exists, it is called and it works as u intended it to.
This can be done by syscall(<SYSCALL ID>,<Parameters if any>)

What else should I remember?

1. The system call can return a value and can get arguments.
2. The number of arguments that can be passed to the system call is specific to the architecture.
This is because each architecture support different number of registers. Eg : x86 supports 6 registers.
3. Because of the above difference specific to architecture, the number of system calls for same kernel version might differ from architecture to architecture.
4. Although the usage of most of the common syscalls are still the same.
5. The syscall can get parameters of size of upto unsigned long int. (size of register dependent).


 

Monday 15 July 2013

LINUX : fdisk

My first blog!!

A new learning that I received today. It is about the command fdisk.

This is a Linux command, that can be used for creating/deleting partitions.
It is abbreviation of "Fixed disk"

fdisk has command line options.

The list of all available partitions can be obtained by fdisk -l

Add an hard disk in your vm, reboot the machine and do the following,

fdisk -l
fdisk
=> n
Select primary partition. Give partition number, size.
Same way create extended partition if necessary.

=>wq
save and quit

To delete a partition, You can use
=> d
and give appropriate partition number to delete

To make the created partition usable, a file system is to be created in this partition. This can be done by mke2fs command.

you can also create ext3 file system using mkfs.ext3 command. Same way can use corresponding binaries for creating ext2, ext4 etc.

Then this partition can be mounted on a folder structure.

Eg :
mount -t ext3 <your partition> <folder where it has to be mounted>

Thanks,
Gomathi