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

Difference between revisions of "RockpiN10/dev/Debian"

< RockpiN10‎ | dev
(Get the source code)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{rockpiN10_header}}
 
{{rockpiN10_header}}
  
{{Languages|rockpiE/dev/Debian}}
+
{{Languages|rockpiN10/dev/Debian}}
  
 
     [[rockpiN10 | ROCK Pi N10]] > [[rockpiN10/dev | Development]] > [[rockpiN10/dev/Debian | Build Debian]]
 
     [[rockpiN10 | ROCK Pi N10]] > [[rockpiN10/dev | Development]] > [[rockpiN10/dev/Debian | Build Debian]]
  
= Rockchip Debian SDK =
+
=== Rockchip Debian SDK ===
  
 
Below is the instructions of how to build image for ROCK Pi N10 on a '''HOST PC'''.
 
Below is the instructions of how to build image for ROCK Pi N10 on a '''HOST PC'''.
  
== Get the source code ==
+
==== Get the source code ====
  
 
You need Git to get multiple git repositories to build the image.
 
You need Git to get multiple git repositories to build the image.
Line 15: Line 15:
 
Install Git if you don't have it.
 
Install Git if you don't have it.
  
    sudo apt-get update
+
sudo apt-get update
    sudo apt-get install git
+
sudo apt-get install git
  
 
Clone the source code
 
Clone the source code
  
    git clone -b rk3399pro https://github.com/radxa/rockchip-bsp.git
+
git clone -b rk3399pro https://github.com/radxa/rockchip-bsp.git
    cd rockchip-bsp
+
cd rockchip-bsp
    git submodule init
+
git submodule init
    git submodule update
+
git submodule update
  
 
You will get  
 
You will get  
  
    build  kernel  README.md  rkbin  rootfs  u-boot
+
build  kernel  README.md  rkbin  rootfs  u-boot
  
 
Directories usage introductions:
 
Directories usage introductions:
Line 38: Line 38:
 
** Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
 
** Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
 
* rootfs:  
 
* rootfs:  
** Bootstrap a Debian based rootfs, support architechture armhf and arm64, support Debian Jessie and Stretch.
+
** Bootstrap a Debian based rootfs, support architechture armhf and arm64, support Debian Jessie, Stretch and Buster.
 
* u-boot:  
 
* u-boot:  
 
** u-boot as the second stage bootloader
 
** u-boot as the second stage bootloader
  
== Update the source code ==
+
==== Update the source code ====
  
    cd rockchip-bsp
+
The rockchip-bsp will be updated all the time, so you can update the source before building the system image.
    git checkout stable-4.4-rockpie
+
    git fetch origin
+
    git rebase origin/stable-4.4-rockpie
+
    git submodule update
+
  
== Install toolchain and other build tools ==
+
cd rockchip-bsp
 +
git checkout rk3399pro
 +
git fetch origin
 +
git rebase origin/rk3399pro
 +
git submodule update
  
    sudo apt-get install gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools
+
==== Install toolchain from Linaro ====
    sudo apt-get install bc python dosfstools
+
  
== Build u-boot ==
+
wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
 +
sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  -C /usr/local/
 +
export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
 +
export PATH=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH
  
Need to checkout branch to '''stable-4.4-rockpie'''.
+
Check if Linaro toolchain is the default choice:
  
Build u-boot with default '''rock-pi-e-rk3328_defconfig'''.
+
which aarch64-linux-gnu-gcc
 +
/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
  
    ./build/mk-uboot.sh rockpie     #For ROCK Pi E
+
==== Install other build tools ====
 +
 
 +
sudo apt-get install gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev build-essential libssl-dev mtools
 +
sudo apt-get install bc python dosfstools
 +
 
 +
==== Build u-boot ====
 +
 
 +
Need to checkout branch to '''rk3399-pie-gms-express-baseline'''.
 +
 
 +
Build u-boot with default '''rk3399pro_defconfig'''.
 +
 
 +
./build/mk-uboot.sh rockpin10     #For ROCK Pi N10
  
 
The generated images will be copied to out/u-boot folder
 
The generated images will be copied to out/u-boot folder
  
    ls out/u-boot/
+
ls out/u-boot/
    idbloader.img  rk3399pro_loader_v1.20.115.bin rk3399pro_npu_loader_v1.02.102.bin trust.img  uboot.img
+
idbloader.img  rk3399pro_loader_v1.20.115.bin rk3399pro_npu_loader_v1.02.102.bin trust.img  uboot.img
  
== Build kernel ==
+
==== Build kernel ====
  
 
Need to checkout branch to '''rk3399pro-toybrick-stable'''.
 
Need to checkout branch to '''rk3399pro-toybrick-stable'''.
Line 74: Line 88:
 
Build kernel with default '''rockchip_linux_defconfig'''.
 
Build kernel with default '''rockchip_linux_defconfig'''.
  
    ./build/mk-kernel.sh rockpin10    #For ROCK Pi N10
+
./build/mk-kernel.sh rockpin10    #For ROCK Pi N10
  
=== Change kernel config(optional)===
+
===== Change kernel config(optional)=====
  
 
Optionally, if you want to change the default kernel config
 
Optionally, if you want to change the default kernel config
  
    cd kernel
+
cd kernel
    export ARCH=arm64
+
export ARCH=arm64
    export CROSS_COMPILE=aarch64-linux-gnu-
+
export CROSS_COMPILE=aarch64-linux-gnu-
    make rockchip_linux_defconfig
+
make rockchip_linux_defconfig
    make menuconfig
+
make menuconfig
    cd ..
+
cd ..
    ./build/mk-kernel.sh rockpin10    #For ROCK Pi N10
+
./build/mk-kernel.sh rockpin10    #For ROCK Pi N10
 
+
  
 
You will get the kernel image and dtb file
 
You will get the kernel image and dtb file
  
    ls out/kernel/
+
ls out/kernel/
    Image  rk3399pro-rockpi-n10-linux-dsi.dtb
+
Image  rk3399pro-rockpi-n10-linux.dtb
  
== Make rootfs image ==
+
==== Make rootfs image ====
 +
 
 +
Check out the rootfs source. The repository is '''https://github.com/radxa/rk-rootfs-build.git''' and the branch is '''debian'''.
  
 
To build 32bit rootfs:
 
To build 32bit rootfs:
 
   
 
   
    export ARCH=armhf
+
export ARCH=armhf
  
 
To build 64bit rootfs:
 
To build 64bit rootfs:
  
    export ARCH=arm64
+
export ARCH=arm64
  
 
Building a base debian system by ubuntu-build-service from linaro.
 
Building a base debian system by ubuntu-build-service from linaro.
  
    cd rootfs
+
cd rootfs
    sudo apt-get install binfmt-support qemu-user-static cpio gdisk
+
sudo apt-get install binfmt-support qemu-user-static cpio gdisk
    sudo dpkg -i ubuntu-build-service/packages/*        # ignore the broken dependencies, we will fix it next step
+
sudo dpkg -i ubuntu-build-service/packages/*        # ignore the broken dependencies, we will fix it next step
    sudo apt-get install -f
+
sudo apt-get install -f
    RELEASE=stretch TARGET=desktop ARCH=$ARCH ./mk-base-debian.sh
+
RELEASE=buster TARGET=desktop ARCH=arm64 ./mk-base-debian.sh
  
This will bootstrap a Debian stretch image, you will get a rootfs tarball named '''linaro-stretch-alip-xxxx.tar.gz'''.  
+
This will bootstrap a Debian Buster image, you will get a rootfs tarball named '''linaro-buster-alip-xxxx.tar.gz'''.  
  
Building the rk-debain rootfs with debug:
+
Building the rk-debian rootfs.
  
    VERSION=debug ARCH=$ARCH ./mk-rootfs-stretch.sh  && ./mk-image.sh
+
RELEASE=buster ARCH=arm64 ./mk-rootfs.sh
  
This will install Rockchip specified packages and hooks on the standard Debian rootfs and generate an ext4 format rootfs image at '''rootfs/linaro-rootfs.img'''.
+
Creating the ext4 image(linaro-rootfs.img):
  
== Combine everything into one image ==
+
./mk-image.sh
  
    build/mk-image.sh -c rk3399pro -t system -r rootfs/linaro-rootfs.img
+
==== Combine everything into one image ====
 +
 
 +
build/mk-image.sh -c rk3399pro -t system -r rootfs/linaro-rootfs.img
  
 
This will combine u-boot, kernel and rootfs into one image and generate GPT partition table. Output is  
 
This will combine u-boot, kernel and rootfs into one image and generate GPT partition table. Output is  
  
    out/system.img
+
out/system.img
 +
 
 +
==== Flash the image ====
 +
 
 +
* [[rockpiN10/install/eMMC | Install on eMMC]]
 +
* [[rockpiN10/install/microSD | Install on microSD]]
 +
 
 +
==== FAQs ====
 +
 
 +
===== 1.I have built one ROCK Pi N10 system image using rockchip-bsp SDK. With an USB to TTL serial cable connected with UART2 pins (pin#10, pin#8, ping#6 on colorful 40-PIN Header) on ROCK Pi N10, the last one line of system logs is shown as follows. =====
 +
 
 +
[    1.072493] bootconsole [uart0] disabled
 +
 
 +
In fact the system starts up. If your ROCK Pi N10 system supports Ethernet/WiFi and SSH, you can access ROCK Pi N10 via SSH.
 +
 
 +
If you read the kernel command line of system log, you will find that the default console is ttyS2 (1500000n8). But due to uart2 is disabled by default in file rk3399pro-rockpi-n10-linux.dts, there will be no more system logs on the screen.
  
== Flash the image ==
+
To enable console ttyS2, you need to enable uart2 node. Add the following lines at the end of file k3399pro-rockpi-n10-linux.dts.
  
When install system image, system.img to uSD card, need APP '''Etcher''' or tool '''dd'''.
+
&uart2 {
 +
    status = "okay";
 +
};
  
== Troubleshooting ==
+
==== Troubleshooting ====
  
Check [[RockpiE/FAQs |ROCK Pi N10 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/dev
+
Check [[RockpiN10/FAQs |ROCK Pi N10 FAQs]] first, if it doesn't help, start a new post on the forum https://forum.radxa.com/c/rockpiN10.

Latest revision as of 04:05, 23 May 2021

    ROCK Pi N10 >  Development >  Build Debian

Rockchip Debian SDK

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

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

git clone -b rk3399pro https://github.com/radxa/rockchip-bsp.git
cd rockchip-bsp
git submodule init
git submodule update

You will get

build  kernel  README.md  rkbin  rootfs  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.4.167.
  • rkbin:
    • Prebuilt Rockchip binaries, include first stage loader and ATF(Arm Trustzone Firmware).
  • rootfs:
    • Bootstrap a Debian based rootfs, support architechture armhf and arm64, support Debian Jessie, Stretch and Buster.
  • u-boot:
    • u-boot as the second stage bootloader

Update the source code

The rockchip-bsp will be updated all the time, so you can update the source before building the system image.

cd rockchip-bsp
git checkout rk3399pro
git fetch origin
git rebase origin/rk3399pro
git submodule update

Install toolchain from Linaro

wget https://releases.linaro.org/components/toolchain/binaries/7.3-2018.05/aarch64-linux-gnu/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz
sudo tar xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz  -C /usr/local/
export CROSS_COMPILE=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export PATH=/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH

Check if Linaro toolchain is the default choice:

which aarch64-linux-gnu-gcc
/usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc

Install other build tools

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

Build u-boot

Need to checkout branch to rk3399-pie-gms-express-baseline.

Build u-boot with default rk3399pro_defconfig.

./build/mk-uboot.sh rockpin10     #For ROCK Pi N10

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

ls out/u-boot/
idbloader.img  rk3399pro_loader_v1.20.115.bin rk3399pro_npu_loader_v1.02.102.bin trust.img  uboot.img

Build kernel

Need to checkout branch to rk3399pro-toybrick-stable.

Build kernel with default rockchip_linux_defconfig.

./build/mk-kernel.sh rockpin10    #For ROCK Pi N10
Change kernel config(optional)

Optionally, if you want to change the default kernel config

cd kernel
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
make rockchip_linux_defconfig
make menuconfig
cd ..
./build/mk-kernel.sh rockpin10    #For ROCK Pi N10

You will get the kernel image and dtb file

ls out/kernel/
Image  rk3399pro-rockpi-n10-linux.dtb

Make rootfs image

Check out the rootfs source. The repository is https://github.com/radxa/rk-rootfs-build.git and the branch is debian.

To build 32bit rootfs:

export ARCH=armhf

To build 64bit rootfs:

export ARCH=arm64

Building a base debian system by ubuntu-build-service from linaro.

cd rootfs
sudo apt-get install binfmt-support qemu-user-static cpio gdisk
sudo dpkg -i ubuntu-build-service/packages/*        # ignore the broken dependencies, we will fix it next step
sudo apt-get install -f
RELEASE=buster TARGET=desktop ARCH=arm64 ./mk-base-debian.sh

This will bootstrap a Debian Buster image, you will get a rootfs tarball named linaro-buster-alip-xxxx.tar.gz.

Building the rk-debian rootfs.

RELEASE=buster ARCH=arm64 ./mk-rootfs.sh

Creating the ext4 image(linaro-rootfs.img):

./mk-image.sh

Combine everything into one image

build/mk-image.sh -c rk3399pro -t system -r rootfs/linaro-rootfs.img

This will combine u-boot, kernel and rootfs into one image and generate GPT partition table. Output is

out/system.img

Flash the image

FAQs

1.I have built one ROCK Pi N10 system image using rockchip-bsp SDK. With an USB to TTL serial cable connected with UART2 pins (pin#10, pin#8, ping#6 on colorful 40-PIN Header) on ROCK Pi N10, the last one line of system logs is shown as follows.
[    1.072493] bootconsole [uart0] disabled

In fact the system starts up. If your ROCK Pi N10 system supports Ethernet/WiFi and SSH, you can access ROCK Pi N10 via SSH.

If you read the kernel command line of system log, you will find that the default console is ttyS2 (1500000n8). But due to uart2 is disabled by default in file rk3399pro-rockpi-n10-linux.dts, there will be no more system logs on the screen.

To enable console ttyS2, you need to enable uart2 node. Add the following lines at the end of file k3399pro-rockpi-n10-linux.dts.

&uart2 {
    status = "okay";
};

Troubleshooting

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