Compile Linux firmware
Download Firefly_Linux_SDK
First prepare an empty folder to place SDK, better under home, here we use ~/proj as example.
Compilation Notes
Attention:
1. SDK uses cross-compile, so download SDK to your X86_64 PC, do not download SDK to arm64 board.
2. Build environment needs to be Ubuntu18.04 (real PC or docker container), other versions may cause build failure.
3. Do not put SDK under shared directory of VM or non-English path.
4. Please get/build SDK as a normal user, root privilege are neither allowed nor required (except installing sth. with apt)
Install Tools
sudo apt update
sudo apt install -y repo git pythonInit Code Repository
- Method One
Download via repo, you can choose to get full SDK or BSP:
mkdir ~/proj/rk3588_sdk/
cd ~/proj/rk3588_sdk/
## Full SDK
repo init --no-clone-bundle --repo-url https://github.com/Firefly-rk-linux-utils/git-repo.git --no-repo-verify -u https://github.com/Firefly-rk-linux/manifests.git -b master -m rk3588_linux_release.xml
## BSP (Only include some basic repositories and compile tools(Only for ubuntu & debian))
## BSP includes device/rockchip, docs, kernel, u-boot, rkbin, tools and cross-compile toolchian
repo init --no-clone-bundle --repo-url https://github.com/Firefly-rk-linux-utils/git-repo.git --no-repo-verify -u https://github.com/Firefly-rk-linux/manifests.git -b master -m rk3588_linux_bsp_release.xml- Method Two
Download Firefly_Linux_SDK sub-volume compressed package: Linux SDK, follow the README document:
└── rk3588_linux_release_xxx
├── linux_sdk_tar
│ ├── rk3588_linux_release_xxx.sdk.split00
│ ├── rk3588_linux_release_xxx.sdk.split01
│ ├── rk3588_linux_release_xxx.sdk.split02
│ ├── rk3588_linux_release_xxx.sdk.split03
├── md5sum.txt
├── README_EN.txt
├── README_ZH.txt
└── sdk_tools.shSync Code
Execute the following command to synchronize the code:
# Enter the SDK root directory
cd ~/proj/rk3588_sdk
# Sync
.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --allYou can use the following command to update the SDK later:
.repo/repo/repo sync -c --no-tagsLinux SDK Configuration introduction
Compile firmware
Compile Ubuntu firmware
This chapter introduces the compilation process of Ubuntu firmware. It is recommended to develop under Ubuntu 18.04 system environment. If you use other system versions, you may need to adjust the compilation environment accordingly.
The compilation portion of this tutorial works with SDK versions above v1.0.6e$ readlink -f .repo/manifest.xml
/home/daijh/p/rk3588/.repo/manifests/rk3588/rk3588_linux_release_20230301_v1.0.6e.xmlPreparatory work
Set up compilation environment
sudo apt-get install repo git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip \
device-tree-compiler ncurses-dev \Compile SDK
Precompile Configuration
There are configuration files for different board in device/rockchip/rk3588/, select the configuration file:
./build.sh roc-rk3588s-pc-ext-ubuntu.mkBuild
Automatic compilation
- Download: Ubuntu rootfs(64-bit),put in SDK path
7z x ubuntu-aarch64-rootfs.7z
mkdir ubuntu_rootfs
mv ubuntu-aarch64-rootfs.img ubuntu_rootfs/rootfs.img- start compiling
./build.shthe firmware will be saved to the directory rockdev/pack/.
Partial compilation
- u-boot
./build.sh uboot- kernel
./build.sh extboot- recovery
./build.sh recovery- Download: Ubuntu rootfs(64-bit),put in SDK path
7z x ubuntu-aarch64-rootfs.7z
mkdir ubuntu_rootfs
mv ubuntu-aarch64-rootfs.img ubuntu_rootfs/rootfs.img- Update each part of the
.imglink to the directoryrockdev/:
./mkfirmware.sh- Pack the firmware, the firmware will be saved to the directory
rockdev/pack/.
./build.sh updateimgCompile Yocto firmware
Get SDK
repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m rk3588_yocto_kirkstone_release.xml
.repo/repo/repo sync -cCompile
Select image
The Yocto project provides some images that can be used without layers. The following table lists currently supported build images and associated recipes.
| Image name | Target | provided by layer |
|---|---|---|
| core-image-minimal | A small image that only allows a device to boot | Poky |
| core-image-minimal-xfce | A XFCE minimal demo image | meta-openembedded/meta-xfce |
| core-image-sato | Image with Sato, a mobile environment and visual style for mobile devices. The image supports X11 with a Sato theme, Pimlico applications, and contains terminal, editor, and file manager | Poky |
| core-image-weston | A very basic Wayland image with a terminal | Poky |
| core-image-x11 | A very basic X11 image with a terminal | Poky |
Build image
The process of building with the bitbake command needs to ensure that the network connection is normal. If it is a customer in inland China, you need to ensure that it can ping the external network
- Enter the directory <path/to/yocto/poky> and execute the following commands in sequence
# Install the required environment packages
# sudo apt install zstd
source oe-init-build-env
# add layer
bitbake-layers add-layer ../../meta-openembedded/meta-oe
bitbake-layers add-layer ../../meta-openembedded/meta-python
bitbake-layers add-layer ../../meta-openembedded/meta-networking
bitbake-layers add-layer ../../meta-openembedded/meta-multimedia
bitbake-layers add-layer ../../meta-openembedded/meta-gnome
bitbake-layers add-layer ../../meta-openembedded/meta-xfce
bitbake-layers add-layer ../../meta-lts-mixins
bitbake-layers add-layer ../../meta-clang
bitbake-layers add-layer ../../meta-browser/meta-chromium
bitbake-layers add-layer ../../meta-rockchipChoose one of the commands to compile the complete core-image recipes. The following is an x11 based core-image.
MACHINE=roc-rk3588s-pc-ext bitbake core-image-minimal
MACHINE=roc-rk3588s-pc-ext bitbake core-image-minimal-xfce
MACHINE=roc-rk3588s-pc-ext bitbake core-image-x11
MACHINE=roc-rk3588s-pc-ext bitbake core-image-satoThe following is a core-image based on wayland. You need to modify DISPLAY_PLATFORM to wayland in /path/to/yocto/meta-rockchip/conf/machine/include/display.conf. Modify as follows:
DISPLAY_PLATFORM ?= "wayland"
# DISPLAY_PLATFORM ?= "x11"After completing the above modifications, execute the command to compile core-image-weston
MACHINE=roc-rk3588s-pc-ext bitbake core-image-westonNote: If you need to change the compiled core-image recipes after you have already compiled core-image once, you need to clean up the currently compiled core-image and then compile a new core-image.
For example: the currently compiled one is core-image-minimal. You need to change it to core-image-sato.
MACHINE=roc-rk3588s-pc-ext bitbake core-image-minimal -c clean
MACHINE=roc-rk3588s-pc-ext bitbake core-image-satoIf you want to compile some recipes separately, you can refer to the following:
# kernel
MACHINE=roc-rk3588s-pc-ext bitbake linux-rockchip
# u-boot
MACHINE=roc-rk3588s-pc-ext bitbake u-boot-rockchip
# rkmpp
MACHINE=roc-rk3588s-pc-ext bitbake rockchip-mpp
# rockchip-librga
MACHINE=roc-rk3588s-pc-ext bitbake rockchip-librga
# See more compilation objects
MACHINE=roc-rk3588s-pc-ext bitbake -sAdjust compilation speed
Modify the BB_NUMBER_THREADS and PARALLEL_MAKE variables in the file /path/to/yocto/meta-rockchip/conf/machine/firefly-rk3588.conf. If the number of threads is set too large, the machine may run out of memory and cause compilation failure. Please set the compilation speed according to the configuration of the compilation machine.
BB_NUMBER_THREADS = "4"
PARALLEL_MAKE = "-j 4"- BB_NUMBER_THREADS: The maximum number of threads BitBake simultaneously executes.
- BB_NUMBER_PARSE_THREADS: The number of threads BitBake uses during parsing.
- PARALLEL_MAKE: Extra options passed to the
makecommand during the do_compile task in order to specify parallel compilation on the local build host. - PARALLEL_MAKEINST: Extra options passed to the
makecommand during the do_install task in order to specify parallel installation on the local build host.
More bitbake options
Fundamentally, BitBake is a generic task execution engine that allows shell and Python tasks to be run efficiently and in parallel while working within complex inter-task dependency constraints. One of BitBake’s main users, OpenEmbedded, takes this core and builds embedded Linux software stacks using a task-oriented approach.For more detailed usage, please check《bitbake-user-manual》。
MACHINE=roc-rk3588s-pc-ext bitbake <target> <paramater>
# e.g
MACHINE=roc-rk3588s-pc-ext bitbake u-boot-rockchip -c clean
MACHINE=roc-rk3588s-pc-ext bitbake u-boot-rockchip| Bitbake paramater | Description |
|---|---|
| -c fetch | Fetches if the downloads state is not marked as done |
| -c clean | Removes all output files for a target |
| -c cleanall | Removes all output files, shared state cache, and downloaded source files for a target |
| -c compile -f | It is not recommended that the source code under the temporary directory is changed directly, but if it is, the Yocto Project might not rebuild it unless this option is used. Use this option to force a recompile after the image is deployed. |
| -c listtasks | Lists all defined tasks for a target |
Partition firmware upgrade
The compiled firmware is located in the directory <path/to/yocto>/build/tmp/deploy/images/<board>/
$ sudo upgrade_tool di -boot boot.img
$ sudo upgrade_tool di -uboot uboot.img
$ sudo upgrade_tool di -misc misc.img
$ sudo upgrade_tool di -recovery recovery.img- Partition burning is suitable for debugging stage. For firmware verification, please use the unified firmware burning below.
- Rootfs does not support separate burning. You need to pack the complete firmware before burning.
Unified firmware upgrade
The compiled firmware is located in the directory <path/to/yocto>/build/tmp/deploy/images/<board>/, the files to be downloaded are .wic and update.img, and after entering the loader mode, execute the following commands :
$ sudo upgrade_tool wl 0 <IMAGE NAME>.wic
$ sudo upgrade_tool uf update.img- The default login account of the firmware is: root, password: firefly. The firmware contains a common user account named firefly, and the password is firefly.
Note: If you are developing on a Windows PC, you can use RKdevtool to directly burn update.img, no need to burn <IMAGE NAME>.wic. However, please note that update.img is a link file, so you must select the actual file that the link file points to.
Related overview
The Yocto Project is an open source collaborative project focused on embedded Linux® operating system development that provides a flexible toolset and development environment that allows embedded device developers worldwide to share technologies, software stacks, configurations and tools for creating these customizations Best Practices for Linux Imaging Collaboration. For more information about the Yocto Project, please refer to the official Yocto Project website:www.yoctoproject.org/. The Yocto Project home page has the Yocto Project Reference Manual and the Yocto Project Overview and other related documents describe in detail how to build the system.
Introduction to Yocto Project Release layer
| layer | path | priority(The higher the number, the higher the priority) | describe |
|---|---|---|---|
| meta-oe | meta-openembedded/meta-oe | 6 | contains a large amount of additional recipes |
| meta-python | meta-openembedded/meta-python | 7 | Provide Python recipes |
| meta-qt5 | meta-qt5 | 7 | Provides QT5 recipes |
| meta-clang | meta-clang | 7 | clang compiler |
| meta-rockchip | meta-rockchip | 9 | Rockchip board level support available |
| meta | meta | 5 | Contains the OpenEmbedded-Core metadata |
| meta-poky | meta-poky | 5 | Holds the configuration for the Poky reference distribution |
| meta-yocto-bsp | meta-yocto-bsp | 5 | Configuration for the Yocto Project reference hardware board support package. |
| meta-chromium | meta-chromium | 7 | Provide chromium browser recipe |
Download the SDK
Please contact sales@t-firefly.com to get SDK download link and read the readme file
Compilation Notes
Notice:
1. SDK use cross-compilation, so use SDK in x86_64 PC, do not download SDK to the device
2. We suggest to use Ubuntu20.04 (real PC or docker) to build, other OS may cause building failure
3. Do not place or decompress the SDK archive in Virtual Machine share folder or non-english folder
4. Please use the regular user to get/compile the SDK, use root privilege may cause building failure
SDK Introduction
Compile firmware
Build Ubuntu Firmware
Preparations
Run these two commands to install necessary tools
sudo apt update
sudo apt install repo git ssh make gcc libssl-dev liblz4-tool \
expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \
qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib \
unzip device-tree-compiler ncurses-dev p7zip-fullDownload rootfs here Ubuntu rootfs(64-bit) Kernel6.1, please use rootfs under kernel-6.1 folder.
After download, decompress and move the rootfs image to SDK/prebuilt_rootfs/, then create a symbolic link.
# Decompress
7z x Ubuntu22.04-xxxx.7z
mkdir ./SDK/prebuilt_rootfs/
mv Ubuntu22.04-xxxx.img ./SDK/prebuilt_rootfs/
cd ./SDK/prebuilt_rootfs/
ln -sf Ubuntu22.04-xxxx.img rk3588_ubuntu_rootfs.img
cd ..Configurations
Run ./build.sh lunch to list all available configs, enter a number to select. Please choose one with "ubuntu" keyword:
./build.sh lunch
############### Rockchip Linux SDK ###############
Manifest: rk3588_linux6.1_release_20250114_v1.1.1c
Log colors: message notice warning error fatal
Log saved at /home2/daijh/p/rk3588/sdk_6.1/output/sessions/2025-01-14_14-39-08
Pick a defconfig:
1. rockchip_defconfig
2. firefly_rk3588_aio-3588jd4_buildroot_defconfig
3. firefly_rk3588_aio-3588jd4_debian_defconfig
4. firefly_rk3588_aio-3588jd4_ubuntu_defconfig
5. firefly_rk3588_aio-3588l_debian_defconfig
6. firefly_rk3588_aio-3588l_ubuntu_defconfig
7. firefly_rk3588_aio-3588q_debian_defconfig
8. firefly_rk3588_aio-3588q_ubuntu_defconfig
9. firefly_rk3588_aio-3588sjd4_debian_defconfig
10. firefly_rk3588_aio-3588sjd4_ubuntu_defconfig
11. firefly_rk3588_itx-3588j_buildroot_defconfig
12. firefly_rk3588_itx-3588j_debian_defconfig
13. firefly_rk3588_itx-3588j_ubuntu_defconfig
14. firefly_rk3588_roc-rk3588-rt-ext-10ge_debian_defconfig
15. firefly_rk3588_roc-rk3588-rt-ext-10ge_ubuntu_defconfig
16. firefly_rk3588_roc-rk3588-rt-ext-2g5e_debian_defconfig
17. firefly_rk3588_roc-rk3588-rt-ext-2g5e_ubuntu_defconfig
18. firefly_rk3588_roc-rk3588-rt_debian_defconfig
19. firefly_rk3588_roc-rk3588-rt_ubuntu_defconfig
20. firefly_rk3588_roc-rk3588s-pc-ext_debian_defconfig
21. firefly_rk3588_roc-rk3588s-pc-ext_ubuntu_defconfig
22. firefly_rk3588_roc-rk3588s-pc_debian_defconfig
23. firefly_rk3588_roc-rk3588s-pc_ubuntu_defconfig
24. rockchip_rk3588_evb1_lp4_v10_defconfig
25. rockchip_rk3588_evb7_v11_defconfig
26. rockchip_rk3588_ipc_evb1_v10_defconfig
27. rockchip_rk3588_ipc_evb7_lp4_v11_defconfig
28. rockchip_rk3588_multi_ipc_evb1_v10_defconfig
29. rockchip_rk3588s_evb1_lp4x_v10_defconfig
Which would you like? [1]:Compilation
Full Compilation
Run
./build.sh allThe output firmware will be output/update/update.img
Partial Compilation
After a full compilation, if you modified kernel or uboot, you can do partial compilation to save time.
- Only build u-boot, will generate u-boot/uboot.img
./build.sh uboot- Only build kernel, will generate kernel/extboot.img
./build.sh extboot- Pack all parts to update.img
./build.sh updateimg
