Difference between revisions of "Buildroot"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
(updated by API)
(35 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
[[Buildroot for RK3399/zh|查看中文]]
 
[[Buildroot for RK3399/zh|查看中文]]
  
==Buildroot简介==
+
==Introduction to Buildroot==
Buildroot是Linux平台上一个构建嵌入式Linux系统的框架,由Makefile脚本和Kconfig配置文件构成,旨在简化系统制作步骤,可实现一站式生成可烧写的系统固件,最终的固件包含boot-loader、kernel和rootfs,以及rootfs中的各种库和应用程序 (例如qt, gstreamer, busybox等)。<br />
+
{{RK3399 Buildroot Intro|NanoPC-T4}}
<br />
+
由 FriendlyELEC 提供的 Buildroot 项目是基于Rockchip原厂的 linux-sdk 制作, 项目使用 git 管理,与原厂的linux sdk更新保持同步;
+
<br />
+
* Rockchip原厂Buildroot项目: https://github.com/rockchip-linux/buildroot<br />
+
* Buildroot官网: https://buildroot.org<br />
+
<br />
+
Buildroot for RK3399运行界面如下:
+
<div><ul>
+
<li style="display: inline-block;">[[File:rk3399-buildroot-home.jpg|500px]]</li>
+
<li style="display: inline-block;">[[File:rk3399-buildroot-console.jpg|500px]] </li>
+
</ul></div><br />
+
<div><ul>
+
<li style="display: inline-block;">[[File:rk3399-buildroot-camera.jpg|500px]]</li>
+
<li style="display: inline-block;">[[File:rk3399-buildroot-player.jpg|500px]] </li>
+
</ul></div>
+
  
==下载体验版固件==
+
==Download Images of Trial Version==
访问[http://download.friendlyarm.com/nanopct4 此处的下载地址]下载:<br />
+
===Buildroot for RK3568===
 +
Visit [http://download.friendlyelec.com/nanopir5s Download Link]Download:<br />
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
 
   | colspan=2 | Image Files
 
   | colspan=2 | Image Files
 
|-
 
|-
   | rk3399-sd-buildroot-linux-4.4-arm64-YYYYMMDD.img.zip
+
   | rk3568-sd-buildroot-5.10-arm64-YYYYMMDD.img.gz
   | 从SD卡启动的固件
+
   | OS image booting from SD card
 
|-
 
|-
   | rk3399-eflasher-buildroot-YYYYMMDD.img.zip
+
  | rk3568-eflasher-buildroot-YYYYMMDD.img.gz
   | 用于烧写到eMMC运行
+
  | Image used to flash to eMMC
 +
|}
 +
===Buildroot for RK3399===
 +
Visit [http://download.friendlyelec.com/nanopct4 Download Link]Download:<br />
 +
{| class="wikitable"
 +
|-
 +
  | colspan=2 | Image Files
 +
|-
 +
  | rk3399-sd-buildroot-linux-4.19-arm64-YYYYMMDD.img.zip
 +
  | OS image booting from SD card
 +
|-
 +
   | rk3399-eflasher-buildroot-4.19-arm64-YYYYMMDD.img.gz
 +
  | Image used to flash to eMMC
 +
|}
 +
===Buildroot for RK3328===
 +
Visit [http://download.friendlyelec.com/nanopir2cplus Download Link]Download:<br />
 +
{| class="wikitable"
 +
|-
 +
  | colspan=2 | Image Files
 +
|-
 +
  | rk3328-sd-buildroot-linux-4.19-arm64-YYYYMMDD.img.zip
 +
   | OS image booting from SD card
 +
|-
 +
  | rk3328-eflasher-buildroot-4.19-arm64-YYYYMMDD.img.gz
 +
  | Image used to flash to eMMC
 
|}
 
|}
解压后用 dd 或者 win32image 烧写到 SD 卡。
 
  
==获取项目源代码==
+
After extract the file you can use either dd or the win32image utility to flash the image to an SD card.
===安装 repo 工具===
+
==User Name and Password==
首先需要安装 repo 工具:
+
User name: root<br />
 +
Password: rockchip<br />
 +
<br />
 +
To change the password, please modify the following file:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
git clone https://github.com/friendlyarm/repo
+
buildroot/configs/rockchip/network.config
cp repo/repo /usr/bin/
+
 
</syntaxhighlight>
 
</syntaxhighlight>
===下载项目源代码===
+
==Connect WiFi==
有以下两种途径获取项目源代码,中国大陆用户建议使用方法1的途径下载:
+
* Edit /etc/wpa_supplicant.conf, fill in the ssid and psk with the WiFi information you want to connect to
====方法一:使用网盘里的repo压缩包====
+
* Start the wpa_supplicant process with the following command
网盘下载地址: [http://download.friendlyarm.com/{{#replace:{{#replace:{{BASEPAGENAME}}| |}}|/zh|}} 点击进入]<br />
+
文件位于网盘的以下路径:sources/linuxsdk-friendlyelec-YYYYMMDD.tar (YYYYMMDD表示打包的日期)<br />
+
从网盘中获取的 repo 压缩包在解压之后,需要执行一下以下命令做一次解包动作:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
tar xvf /path/to/netdisk/sources/linuxsdk-friendlyelec-YYYYMMDD.tar
+
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
cd linuxsdk-friendlyelec
+
repo sync -l
+
 
</syntaxhighlight>
 
</syntaxhighlight>
用此方法得到的源代码版本是repo打包时的版本,如果想拉取到官方最新的版本,可以去掉 -l 参数,执行一次 repo sync, 例如:
+
* If there is no error, you can check the ip address with the command 'ifconfig wlan0'
 +
==Obtain Source Code==
 +
===Install repo Utility===
 +
Install the repo utility:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd linuxsdk-friendlyelec
+
git clone https://github.com/friendlyarm/repo --depth 1
repo sync
+
sudo cp repo/repo /usr/bin/
 
</syntaxhighlight>
 
</syntaxhighlight>
====方法二:从github下载====
+
===Download Source Code===
 +
You can retrieve a project's source code in either of the following two ways. The first works better with Mainland Chinese users:
 +
====1: Retrieve Repo Package from NetDrive====
 +
Download link: [http://download.friendlyelec.com/nanopir5s RK3568]  [http://download.friendlyelec.com/nanopct4 RK3399]  [http://download.friendlyelec.com/nanopir2cplus RK3328]<br />
 +
File location: '07_Source codes'/buildroot-rkXXXX-YYYYMMDD.tar (YYYYMMDD stands for the data when the package is generated)<br />
 +
After you get a tar package, untar it and run the following command to extract it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
mkdir linuxsdk-friendlyelec
+
tar xvf /path/to/netdrive/'07_Source codes'/buildroot-rkXXXX-YYYYMMDD.tar
cd linuxsdk-friendlyelec
+
cd buildroot-rkXXXX
repo init -u https://github.com/friendlyarm/buildroot_manifests -b master -m rk3399_linux_release.xml --repo-url=https://github.com/rockchip-linux/repo
+
repo sync -l --no-clone-bundle
repo sync -c
+
 
</syntaxhighlight>
 
</syntaxhighlight>
====同步项目到最新版本====
+
If you want to get the latest official source code you can run the following commands:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
cd linuxsdk-friendlyelec
+
cd buildroot-rkXXXX
repo sync -c
+
repo sync --no-clone-bundle
 
</syntaxhighlight>
 
</syntaxhighlight>
同步过程中,由于网络原因出现中断,可以使用下面脚本同步代码:
+
====2: Retrive Repo Package from Github====
 +
=====Buildroot for RK3568=====
 +
<syntaxhighlight lang="bash">
 +
mkdir buildroot-rk3568
 +
cd buildroot-rk3568
 +
repo init -u https://github.com/friendlyarm/buildroot_manifests \
 +
    -b rockchip-kernel4.19 -m rk3568.xml --repo-url=https://github.com/friendlyarm/repo \
 +
    --no-clone-bundle
 +
repo sync -c --no-clone-bundle
 +
</syntaxhighlight>
 +
=====Buildroot for RK3399=====
 +
<syntaxhighlight lang="bash">
 +
mkdir buildroot-rk3399
 +
cd buildroot-rk3399
 +
repo init -u https://github.com/friendlyarm/buildroot_manifests \
 +
    -b rockchip-kernel4.19 -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo \
 +
    --no-clone-bundle
 +
repo sync -c --no-clone-bundle
 +
</syntaxhighlight>
 +
=====Buildroot for RK3328=====
 +
<syntaxhighlight lang="bash">
 +
mkdir buildroot-rk3328
 +
cd buildroot-rk3328
 +
repo init -u https://github.com/friendlyarm/buildroot_manifests \
 +
    -b rockchip-kernel4.19 -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo \
 +
    --no-clone-bundle
 +
repo sync -c --no-clone-bundle
 +
</syntaxhighlight>
 +
====Get Latest Version with Sync====
 +
<syntaxhighlight lang="bash">
 +
repo sync -c --no-clone-bundle
 +
</syntaxhighlight>
 +
If your network connection is broken during sync you can run the following script to do it:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
#! /bin/bash
 
#! /bin/bash
repo sync -c
+
repo sync -c --no-clone-bundle
 
while [ $? -ne 0 ];  
 
while [ $? -ne 0 ];  
 
do   
 
do   
     repo sync -c
+
     repo sync -c --no-clone-bundle
 
done
 
done
 +
</syntaxhighlight>
 +
==Compile Source Code==
 +
===Setup Development Environment===
 +
You need a host PC running a 64-bit Ubuntu 18.04 system and run the following command on the PC:
 +
<syntaxhighlight lang="bash">
 +
wget -O - https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | bash
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==如何编译==
+
===Build buildroot in Docker container===
===搭建编译环境===
+
Please use the Docker image provided by this link, for details, please refer to the README document:<br />
在PC的Ubuntu系统下,执下以下命令安装所需的软件:
+
https://github.com/friendlyarm/friendlyelec-ubuntu18-docker<br />
 +
 
 +
===Get Help Info===
 +
Run the build.sh script without any options it will print the help information:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo apt-get install repo git-core gitk git-gui gcc-arm-linux-gnueabihf u-boot-tools device-tree-
+
./build.sh
compiler gcc-aarch64-linux-gnu mtools parted libudev-dev libusb-1.0-0-dev python-linaro-image-
+
</syntaxhighlight>
tools linaro-image-tools autoconf autotools-dev libsigsegv2 m4 intltool libdrm-dev curl sed make
+
Let's take RK3399 as an example, the help information will be presented as follows:
binutils build-essential gcc g++ bash patch gzip bzip2 perl tar cpio python unzip rsync file bc wget
+
<syntaxhighlight lang="bash">
libncurses5 libqt4-dev libglib2.0-dev libgtk2.0-dev libglade2-dev cvs git mercurial rsync openssh-
+
USAGE: ./build.sh <parameter>
client subversion asciidoc w3m dblatex graphviz python-matplotlib libc6:i386 libssl-dev texinfo
+
 
liblz4-tool genext2fs lib32stdc++6
+
# Select Board Type:
 +
  ./build.sh nanopc_t4.mk
 +
  ./build.sh nanopi_m4.mk
 +
  ./build.sh nanopi_neo4.mk
 +
  ./build.sh nanopi_r4s.mk
 +
  ./build.sh som-rk3399.mk
 +
 
 +
# Select Module:
 +
  ./build.sh all                -compile all
 +
  ./build.sh uboot              -compile uboot
 +
  ./build.sh kernel            -compile kernel
 +
  ./build.sh buildroot          -compile buildroot
 +
  ./build.sh sd-img            -generate an image for an sd card
 +
  ./build.sh emmc-img          -generate an image for emmc (the generated image should be flased to an SD card and then flashed to emm with this SD card)
 +
# Clean:
 +
  ./build.sh clean              -remove old images
 +
  ./build.sh cleanall
 
</syntaxhighlight>
 
</syntaxhighlight>
  
===全自动方式编译===
+
===Auto Compile===
 +
For a first time compilation you need to select an board. Let's take the NanoPi R4S as an example:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./build.sh
+
./build.sh nanopi_r1.mk
 
</syntaxhighlight>
 
</syntaxhighlight>
===部分编译===
+
After the script is done successfully all components including a u-boot, a kernel and a buildroot will be compiled, and an image file will be generated.
 +
 
 +
===Compile Individual Component===
 
====kernel====
 
====kernel====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
Line 104: Line 177:
 
./build.sh uboot
 
./build.sh uboot
 
</syntaxhighlight>
 
</syntaxhighlight>
====rootfs====
+
====buildroot====
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./build.sh rootfs
+
./build.sh buildroot
 
</syntaxhighlight>
 
</syntaxhighlight>
===生成sdcard固件===
+
===Generate Image for SD Card===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./build.sh sd-img
+
sudo ./build.sh sd-img
 
</syntaxhighlight>
 
</syntaxhighlight>
或者直接将固件烧写到sd卡:
+
If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:<br />
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./friendlyelec/rk3399/sd-fuse_rk3399/fusing.sh /dev/sdX buildroot
+
Run the following for sdcard install:
 +
    sudo dd if=out/Buildroot_20211213_NanoPi-R4S_arm64_sd.img bs=1M of=/dev/sdX
 
</syntaxhighlight>
 
</syntaxhighlight>
其中,/dev/sdX请替换为真实的SD卡设备文件名。
+
===Generate emmc (eflasher) Image===
===生成emmc (eflasher) 固件===
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
./build.sh emmc-img
+
sudo ./build.sh emmc-img
 
</syntaxhighlight>
 
</syntaxhighlight>
 
+
If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:<br />
===查看帮助===
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
# ./build.sh help
+
Run the following for sdcard install:
====USAGE: build.sh modules====
+
    sudo dd if=out/Buildroot_20211213_NanoPi-R4S_arm64_eflasher.img bs=1M of=/dev/sdX
uboot              -build uboot
+
kernel            -build kernel
+
rootfs            -build default rootfs, currently build buildroot as default
+
buildroot          -build buildroot rootfs
+
ramboot            -build ramboot image
+
yocto              -build yocto rootfs, currently build ros as default
+
ros                -build ros rootfs
+
debian            -build debian rootfs
+
pcba              -build pcba
+
recovery          -build recovery
+
all                -build uboot, kernel, rootfs, recovery image
+
cleanall          -clean uboot, kernel, rootfs, recovery
+
firmware          -pack all the image we need to boot up system
+
updateimg          -pack update image
+
sd-img            -build sd-card image
+
emmc-img          -build sd-card image
+
save              -save images, patches, commands used to debug
+
default            -build all module
+
 
</syntaxhighlight>
 
</syntaxhighlight>
重点参数说明:<br />
+
Use this SD card to boot the eflasher system and run eflasher commands to install an OS to emmc. After installation is done, take off the SD card of the board and boot your system buildroot will load from eMMC.
uboot              -单独编译uboot<br />
+
kernel            -单独编译kernel<br />
+
rootfs            -单独编译buildroot<br />
+
buildroot         -同上<br />
+
sdimg              -生成用于dd到sd卡的image文件,以及用于eFlasher工具使用的eMMC烧写文件<br />
+
<br />
+
  
==Buildroot定制与开发==
+
==Customize Buildroot==
===目录结构===
+
===Structure of Directories===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
├── linuxsdk-friendlyelec
+
├── buildroot-xxyyzz
│  ├── app
+
│  ├── buildroot -> buildroot's source code
│  ├── buildroot buildroot根文件系统的编译目录
+
│  └── toolchain -> cross-compiler, used for compiling a u-boot and kernel
│  ├── build.sh -> device/rockchip/common/build.sh 全自动编译脚本
+
│  ├── build.sh -> build script
│  ├── device 编译相关配置文件
+
│  ├── device/friendlyelec -> configuration file for friendlyelec boards
│  ├── distro debian根文件系统生成目录
+
│  ├── kernel -> kernel
│  ├── docs 文档
+
│  └── u-boot -> u-boot
│  ├── envsetup.sh -> buildroot/build/envsetup.sh
+
│  └── app -> rockchip app
│  ├── external
+
│  └── external -> rockchip buildroot package
│  ├── friendlyelec 用于适配友善电子RK3399开发板的文件
+
│  └── rkbin -> rockchip loader binaries
│  ├── kernel 内核
+
│  └── scripts -> script files for generating an img
│  ├── Makefile -> buildroot/build/Makefile
+
│  ├── mkfirmware.sh -> device/rockchip/common/mkfirmware.sh rockdev链接更新脚本
+
│  ├── prebuilts
+
│  ├── rkbin  
+
│  ├── rkflash.sh -> device/rockchip/common/rkflash.sh 烧写脚本
+
│  ├── rootfs debian根文件系统编译目录
+
│  ├── tools 烧写、打包工具
+
│  └── u-boot u-boot
+
 
</syntaxhighlight>
 
</syntaxhighlight>
====更改Buildroot配置====
+
 
* 列出当前可用的配置
+
====Update Buildroot Configurations====
 +
* List Available Configurations
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd buildroot
 
cd buildroot
 
make list-defconfigs
 
make list-defconfigs
 
</syntaxhighlight>
 
</syntaxhighlight>
显示所下:<br />
+
The configuration of FriendlyELEC RK3399:<br />
rockchip_rk3399_defconfig           - Build for rockchip_rk3399<br />
+
friendlyelec_rk3399_defconfig           - Build for friendlyelec_rk3399<br />
* 使用menuconfig更改配置
+
* Update Configurations Using menuconfig
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
make rockchip_rk3399_defconfig
+
make friendlyelec_rk3399_defconfig
 
make menuconfig
 
make menuconfig
 
make savedefconfig
 
make savedefconfig
diff .defconfig configs/rockchip_rk3399_defconfig
+
diff .defconfig configs/friendlyelec_rk3399_defconfig
cp .defconfig configs/rockchip_rk3399_defconfig
+
cp .defconfig configs/friendlyelec_rk3399_defconfig
 
</syntaxhighlight>
 
</syntaxhighlight>
* 重新编译
+
* Recompile
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
cd ../
 
cd ../
./build.sh rootfs
+
./build.sh buildroot
 +
</syntaxhighlight>
 +
===Customize File System===
 +
Put the file in device/friendlyelec/rk3399/common-files, then repackage the img:
 +
<syntaxhighlight lang="bash">
 +
sudo ./build.sh sd-img
 +
sudo ./build.sh emmc-img
 
</syntaxhighlight>
 
</syntaxhighlight>
===预装文件到文件系统===
+
===Update U-boot and Kernel===
将文件放在 friendlyelec/rk3399/fs-overlay-64,然后重新编译 rootfs。
+
You can do it by directly updating the files in the u-boot and kernel directories.
===修改u-boot和kernel===
+
===Use Cross Compiler in SDK===
直接修改u-boot和kernel目录下的文件即可。
+
===使用sdk里的交叉编译器===
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
export PATH=$PWD/buildroot/output/rockchip_rk3399/host/bin/:$PATH
 
export PATH=$PWD/buildroot/output/rockchip_rk3399/host/bin/:$PATH
 
aarch64-buildroot-linux-gnu-g++ -v
 
aarch64-buildroot-linux-gnu-g++ -v
 
</syntaxhighlight>
 
</syntaxhighlight>
显示版本如下:<br />
+
Version information:<br />
gcc 版本 6.4.0 (Buildroot 2018.02-rc3-g4f000a0797)
+
gcc version 6.4.0 (Buildroot 2018.02-rc3-g4f000a0797)
===交叉编译Qt程序===
+
===Cross Compile Qt Program===
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
git clone https://github.com/friendlyarm/QtE-Demo.git
 
git clone https://github.com/friendlyarm/QtE-Demo.git
Line 215: Line 260:
 
make
 
make
 
</syntaxhighlight>
 
</syntaxhighlight>
要实现开机自动运行你的Qt程序,可将QtE-Demo拷贝到开发板上,然后修改 /etc/init.d/下的S50launcher,将/usr/local/QLauncher/QLauncher &这一行改为QtE-Demo的文件路径即可。
+
You can auto-run your Qt program on system boot. For example you want to auto-run a QtE-Demo program. Firstly you can copy the QtE-Demo to your board, open and edit the S50launcher file under the "/etc/init.d/" directory, replace "/usr/local/QLauncher/QLauncher &" with the full path of your QtE-Demo program.
 +
==Q&A==
 +
===Generate Image File for Flashing with USB Type-C===
 +
After you run the "build.sh emmc-img" command a "buildroot" directory will be generated under the "scripts/sd-fuse" directory. You can use the android_tools to load all the files under this "buildroot" directory.
 +
==Report bug==
 +
Please mail-to:techsupport@friendlyarm.com<br />
 +
==Update Log==
 +
===2022-07-20===
 +
* add support for rk3568
 +
* update buildroot
 +
===2021-12-23===
 +
* Simplify the build script and update buildroot
 +
===May-16-2019===
 +
* Released English version

Revision as of 08:22, 8 September 2022

查看中文

1 Introduction to Buildroot

Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux systems through cross-compilation. It contains a boot-loader, kernel, rootfs, various libraries and utilities(e.g. qt, gstreamer, busybox etc).

FriendlyELEC's Buildroot is based on Rockchip's version which is made with linux-sdk and maintained with git. FriendlyELEC's version is synced with Rockchip's version;


Here is what Buildroot for rockchip looks like

  • Rk3399-buildroot-home.jpg
  • Rk3399-buildroot-console.jpg

  • Rk3399-buildroot-camera.jpg
  • Rk3399-buildroot-player.jpg

2 Download Images of Trial Version

2.1 Buildroot for RK3568

Visit Download LinkDownload:

Image Files
rk3568-sd-buildroot-5.10-arm64-YYYYMMDD.img.gz OS image booting from SD card
rk3568-eflasher-buildroot-YYYYMMDD.img.gz Image used to flash to eMMC

2.2 Buildroot for RK3399

Visit Download LinkDownload:

Image Files
rk3399-sd-buildroot-linux-4.19-arm64-YYYYMMDD.img.zip OS image booting from SD card
rk3399-eflasher-buildroot-4.19-arm64-YYYYMMDD.img.gz Image used to flash to eMMC

2.3 Buildroot for RK3328

Visit Download LinkDownload:

Image Files
rk3328-sd-buildroot-linux-4.19-arm64-YYYYMMDD.img.zip OS image booting from SD card
rk3328-eflasher-buildroot-4.19-arm64-YYYYMMDD.img.gz Image used to flash to eMMC

After extract the file you can use either dd or the win32image utility to flash the image to an SD card.

3 User Name and Password

User name: root
Password: rockchip

To change the password, please modify the following file:

buildroot/configs/rockchip/network.config

4 Connect WiFi

  • Edit /etc/wpa_supplicant.conf, fill in the ssid and psk with the WiFi information you want to connect to
  • Start the wpa_supplicant process with the following command
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
  • If there is no error, you can check the ip address with the command 'ifconfig wlan0'

5 Obtain Source Code

5.1 Install repo Utility

Install the repo utility:

git clone https://github.com/friendlyarm/repo --depth 1
sudo cp repo/repo /usr/bin/

5.2 Download Source Code

You can retrieve a project's source code in either of the following two ways. The first works better with Mainland Chinese users:

5.2.1 1: Retrieve Repo Package from NetDrive

Download link: RK3568 RK3399 RK3328
File location: '07_Source codes'/buildroot-rkXXXX-YYYYMMDD.tar (YYYYMMDD stands for the data when the package is generated)
After you get a tar package, untar it and run the following command to extract it:

tar xvf /path/to/netdrive/'07_Source codes'/buildroot-rkXXXX-YYYYMMDD.tar
cd buildroot-rkXXXX
repo sync -l --no-clone-bundle

If you want to get the latest official source code you can run the following commands:

cd buildroot-rkXXXX
repo sync --no-clone-bundle

5.2.2 2: Retrive Repo Package from Github

5.2.2.1 Buildroot for RK3568
mkdir buildroot-rk3568
cd buildroot-rk3568
repo init -u https://github.com/friendlyarm/buildroot_manifests \
    -b rockchip-kernel4.19 -m rk3568.xml --repo-url=https://github.com/friendlyarm/repo \
    --no-clone-bundle
repo sync -c --no-clone-bundle
5.2.2.2 Buildroot for RK3399
mkdir buildroot-rk3399
cd buildroot-rk3399
repo init -u https://github.com/friendlyarm/buildroot_manifests \
    -b rockchip-kernel4.19 -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo \
    --no-clone-bundle
repo sync -c --no-clone-bundle
5.2.2.3 Buildroot for RK3328
mkdir buildroot-rk3328
cd buildroot-rk3328
repo init -u https://github.com/friendlyarm/buildroot_manifests \
    -b rockchip-kernel4.19 -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo \
    --no-clone-bundle
repo sync -c --no-clone-bundle

5.2.3 Get Latest Version with Sync

repo sync -c --no-clone-bundle

If your network connection is broken during sync you can run the following script to do it:

#! /bin/bash
repo sync -c --no-clone-bundle
while [ $? -ne 0 ]; 
do  
    repo sync -c --no-clone-bundle
done

6 Compile Source Code

6.1 Setup Development Environment

You need a host PC running a 64-bit Ubuntu 18.04 system and run the following command on the PC:

wget -O - https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh | bash

6.2 Build buildroot in Docker container

Please use the Docker image provided by this link, for details, please refer to the README document:
https://github.com/friendlyarm/friendlyelec-ubuntu18-docker

6.3 Get Help Info

Run the build.sh script without any options it will print the help information:

./build.sh

Let's take RK3399 as an example, the help information will be presented as follows:

USAGE: ./build.sh <parameter>
 
# Select Board Type:
  ./build.sh nanopc_t4.mk
  ./build.sh nanopi_m4.mk
  ./build.sh nanopi_neo4.mk
  ./build.sh nanopi_r4s.mk
  ./build.sh som-rk3399.mk
 
# Select Module:
  ./build.sh all                -compile all
  ./build.sh uboot              -compile uboot
  ./build.sh kernel             -compile kernel
  ./build.sh buildroot          -compile buildroot
  ./build.sh sd-img             -generate an image for an sd card
  ./build.sh emmc-img           -generate an image for emmc (the generated image should be flased to an SD card and then flashed to emm with this SD card)
# Clean:
  ./build.sh clean              -remove old images
  ./build.sh cleanall

6.4 Auto Compile

For a first time compilation you need to select an board. Let's take the NanoPi R4S as an example:

./build.sh nanopi_r1.mk

After the script is done successfully all components including a u-boot, a kernel and a buildroot will be compiled, and an image file will be generated.

6.5 Compile Individual Component

6.5.1 kernel

./build.sh kernel

6.5.2 u-boot

./build.sh uboot

6.5.3 buildroot

./build.sh buildroot

6.6 Generate Image for SD Card

sudo ./build.sh sd-img

If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:

Run the following for sdcard install:
    sudo dd if=out/Buildroot_20211213_NanoPi-R4S_arm64_sd.img bs=1M of=/dev/sdX

6.7 Generate emmc (eflasher) Image

sudo ./build.sh emmc-img

If an img file is generated successfully you will see the following messages. You can use the "dd" command to flash the img file to an SD card. Note: you will need to replace "/dev/sdX" with the actual device name which your system recognizes the device as:

Run the following for sdcard install:
    sudo dd if=out/Buildroot_20211213_NanoPi-R4S_arm64_eflasher.img bs=1M of=/dev/sdX

Use this SD card to boot the eflasher system and run eflasher commands to install an OS to emmc. After installation is done, take off the SD card of the board and boot your system buildroot will load from eMMC.

7 Customize Buildroot

7.1 Structure of Directories

├── buildroot-xxyyzz
│   ├── buildroot -> buildroot's source code
│   └── toolchain -> cross-compiler, used for compiling a u-boot and kernel
│   ├── build.sh -> build script
│   ├── device/friendlyelec -> configuration file for friendlyelec boards
│   ├── kernel -> kernel
│   └── u-boot -> u-boot
│   └── app -> rockchip app
│   └── external -> rockchip buildroot package
│   └── rkbin -> rockchip loader binaries
│   └── scripts -> script files for generating an img

7.1.1 Update Buildroot Configurations

  • List Available Configurations
cd buildroot
make list-defconfigs

The configuration of FriendlyELEC RK3399:
friendlyelec_rk3399_defconfig - Build for friendlyelec_rk3399

  • Update Configurations Using menuconfig
make friendlyelec_rk3399_defconfig
make menuconfig
make savedefconfig
diff .defconfig configs/friendlyelec_rk3399_defconfig 
cp .defconfig configs/friendlyelec_rk3399_defconfig
  • Recompile
cd ../
./build.sh buildroot

7.2 Customize File System

Put the file in device/friendlyelec/rk3399/common-files, then repackage the img:

sudo ./build.sh sd-img
sudo ./build.sh emmc-img

7.3 Update U-boot and Kernel

You can do it by directly updating the files in the u-boot and kernel directories.

7.4 Use Cross Compiler in SDK

export PATH=$PWD/buildroot/output/rockchip_rk3399/host/bin/:$PATH
aarch64-buildroot-linux-gnu-g++ -v

Version information:
gcc version 6.4.0 (Buildroot 2018.02-rc3-g4f000a0797)

7.5 Cross Compile Qt Program

git clone https://github.com/friendlyarm/QtE-Demo.git
cd QtE-Demo
../buildroot/output/rockchip_rk3399/host/bin/qmake QtE-Demo.pro
make

You can auto-run your Qt program on system boot. For example you want to auto-run a QtE-Demo program. Firstly you can copy the QtE-Demo to your board, open and edit the S50launcher file under the "/etc/init.d/" directory, replace "/usr/local/QLauncher/QLauncher &" with the full path of your QtE-Demo program.

8 Q&A

8.1 Generate Image File for Flashing with USB Type-C

After you run the "build.sh emmc-img" command a "buildroot" directory will be generated under the "scripts/sd-fuse" directory. You can use the android_tools to load all the files under this "buildroot" directory.

9 Report bug

Please mail-to:techsupport@friendlyarm.com

10 Update Log

10.1 2022-07-20

  • add support for rk3568
  • update buildroot

10.2 2021-12-23

  • Simplify the build script and update buildroot

10.3 May-16-2019

  • Released English version