NanoPi Zero2
Contents
- 1 Introduction
- 2 Hardware Spec
- 3 Diagram, Layout and Dimension
- 4 Get Started
- 4.1 Essentials You Need
- 4.2 TF Cards We Tested
- 4.3 Configure parameters for serial port
- 4.4 Install OS
- 5 Work with FriendlyCore
- 6 Work with Debian Core
- 7 How to Compile
- 8 Using On-Board Hardware Resources
- 9 Backup rootfs and create custom SD image (to burn your application into other boards)
- 10 Common Linux-based operating system operations
- 11 Unbricking Method
- 12 Resources
- 13 Update Log
1 Introduction
- The NanoPi-Zero2 is another fun board developed by FriendlyELEC for makers, hobbyists and fans.
2 Hardware Spec
- SoC: Rockchip RK3528A
- CPU: Quad-core ARM Cortex-A53
- GPU: ARM Mali-450 GPU
- VPU: 4K H265/H264 60fps decoding
- RAM: 1GB/2GB LPDDR4/LPDDR4X
- Flash: Supports eMMC Module
- Ethernet: one Native Gigabit Ethernet
- M.2 Key-E 2230 connector with PCIe 2.1
- USB Ports:
- One USB 2.0 Host Type-A port
- One USB 2.0 Device Type-C port for eMMC upgrade
- One microSD Slot
- One 30-pin FPC GPIO connector
- Debug: Debug UART, 3.3V level, 1500000bps
- LEDs: 2 x GPIO Controlled LEDs (SYS & LED1)
- others:
- 2 Pin 1.27/1.25mm battery connector for Low-power RTC
- RESET Button, RECOVERY Button, and MASK Button for eMMC upgrade
- Power supply: DC 5V/2A, via USB-C connector or 2.54mm Header
- PCB Size: 45*45*1.2mm
- Temperature measuring range: 0℃ to 80℃
3 Diagram, Layout and Dimension
3.1 Layout
- 8-Pin 2.54mm Header & Debug UART Pin Spec
- Debug UART is 3.3V level, 1500000bps
Pin# Assignment Description Pin# Assignment Description 1 GND 0V 2 VCC5V0_SYS 5V power output/input 3 UART2DBG_TX Debug UART TX 4 VCC5V0_SYS 5V power output/input 5 UART2DBG_RX Debug UART RX 6 GND 0V 7 VCC_3V3 3.3V power output 8 GND 0V
- VCC5V0_SYS is connected to USB-C 5V directly.
- VCC_3V3 is system 3.3V power, and shared with M.2 Key-E, eMMC, SD, 30-pin GPIO, Ethernet etc. The maxium output of this pin is 300mA.
- M.2 Key-E
- It has a PCIe 2.1 x1, supports PCIe wifi.
- 30-Pin FPC GPIO
- It is a 0.5mm FPC Connector.
- VCC5V0_SYS is connected to USB-C 5V directly. Don't input 5V Via this Pins.
- VCC_3V3 is system 3.3V power, and shared with M.2 Key-E, eMMC, SD, 30-pin GPIO, Ethernet etc. The maxium output of this pins is 300mA.
- USB Port
- USB 2.0 Type-A port has 0.95A overcurrent protection.
- RTC
- RTC backup current is 0.25μA TYP (VDD =3.0V, TA =25℃).
- Connector P/N: Molex 53398-0271
- Power
- The peak power of this SBC Soc is 5W.
- To estimate the overall power consumption, in addition to the SBC power supply, the eMMC module, M.2 module, USB peripherals, and GPIO board should also be considered.
4 Get Started
4.1 Essentials You Need
Before starting to use your NanoPi-Zero2 get the following items ready
- NanoPi-Zero2
- MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
- 5V/3A and above USB Type-C interface power adapter
- If you need to develop and compile,you need a computer that can connect to the Internet. It is recommended to install Ubuntu 20.04 64-bit system and use the following script to initialize the development environment, or use docker container:
4.2 TF Cards We Tested
Refer to: TFCardsWeTested
4.3 Configure parameters for serial port
Use the following serial parameters:
Baud rate | 1500000 |
Data bit | 8 |
Parity check | None |
Stop bit | 1 |
Flow control | None |
4.4 Install OS
4.4.1 Downloads
4.4.1.1 Official image
Visit download link to download official image files (in the "01_Official images" directory).
The table below lists all official images, the word 'XYZ' in image filename meaning:
- sd: Use it when you need to boot the entire OS from the SD card
- eflasher: Use it when you need to flash the OS to eMMC via TF card
- usb: Use it when you need to flash the OS to eMMC via USB
Icon | Image Filename | Version | Description | Kernel Version |
---|---|---|---|---|
rk3528-XYZ-debian-bookworm-core-6.1-arm64-YYYYMMDD.img.gz | bookworm | Debian 12 Core, No desktop environment, command line only | 6.1.y | |
rk3528-XYZ-ubuntu-noble-core-6.1-arm64-YYYYMMDD.img.zip | noble | 64-bit Ubuntu image file based on Ubuntu core 24.04 64bit | 6.1.y | |
rk3528-XYZ-openmediavault-6.1-YYYYMMDD.img.gz | Shaitan | OpenMediaVault NAS system, base on Debian 12 | 6.1.y | |
rk3528-XYZ-proxmox-6.1-YYYYMMDD.img.gz | 8.2.7 | Proxmox VE OS (Preview), base on Debian 12 | 6.1.y | |
rk3528-XYZ-friendlywrt-21.02-YYYYMMDD.img.gz | 21.02 | FriendlyWrt, based on OpenWrt 21.02 | 6.1.y | |
rk3528-XYZ-friendlywrt-21.02-docker-YYYYMMDD.img.gz | 21.02 | FriendlyWrt with Docker, based on OpenWrt 21.02 | 6.1.y | |
rk3528-XYZ-friendlywrt-23.05-YYYYMMDD.img.gz | 23.05 | FriendlyWrt, based on OpenWrt 23.05 | 6.1.y | |
rk3528-XYZ-friendlywrt-23.05-docker-YYYYMMDD.img.gz | 23.05 | FriendlyWrt with Docker, based on OpenWrt 23.05 | 6.1.y | |
Other Image | ||||
rk3528-XYZ-multiple-os-YYYYMMDD-25g.img.gz | - | It contains multiple OS image files, making it convenient for testing different operating systems, this image disables automatic flashing at startup; you will need to manually select the OS to flash. |
4.4.1.2 Tools (optional)
Visit download link to download tools (in the "05_Tools" directory).
Filename | Description |
---|---|
win32diskimager.rar | This program is designed to write a raw disk image to a removable device or backup a removable device to a raw image file |
SD Card Formatter | A program (application) that allows easy and quick clear the SD card |
RKDevTool_Release_v2.84.zip | Rockchip flashing tool, for USB upgrade |
4.4.2 Flashing the OS to the microSD card
Follow the steps below:
- Get an 8G microSD card;
- Visit download linkto download image files (in the "01_Official images/01_SD card images" directory);
- Download the win32diskimager tool (in the "05_Tools" directory), or use your preferred tool;
- Extract the .gz format compressed file to get the .img format image file;
- Run the win32diskimager utility under Windows as administrator. On the utility's main window select your SD card's drive, the wanted image file and click on "write" to start flashing the SD card.
- Take out the SD and insert it to NanoPi-Zero2's microSD card slot;
- Power on NanoPi-Zero2 and it will be booted from your TF card, some models may require pressing the Power button to start;
4.4.3 Install OS to eMMC
4.4.3.1 Option 1: Install OS via TF Card
This method firstly boots a mini Linux from a TF card and then automatically runs an EFlasher utility to install the OS to eMMC. You can connect your system to an HDMI monitor and watch its progress.
This is optional. You can watch its progress by observing its LEDs as well:
Progress |
SYS LED(Red) |
---|---|
Power On |
Solid On |
System Boot |
Slow Flashing |
Installation in Progress |
Fast Flashing |
Installation Done |
Slow Flashing |
By default, flashing starts automatically upon power-up, so be sure to back up the data in eMMC. If you don't want it to start automatically, you can use image file with a filename containing the words 'multiple-os' and manually select the OS you want to flash on the interface.
4.4.3.1.1 Flash Official OS to eMMC
Follow the steps below:
- Get an SDHC card with a minimum capacity of 8G
- Visit download linkto download image files (in the "01_Official images/02_SD-to-eMMC images" directory) and win32diskimager tool (in the "05_Tools" directory);
- Extract the .gz format compressed file to get the .img format image file;
- Run the win32diskimager utility under Windows as administrator. On the utility's main window select your SD card's drive, the wanted image file and click on "write" to start flashing the SD card.
- Eject your SD card and insert it to NanoPi-Zero2’s microSD card slot.
- Turn on NanoPi-Zero2, it will boot from the SD card and automatically run EFlasher to install the OS to the board’s eMMC.
- After flashing is complete, eject the SD card from NanoPi-Zero2, NanoPi-Zero2 will automatically reboot and boot from eMMC.
4.4.3.1.2 Flash third party OS (Image file) to eMMC
- Auto Install (Default Behavior)
1) Download an “eflasher” firmware from network drive(in the "01_Official images/02_SD-to-eMMC images" directory), extract it and install it to a TF card ;
2) Eject and insert the TF card to your PC, after a “FriendlyARM” device shows up(Under Linux, it is a “FriendlyARM” directory), copy the image file ending with .raw or .gz into the directory (Note: if your file is in .img format, please rename it to .raw format).
3) Open the eflasher.conf file on the TF card, set “autoStart=” to the name of your image file, such as:
autoStart=openwrt-rockchip-armv8_nanopi-ext4-sysupgrade.img.gz
In addition to third-party image, official image files which with the '-sd-' word in the filename are also supported, for example: rk3NNN-sd-friendlywrt-21.02-YYYYMMDD.img.gz
4) Eject the TF card, insert the TF card to NanoPi-Zero2, power it on it will automatically install your firmware. You can watch the installation progress by observing the LEDs’ status.
4.4.3.2 Option 2: Install OS on Web Page
Get a TF card which has been installed with FriendlyWrt, log in FriendlyWrt on the web page, click on “System” ->”eMMC Tools”. Click on “Select file” to select your wanted image file, either an official image (filename containing '-sd-') or a third party image. The file should be a “.gz” or “.img” file.
After a file is selected, click on “Upload and Write” to start installing an OS.
After installation is done, eject the SD card, the system will automatically reboot and load the OS from eMMC. After the OS begins to load, if the system LED is flashing and the network LED is on, it means the the OS has loaded successfully. If the OS is FriendlyWrt, you can click on “Go to Homepage” to enter the homepage.
For official OS, you need select the file with the filename containing '-sd-', for example: rk3NNN-sd-friendlywrt-21.02-YYYYMMDD.img.gz, the compression file only supports the .gz format. If the file is too large, you can compress it into .gz format before uploading.
4.4.3.3 Option 3: Install OS via USB
4.4.3.3.1 Step 1: Install USB Driver and Tools/Utilities
Download a driver file DriverAssitant_v5.12.zip under the “tools” directory from network drive, extract and install it.
Under the same directory, download a utility RKDevTool_Release_v2.84.zip and extract it.
4.4.3.3.2 Step 2: Connect NanoPi-Zero2 to PC and Enter Installation Mode
Press and hold the “Mask” key, Use a USB C-to-A cable, connect NanoPi-Zero2 to a PC,After the status LED has been on for at least 3 seconds, release the Mask key;
4.4.3.3.3 Step 3: Install image to eMMC
A firmware in general is packaged in either of the two options: the first is an whole image (ie, update.img) which is often offered by third party developers, the second is that an image is packaged and placed in multiple partition images. FriendlyElec offers an image in the latter option.
- Option 1: Install whole image (ie, update.img)
On a PC which has the extracted RKDevTool_Release_v2.84 utility, go to the RKDevTool_Release_v2.84 directory, run the RKDevTool.exe file. If everything works, you will see a “Found a new Maskrom device” message on the utility;
Go to “Upgrade Firmware(升级固件)”, click on “Firmware(固件)”, select your wanted image file, and click on “Upgrade(升级)” to install. After installation is done, your board will reboot automatically and load the system from eMMC;
- Option 2: Install OS that is packaged & placed in multiple partition images
Go to network drive to download your needed package and extract it (in the "01_Official images/03_USB upgrade images).
After it is extracted, you will see some utilities and a configuration file under the directory. double click on RKDevTool.exe, you will see a “Found a new Maskrom device” message on the utility. Click on the “Execute”, wait a moment and it will be installed. After installation is done your system will automatically reboot and load the system from eMMC.
4.4.4 Installing the System to M.2 or USB Drive
You can use a TF card to boot the eFlasher system, allowing the boot and system to be installed on different storage devices. However, since the CPU doesn’t support booting directly from M.2 and USB devices, the system can be installed on M.2 and USB devices, but the boot must still be installed on eMMC or a TF card.
Steps are as follows:
- Prepare a TF card with a capacity of 32GB or larger.
- Visit [the download link here](http://download.friendlyelec.com/NanoPiZero2) to download the firmware file named XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz (located in the “01_Official images/02_SD-to-eMMC images” directory).
- Flash the firmware to the TF card, connect the storage device you intend to use on NanoPi-Zero2, insert the TF card and power on, we need to perform the operations in the eFlasher GUI. If your NanoPi-Zero2 does not have a display interface, you can use VNC; refer to Using VNC to Operate eFlasher.
- In the eFlasher GUI, select the OS to install, and in the OS settings interface, choose the destination for boot installation (typically eMMC), then choose the destination for system installation (options include eMMC, M.2 hard drive, USB storage, etc.), as shown below:
- If no eMMC is available, the TF card can serve as the boot by inserting another TF card into the USB port via a USB card reader and selecting it as the boot destination, enabling booting from the TF card with the system stored on the M.2 or USB drive.
- After flashing, eject the SD card from NanoPi-Zero2. If booting from eMMC, NanoPi-Zero2 will automatically restart into the newly flashed system. If boot installation is on a TF card, power off, insert the boot TF card, and power on again.
- For a more detailed installation guide, please refer to this link.
5 Work with FriendlyCore
5.1 FriendlyCore User Account
- Non-root User:
User Name: pi Password: pi
- Root:
User Name: root Password: fa
5.2 Update Software Packages
$ sudo apt-get update
5.3 Setup Network Configurations
5.3.1 Set static IP address
By default "eth0" is assigned an IP address obtained via dhcp. If you want to change the setting you need to change the following file:
vi /etc/network/interfaces.d/eth0
For example if you want to assign a static IP to it you can run the following commands:
auto eth0 iface eth0 inet static address 192.168.1.231 netmask 255.255.255.0 gateway 192.168.1.1
5.3.2 Set a DNS
You also need to modify the following file to add the DNS configuration:
vi /etc/systemd/resolved.conf
For example, set to 192.168.1.1:
[Resolve] DNS=192.168.1.1
Restart the systemd-resolved service with the following command:
sudo systemctl restart systemd-resolved.service sudo systemctl enable systemd-resolved.service
5.3.3 Set up to use another network interface
To change the setting of "eth1" you can add a new file similar to eth0's configuration file under the /etc/network/interfaces.d/ directory.
5.4 Setup Wi-Fi
First, use the following command to check if Network-Manager is installed on your system:
which nmcli
If you have installed it, refer to this link to connect to WiFi: Use NetworkManager to configure network settings, If you do not have Network-Manager installed on your system, please refer to the following method to configure WiFi,
By default the WiFi device is "wlan0". You need to create a configuration file under "/etc/network/interfaces.d/" for WiFi:
vi /etc/network/interfaces.d/wlan0
Here is a sample wlan0 file:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp
wpa-driver wext
wpa-ssid YourWiFiESSID
wpa-ap-scan 1
wpa-proto RSN
wpa-pairwise CCMP
wpa-group CCMP
wpa-key-mgmt WPA-PSK
wpa-psk YourWiFiPassword
Please replace "YourWiFiESSID" and "YourWiFiPassword" with your WiFiESSID and password. After save and close the file you can connect to your WiFi source by running the following command:
sudo systemctl daemon-reload sudo systemctl restart networking
After you power on your board it will automatically connect to your WiFi source.
Please note that if you use one TF card to boot multiple boards the WiFi device name will likely be named to "wlan1", "wlan2" and etc. You can reset it to "wlan0" by deleting the contents of the following file and reboot your board:
/etc/udev/rules.d/70-persistent-net.rules
5.5 Install the kernel-header package
sudo dpkg -i /opt/linux-headers-*.deb
6 Work with Debian Core
6.1 Account & Password
Regular Account:
User Name: pi
Password: pi
Root:
the root user account is disabled by default, you may configure the root password through the 'sudo passwd root' command.
6.2 View IP address
Since the Debian Bullseye hostname is the hardware model by default, you can use the ping command to get the IP address:ping NanoPi-Zero2
Debian Bullseye uses network-manager to manage the network, and the network ports are configured to automatically obtain IP addresses by DHCP (including devices with multiple network ports).
6.3 Connect to Debian via SSH
Run the following commandssh pi@NanoPi-Zero2
The default password is: pi
6.4 Update Software Packages
$ sudo apt-get update
6.5 Change time zone
6.5.1 Check the current time zone
timedatectl
6.5.2 List all available time zones
timedatectl list-timezones
6.5.3 Set the time zone (e.g. Shanghai)
sudo timedatectl set-timezone Asia/Shanghai
6.6 Change startup LOGO
Replace the following two files in the kernel source code directory and recompile the kernel:
kernel/logo.bmp
kernel/logo_kernel.bmp
Or use the script to operate, as shown below:
- Download scripts:
git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b kernel-4.19 --single-branch cd sd-fuse_rk3399
- Compile kernel and repackage firmware
convert files/logo.jpg -type truecolor /tmp/logo.bmp convert files/logo.jpg -type truecolor /tmp/logo_kernel.bmp sudo LOGO=/tmp/logo.bmp KERNEL_LOGO=/tmp/logo_kernel.bmp ./build-kernel.sh debian-bookworm-core-arm64 sudo ./mk-sd-image.sh debian-bookworm-core-arm64 sudo ./mk-emmc-image.sh debian-bookworm-core-arm64
6.7 Soft Factory Reset
Execute the following command in a terminal:
sudo firstboot && sudo reboot
6.8 Install Docker on Debian
Please refer to: How to Install Docker on Debian
7 How to Compile
Coming soon
7.1 Setup Development Environment
7.1.1 Method 1: Using docker to cross-compile
Please refre to docker-cross-compiler-novnc
7.1.2 Method 2: Setup build environment on the host machine
7.1.2.1 Install required packages
Install and run requirements ubuntu 20.04, install required packages using the following commands:
sudo apt-get -y update sudo apt-get install -y sudo curl sudo bash -c \ "$(curl -fsSL https://raw.githubusercontent.com/friendlyarm/build-env-on-ubuntu-bionic/master/install.sh)"
The following cross-compilers will be installed:
Version | Architecture | Compiler path | Purpose |
---|---|---|---|
4.9.3 | armhf | /opt/FriendlyARM/toolchain/4.9.3 | Can be used to build 32-bit ARM applications |
6.4 | aarch64 | /opt/FriendlyARM/toolchain/6.4-aarch64 | Can be used to build kernel 4.4 |
11.3 | aarch64 | /opt/FriendlyARM/toolchain/11.3-aarch64 | Can be used to build kernel 4.19 or higher and U-Boot |
7.1.2.2 Setting the compiler path
Based on the table in the previous section, select the appropriate version of the compiler and add the compiler's path to PATH. For example, if you want to use the 11.3 cross-compiler, edit ~/.bashrc using vi and add the following content to the end:
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin:$PATH export GCC_COLORS=auto
Run the ~/.bashrc script to make it effective in the current commandline. Note: there is a space after ".":
. ~/.bashrc
To verify if the installation was successful:
$ aarch64-linux-gcc -v Using built-in specs. COLLECT_GCC=aarch64-linux-gcc COLLECT_LTO_WRAPPER=/opt/FriendlyARM/toolchain/11.3-aarch64/libexec/gcc/aarch64-cortexa53-linux-gnu/11.3.0/lto-wrapper Target: aarch64-cortexa53-linux-gnu Configured with: /home/cross/arm64/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=aarch64-cortexa53-linux-gnu --prefix=/opt/FriendlyARM/toolchain/11.3-aarch64 --exec_prefix=/opt/FriendlyARM/toolchain/11.3-aarch64 --with-sysroot=/opt/FriendlyARM/toolchain/11.3-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-languages=c,c++ --enable-fix-cortex-a53-843419 --with-arch=armv8-a+crypto+crc --with-cpu=cortex-a53 --with-pkgversion=ctng-1.25.0-119g-FA --with-bugurl=http://www.friendlyelec.com/ --enable-objc-gc --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/home/cross/arm64/buildtools --with-mpfr=/home/cross/arm64/buildtools --with-mpc=/home/cross/arm64/buildtools --with-isl=/home/cross/arm64/buildtools --enable-lto --enable-threads=posix --disable-libstdcxx-pch --enable-clocale=gnu --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-indirect-function --enable-gnu-unique-object --enable-default-pie --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-gold --with-libintl-prefix=/home/cross/arm64/buildtools --disable-multilib --with-local-prefix=/opt/FriendlyARM/toolchain/11.3-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-long-long --enable-checking=release --enable-link-serialization=2 Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.3.0 (ctng-1.25.0-119g-FA)
7.2 Build Openwrt/Friendlywrt
7.2.1 Download Code
Two versions are available, please choose as required:
7.2.1.1 FriendlyWrt 21.02
mkdir friendlywrt21-rk3528 cd friendlywrt21-rk3528 git clone https://github.com/friendlyarm/repo --depth 1 tools tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v21.02 \ -m rk3528.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle tools/repo sync -c --no-clone-bundle
7.2.1.2 FriendlyWrt 23.05
mkdir friendlywrt23-rk3528 cd friendlywrt23-rk3528 git clone https://github.com/friendlyarm/repo --depth 1 tools tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v23.05 \ -m rk3528.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle tools/repo sync -c --no-clone-bundle
7.2.2 First compilation step
./build.sh rk3528.mk # or rk3528-docker.mk
All the components (including u-boot, kernel, and friendlywrt) are compiled and the sd card image will be generated, then execute the following command to generate the image file for installing the system into the emmc:
./build.sh emmc-img
After making changes to the project, the sd card image needs to be repackaged by running the following command:
./build.sh sd-img
7.2.3 Secondary compilation steps
cd friendlywrt make menuconfig rm -rf ./tmp make -j${nproc} cd ../ ./build.sh sd-img ./build.sh emmc-img
7.2.4 Build u-boot only
./build.sh uboot
7.2.5 Build kernel only
./build.sh kernel
7.2.6 Build friendlywrt only
./build.sh friendlywrt
Or go to the friendlywrt directory and follow the standard openwrt commands. If you get an error with the above command, try using the following command to compile in a single thread:
cd friendlywrt make -j1 V=s
7.3 Build Other Linux
7.3.1 Kernel and u-boot versions
Operating System | Kernel Version | U-boot version | Cross-compiler | Partition type | Packaging Tool | Kernel branch | Kernel configuration | U-boot branch | U-boot configuration |
---|---|---|---|---|---|---|---|---|---|
openmediavault-arm64 | linux v6.1.y | u-boot v2017.09 |
11.3-aarch64 | GPT | sd-fuse |
nanopi6-v6.1.y | nanopi5_linux_defconfig | nanopi5-v2017.09 | nanopi5_defconfig |
ubuntu-noble-core-arm64 | GPT | ||||||||
debian-bookworm-core-arm64 | |||||||||
friendlywrt21 | nanopi5_linux_defconfig +friendlywrt.config | ||||||||
friendlywrt21-docker | |||||||||
friendlywrt23 | |||||||||
friendlywrt23-docker |
- Kernel git repo:https://github.com/friendlyarm/kernel-rockchip
- U-boot git repo:https://github.com/friendlyarm/uboot-rockchip
- The cross-compile toolchain is located in the path: /opt/FriendlyARM/toolchain/
- The SD-Fuse is a helper script to make bootable SD card image.
7.3.2 Build kernel linux-v6.1.y
This section applies to the following operating systems:
friendlywrt21 | friendlywrt21-docker | friendlywrt23 | friendlywrt23-docker | ubuntu-noble-core-arm64 | openmediavault-arm64 | debian-bookworm-core-arm64 |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi6-v6.1.y kernel-rockchip cd kernel-rockchip export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH touch .scmversion # Configuring the Kernel # Load default configuration make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig # Optionally, load configuration for FriendlyWrt # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi5_linux_defconfig friendlywrt.config # Optionally, if you want to change the default kernel config # make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 menuconfig # Start building kernel make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -j$(nproc) # Start building kernel modules mkdir -p out-modules && rm -rf out-modules/* make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc) make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 INSTALL_MOD_PATH="$PWD/out-modules" modules_install KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease) [ ! -f "$PWD/out-modules/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b $PWD/out-modules -E Module.symvers -F System.map -w ${KERNEL_VER} (cd $PWD/out-modules && find . -name \*.ko | xargs aarch64-linux-strip --strip-unneeded)
Pack the kernel.img and resource.img:
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3528/kernel-6.1.y/tools/mkkrnlimg && chmod 755 mkkrnlimg wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3528/kernel-6.1.y/tools/resource_tool && chmod 755 resource_tool wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3528/kernel-6.1.y/prebuilt/boot/logo.bmp wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3528/kernel-6.1.y/prebuilt/boot/logo_kernel.bmp ./mkkrnlimg arch/arm64/boot/Image kernel.img ./resource_tool --dtbname arch/arm64/boot/dts/rockchip/rk3528-nanopi*-rev*.dtb logo.bmp logo_kernel.bmp
After the compilation, the following files will be generated:
kernel.img | resource.img | The kernel modules are located in the out-modules directory |
Run your build:
Please refre to #Running the build
7.3.3 Build u-boot v2017.09
This section applies to the following operating systems:
friendlywrt21 | friendlywrt21-docker | friendlywrt23 | friendlywrt23-docker | ubuntu-noble-core-arm64 | openmediavault-arm64 | debian-bookworm-core-arm64 |
Clone the repository to your local drive then build:
git clone https://github.com/friendlyarm/rkbin --single-branch --depth 1 -b friendlyelec git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi5-v2017.09 export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH cd uboot-rockchip/ ./make.sh nanopi_r3
After the compilation, the following files will be generated:
uboot.img | trust.img | rk356x_spl_loader_vX.YY.ZZZ.bin (aka MiniLoaderAll.bin) |
Run your build:
Please refre to #Running the build
7.3.4 Running the build
7.3.4.1 Install to target board
This section applies to the following operating systems:
friendlywrt21 | friendlywrt21-docker | friendlywrt23 | friendlywrt23-docker | ubuntu-noble-core-arm64 | openmediavault-arm64 | debian-bookworm-core-arm64 |
RK3528 uses GPT partitions by default, you can use the dd command, but be careful to choose the right output device:
- The SD/TF Card device node: /dev/mmcblk0
- The eMMC device node: /dev/mmcblk2
The following is an example of how to update the kernel to eMMC:
Use the 'parted' command to view the partition layout:
parted /dev/mmcblk2 print
Sample outputs:
Model: MMC BJTD4R (sd/mmc) Disk /dev/mmcblk2: 31.3GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 8389kB 12.6MB 4194kB uboot 2 12.6MB 16.8MB 4194kB trust 3 16.8MB 21.0MB 4194kB misc 4 21.0MB 25.2MB 4194kB dtbo 5 25.2MB 41.9MB 16.8MB resource 6 41.9MB 83.9MB 41.9MB kernel 7 83.9MB 134MB 50.3MB boot 8 134MB 2500MB 2366MB ext4 rootfs 9 2500MB 31.3GB 28.8GB ext4 userdata
as shown above, the resource partition is located at 5 and the kernel partition is located at 6. Use the dd command to write the resource.img and kernel.img files to these partitions, the commands are as follows:
dd if=resource.img of=/dev/mmcblk2p5 bs=1M dd if=kernel.img of=/dev/mmcblk2p6 bs=1M
If you want to update u-boot:
dd if=uboot.img of=/dev/mmcblk2p1 bs=1M
To update new driver modules, copy the newly compiled driver modules to the appropriate directory under /lib/modules.
7.3.4.2 Packaging and creating an SD image
To create a new OS image file, you need to use the "sd-fuse" packaging tool.
"sd-fuse" is a collection of scripts that can be used to create bootable SD card images for FriendlyElec boards. Its main features include:
- Creation of root filesystem images from a directory
- Building of bootable SD card images
- Simple compilation of kernel, U-Boot, and third-party drivers
Please click on the following link to find out more:
Kernel version | Packaging Tool |
---|---|
linux v6.1.y | sd-fuse_rk3528/kernel-6.1.y |
7.3.4.3 USB flashing
7.3.4.3.1 Linux
Reboot the board and enter loader mode with the following command:
sudo reboot loader
To flash U-Boot and kernel using the "upgrade_tool_v2.30_for_linux" tool, please use the following command:
sudo upgrade_tool di -k kernel.img sudo upgrade_tool di -re resource.img sudo upgrade_tool di -u uboot.img sudo upgrade_tool RD
Note: "upgrade_tool" is a command-line tool provided by Rockchip for Linux operating systems (Linux_Upgrade_Tool).
7.4 Build the code using scripts
7.4.1 Download scripts and image files
git clone https://github.com/friendlyarm/sd-fuse_rk3528.git -b kernel-6.1.y cd sd-fuse_rk3528 wget http://112.124.9.243/dvdfiles/rk3528/images-for-eflasher/ubuntu-noble-core-arm64-images.tgz tar xvzf ubuntu-noble-core-arm64-images.tgz
7.4.2 Compile the kernel
Download the kernel source code and compile it. the relevant image files in the ubuntu-noble-core-arm64 directory will be automatically updated, including the kernel modules in the file system:
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi6-v6.1.y kernel-rk3528 KERNEL_SRC=$PWD/kernel-rk3528 ./build-kernel.sh ubuntu-noble-core-arm64
7.4.3 Compile the kernel headers
git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi6-v6.1.y kernel-rk3528 MK_HEADERS_DEB=1 BUILD_THIRD_PARTY_DRIVER=0 KERNEL_SRC=$PWD/kernel-rk3528 ./build-kernel.sh ubuntu-noble-core-arm64
7.4.4 Compile the uboot
Download the uboot source code and compile it. the relevant image files in the ubuntu-noble-core-arm64 directory will be automatically updated:
git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi5-v2017.09 UBOOT_SRC=$PWD/uboot-rockchip ./build-uboot.sh ubuntu-noble-core-arm64
7.4.5 Generate new image
Repackage the image file in the ubuntu-noble-core-arm64 directory into sd card image:
./mk-sd-image.sh ubuntu-noble-core-arm64
After the command is completed, the image is in the out directory.
8 Using On-Board Hardware Resources
8.1 Using VPU
Please refer to NPU
8.2 Using NPU
Please refer to NPU
8.3 DTS files
Please refer to DTS files
9 Backup rootfs and create custom SD image (to burn your application into other boards)
9.1 Backup rootfs
Run the following commands on your target board. These commands will back up the entire root partition:
sudo passwd root su root cd / tar --warning=no-file-changed -cvpzf /rootfs.tar.gz \ --exclude=/rootfs.tar.gz --exclude=/var/lib/docker/runtimes \ --exclude=/etc/firstuser --exclude=/etc/friendlyelec-release \ --exclude=/usr/local/first_boot_flag --one-file-system /
Note: if there is a mounted directory on the system, an error message will appear at the end, which can be ignored.
9.2 Making a bootable SD card from a root filesystem
Only support RK3328/RK3399/RK3568/RK3566/RK3588
10 Common Linux-based operating system operations
10.1 Using ADB on Linux Systems
10.1.1 Enabling ADB in Buildroot System
Enable on Startup
mv /etc/init.d/K50usbdevice.sh /etc/init.d/S50usbdevice.sh reboot
Enable Temporarily
usbdevice-wrapper start
10.1.2 Enabling ADB in Ubuntu and Debian Systems
Enable on Startup
sudo systemctl enable usbdevice sudo reboot
Enable Temporarily
usbdevice-wrapper start
10.1.3 How to Connect
When using ADB, the port connected to the computer is the same as the USB flashing port.
10.2 Install Kernel Headers
To install the .deb file located in the /opt/archives directory:
sudo dpkg -i /opt/archives/linux-headers-*.deb
To download and update the kernel header files online:
wget http://112.124.9.243/archives/RK3528/linux-headers-$(uname -r)-latest.deb
sudo dpkg -i ./linux-headers-latest.deb
You can visit http://112.124.9.243/archives/RK3528 to see which kernel deb packages are available.
10.3 Setting Kernel Boot Parameters (eMMC Only)
Flash the firmware file XXXX-eflasher-multiple-os-YYYYMMDD-30g.img.gz to a TF card, then insert the TF card into your computer. Windows will usually recognize the TF card partition automatically (formatted as exFAT). For Linux or Mac users, manually mount the first partition of the TF card. Assuming the TF card’s device name is /dev/sdX, mount /dev/sdX1.
Edit the info.conf configuration file in the OS directory on the TF card, adding the bootargs-ext parameter. For example:
bootargs-ext=rockchipdrm.fb_max_sz=2048
To remove a specified parameter, set it to empty. For example, to remove the userdata parameter:
bootargs-ext=userdata=
After editing, use this TF card to flash the system to eMMC.
To set kernel boot parameters during the creation of a mass production card, refer to the following script (example for RK3588):
https://github.com/friendlyarm/sd-fuse_rk3588/blob/kernel-6.1.y/test/test-custom-bootargs.sh
11 Unbricking Method
If the ROM is not installed correctly, causing the development board to become bricked, and you might not have the opportunity to reinstall the ROM via an SD card, you need to enter Maskrom mode to unbrick it by erasing the storage device.
11.1 Windows Users
11.1.1 Download Required Files
- Get the necessary tools: Visit here, find RKDevTool_v3.19_for_window.zip and DriverAssitant_v5.12.zip in the 05_Tools directory, and download them to your local machine.
- Install Rockchip USB driver and RKDevTool: Extract DriverAssitant_v5.12.zip to install the Rockchip USB driver, and extract RKDevTool_v3.19_for_window.zip to obtain the Rockchip flashing tool RKDevTool.
- Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.
11.1.2 Enter Maskrom Mode to Erase the Storage Device
- Remove the SD card, USB device, and other peripherals from the development board
- Start RKDevTool on your computer.
- Press and hold the “Mask” key, Use a USB cable, connect NanoPi-Zero2 to a PC,After the status LED has been on for at least 3 seconds, release the Mask key
- You will see Found One MASKROM Device displayed at the bottom of the RKDevTool interface, as shown below:
- Click the Advanced Function tab in the RKDevTool interface.
- In the Boot text box, select MiniLoaderAll.bin, then click the Download button.
- Select EMMC, click Switch Storage, then click the EraseAll button to erase the eMMC.
- At this point, NanoPi-Zero2 is restored to its initial state and can be normally booted via SD card or eMMC.
11.2 Linux Users
11.2.1 Download the Required Files
- Get the necessary tools: Visit here and find upgrade_tool_v2.30_for_linux.tgz in the 05_Tools directory and download it locally.
- Get the loader: Visit here, enter the tools directory corresponding to your CPU model, and download MiniLoaderAll.bin.
11.2.2 Installation for upgrade_tool
Using the following commands:
tar xzf upgrade_tool_v2.30_for_linux.tgz cd upgrade_tool_v2.30_for_linux sudo cp upgrade_tool /usr/local/sbin/ sudo chmod 755 /usr/local/sbin/upgrade_tool
11.2.3 Enter Maskrom Mode to Erase the Storage Device
- Connect NanoPi-Zero2 to the computer using a USB data cable.
- Disconnect the power from NanoPi-Zero2, hold down the MASK button, connect the power, and release the button after 4 seconds.
- Check the connection with the following command:
upgrade_tool LD
A result similar to "DevNo=1 Vid=0x2207,Pid=0x350b,LocationID=13 Mode=Maskrom SerialNo=" indicates that the device has been detected.
- Erase the eMMC with the following command:
upgrade_tool EF MiniLoaderAll.bin
- At this point, NanoPi-Zero2 has been restored to its initial state and can boot the system normally via SD card or eMMC.
11.3 Mac Users
Our tests found that upgrade_tool_v2.25 does not work properly on macOS. Therefore, we recommend using Windows or Linux unless an updated version of upgrade_tool becomes available.
12 Resources
12.1 Datasheets and Schematics
- Schematic: NanoPi_Zero2_2407_SCH.pdf
- PCB CAD File:NanoPi_Zero2_2407_DXF.zip
- RK3528A Datasheet:Rockchip_RK3528A_Datasheet_V1.2-20240410.pdf
13 Update Log
13.1 2024-11-12
- Improved ramdisk and eflasher for more flexibility and reliability when installing the system on external storage
13.2 2024-10-16
- KVM is enabled by default in the kernel
- Optimized standby power consumption
- Added Proxmox VE system
- Updated FriendlyWrt to version openwrt-23.05.05
13.3 2024-09-04
Initial Release