Difference between revisions of "Rockchip Kernel"
Line 67: | Line 67: | ||
or write to emmc with rkdeveloptool, see [[Emmc_boot|emmc_boot]]. | or write to emmc with rkdeveloptool, see [[Emmc_boot|emmc_boot]]. | ||
+ | |||
== generate fatfs boot partition == | == generate fatfs boot partition == | ||
+ | |||
+ | === Via U-Boot in target === | ||
After flash and boot the U-Boot, write the gpt table from default partition table | After flash and boot the U-Boot, write the gpt table from default partition table | ||
Line 80: | Line 83: | ||
<pre>sudo mkfs.fat /dev/sdb6 | <pre>sudo mkfs.fat /dev/sdb6 | ||
cp -r boot/* /media/machine/9F35-9565/</pre> | cp -r boot/* /media/machine/9F35-9565/</pre> | ||
+ | |||
+ | === Generae boot.img in fatfs === | ||
+ | |||
+ | Below commands can generate a fatfs boot.img | ||
+ | <pre>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</pre> | ||
+ | |||
+ | Done! | ||
+ | |||
+ | Flash this boot.img to boot partition, which is offset 0x8000 in Rockchip partition definition. | ||
== Boot from U-Boot == | == Boot from U-Boot == |
Revision as of 03:22, 17 March 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
Supported SoCs and Devices
Rockchip kernel 4.4 supports:
RK3036, RK3066, RK312X, RK3188, RK322X, RK3288, RK3328, RK3368, RK3399
Configure and Build
You will need to use rockchip_linux_defconfig for Linux OS
configure for armv7:
make rockchip_linux_defcofig
configure for aarch64:
make ARCH=arm64 rockchip_linux_defconfig
After configure, you need to decide which board to use, get the dts file name, and replace its postfix to img in make command,
For armv7:
make rk3288-firefly.img -j8
For aarch64:
make ARCH=arm64 rk3399-evb.img -j8
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/arm64/boot/dts/rockchip/rockchip/rk3399-evb.dtb boot/rk3399.dtb cp arch/arm64/boot/Image boot/
Add extlinux/extlinux.conf for distro boot.
mkdir boot/extlinux vi boot/extlinux/extlinux.conf
lable rockchip-kernel-4.4 kernel /Image fdt /rk3399.dtb append earlycon=uart8250,mmio,0xff1a0000 root=dev/mmcblk1p7 rootwait rootfstype=ext4 init=/sbin/init
You need to change the base address of debug UART, root partition for your board.
Pls reference to rockchip Linux parttion definition for rootfs partition and where boot to flash.
After all these file prepare complete, we write the file to the boot partition
Generate ext2fs boot partition
by genext2fs:
genext2fs -b 32768 -B $((32*1024*1024/32768)) -d boot/ -i 8192 -U boot_rk3399.img
According to Rockchip partition definition, you need to flash this image to boot partiton which offset is 0x8000.
dd this image to sd card, see sd_boot,
or write to emmc with rkdeveloptool, see emmc_boot.
generate fatfs boot partition
Via U-Boot in target
After flash and boot the U-Boot, write the gpt table from default partition table
gpt write mmc 1 $partitions gpt verify mmc 1 $partitions
connect target to PC and start the ums in command line:
ums 0 mmc 1:6
We should able to see a device connect to PC, formate and copy data into the partition(dev/sdb6 for example).
sudo mkfs.fat /dev/sdb6 cp -r boot/* /media/machine/9F35-9565/
Generae 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.
Boot from U-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:6... Found /extlinux/extlinux.conf Retrieving file: /extlinux/extlinux.conf 205 bytes read in 82 ms (2 KiB/s) 1: upstream-4.10 Retrieving file: /Image 13484040 bytes read in 1833 ms (7 MiB/s) append: earlycon=uart8250,mmio32,0xff1a0000 console=ttyS2,1500000n8 rw root=/dev/mmcblk0p7 rootwait rootfstype=ext4 init=/sbin/init Retrieving file: /rk3399.dtb 61714 bytes read in 54 ms (1.1 MiB/s) ## Flattened Device Tree blob at 01f00000 Booting using the fdt blob at 0x1f00000 Loading Device Tree to 000000007df14000, end 000000007df26111 ... OK Starting kernel ...