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.
- $ 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:
- $ sudo apt-get install build-essential git u-boot-tools texinfo texlive ccache zlib1g-dev gawk
- $ sudo apt-get install bison flex gettext uuid-dev ia32-libs
Download the recommended linaro toolchain(choose the “arm hf crosscompiler for Linux”):
- $ tar jzxf gcc-linaro-arm-linux-gnueabihf-xxx_linux.tar.bz2 -C your-path
- $ 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 ).
- $ cd kernel/
- $ 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
- $ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
- $ sudo mount /dev/nanda /boot
- $ sudo cp /tmp/kernel/* /boot -f
- $ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
- $ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
- $ sudo sync
- $ sudo umount /boot/
- $ sudo reboot
b) update kernel for mmc-boot board
- $ tar xvf pcduino_a10_hwpack_YYYYMMDD.tar.xz -C /tmp
- $ sudo mount /dev/mmcblk0p1 /boot
- $ sudo cp /tmp/kernel/* /boot -f
- $ sudo mv /lib/modules/3.4.29+ /lib/modules/3.4.29_old
- $ sudo cp /tmp/rootfs/lib/modules/3.4.29+ /lib/modules/ -ar
- $ sudo sync
- $ sudo umount /boot/
- $ 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.
- $ cd kernel/build/sun4i_defconfig-linux/
- $ make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
- $ 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.