Difference between revisions of "Linux user guide"

From Rockchip open source Document
Jump to: navigation, search
Line 15: Line 15:
 
*boot(including kernel, dtb and config file)  
 
*boot(including kernel, dtb and config file)  
 
*rootfs(Debian, Ubuntu, etc.)  
 
*rootfs(Debian, Ubuntu, etc.)  
 
 
 
  
 
= Environment =
 
= Environment =
Line 30: Line 28:
  
 
If you insist on developing on your own environment, please make sure the version of&nbsp;<span style="font-size: 13px;">gcc-arm-linux-gnueabihf and gcc-aarch64-linux-gnu is&nbsp;less than 6.</span>
 
If you insist on developing on your own environment, please make sure the version of&nbsp;<span style="font-size: 13px;">gcc-arm-linux-gnueabihf and gcc-aarch64-linux-gnu is&nbsp;less than 6.</span>
 
&nbsp;
 
 
&nbsp;
 
  
 
= Getting the Sources =
 
= Getting the Sources =
Line 50: Line 44:
 
There are three Linux SDK,&nbsp;You can choose one of them.
 
There are three Linux SDK,&nbsp;You can choose one of them.
  
<small>'''(Please check the&nbsp;[[Status_Matrix|Software Status]]&nbsp;because different chips have a different support. e.g: RK3288 don't have buildroot support, please use yocto.)'''</small>
+
The rockchip linux SDK source tree is located in multi Git repository hosted by Github. The SDK uses repo to sync down source code.
  
 
&nbsp;
 
&nbsp;
  
Basic Linux SDK/Debian&nbsp;<small>(standalone kernel/u-boot/rootfs)</small>
+
Basic Linux SDK/Debian
 +
 
 +
Standalone&nbsp;u-boot/kernel/rootfs build/flash, help you do developments like bringup new boards/hardware.
 +
 
 +
Debian rootfs with RK&nbsp;packages installed, help you do evaluation quickly.
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b master
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b master
 
repo sync
 
repo sync
 
</pre>
 
</pre>
  
You can easily&nbsp;do u-boot/kernel&nbsp;development to bringup board with this SDK , debian is also more convenient than yocto/buildroot&nbsp;''to do evaluation.''
+
&nbsp;
  
 
Yocto
 
Yocto
 +
 +
Yotco&nbsp;can&nbsp;generate both rootfs image and gpt image included kernel/u-boot.
 +
 +
For serious project, it's recommended to use yocto.
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto
 
repo sync
 
repo sync
 
</pre>
 
</pre>
 +
 +
&nbsp;
  
 
Buildroot
 
Buildroot
 +
 +
Buildroot support rk3399, Yocto&nbsp;and&nbsp;Buildroot&nbsp;both have same&nbsp;ability.<small>(RK3288 don't have buildroot support, please use yocto.)</small>
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b buildroot
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b buildroot
 
repo sync
 
repo sync
 
</pre>
 
</pre>
 
Yotco/Buildroot can&nbsp;generate both rootfs image and gpt image included kernel/u-boot.
 
 
If you are not familier&nbsp;with&nbsp; Yotco/Buildroot, then you can use Basic Linux SDK for&nbsp;u-boot/kernel&nbsp;development, and Yotco/Buildroot just for rootfs image.
 
  
 
&nbsp;
 
&nbsp;
  
 
Below guides are based on basic Linux SDK, guides for yocto/buildroot could be found in the separate page.
 
Below guides are based on basic Linux SDK, guides for yocto/buildroot could be found in the separate page.
 
&nbsp;
 
  
 
= Quick start =
 
= Quick start =
 
<small>'''ref&nbsp;:&nbsp;[[Partitions|partition]], [[Rockusb|rockusb]], [[Boot_option|boot]]'''</small>
 
  
 
We have provide&nbsp;[https://github.com/rockchip-linux/build build scripts]&nbsp;which essentially wraps the commands, so you can quickly start your development by them.
 
We have provide&nbsp;[https://github.com/rockchip-linux/build build scripts]&nbsp;which essentially wraps the commands, so you can quickly start your development by them.
Line 91: Line 89:
 
'''choose/add board-config'''
 
'''choose/add board-config'''
  
We use rk3288-firefly as example. You can change&nbsp;rk3288-firefly to any other board supported,.
+
We use rk3288-firefly as example. You can change&nbsp;rk3288-firefly to any other board supported.
  
 
Before starting to develop, please refer to [[Board_Config|board config]]&nbsp;and''&nbsp;''[http://opensource.rock-chips.com/wiki_FAQ#How_to_select_board_config how-to] to choose a&nbsp;most matching config&nbsp;as the&nbsp;foundation.
 
Before starting to develop, please refer to [[Board_Config|board config]]&nbsp;and''&nbsp;''[http://opensource.rock-chips.com/wiki_FAQ#How_to_select_board_config how-to] to choose a&nbsp;most matching config&nbsp;as the&nbsp;foundation.
Line 105: Line 103:
 
This command will compile u-boot and copy all binarys to "out/u-boot".
 
This command will compile u-boot and copy all binarys to "out/u-boot".
  
If u-boot is stuck in SPL, please see "choose/add board-config".
+
If u-boot is stuck in SPL, please choose a&nbsp;most matching board-config!&nbsp; If it's still stuck in SPL, please use [https://github.com/rockchip-linux/build/blob/debian/mk-uboot.sh#L48 old ddr.bin] to replace u-boot SPL.
 +
 
 +
Please see u-boot page for more infos.
 
<pre>build/mk-uboot.sh rk3288-firefly
 
<pre>build/mk-uboot.sh rk3288-firefly
 
</pre>
 
</pre>
 +
 +
'''build debian rootfs image'''
 +
 +
It's better&nbsp;to download&nbsp;[http://opensource.rock-chips.com/wiki_Debian prebuilt debian image]&nbsp;at first, and&nbsp;build rootfs&nbsp;later, since many users have complain to us that they waste a lot of time to&nbsp;build debian image(mostly&nbsp;environment problem).
  
 
'''Pack all parts to a complete image'''
 
'''Pack all parts to a complete image'''
  
 
`s` is size in Mbyte, `r` is your rootfs image location. Here we use rk3288 as example. You can change it to any other supported chips(ie. rk3399, rk3328).
 
`s` is size in Mbyte, `r` is your rootfs image location. Here we use rk3288 as example. You can change it to any other supported chips(ie. rk3399, rk3328).
 
Since many users have complain to us that they waste many time to&nbsp;build debian image(mostly&nbsp;environment problem), so i suggest to download&nbsp;[http://opensource.rock-chips.com/wiki_Debian prebuilt debian image]&nbsp;at first, and&nbsp;build rootfs by yourself later.
 
 
<pre>build/mk-image.sh -c rk3288 -t system -r rk-debian-build/linaro-rootfs.img
 
<pre>build/mk-image.sh -c rk3288 -t system -r rk-debian-build/linaro-rootfs.img
 
</pre>
 
</pre>
Line 126: Line 128:
 
<pre>build/flash_tool.sh -c rk3288 -p loader -i out/u-boot/idbloader.img -d /dev/sdb
 
<pre>build/flash_tool.sh -c rk3288 -p loader -i out/u-boot/idbloader.img -d /dev/sdb
 
</pre>
 
</pre>
 +
 +
Please refer to [https://github.com/rockchip-linux/rkbin/tree/master/tools/AndroidTool_Release_v2.39 AndroidFlashTool]<small>&nbsp;</small>for flashing image on Windows.&nbsp;<small>(For the first time, it's recommended to use a linux host, to save the time.)</small>
 +
 +
Please note there is no&nbsp;parameter!&nbsp;The system image created by linux SDK is a pure&nbsp;GPT formatted image, burned to spefic offset in&nbsp;flash.
 +
 +
It's recommended to read&nbsp;'''[[Partitions|partition]], [[Rockusb|rockusb]], [[Boot_option|boot]]&nbsp;'''to understand how it works if you failed to flash image.
  
 
'''bringup(burn kernel, uboot, gpt)'''
 
'''bringup(burn kernel, uboot, gpt)'''
Line 151: Line 159:
  
 
Before asking questions, please, read&nbsp;references and follow&nbsp;the setp by setp guide to boot your device.
 
Before asking questions, please, read&nbsp;references and follow&nbsp;the setp by setp guide to boot your device.
 
&nbsp;
 
 
Please refer to [https://github.com/rockchip-linux/rkbin/tree/master/tools/AndroidTool_Release_v2.39 AndroidFlashTool]<small>(TODO: wiki)&nbsp;</small>for flashing image on Windows.&nbsp;<small>(For the first time, it's recommended to use a linux host, to save the time.)</small>
 
 
Please note there is no&nbsp;parameter!&nbsp;The system image created by linux SDK is a pure&nbsp;GPT formatted image , burned to spefic offset in&nbsp;flash.
 
  
 
&nbsp;
 
&nbsp;

Revision as of 15:39, 23 January 2018

 

Overall

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. 

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

Environment

Note that our development environment is Ubuntu, you can use 16.04 or later version(with downgraded arm gcc).

Debian-9  and Docker-Rockchip are also available.

Ubuntu 14.04 is deprecated, we don't guarantee that Linux SDK can work on it.

Here are some necessary 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 pv e2fsprogs build-essential fakeroot devscripts

If you insist on developing on your own environment, please make sure the version of gcc-arm-linux-gnueabihf and gcc-aarch64-linux-gnu is less than 6.

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

There are three Linux SDK, You can choose one of them.

The rockchip linux SDK source tree is located in multi Git repository hosted by Github. The SDK uses repo to sync down source code.

 

Basic Linux SDK/Debian

Standalone u-boot/kernel/rootfs build/flash, help you do developments like bringup new boards/hardware.

Debian rootfs with RK packages installed, help you do evaluation quickly.

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

 

Yocto

Yotco can generate both rootfs image and gpt image included kernel/u-boot.

For serious project, it's recommended to use yocto.

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

 

Buildroot

Buildroot support rk3399, Yocto and Buildroot both have same ability.(RK3288 don't have buildroot support, please use yocto.)

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

 

Below guides are based on basic Linux SDK, guides for yocto/buildroot could be found in the separate page.

Quick start

We have provide build scripts which essentially wraps the commands, so you can quickly start your development by them.

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

choose/add board-config

We use rk3288-firefly as example. You can change rk3288-firefly to any other board supported.

Before starting to develop, please refer to board config and how-to to choose a most matching config as the foundation.

compile kernel

This command will compile kernel and copy kernel-image/dtb to "out/kernel" and create a fat image "out/boot.img" which contains kernel-image/dtb/extlinux.conf.

build/mk-kernel.sh rk3288-firefly

compile uboot

This command will compile u-boot and copy all binarys to "out/u-boot".

If u-boot is stuck in SPL, please choose a most matching board-config!  If it's still stuck in SPL, please use old ddr.bin to replace u-boot SPL.

Please see u-boot page for more infos.

build/mk-uboot.sh rk3288-firefly

build debian rootfs image

It's better to download prebuilt debian image at first, and build rootfs later, since many users have complain to us that they waste a lot of time to build debian image(mostly environment problem).

Pack all parts to a complete image

`s` is size in Mbyte, `r` is your rootfs image location. Here we use rk3288 as example. You can change it to any other supported chips(ie. rk3399, rk3328).

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

flash image

eMMC (Ensure the board is in maskrom mode. maskrom, Not rockusb! ):

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

SD Card:
`d` is your target device

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

Please refer to AndroidFlashTool for flashing image on Windows. (For the first time, it's recommended to use a linux host, to save the time.)

Please note there is no parameter! The system image created by linux SDK is a pure GPT formatted image, burned to spefic offset in flash.

It's recommended to read partition, rockusb, boot to understand how it works if you failed to flash image.

bringup(burn kernel, uboot, gpt)

build/mk-kernel.sh rk3288-firefly
build/mk-uboot.sh rk3288-firefly
build/mk-image.sh -c rk3288 -t system -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 (armv7)

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

update uboot(armv8 with miniloader)

build/mk-uboot.sh rk3399-excavator
build/flash_tool.sh -p loader1 -i out/u-boot/idbloader.img -c rk3399
build/flash_tool.sh -p loader2 -i out/u-boot/uboot.img -c rk3399
build/flash_tool.sh -p atf -i out/u-boot/trust.img -c rk3399

Before asking questions, please, read references and follow the setp by setp guide to boot your device.

 

Step By Step

Building the sources

Building uboot

Installing the build tools and download source

Compile the Uboot

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

It's recommend to download prebuilt debian image for bringup.

Debian

See debian-guide for detail.

You should get xxx-rootfs.img.

Yocto

See yocto-user-guide for detail.

You should get xxx.ext4 rootfs image.

Buildroot

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.

 

See also

U-Boot guide

Rockchip kernel guide

Yocto guide

Buildroot guide

 

Driver for Linux

Display:

Graphic:

Customization

Boot_Time

Boot_Logo

Image_Size

Firmware_Upgrade