Difference between revisions of "Rockchip RK3036 Kernel"
(4 intermediate revisions by the same user not shown) | |||
Line 47: | Line 47: | ||
According to Rockchip partition definition, you need to flash this image to boot partiton which offset is 0x8000. | According to Rockchip partition definition, you need to flash this image to boot partiton which offset is 0x8000. | ||
+ | <pre>sudo rkdeveloptool wl 0x8000 boot_rk3036.img</pre> | ||
− | + | Then, how to generate boot.img? Please have a look at the following: | |
== Generate fatfs boot partition == | == Generate fatfs boot partition == | ||
Line 65: | Line 66: | ||
Flash this boot.img to boot partition, which is offset 0x8000 in Rockchip partition definition. | Flash this boot.img to boot partition, which is offset 0x8000 in Rockchip partition definition. | ||
+ | <pre>sudo rkdeveloptool wl 0x8000 boot.img</pre> | ||
=== Update boot.img via U-Boot in target === | === Update boot.img via U-Boot in target === | ||
Line 115: | Line 117: | ||
</pre> | </pre> | ||
+ | |||
+ | | ||
+ | |||
+ | == '''DEBUG Kernel''' == | ||
+ | |||
+ | if you have some issues on bringup kernel, you can enable the earlyprintk configs for rockchip_linux_defconfig | ||
+ | |||
+ | For example: | ||
+ | <pre>cat >> arch/arm/configs/rockchip_linux_defconfig << EOF | ||
+ | CONFIG_DEBUG_LL=y | ||
+ | CONFIG_DEBUG_RK29_UART2=y | ||
+ | CONFIG_EARLY_PRINTK=y | ||
+ | EOF</pre> | ||
+ | |||
+ | Then build and re-install kernel for debug. |
Latest revision as of 09:19, 8 December 2017
Contents
Download Kernel
You can clone the rockchip kernel repository from github which is kernel 4.4 based:
git clone https://github.com/rockchip-linux/kernel.git
Configure and Build
You will need to use rockchip_linux_defconfig for Linux OS
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rockchip_linux_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
Then you can get Image/zImage and dtb file.
Install Boot/kernel
We use distro boot in U-Boot, so we need to make a boot partition for U-Boot with kernel image and dtb inside.
mkdir boot cp arch/arm/boot/dts/rk3036-kylin.dtb boot/rk3036-kylin.dtb cp arch/arm/boot/zImage boot/
Add extlinux/extlinux.conf for distro boot.
mkdir boot/extlinux
cat >> boot/extlinux/extlinux.conf << EOF label kernel-4.4 kernel /zImage fdt /rk3036-kylin.dtb append earlyprintk console=tty1 console=ttyS2,115200n8 rw root=PARTUUID=69dad710-2c rootfstype=ext4 init=/sbin/init rootwait EOF
Generate ext2fs boot partition
by genext2fs:
genext2fs -b 32768 -B $((32*1024*1024/32768)) -d boot/ -i 8192 -U boot_rk3036.img
According to Rockchip partition definition, you need to flash this image to boot partiton which offset is 0x8000.
sudo rkdeveloptool wl 0x8000 boot_rk3036.img
Then, how to generate boot.img? Please have a look at the following:
Generate fatfs boot partition
Generate boot.img in fatfs
Below commands can generate a fatfs boot.img
dd if=/dev/zero of=boot.img bs=1M count=32 sudo mkfs.fat boot.img mkdir tmp sudo mount boot.img tmp/ cp -r boot/* tmp/ umount tmp
Done!
Flash this boot.img to boot partition, which is offset 0x8000 in Rockchip partition definition.
sudo rkdeveloptool wl 0x8000 boot.img
Update boot.img via U-Boot in target
After flash and boot the U-Boot, write the gpt table from default partition table
gpt write mmc 0 $partitions gpt verify mmc 0 $partitions
connect target to PC and start the ums in command line:
ums mmc 0
We should able to see a device connect to PC, formate and copy data into the partition(dev/sdb6 for example).
cp -r boot/* /media/machine/9F35-9565/
Done!
Boot from U-Boot
If you are using genext2fs to genarate the boot.img, you need write the gpt table in U-Boot command line:
gpt write mmc 0 $partitions
Then boot from eMMC or reset:
boot
If everything is OK, you should able to see the U-Boot log like this:
switch to partitions #0, OK mmc0(part 0) is current device Scanning mmc 0:4... Found /extlinux/extlinux.conf Retrieving file: /extlinux/extlinux.conf reading /extlinux/extlinux.conf 192 bytes read in 4 ms (46.9 KiB/s) 1: kernel-4.4 Retrieving file: /zImage reading /zImage 7810312 bytes read in 726 ms (10.3 MiB/s) append: earlyprintk console=tty1 console=ttyS2,115200n8 rw root=PARTUUID=69dad710-2c rootfstype=ext4 init=/sbin/init rootwait Retrieving file: /rk3036-kylin.dtb reading /rk3036-kylin.dtb 23641 bytes read in 6 ms (3.8 MiB/s) Kernel image @ 0x62000000 [ 0x000000 - 0x772d08 ] ## Flattened Device Tree blob at 61f00000 Booting using the fdt blob at 0x61f00000 Loading Device Tree to 7df52000, end 7df5ac58 ... OK Starting kernel ...
DEBUG Kernel
if you have some issues on bringup kernel, you can enable the earlyprintk configs for rockchip_linux_defconfig
For example:
cat >> arch/arm/configs/rockchip_linux_defconfig << EOF CONFIG_DEBUG_LL=y CONFIG_DEBUG_RK29_UART2=y CONFIG_EARLY_PRINTK=y EOF
Then build and re-install kernel for debug.