The Rockchip Linux SDK support Buildroot, Debian and Yocto. We will introduce how to build Edge2 firmware using the Rockchip Linux SDK here. For readability, the subsequent Rockchip Linux SDK will be referred to as SDK.
Install essential dependencies. It is recommended to use Ubuntu 22.04 for compilation, or you can choose to Build in Docker.
$ sudo apt update && sudo apt install -y git ssh make gcc libssl-dev \
liblz4-tool expect expect-dev 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 \
libgucharmap-2-90-dev bzip2 expat gpgv2 cpp-aarch64-linux-gnu libgmp-dev \
libmpc-dev bc python-is-python3 python2 libstdc++-12-dev xz-utils repo git-lfs
1. Download the base SDK packages here: khadas_edges_yocto_sdk_base.tar.gz0x
You need to download all 5 compressed files:
You can also download the md5 checksum to verify the downloaded files:
$ md5sum -c md5sum/*
khadas_edges_yocto_sdk_base.tar.gz00: OK
khadas_edges_yocto_sdk_base.tar.gz01: OK
khadas_edges_yocto_sdk_base.tar.gz02: OK
khadas_edges_yocto_sdk_base.tar.gz03: OK
khadas_edges_yocto_sdk_base.tar.gz04: OK
2. Create and enter the working directory:
$ mkdir -p ~/project/edge2-linux-sdk && cd ~/project/edge2-linux-sdk
3. Decompress base SDK:
$ cat path/to/sdk-base-packages/khadas_edges_yocto_sdk_base.tar.gz* | tar -zxv -C ~/project/edge2-linux-sdk
4. Then you can see .repo
derctory in ~/project/edge2-linux-sdk
directory by using ls -la
command.
$ ls -al ~/project/edge2-linux-sdk
total 12
drwxrwxr-x 3 nick nick 4096 Dec 31 14:40 .
drwxrwxr-x 3 nick nick 4096 Dec 31 14:39 ..
drwxrwxr-x 7 nick nick 4096 Dec 30 16:21 .repo
5. Sync and update code:
$ .repo/repo/repo sync -l $ .repo/repo/repo sync -c $ ls Copyright_Statement.md Makefile app build.sh buildroot debian device docs external kernel prebuilts rkbin rkflash.sh tools u-boot yocto
6. Sync large files:
$ .repo/repo/repo forall -c 'git lfs pull'
7. If you need to build Yocto, please disable the auto-detaching feature of git gc:
$ git config --global gc.autoDetach false
8. Create a work branch for each repository:
$ .repo/repo/repo start khadas --all
In the future, you can use the following command to update the SDK code:
$ cd ~/project/edge2-linux-sdk $ .repo/repo/repo sync -c
The SDK project directory includes buildroot, debian, app, kernel, u-boot, device, docs, external, etc.
Repositories are managed by manifests, and the repo tool is utilized to manage each directory or its corresponding Git project, including the following subdirectories:
The SDK can be easily compiled using the build.sh
script.
You should setup the compile configuration before compilation.
$ cd <SDK> $ ./build.sh lunch
Just input the number of khadas_rk3588s_edge2_xxx_defconfig
is ok. xxx
can be buildroot
, debian
, yocto
.
There are three configuration files for Edge2 in <SDK>/device/rockchip/rk3588/
$ ls <SDK>/device/rockchip/rk3588/khadas_rk3588s_edge2_*
khadas_rk3588s_edge2_buildroot_defconfig # for Buildroot
khadas_rk3588s_edge2_debian_defconfig # for Debian
khadas_rk3588s_edge2_yocto_defconfig # for Yocto
The khadas_rk3588s_edge2_xxx_defconfig
content is as follow:
KHADAS=y # Flag of Khadas RK_BUILDROOT_BASE_CFG="rk3588s_edge2" # Indicate Buildroot default configuration file RK_ROOTFS_HOSTNAME_CUSTOM=y # Custom the host name RK_ROOTFS_HOSTNAME="Edge2" # Set the host name as Edge2 RK_UBOOT_CFG="khadas-edge2-rk3588s" # Indicate U-Boot default configuration file RK_KERNEL_CFG="kedges_defconfig" # Indicate Kernel default configuration file RK_KERNEL_DTS_NAME="rk3588s-khadas-edge2" # Indicate Kernel DTS file RK_USE_FIT_IMG=y # Use FIT Image
RK_ROOTFS_SYSTEM_DEBIAN=y # Set Debian as default rootfs. RK_ROOTFS_HOSTNAME_CUSTOM=y # Custom the host name RK_ROOTFS_HOSTNAME="Edge2" # Set the host name as Edge2 RK_UBOOT_CFG="khadas-edge2-rk3588s" # Indicate U-Boot default configuration file RK_KERNEL_CFG="kedges_defconfig" # Indicate Kernel default configuration file RK_KERNEL_DTS_NAME="rk3588s-khadas-edge2" # Indicate Kernel DTS file RK_USE_FIT_IMG=y # Use FIT Image
RK_YOCTO_CFG_CUSTOM=y # Use custom configuration file RK_YOCTO_CFG="khadas-edge2.conf" # Custom configuration file name RK_ROOTFS_SYSTEM_YOCTO=y # Set Yocto as default rootfs. RK_ROOTFS_HOSTNAME_CUSTOM=y # Custom the host name RK_ROOTFS_HOSTNAME="Edge2" # Set the host name as Edge2 RK_UBOOT_CFG="khadas-edge2-rk3588s" # Indicate U-Boot default configuration file RK_KERNEL_CFG="kedges_defconfig" # Indicate Kernel default configuration file RK_KERNEL_DTS_NAME="rk3588s-khadas-edge2" # Indicate Kernel DTS file RK_USE_FIT_IMG=y # Use FIT Image
After setting up the compile configuration, just run ./build.sh
to start building.
Then you can get the image in <SDK>/output/
directory.
You have to install some packages before compiling Debian
sudo dpkg -i <SDK>/debian/ubuntu-build-service/packages/* sudo apt-get install -f
Important Points for Yocto Build:
$ ./build.sh uboot
$ ./build.sh kernel
$ ./build.sh rootfs
You can get help messages by executing ./build.sh help
:
Usage: build.sh [OPTIONS] Available options: chip[:<chip>[:<config>]] choose chip defconfig[:<config>] choose defconfig *_defconfig switch to specified defconfig available defconfigs: khadas_rk3588s_edge2_buildroot_defconfig khadas_rk3588s_edge2_debian_defconfig khadas_rk3588s_edge2_yocto_defconfig olddefconfig resolve any unresolved symbols in .config savedefconfig save current config to defconfig menuconfig interactive curses-based configurator config modify SDK defconfig print-parts print partitions list-parts alias of print-parts mod-parts interactive partition table modify edit-parts edit raw partitions new-parts:<offset>:<name>:<size>... re-create partitions insert-part:<idx>:<name>[:<size>] insert partition del-part:(<idx>|<name>) delete partition move-part:(<idx>|<name>):<idx> move partition rename-part:(<idx>|<name>):<name> rename partition resize-part:(<idx>|<name>):<size> resize partition misc pack misc image kernel[:cmds] build kernel recovery-kernel[:cmds] build kernel for recovery modules[:cmds] build kernel modules linux-headers[:cmds] build linux-headers kernel-config[:cmds] modify kernel defconfig kconfig[:cmds] alias of kernel-config kernel-make[:<arg1>:<arg2>] run kernel make kmake[:<arg1>:<arg2>] alias of kernel-make wifibt[:<dst dir>[:<chip>]] build Wifi/BT rtos build and pack RTOS buildroot-config[:<config>] modify buildroot defconfig bconfig[:<config>] alias of buildroot-config buildroot-make[:<arg1>:<arg2>] run buildroot make bmake[:<arg1>:<arg2>] alias of buildroot-make rootfs[:<rootfs type>] build default rootfs buildroot build buildroot rootfs yocto build yocto rootfs debian build debian rootfs recovery build recovery pcba build PCBA security-createkeys create keys for security security-misc build misc with system encryption key security-ramboot build security ramboot security-system build security system loader[:cmds] build loader (uboot) uboot[:cmds] build u-boot uefi[:cmds] build uefi extra-part pack extra partition images firmware pack and check firmwares edit-package-file edit package-file edit-ota-package-file edit package-file for OTA updateimg build update image ota-updateimg build update image for OTA all build images release release images and build info all-release build and release images shell setup a shell for developing cleanall cleanup clean[:module[:module]]... cleanup modules available modules: all config extra-part firmware kernel loader misc pcba recovery rootfs rtos security updateimg post-rootfs <rootfs dir> trigger post-rootfs hook scripts help usage Default option is 'all'.
You can also choose to build the OS image in a Docker container.
Please refer to Docker Documentation.
$ sudo usermod -aG docker $USER
You need to logout or reboot the system to take effect.
Get Docker image:
$ docker pull wesion/yocto-rockchip
Enter Docker:
$ cd ~/project/edge2-linux-sdk $ docker run --rm -it --privileged --device=/dev/loop-control:/dev/loop-control \ --device=/dev/loop0:/dev/loop0 --cap-add SYS_ADMIN -v /opt:/opt \ -v $(pwd):/home/khadas/yocto wesion/yocto-rockchip bash
Start your build from inside the Docker container.
khadas@59f19b6a36e2:~/yocto$ ./build.sh lunch khadas@59f19b6a36e2:~/yocto$ ./build.sh
1. Copy upgrade tool to your local path
$ sudo cp <SDK>/tools/linux/Linux_Upgrade_Tool/Linux_Upgrade_Tool/upgrade_tool /usr/local/bin/
2. Put your Edge2 into upgrade mode. Ref: Boot into upgrade mode
Please check Edge2 Install OS into eMMC via USB Flash Tool.
Invalid in Maskrom Mode!
$ sudo upgrade_tool di -uboot <SDK>/output/update/Image/uboot.img
$ sudo upgrade_tool di -boot <SDK>/output/update/Image/boot.img
$ sudo upgrade_tool di -rootfs <SDK>/output/update/Image/rootfs.img
You can execute upgrade_tool RD
to reboot Edge2 after upgrade.
passwd
command to set a password for root.passwd
command to set a password for root.You can use the following command to connect WIFI:
$ wifi-connect.sh <wifi_name> <wifi_password> $ udhcpc -i wlan0 -b
Or reboot after editing /etc/wpa_supplicant.conf as follow:
ctrl_interface=/var/run/wpa_supplicant ap_scan=1 update_config=1 network={ ssid="wifi_name" psk="wifi_password" key_mgmt=WPA-PSK }
You can use the following command to connect WIFI:
$ sudo nmcli radio wifi on $ sudo nmcli device wifi connect wifi_name password wifi_password
Or use the desktop UI to connect WIFI.
Please refer to the bluetooth usage on ubuntu-server .
Bluetooth settings are in the upper-right corner, click Bluetooth Enabled
to set the bluetooth.
Please refer to Edge2 MIPI Camera Usage