Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:edge2:development:linux:build-linux

Edge2 Build Yocto/Buildroot/Debian

Introduction

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.

Preparation

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

Get SDK

1. Download the base SDK packages here: khadas_edges_yocto_sdk_base.tar.gz0x

You need to download all 5 compressed files:

  • khadas_edges_yocto_sdk_base.tar.gz00
  • khadas_edges_yocto_sdk_base.tar.gz01
  • khadas_edges_yocto_sdk_base.tar.gz02
  • khadas_edges_yocto_sdk_base.tar.gz03
  • khadas_edges_yocto_sdk_base.tar.gz04

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

Update SDK

In the future, you can use the following command to update the SDK code:

$ cd ~/project/edge2-linux-sdk
$ .repo/repo/repo sync -c 

Introduction to SDK project directory

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:

  • app : Contains upper-level application apps, mainly various application demos.
  • buildroot : Contains the root file system developed with Buildroot.
  • debian : Contains the root file system developed with Debian.
  • device/rockchip : Contains chip board-level configurations and scripts/files for compiling and packaging firmware.
  • docs : Contains general development guides, Linux system development guides, chip platform-related documents, etc.
  • external : Contains third-party related repositories, including display, audio/video, camera, network, security, etc.
  • kernel : Contains Kernel development code.
  • output : Contains firmware information, compilation details, XML files, host environment, etc., generated during each build.
  • prebuilts : Contains cross-compilation toolchains.
  • rkbin : Contains Rockchip-related binaries and tools.
  • rockdev : Contains compiled output firmware, actually, it soft link to xxx output/firmware .
  • tools : Contains commonly used tools for both Linux and Windows operating systems.
  • u-boot : Contains U-Boot code developed based on version v2017.09.
  • yocto : Contains the root file system developed with Yocto.

Compilation

The SDK can be easily compiled using the build.sh script.

Setup the Compile Configuration

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:

Buildroot

khadas_rk3588s_edge2_buildroot_defconfig
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

Debian

khadas_rk3588s_edge2_debian_defconfig
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

Yocto

khadas_rk3588s_edge2_yocto_defconfig
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

Build the OS Image

After setting up the compile configuration, just run ./build.sh to start building.

Then you can get the image in <SDK>/output/ directory.

Debian

You have to install some packages before compiling Debian

sudo dpkg -i <SDK>/debian/ubuntu-build-service/packages/*
sudo apt-get install -f

Yocto

Important Points for Yocto Build:

  1. The network must have access to Google.
  2. The build process requires fetching packages from the internet. If fetching fails, retry continuously.
  3. You need a system with at least 150 GB of free disk space and at least 8 GB of RAM.

Other Build Commands

Build u-boot

$ ./build.sh uboot

Build kernel

$ ./build.sh kernel

Build rootfs

$ ./build.sh rootfs

Help messages

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

Build in Docker

You can also choose to build the OS image in a Docker container.

Install Docker

Please refer to Docker Documentation.

Add User to a Docker Group

$ sudo usermod -aG docker $USER

You need to logout or reboot the system to take effect.

Build SDK in Docker

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

Install OS

Preparation

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

Install OS into eMMC

Partition Upgrade

Invalid in Maskrom Mode!

Upgrade Uboot

$ sudo upgrade_tool di -uboot <SDK>/output/update/Image/uboot.img

Upgrade kernel

$ sudo upgrade_tool di -boot <SDK>/output/update/Image/boot.img

Upgrade rootfs

$ sudo upgrade_tool di -rootfs <SDK>/output/update/Image/rootfs.img

You can execute upgrade_tool RD to reboot Edge2 after upgrade.

User and password

Buildroot

  • user: root
  • password: khadas

Yocto

  • user: root
  • Have no password, you can use passwd command to set a password for root.

Debian

  • user: root
  • Have no password, you can use passwd command to set a password for root.
  • (default)user: khadas
  • password: khadas
  • user: linaro
  • password: linaro

WIFI

Buildroot && Yocto

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
}

Debian

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.

Bluetooth

Buildroot && Yocto

Please refer to the bluetooth usage on ubuntu-server .

Debian

Bluetooth settings are in the upper-right corner, click Bluetooth Enabled to set the bluetooth.

Camera

Please refer to Edge2 MIPI Camera Usage

2024/11/24 22:59 · gray
Last modified: 2024/12/31 02:19 by nick