Rockchip RK3036 Kernel

From Rockchip open source Document
Revision as of 09:07, 8 December 2017 by Admin (talk | contribs)
Jump to: navigation, search

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.

 

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.

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 ...