Linux user guide

From Rockchip open source Document
Jump to: navigation, search

This guide provides information which will help you get started with rockchip opensource linux. If you have any questions, please report to us on github project issue page.


We are providing 3 ways to build rootfs including prebuilt Debian, Yocto, Buildroot. You can choose the way you prefer by yourself.

You will need below firmware/image for a full Linux OS and flash them to different locations:

  • U-Boot SPL/Rockchip miniloader
  • U-Boot
  • ARM Trusted Firmware(only need in arm v8)
  • boot(including kernel, dtb and config file)
  • rootfs(Debian, Ubuntu, etc.)

Board config

defconfig and dts

Every Board has its device tree file and config file required by the kernel and uboot. Therefore, you will need to choose the correct dts and config to build the source.Below list various Boards and the matching file.

board uboot kernel config kernel dts
rk3288-evb evb-rk3288_defconfig rockchip_linux_defconfig rk3288-evb-act8846.dts or rk3288-evb-rk808.dts
rk3288-fennec fennec-rk3288_defconfig rockchip_linux_defconfig rk3288-fennec.dts
rk3288-miniarm tinker-rk3288_defconfig rockchip_linux_defconfig rk3288-miniarm.dts
rk3288-firefly firefly-rk3288_defconfig rockchip_linux_defconfig rk3288-firefly.dts
rk3328-evb evb-rk3328_defconfig rockchip_linux_defconfig rk3328-evb.dts
rk3399-excavator evb-rk3399_defconfig rockchip_linux_defconfig rk3399-sapphire-excavator-linux.dts
rk3399-firefly firefly-rk3399_defconfig rockchip_linux_defconfig rk3399-firefly-linux.dts
rk3036-kylin kylin-rk3036_defconfig rockchip_linux_defconfig rk3036-kylin.dts

Config Per Chip

chip Kernel eMMC index Kernel SD index Uboot eMMC index Uboot SD index Baud speed
rk3399 1 0 0 1 1500000
rk3328 2 0 0 1 1500000
rk3288 2 0 0 1 115200
rk3036 2 0 0 - 115200

 

 

 

 

Getting the Sources

The rockchip linux SDK source tree is located in multi Git repository hosted by Github. The SDK uses repo to sync down source code.
Create an empty directory to hold your working files.

mkdir rk-linux
cd rk-linux

To initialize Linux SDK source tree, you need to get repo first

sudo apt-get install repo

Debian

repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b master
repo sync

Yocto

repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto
repo sync

Buildroot

repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b buildroot
repo sync

Building the Sources

The steps below aren't suitable for all boards, don't forget to choose correct option for your board!

 



Setup build environment

Note that our development environment is Ubuntu, you can use 14.04 or later version, here are some nessary packages for building the project.

$ sudo apt-get install git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-compiler gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev libssl-dev

Building uboot

Installing the build tools and download source

Compile the Uboot

You should choose your board defconfig from Board_config section. ie. we are using evb-rk3288.

CROSS_COMPILE=arm-linux-gnueabihf- make evb-rk3288_defconfig all

You can get spl/u-boot-spl.bin(if there is) and u-boot.bin when build complete, we will use these files to generate idb.img or uboot.img

See U-Boot page for more detail.

There are two feasible ways to boot to U-Boot.
1. RK SPL bin(DDR.bin, miniloader)
2. U-Boot SPL

See boot option page for more detail.

 

Building kernel

Compile the kernel:

For ARM v7

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rockchip_linux_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4

For ARM V8

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rockchip_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4

You can get zImage/Image and dtbs when build complete, we will use these files to generate boot.img for boot partition.

See Rockchip kernel for more detail.

Building rootfs

Debian

Download the prebuit image directly.

Baidu PanGoogle Drive

or use the rootfs-build-script from Rockchip to build rootfs.

Yocto

If you want to use Yocto to build your rootfs see yocto-user-guide for detail.

Buildroot

If you want to use Buildroot to build your rootfs see buildroot-user-guide for detail.

You should get rootfs.img in this step for the Linux OS.

 

Booting the Board

Then you can chose a suitable way for you to boot the board with flash all the image to media device.


Using build sciprt

To make it more convenient, we provided some build scripts which essentially wraps those commands.

Please note that those scripts are assumed your directory structure is same with the one created by manifest.


compile kernel

build/mk-kernel.sh rk3288-firefly


compile uboot

build/mk-uboot.sh rk3288-firefly

pack one image

`s` is size in Mbyte, `r` is your rootfs image location.

build/mk-image.sh -c rk3288 -t system -s 3000 -r rk-debian-build/linaro-rootfs.img

 

 

flash image

Please note that you must flash system image before burning the other single image. (To write gpt partitions)
`p` is the target partiton which is defined in partition.sh, `i` is your image location.

eMMC:
You must get your board into ROM boot mode.
If your board can't easily enter maskrom(e.g. firefly), you'd better use sd-card.
if your board have already been flashed with linux u-boot(not android u-boot), then you can enter rkusb mode.

build/flash_tool.sh  -c rk3288 -p system  -i  out/system.img

BTW, besides rkusb, linux u-boot also support ums and fastboot.

SD Card:
`d` is your target device

build/flash_tool.sh -c rk3288 -p loader  -i  out/u-boot/idbloader.img -d /dev/sdb

Some cases

first using

build/mk-kernel.sh rk3288-firefly
build/mk-uboot.sh rk3288-firefly
build/mk-image.sh -c rk3288 -t system -s 3000 -r rk-debian-build/linaro-rootfs.img
build/flash_tool.sh -p system -i out/system.img


update kernel

build/mk-kernel.sh rk3288-firefly
build/flash_tool.sh -p boot -i out/boot.img

 


update uboot

build/mk-uboot.sh rk3288-firefly
build/flash_tool.sh -p loader1 -i out/idbloader.img

 

See also

U-Boot guide

Rockchip kernel guide

Yocto guide

Buildroot guide