User Tools

Site Tools


tutorials:dvk521:documentations:prepare_for_kernel_and_drivers_porting

Prepare for Kernel and Drivers Porting

Note:

  • This document covers the preliminary knowledge before porting kernel and drivers. The default target system is the SD bootable Linaro system that we provide. However, the rules apply to other Linux distros as well, say, debian, etc.
  • Commands on PC ubuntu terminal: preceding with '#',Commands on Cubieboard SD card Linaro terminal: preceding with '$'
  • The Cubieboard Linaro terminal commands are executed on serial port monitor under root permission, which is installed on PC ubuntu.

SD Card Linaro System Structure

Burn the Linaro into SD card, then insert the SD card into Cubieboard, power up the board and boot. Under the /dev/ directory of Cubieboard system, there are three folders: mmcblk0, mmcblk0p1, mmcblk0p2.

mmcblk0 includes system boot info, like u-boot.

mmcblk0p1 includes script.bin and uImage. The script.bin is a default config file for Linaro system startup. Modify the script.bin file to change startup option. For instance, set the default display mode as VGA or LCD, change the default voltage level of the pins, etc. The uImage is the Linux kernel image, replace the file to change system kernel.

mmcblk0p2 includes system file of the Linaro file system, as well as the .ko module driver files, which are generated by Linux kernel module compilation, and are located under the /lib/modules/ directory. If any module driver config was changed while compiling Linux kernel, this directory should also be replaced. As for Linux kernel and drivers porting, actually what we do is, replace the modified script.bin and uImage files under mmcblk0p1.

NFS Configuration

NFS make it possible to share files between PC and Cubieboard. Use this command to check out system IP:

#ifconfig

Assume the IPs are: PC: 192.168.1.11; Cubieboard: 192.168.1.235

Enter the following commands on the PC terminal:

# sudo mkdir /home/waveshare
# sudo apt-get install portmap
# sudo apt-get install nfs-kernel-server

Modify the config file:

#sudo gedit /etc/exports

Add the following line in the opened file:

/home/ waveshare *(subtree_check,rw,no_root_squash,async)	

which means: /home/ waveshare : the shared directory, * : valid IP range, (subtree_check,rw,no_root_squash,async) : permission config,

# sudo /etc/init.d/portmap restart
# sudo /etc/init.d/nfs-kernel-server restart

Enter the following commands on Cubieboard terminal:

$ apt-get install nfs-common
$ mkdir /mnt/nfs

Execute the testing command:

$ showmount -e 192.168.1.11
Export list for 192.168.1.11
/home/waveshare *  

Mount it manually:

$ mount -t nfs4 192.168.1.11:/home/waveshare  /mnt/nfs

Now the contents under waveshare folder on ubuntu have been mounted to the Linaro system, under the /mnt/nfs directory. Ported kernel and driver files can be placed directly into the waveshare folder, and the Cubieboard will get the files easily via /mnt/nfs. There's no need to copy files from PC to Cubieboard anymore. However, in case the PC or Cubieboard reboots, the mounting command should be executed again:

$ mount -t nfs4 192.168.1.11:/home/waveshare  /mnt/nfs 

fex2bin and bin2fex Installation

Enter on Cubieboard terminal:

$ apt-get install git

Obtain the install package sunxi-tools from the internet:

$ git clone git://github.com/linux-sunxi/sunxi-tools.git

The install package can also be found on DVD_DVK521_CN\相关源码\sunxi-tools, copy it to the Cubieboard.

$ cd sunxi-tools/
$ apt-get install make
$ apt-get install gcc
$ apt-get install libusb-1.0
$ make

Two files will be generated, fex2bin and bin2fex, execute command:

$ cp fex2bin bin2fex /usr/bin/

Now you can use the following commands to convert the config file between script.bin and script.fex format:

$ bin2fex script.bin > script.fex
$ fex2bin script.fex > script.bin

The script.bin is a binary file, which is not modifiable, and should be converted to script.fex first for modifying. Edit the script.fex, then convert it to script.bin back. Text editor vim is required for editing, use the following command to install:

$ apt-get install vim

Replace the uImage and script.bin

Once the new compiled uImage and modified script.bin are ready, just use them to replace the files under mmcblk0p1 in SD card. Enter the following commands on Cubieboard to mount the SD card's first partition:

$ mkdir /mnt/mmp1
$ mount /dev/mmcblk0p1 /mnt/mmp1/
$ cd /mnt/mmp1/

Where you can find the old uImage and script.bin files, replace them via NFS. No matter uImage or script.bin is replaced, the Cubieboard needs to reboot to apply the new configuration.

tutorials/dvk521/documentations/prepare_for_kernel_and_drivers_porting.txt · Last modified: 2013/12/23 14:50 (external edit)