Build Kernel
Update time:2018-06-02 Views:9194
Ubuntu16.04 Firemware
1 Before You Start
1.1 Initialize compiling environment
Ubuntu 14.04 packages install
$ sudo apt-get install git gnupg flex bison gperf build-essential \ zip tar curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 cmake tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 lzop $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Install ARM cross compiling toolchain and related package to compile Linux kernel
$ sudo apt-get install gcc-arm-linux-gnueabihf \ gcc-aarch64-linux-gnu device-tree-compiler lzop libncurses5-dev \ libssl1.0.0 libssl-dev
1.2 Get the source code
git clone -b firefly https://github.com/FireflyTeam/kernel.git
2 Compile Kernel
Before compiling, execute the following command
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf-
Compile firefly-rk3288
make firefly_linux_defconfig make rk3288-firefly-linux.img -j4
Compile aio-3288j
make rk3288-firefly-aio-linux.img -j4
After the compilation is complete , the kernel.img and resource.img should be generated in the kernel folder.
If you need to compile a xxx.dts in the arch/arm/boot/dts/rockchip/ directory, then
make xxx.img -j4
3 Flash partition images
3.1 View parameter file
CMDLINE:console=ttyS2,115200 root=/dev/mmcblk2p6 rw rootwait \ mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),0x00002000@0x00004000(trust),\ 0x00008000@0x00006000(resource),0x0000A000@0x0000E000(kernel),\ 0x00002000@0x00018000(backup),-@0x0001A000(boot)
be careful
root=/dev/mmcblk2p6 ---> rootfs partition If the size of the root file partition is abnormal, resize2fs /dev/mmcblk2p6 0x0000A000@0x0000E000(kernel) ---> kernel partition kernel ---> partition name 0x0000E000 ---> partition start address 0x0000A000 ---> partition size, generally do not need to pay attention
3.2 Linux upgrade_tool flash partition images( xx.img )
Note whether the corresponding name of the parameter partition corresponds to
sudo upgrade_tool di kernel kernel.img sudo upgrade_tool di boot rootfs.img ... kernel ---> on the parameter partition name kernel.img ---> Compiled production kernel.img partition image
3.3 Windows AndroidTool tool upgrade partition images
Note whether the starting address of the parameter partition corresponds to
3.4 Other partition images
Please reference Customize Firmware, unpack the official release firmware.
Ubuntu14.04 Firemware
1 Before You Start
1.1 Install Dev Packages
Install dev packages:
sudo apt-get install gcc-arm-linux-gnueabihf build-essential lzop libncurses5-dev libssl-dev # If using 64 bits Ubuntu, you need also: sudo apt-get install libc6:i386
1.2 Install mkbootimg utility
git clone https://github.com/neo-technologies/rockchip-mkbootimg.gitcd rockchip-mkbootimg make && sudo make install
1.3 Get Kernel Source and Cross Compiling Toolchain
If you have already downloaded the Firefly-RK3288 Android SDK, the kernel source and cross compiling toolchain are in SDK/kernel and SDK/prebuilts respectively. Please skip to next step.
If not, please download the kernel source code and Android's arm-eabi-4.6 cross compiling toolchain.
Download the kernel source code:
git clone https://bitbucket.org/T-Firefly/firefly-rk3288-kernel.git
If you are using Firefly-RK3288-Reload board, please download the "lollipop" branch, and then checkout to "lollipop"
git fetch origin lollipop:lollipop git checkout lollipop
Note: This is Linux kernel source code in separated source repository, which is extracted from Firefly-RK3288 Android SDK, for convenience of users who only want the kernel source code instead of the huge sdk.
For Android's arm-eabi-4.6 cross compiling toolchain, you may look around to see if any local Android SDK has prebuilts/gcc/linux-x86/arm/arm-eabi-4.6. If there is, you can reuse it; otherwise download from here and extract it.
2 Compile Kernel
2.1 Compile Image
If you are not compiling kernel in the SDK, you need to specify ARCH and CROSS_COMPILE first:
export ARCH=arm export CROSS_COMPILE=/path/to/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
In the kernel source directory, execute:
make firefly-rk3288-linux_defconfig make -j8 firefly-rk3288-linux.img
If you are using Firefly-RK3288-Reload board, executeː
make firefly-rk3288-reload-linux_defconfig make -j8 firefly-rk3288-reload-linux.img
Note: if you are using the beta development board, please replace "firefly-rk3288.img" above with "firefly-rk3288_beta.img".
2.2 Compile Modules
Run:
make modules mkdir modules_install make INSTALL_MOD_PATH=./modules_install modules_insatll
Copy the kernel module files to the root file system:
rsync -av ./modules_install/ /path/to/your/rfs/
You can also copy to the development board, using ssh remote connection:
rsync -av ./modules_install/ root@:/
Clean up the module install directory (it contains links which impact compilation of Android SDK):
rm -rf ./modules_install
3 Create boot.img
3.1 Create Initramfs
The kernel will load the initramfs as the first root file system. It is in charge of finding the actual root device, load it then finally switch to it. The development board use eMMC flash. There is no need of special kernel module file. Actually you can skip this step. But initramfs offers flexibility like multiple OS boot.
git clone -b for-kernel_4.4 make -C initrd
3.2 Package Kernel and Initramfs
Package kernel and initramfs into boot.img:
# mkbootimg --kernel arch/arm/boot/zImage --ramdisk initrd.img -o boot.img mkbootimg --kernel zImage --ramdisk initrd.img --second resource.img --output boot.img
4 Modify Parameter File
The root file system can reside on different partitions in different storage devices (eMMC, TF card or USB disk, etc). It must be specified in the kernel's command line. There is a CMDLINE in the paramter file:
CMDLINE:console=tty0 ... mtdparts=rk29xxnand:0x00002000@0x00002000(uboot),...,-@0x00394000(user)
Add one of below according to your need: (# and contents after are comments, no need to enter):
root=/dev/block/mtd/by-name/linuxroot # flash partition named "linuxroot" root=/dev/mmcblk0p1 # First partition of TF card root=/dev/sda1 # First partition of USB disk root=LABEL=linuxroot # Partition whose label is "linuxroot"
5 Flash to Device
Please reference Flash image, choose the newly created boot.img and modified parameter files, flash to "boot" and "parameter" partitions respectively. Then the kernel update is done.
If the root filesystem image is not flashed yet, you can download the prebuilt image, or customize your own one, and flash it to the partition specified in parameter file.