Linux Kernel Developing
U-boot and Kernel Compilation
- Get right toolchain for your platform.
a. Ubuntu: sudo apt-get install gcc-arm-linux-gnueabi/gcc-arm-linux-gnueabihf
or
b. Get from linaro.org : wget -c https://releases.linaro.org/14.04/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2...
2. Get U-boot code source
- git clone http://git.denx.de/u-boot-imx.git
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- wandboard_quad_config
- make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
3. Get Kernel source with Wandboard support
- Wandboard repo:
- git clone https://github.com/wandboard-org/linux.git
- Select the right branch:
- git checkout wandboard_imx_3.10.17_1.0.0_beta
or
git checkout wandboard_imx_3.0.35_4.1.0
b. Kernel Configuration ( load the wandboard config )
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- wandboard_defconfig
or
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
c. Kernel Compilation
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
4. Prepare the sdcard:
I. Copy the u-boot on the sdcard
- Determine the sdcard device name : sudo df -h
- sudo umount /dev/sdd*
- sudo dd if=/<path>/u-boot.imx of=/dev/sdd bs=512 seek=2
II. Partitionating the sdcard
- sudo fdisk /dev/sdd
- o
- n
- p
- 1
- 2048
- +1G
- t
- c
- n
- p
- 2
- 12288
- +5G
- P
- sudo mkfs.vfat -n KERNEL /dev/sdd1
- sudo mkfs.ext3 -L RFS /dev/sdd2
- cd /media/
- sudo mkdir KERNEL
- sudo mkdir RFS
- sudo mount /dev/sdd1 KERNEL/
- v. sudo mount /dev/sdd2 RFS/
|||. Download a RFS and put on the sdcard
IV. Setup the u-boot:
- run loadimage
- run loadfdt
- setenv bootargs console=ttymxc0,115200 root=/dev/mmcblk0p2 rootwait rw
- bootz ${loadaddr} - ${fdt_addr}
Kernel devices
Realise a kernel device controlled from user space. The following steps will be done on the virtual machine.
NEEDED: Get the Virtual Box softwarte: https://www.virtualbox.org/wiki/Downloads
- Realize a kernel device which prints “Hello World” starting from you’re the attached code.
a . First determine the kernel version from target platform:
- uname –a
- Get the kernel sources or kernel headers using one of the following methods. On the current virtual machine this step is already done.
- For kernel headers: sudo apt-get install linux-headers-$(uname -r)
- For kernel sources:
- sudo apt-get install linux-source
b. Now go to the directory tasks/kernel. Create a function void hello() which prints “Hello World”. It should be called when the device is inserted.
c. Compile the module : make
d. Insert the module on the virtual machine : insmod lec_cdev.ko
e. See if the module is inserted
f. Remove the kernel module : rmmod lec_cdev.ko
2. Create the device lec_cdev using mknod /dev/lec_cdev c 243 0
3. Implement the read function of the device in order to have the following effect:
- cat /dev/lec_cdev => print to infinit “a”
- Modify the previous module in order to be commanded using ioctl from userspace.
- In function lec_cdev_ioctl detect the command sent from userspace and
If command is
- MY_IOCTL_HELLO prints “HELLO WORLD”;
- MY_IOCTL_SET_BUFFER – prints the buffer received from userspace.
- MY_IOCTL_GET_BUFFER – prints the data from the char device driver buffer
HINT: use functions
* copy_to_user(user_buffer, kernel_buffer, size)
* copy_from_user(kernel_buffer, user_buffer , size)