Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Rock5/guide/build-debian-from-debos-radxa

< Rock5‎ | guide
Revision as of 02:17, 28 June 2022 by Stephen (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
    ROCK 5 >  Guide >  How to build Debian from debos-radxa

Rockchip Debian SDK

Below is the instructions of how to build image for ROCK 5 on a HOST PC.

Available boards:

  • ROCK 5B

Get the source code

You need Git to get multiple git repositories to build the image.

Install Git if you don't have it.

sudo apt-get update
sudo apt-get install git

Clone the source code

mkdir ~/rk3588-sdk && cd ~/rk3588-sdk
git clone -b stable-5.10-rock5 https://github.com/radxa/u-boot.git
git clone -b stable-5.10-rock5 https://github.com/radxa/kernel.git
git clone -b master https://github.com/radxa/rkbin.git
git clone -b debian https://github.com/radxa/build.git
git clone -b main https://github.com/radxa/debos-radxa.git

And you will get

build  kernel  rkbin u-boot

Directories usage introductions:

  • build:
    • Some script files and configuration files for building u-boot, kernel and rootfs.
  • kernel:
    • kernel source code, current version is 4.19.193.
  • rkbin:
    • Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
  • u-boot:
    • u-boot as the second stage bootloader

Install toolchain

wget https://dl.radxa.com/tools/linux/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.gz
sudo tar zxvf gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu.tar.gz -C /usr/local/

Add the following line to the end of file ~/.bashrc

export PATH="/usr/local/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin:$PATH"

And source ~/.bashrc

source ~/.bashrc

Check the version of toolchain

radxa@x86-64:~$ which aarch64-none-linux-gnu-gcc
/usr/local/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-gcc

radxa@x86-64:~$ aarch64-none-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-none-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/../libexec/gcc/aarch64-none-linux-gnu/10.3.1/lto-wrapper
Target: aarch64-none-linux-gnu
Configured with: /data/jenkins/workspace/GNU-toolchain/arm-10/src/gcc/configure --target=aarch64-none-linux-gnu --prefix= --with-sysroot=/aarch64-none-linux-gnu/libc --with-build-sysroot=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-linux-gnu/install//aarch64-none-linux-gnu/libc --with-bugurl=https://bugs.linaro.org/ --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-linux-gnu/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-linux-gnu/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-linux-gnu/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-linux-gnu/host-tools --enable-fix-cortex-a53-843419 --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)'
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))

Install other build tools

sudo apt-get install device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools bc python dosfstools

Build u-boot

Need to checkout branch to stable-5.10-rock5.

Build u-boot with default rock-5b-rk3588_defconfig.

cd ~/rk3588-sdk
./build/mk-uboot.sh k3588-rock-5b     #For ROCK 5B

The generated images will be copied to out/u-boot folder

ls out/u-boot/
idbloader.img  rk3588_spl_loader_v1.07.111.bin  spi  u-boot.itb

Apply u-boot

1. you should check file in out/u-boot should be like this:

ls out/u-boot/
idbloader.img  rk3588_spl_loader_v1.07.111.bin  spi  u-boot.itb

2. flash u-boot to you storage

sudo dd if=./idbloader.img of=/path/to/storage/device bs=512 seek=64
sudo dd if=./u-boot.itb of=/path/to/storage/device bs=512 seek=16384

Build kernel

Need to checkout branch to stable-5.10-rock5.

Build kernel with default rockchip_linux_defconfig.

cd ~/rk3588-sdk
./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B
Change kernel config

Optionally, if you want to change the default kernel config

cd ~/rk3588-sdk
cd kernel
export ARCH=arm64
export CROSS_COMPILE=aarch64-none-linux-gnu-
make rockchip_linux_defconfig
make menuconfig
make savedefconfig
cp defconfig arch/arm64/configs/rockchip_linux_defconfig
cd ..
./build/mk-kernel.sh rk3588-rock-5b    #For ROCK 5B

You will get the kernel image and dtb file

ls out/kernel/
Image  rk3588-rock-5b.dtb

Build kernel deb package

The kernel package build can pack the kernel, device tree, modules and firmware into Debian packages, which makes it easier to install on the ROCK 5.

./build/pack-kernel.sh -d rockchip_linux_defconfig -r 10 # rockchip_linux_defconfig: kernel defconfig; 1: release number

The generated packages will be copied to out/packages directory.

ls out/packages/
linux-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.changes
linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb
linux-headers-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.deb
linux-libc-dev_5.10.66-10-rockchip_arm64.deb
linux-image-5.10.66-10-rockchip-ge5013df5e066_5.10.66-10-rockchip_arm64.deb

When you want to install specified kernel packages to your OS, try the following steps.

copy linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb to your ROCK 5.

Install them on ROCK 5.

# dpkg -i linux-image-5.10.66-10-rockchip-ge5013df5e066-dbg_5.10.66-10-rockchip_arm64.deb

Generate system image

Remove old ROCK 5B U-boot and Kernel packages.

$ cd ~/rk3588-sdk/debos-radxa

$ ls rootfs/packages/arm64/kernel/*5.10.66*
rootfs/packages/arm64/kernel/linux-headers-5.10.66-6-rockchip-gbb60f4aeba31_5.10.66-6-rockchip_arm64.deb
rootfs/packages/arm64/kernel/linux-image-5.10.66-6-rockchip-gbb60f4aeba31_5.10.66-6-rockchip_arm64.deb

$ ls rootfs/packages/arm64/u-boot/rock-5b*
rootfs/packages/arm64/u-boot/rock-5b-rk-ubootimg_2017.09-g592fa62ffe2-220419_all.deb

Copy new ROCK 5B U-boot and Kernel packages to the specified place. Like Kernel packages in rootfs/packages/arm64/kernel/ and U-boot package in rootfs/packages/arm64/u-boot

Set up Docker

$ cd ~/rk3588-sdk/debos-radxa
$ ./docker/dev-shell

Build image in Docker container.

# ./build.sh -c rk3588 -b rock-5b -m debian -d bullseye -v xfce4 -a arm64 -f gpt

The generated system images will be copied to ~/rk3588-sdk/debos-radxa/output directory.

Flash the image

FAQs

Troubleshooting

Check ROCK 5 FAQs first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rock5.