Difference between revisions of "Linux user guide"

From Rockchip open source Document
Jump to: navigation, search
 
(47 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
 +
 
  
 
 
 
 
Line 4: Line 6:
 
= Overall =
 
= 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.
+
This guide provides information which will help you geting start with Rockchip Linux SDK. Please contact service@rock-chips.com if you need business support.
 +
 
 +
We are providing 2 kind of&nbsp;rootfs. Buildroot and prebuilt Debian.&nbsp;You can choose the way you prefer.<small>&nbsp;</small>
  
We are providing 3 ways to build rootfs including prebuilt Debian, Yocto, Buildroot.&nbsp;You can choose the way you prefer.<small>&nbsp;</small>
+
*Buildroot: An easy and small embedded Linux system. Recommend for your product development.&nbsp;  
 +
*Prebuilt Debian: A generic desktop Distro. Only for your evaluation.&nbsp;  
  
 
You will need below firmware/image for a full Linux OS and flash them to different locations:
 
You will need below firmware/image for a full Linux OS and flash them to different locations:
  
*U-Boot SPL/Rockchip miniloader  
+
*Rockchip miniloader: This is the first level boot loader
*U-Boot  
+
*U-Boot: This is the second level boot loader
*ARM Trusted Firmware(only need in arm v8)
+
*Trusted:&nbsp;ARM Trusted Firmware  
*boot(including kernel, dtb and config file)
+
*Boot: It is Android boot image format. Pack kernel dtb and image to one partition. Use it for production.&nbsp;
*rootfs(Debian, Ubuntu, etc.)
+
*Rootfs: Buildroot or Debian system image
 +
*Recovery:&nbsp;It is Android boot image format. Pack kernel dtb, image and ramdisk to one partition. Use it for OTA update.&nbsp;
 +
*Misc: used for&nbsp;transfer command between rootfs and recovery
  
 
&nbsp;
 
&nbsp;
  
= Environment =
 
  
Note that our development environment is Ubuntu, you can use 16.04 or later version<small>(with downgraded arm gcc)</small>.
 
  
Debian-9&nbsp; and [https://github.com/rockchip-linux/docker-rockchip Docker-Rockchip]&nbsp;are also available.
+
= Environment =
  
'''Ubuntu 14.04 is ''deprecated, we don't guarantee that Linux SDK can work on it.'''''
+
'''Please&nbsp;use&nbsp;Ubuntu 16.04 or later version. The&nbsp;early version can't&nbsp;work.'''
  
 
Here are some necessary packages for building the project.
 
Here are some necessary packages for building the project.
<pre>$ 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</pre>
+
<pre>$ sudo apt-get install repo git u-boot-tools device-tree-compiler mtools parted libudev-dev libusb-1.0-0-dev lib32gcc-7-dev python-linaro-image-tools linaro-image-tools gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libstdc++-7-dev autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs mercurial rsync openssh-client subversion asciidoc w3m dblatex graphviz python-matplotlib libssl-dev pv e2fsprogs fakeroot devscripts libi2c-dev libncurses5-dev texinfo liblz4-tool genext2fs
 
+
</pre>
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;
 
&nbsp;
Line 37: Line 39:
 
= Getting the Sources =
 
= 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.
+
Rockchip provide open source software on&nbsp;[https://github.com/rockchip-linux Github&nbsp;]. Please check&nbsp;[http://opensource.rock-chips.com/wiki_Source here]&nbsp;to get the source code of Rockchip Linux SDK.&nbsp;
 
 
<br/> Create an empty directory to hold your working files.
 
<pre>mkdir rk-linux
 
cd rk-linux
 
</pre>
 
 
 
To initialize Linux SDK source tree, you need to get repo first
 
<pre>sudo apt-get install repo
 
</pre>
 
 
 
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>
 
 
 
&nbsp;
 
 
 
Basic Linux SDK/Debian&nbsp;<small>(standalone kernel/u-boot/rootfs)</small>
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b master
 
repo sync
 
</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.''
 
 
 
Yocto
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b yocto
 
repo sync
 
</pre>
 
 
 
Buildroot
 
<pre>repo init --repo-url=https://github.com/rockchip-linux/repo -u https://github.com/rockchip-linux/manifests -b buildroot
 
repo sync
 
</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;
 
 
 
Below guides are based on basic Linux SDK, guides for yocto/buildroot could be found in the separate page.
 
 
 
&nbsp;
 
 
 
= 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.
 
 
 
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&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.
 
 
 
'''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&nbsp;kernel-image/dtb/extlinux.conf.
 
<pre>build/mk-kernel.sh rk3288-firefly
 
</pre>
 
 
 
'''compile uboot'''
 
 
 
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".
 
<pre>build/mk-uboot.sh rk3288-firefly
 
</pre>
 
 
 
'''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).
 
 
 
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>
 
 
 
'''flash image'''
 
 
 
eMMC <small>(Ensure the board is in&nbsp;maskrom mode. [http://opensource.rock-chips.com/wiki_Rockusb#Maskrom_mode maskrom],&nbsp;Not [http://opensource.rock-chips.com/wiki_Rockusb#Miniloader_Rockusb.C2.A0mode rockusb]! )</small>:
 
<pre>build/flash_tool.sh -c rk3288 -p system -i out/system.img
 
</pre>
 
 
 
SD Card:<br/> `d` is your target device
 
<pre>build/flash_tool.sh -c rk3288 -p loader -i out/u-boot/idbloader.img -d /dev/sdb
 
</pre>
 
 
 
'''bringup(burn kernel, uboot, gpt)'''
 
<pre>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</pre>
 
 
 
'''update kernel'''
 
<pre>build/mk-kernel.sh rk3288-firefly
 
build/flash_tool.sh -p boot -i out/boot.img
 
</pre>
 
 
 
'''update uboot (armv7)'''
 
<pre>build/mk-uboot.sh rk3288-firefly
 
build/flash_tool.sh -p loader1 -i out/u-boot/idbloader.img -c rk3288
 
</pre>
 
 
 
'''update uboot(armv8 with miniloader)'''
 
<pre>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
 
</pre>
 
 
 
Before asking questions, please, read&nbsp;references and follow&nbsp;the setp by setp guide to boot your device.
 
  
&nbsp;
+
= Build Image =
  
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>
+
*Build all image
 +
**enter the root directory of Rockchip Linux SDK. use below command to build all image.&nbsp;  
 +
<pre>./build.sh all</pre>
  
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.
+
*Build U-Boot
 +
**Please refer to [[Uboot|U-Boot]] for how to build U-Boot 
 +
*Building kernel
 +
**Please refer to [[Kernel|kernel]]&nbsp;for how to build Kernel 
 +
*Building rootfs
 +
**Buildroot:&nbsp;Please refer to [[Buildroot|Buildroot]]&nbsp;for how to build Buildroot,&nbsp;&nbsp;'''We recommand customers&nbsp;use&nbsp;Buildroot for product development.&nbsp;'''
 +
**Debian:&nbsp;Please refer to [[Debian|Debian user guide]]&nbsp;for how to build Debian. '''Please note that Debian is a desktop OS, We recommand customers only use Debian for evaluation. Please use Buildroot for product development.&nbsp;''' 
 +
*Building recovery
 +
**please refer to [[Recovery|recovery page]] for how to build recovery image 
  
&nbsp;
+
= Pack Image =
  
= Step By Step =
+
Go back to root directory of Linux
  
== Building the sources ==
+
Please use below command to pack image for Debian
 
+
<pre>./mkfirmware.sh debian
=== Building uboot ===
 
 
 
Installing the build tools and download source
 
 
 
Compile the Uboot
 
<pre>CROSS_COMPILE=arm-linux-gnueabihf- make evb-rk3288_defconfig all
 
 
</pre>
 
</pre>
  
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
+
Please use below command to pack image for Buildroot
 
+
<pre>./mkfirmware.sh buildroot
See [[U-Boot|U-Boot]] page for more detail.
 
 
 
There are two feasible ways to boot to U-Boot.<br/> 1. RK SPL bin(DDR.bin, miniloader)<br/> 2. U-Boot SPL
 
 
 
See [[Boot_option|boot option]] page for more detail.
 
 
 
&nbsp;
 
 
 
=== Building kernel ===
 
 
 
Compile the kernel:
 
 
 
For ARM v7
 
<pre>make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rockchip_linux_defconfig
 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
 
 
</pre>
 
</pre>
  
For ARM V8
+
It will generate all the image you need in the rockimg directory.
<pre>make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- rockchip_linux_defconfig
+
<pre>rockdev/
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j4
+
├── boot.img
 +
├── MiniLoaderAll.bin
 +
├── misc.img
 +
├── oem.img
 +
├── parameter.txt
 +
├── recovery.img
 +
├── rootfs.img
 +
├── trust.img
 +
├── uboot.img
 +
└── userdata.img&nbsp;
 
</pre>
 
</pre>
  
You can get zImage/Image and dtbs when build complete, we will use these files to generate boot.img for boot partition.
+
= Flash image =
 
 
See [[Rockchip_Kernel|Rockchip kernel]] for more detail.
 
 
 
&nbsp;
 
 
 
=== Building rootfs ===
 
 
 
<small>It's recommend to download&nbsp;[http://opensource.rock-chips.com/wiki_Debian prebuilt debian image]&nbsp;for bringup.</small>
 
 
 
==== Debian ====
 
 
 
See&nbsp;[[Debian|debian-guide]]&nbsp;for detail.
 
 
 
You should get xxx-rootfs.img.
 
 
 
==== Yocto ====
 
 
 
See&nbsp;[[Yocto|yocto-user-guide]]&nbsp;for detail.
 
 
 
You should get xxx.ext4&nbsp;rootfs image.
 
 
 
==== Buildroot ====
 
 
 
See&nbsp;[[Buildroot|buildroot-user-guide]]&nbsp;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.
 
 
 
*[[Boot_option#Boot_from_eMMC|''Booting from emmc'']]
 
*[[Boot_option#Boot_from_SD.2FTF_Card|''Booting from sdcard'']]
 
*[[Boot_option#Boot_from_USB-Disk|''Booting from udisk'']]
 
 
 
&nbsp;
 
 
 
= See also =
 
 
 
[[U-Boot|U-Boot guide]]
 
 
 
[[Rockchip_Kernel|Rockchip kernel guide]]
 
 
 
[[Yocto|Yocto guide]]
 
 
 
[[Buildroot|Buildroot guide]]
 
 
 
&nbsp;
 
 
 
== Driver for Linux ==
 
 
 
Display:
 
 
 
*[[EDP|eDP]]
 
*[[MIPI-DSI|MIPI-DSI]]
 
*[[LVDS|LVDS]]
 
*[[HDMI|HDMI]]
 
 
 
Graphic:
 
 
 
*[[Rga|RGA]]
 
*[[GPU|GPU]]
 
*[[VOP|VOP]]
 
  
== Customization ==
+
Windows: Please refer to [[AndroidTool|AndroidTool]] for how to flash image to device
  
[[Boot_Time|Boot_Time]]
+
Linux: Please refer to [[Upgradetool|upgrade tool]] for how to flash image to device
  
[[Boot_Logo|Boot_Logo]]
 
  
[[Image_Size|Image_Size]]
+
= Download&nbsp;Image =
  
[[Firmware_Upgrade|Firmware_Upgrade]]
+
We provide prebuilt for all the board we support. Please go to [[Download|download]] page to download image you need
  
 
&nbsp;
 
&nbsp;

Latest revision as of 17:18, 23 July 2018

 

 

Overall

This guide provides information which will help you geting start with Rockchip Linux SDK. Please contact service@rock-chips.com if you need business support.

We are providing 2 kind of rootfs. Buildroot and prebuilt Debian. You can choose the way you prefer. 

  • Buildroot: An easy and small embedded Linux system. Recommend for your product development. 
  • Prebuilt Debian: A generic desktop Distro. Only for your evaluation. 

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

  • Rockchip miniloader: This is the first level boot loader
  • U-Boot: This is the second level boot loader
  • Trusted: ARM Trusted Firmware
  • Boot: It is Android boot image format. Pack kernel dtb and image to one partition. Use it for production. 
  • Rootfs: Buildroot or Debian system image
  • Recovery: It is Android boot image format. Pack kernel dtb, image and ramdisk to one partition. Use it for OTA update. 
  • Misc: used for transfer command between rootfs and recovery

 


Environment

Please use Ubuntu 16.04 or later version. The early version can't work.

Here are some necessary packages for building the project.

$ sudo apt-get install repo git u-boot-tools device-tree-compiler mtools parted libudev-dev libusb-1.0-0-dev lib32gcc-7-dev python-linaro-image-tools linaro-image-tools gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libstdc++-7-dev autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs mercurial rsync openssh-client subversion asciidoc w3m dblatex graphviz python-matplotlib libssl-dev pv e2fsprogs fakeroot devscripts libi2c-dev libncurses5-dev texinfo liblz4-tool genext2fs

 

Getting the Sources

Rockchip provide open source software on Github . Please check here to get the source code of Rockchip Linux SDK. 

Build Image

  • Build all image
    • enter the root directory of Rockchip Linux SDK. use below command to build all image. 
./build.sh all
  • Build U-Boot
    • Please refer to U-Boot for how to build U-Boot
  • Building kernel
    • Please refer to kernel for how to build Kernel
  • Building rootfs
    • Buildroot: Please refer to Buildroot for how to build Buildroot,  We recommand customers use Buildroot for product development. 
    • Debian: Please refer to Debian user guide for how to build Debian. Please note that Debian is a desktop OS, We recommand customers only use Debian for evaluation. Please use Buildroot for product development. 
  • Building recovery

Pack Image

Go back to root directory of Linux

Please use below command to pack image for Debian

./mkfirmware.sh debian

Please use below command to pack image for Buildroot

./mkfirmware.sh buildroot

It will generate all the image you need in the rockimg directory.

rockdev/
├── boot.img
├── MiniLoaderAll.bin
├── misc.img
├── oem.img
├── parameter.txt
├── recovery.img
├── rootfs.img
├── trust.img
├── uboot.img
└── userdata.img 

Flash image

Windows: Please refer to AndroidTool for how to flash image to device

Linux: Please refer to upgrade tool for how to flash image to device


Download Image

We provide prebuilt for all the board we support. Please go to download page to download image you need