Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4191880
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类: LINUX

2013-07-26 08:09:13

In this tutorial, we discuss how to build kernel for pcDuino.

The commands discussed below are on a regular X86 PC.

 

1. Download kernel source files from Github.

	
  1. $ git clone https://github.com/pcduino/kernel.git

Note:

  • This step only downloads the build environment.
  • There are some submodules from
  • Source files of submodules will be downloaded when running “make” under kernel/ directory for the first time
  • (or if the submodules have not been downloaded before when running “make”)

2. Install required software and toolchain on PC for cross-compile

On x86 ubuntu, install the following packages using apt-get:

	
  1. $ sudo apt-get install build-essential git u-boot-tools texinfo texlive ccache zlib1g-dev gawk
  2. $ sudo apt-get install bison flex gettext uuid-dev ia32-libs

Download the recommended linaro toolchain(choose the “arm hf crosscompiler for Linux”):

	
  1. $ tar jzxf gcc-linaro-arm-linux-gnueabihf-xxx_linux.tar.bz2 -C your-path
  2. $ export PATH=$PATH:your-path/gcc-linaro-arm-linux-gnueabihf-xxx_linux/bin/

 

3. Build Kernel Image

 

Run “make” under kernel/ directory ( Do not compile the source file under kernel/linux-sunxi directory ).

	
  1. $ cd kernel/
  2. $ make

 

If no error occurs, a livesuitable image and a HW_pack will be in the output folder:

  • pcduino_a10_hwpack_YYYYMMDD.tar.xz ( includes uboot for mmc-boot, kernel, and driver modules ).
  • pcduino_a10_kernel_livesuit_YYYYMMDD.img ( kernel image update by livesuit )

Note:

  • For the first time, it will download the required source code from
  • For each time run “make”, it will apply the patch for pcduino.
  • The patch for pcduino is located at kernel/patch/ directory.
  • All the object files generated by compile tools saved in kernel/build directory.
  • Compile kernel under kernel/linux-sunxi directory will make the build environment “dirty”.
  • If your have done it before. clean up by running “make mrproper” under kernel/linux-sunxi.

 

4. Update  pcDuino with your new kernel  

The following commands should be run on pcDuino.

If you only want to update kernel and modules ( not desktop like ubuntu ), just unpack hwpack file, and replace files on board:

a) update kernel for nand-boot board

	
  1. $ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
  2. $ sudo mount /dev/nanda /boot
  3. $ sudo cp /tmp/kernel/* /boot -f
  4. $ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
  5. $ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
  6. $ sudo sync
  7. $ sudo umount /boot/
  8. $ sudo reboot

b) update kernel for mmc-boot board

	
  1. $ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
  2. $ sudo mount /dev/mmcblk0p1 /boot
  3. $ sudo cp /tmp/kernel/* /boot -f
  4. $ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
  5. $ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
  6. $ sudo sync
  7. $ sudo umount /boot/
  8. $ sudo reboot

Note:

  • Hardwarelibs are closed source modules now, you can copy those modules from /lib/modules/3.4.29_old:
  • $ sudo cp /lib/modules/3.4.29+_old/kernel/drivers/hardwarelib/ /lib/modules/3.4.29+/kernel/drivers/ -ar

 

5. Customize your kernel

You can change or add drivers for your own. Before compile, save all the source code you changed/added under kernel/patch dir.  ( this step can be done by running “./make_kernel_patch.sh” under kernel/patch/linux-sunxi )
files under kernel/linux-sunxi may will be over written by the patch.

If you want to change kernel config file (add/remove some drivers), there is something different.
Customize kernel config by running “make menuconfig”, then save it to patch directory and re-build kernel.

	
  1. $ cd kernel/build/sun4i_defconfig-linux/
  2. $ make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
  3. $ mv .config ./../patch/linux-sunxi/arch/arm/configs/sun4i_defconfig -f

Follow step 3) to re-build kernel and step 4) to update pcDuino with your new kernel.

Posted in , 
阅读(1167) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~