Difference between revisions of "NanoPi Zero2"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(updated by API)
Line 1: Line 1:
[[NanoPi R4SE/zh|查看中文]]
+
[[NanoPi Zero2/zh|查看中文]]
  
 
==Introduction==
 
==Introduction==
Line 9: Line 9:
 
[[File:R4SE_Case-03.jpg|thumb|300px|Case]]
 
[[File:R4SE_Case-03.jpg|thumb|300px|Case]]
 
[[File:R4SE_Case-04.jpg|thumb|300px|Case]]
 
[[File:R4SE_Case-04.jpg|thumb|300px|Case]]
* The NanoPi R4SE(as "R4SE") is an open source platform with dual-Gbps Ethernet ports designed and developed by FriendlyElec for IoT applications.
+
* The ZeroPi is another fun board developed by FriendlyELEC for makers, hobbyists and fans.
* The NanoPi R4SE uses the RK3399 SoC. It has two Gbps Ethernet ports and 4G LPDDR4 RAM. FriendlyElec ported an OpenWrt system for it. It works with Docker CE. It is a good platform for developing IoT applications, NAS applications etc.
+
 
 
==Hardware Spec==
 
==Hardware Spec==
* SoC: Rockchip RK3399
+
* SoC: Rockchip RK3528
 
** CPU: big.LITTLE,Dual-Core Cortex-A72(up to 2.0GHz) + Quad-Core Cortex-A53(up to 1.5GHz)
 
** CPU: big.LITTLE,Dual-Core Cortex-A72(up to 2.0GHz) + Quad-Core Cortex-A53(up to 1.5GHz)
 
** GPU: Mali-T864 GPU,supports OpenGL ES1.1/2.0/3.0/3.1, OpenCL, DX11, and AFBC
 
** GPU: Mali-T864 GPU,supports OpenGL ES1.1/2.0/3.0/3.1, OpenCL, DX11, and AFBC
Line 74: Line 74:
 
{{BurnLinuxToSD-RK3399Router|NanoPi-R4SE}}
 
{{BurnLinuxToSD-RK3399Router|NanoPi-R4SE}}
 
{{BurnLinuxToEMMC-RK3399Router|NanoPi-R4SE}}
 
{{BurnLinuxToEMMC-RK3399Router|NanoPi-R4SE}}
{{FriendlyWrt21|NanoPi-R4SE}}
 
 
{{OfficialUbuntuCore|NanoPi-R4SE}}
 
{{OfficialUbuntuCore|NanoPi-R4SE}}
 
{{FriendlyCoreRemoveQt}}
 
{{FriendlyCoreRemoveQt}}
==Work with Debian11 Desktop==
 
===Introduction to Debian11 Desktop===
 
{{DebianBullseyeDesktop-Intro|NanoPi-R4SE}}
 
{{DebianBullseyeDesktop-Common|NanoPi-R4SE}}
 
==Work with Debian10 Desktop==
 
* Refer to:
 
** [[Debian Buster Desktop|Debian Buster]]
 
==Buildroot Linux==
 
{{RK3399 Buildroot Intro|NanoPi-R4SE}}
 
<br />
 
For a more detailed description of the Buildroot system, please refer to: [[Buildroot|Buildroot]]<br />
 
 
==How to Compile==
 
==How to Compile==
 
{{Rockchip-DevEnv|NanoPi-R4SE}}
 
{{Rockchip-DevEnv|NanoPi-R4SE}}

Revision as of 03:35, 4 September 2024

查看中文

Contents

1 Introduction

Overview
Front
Back
Case
Case
Case
Case
  • The ZeroPi is another fun board developed by FriendlyELEC for makers, hobbyists and fans.

2 Hardware Spec

  • SoC: Rockchip RK3528
    • CPU: big.LITTLE,Dual-Core Cortex-A72(up to 2.0GHz) + Quad-Core Cortex-A53(up to 1.5GHz)
    • GPU: Mali-T864 GPU,supports OpenGL ES1.1/2.0/3.0/3.1, OpenCL, DX11, and AFBC
    • VPU: 4K VP9 and 4K 10bits H265/H264 60fps decoding, Dual VOP, etc
  • PMU: RK808-D PMIC, cooperated with independent DC/DC, enabling DVFS, software power-down, RTC wake-up, system sleep mode
  • RAM: 4GB LPDDR4
  • Flash: 32GB eMMC
  • Ethernet: one Native Gigabit Ethernet, and one PCIe Gigabit Ethernet
  • USB: two USB 3.0 Type-A ports
  • microSD Slot x 1
  • Debug: one Debug UART, 3 Pin 2.54mm header, 3V level, 1500000bps
  • LEDs: 1 x power LED and 3 x GPIO Controlled LED (SYS, LAN, WAN)
  • others:
    • 2 Pin 1.27/1.25mm RTC battery input connector
    • one User Button
    • one MASK Button for eMMC upgrade
    • one 5V Fan connector
  • Power supply: DC 5V/3A, via USB-C connector
  • PCB: 8 Layer, 66 mm x 66 mm
  • Temperature measuring range: 0℃ to 80℃

3 Diagram, Layout and Dimension

3.1 Layout

NanoPi R4SE Layout
  • Debug UART Pin Spec
3V level signals, 1500000bps
Pin# Assignment Description
1 GND 0V
2 UART2DBG_TX output
3 UART2DBG_RX intput
  • USB Port
Each USB 3.0 port has 2A overcurrent protection.
  • RTC
RTC backup current is 27uA.
Connector P/N: Molex 53398-0271
Notes
  1. Power Input : 5V/3A, via USB Type-C(USB PD Specification is not supported)

4 Get Started

4.1 Essentials You Need

Before starting to use your NanoPi-R4SE get the following items ready

  • NanoPi-R4SE
  • MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
  • 5V/3A and above USB Type-C interface power adapter (Note: QC/PD fast charger may have compatibility issues), it is recommended to use the following or similar 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 Flash to TF

Visit download linkto download image files (in the "01_Official images/01_SD card images" directory) and utilities (in the "05_Tools" directory):

Image Files
rk3399-sd-friendlywrt-21.02-YYYYMMDD.img.gz FriendlyWrt image file, based on OpenWrt 21.02, kernel version 6.1.y
rk3399-sd-friendlywrt-21.02-docker-YYYYMMDD.img.gz FriendlyWrt image file, built-in docker, based on OpenWrt 21.02, kernel version 6.1.y
rk3399-sd-friendlywrt-23.05-YYYYMMDD.img.gz FriendlyWrt image file, based on OpenWrt 23.05, kernel version 6.1.y
rk3399-sd-friendlywrt-23.05-docker-YYYYMMDD.img.gz FriendlyWrt image file, built-in docker, based on OpenWrt 23.05, kernel version 6.1.y
rk3399-sd-ubuntu-noble-core-4.19-arm64-YYYYMMDD.img.zip Ubuntu 24.04 Core
No desktop environment, command line only
Kernel version 4.19.y
rk3399-sd-debian-bookworm-core-4.19-arm64-YYYYMMDD.img.gz Debian 12 Core
No desktop environment, command line only
Kernel version 4.19.y
rk3399-sd-debian-bullseye-minimal-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
No pre-installed recommended software
Supports hardware acceleration
Kernel version 4.19.y
rk3399-sd-debian-bullseye-desktop-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
Pre-installed mpv, smplayer and chromium brower
Supports hardware acceleration
Kernel version 4.19.y
Other Image
Github Actions FriendlyWrt
Flash Utility:
win32diskimager.rar Windows utility. Under Linux users can use "dd"

The detailed steps are as follows:

  • Get an 8G SDHC card and backup its data if necessary;
  • Download and extract the xxx.img.gz and win32diskimager;
  • 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. Under Linux run "dd" to flash the rkXXXX-sd-OSNAME-YYYYMMDD.img file to your SD card;
  • Take out the SD and insert it to NanoPi-R4SE's microSD card slot;
  • Power on NanoPi-R4SE and it will be booted from your TF card;

4.4.2 Install OS to eMMC

4.4.2.1 Option 1: 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 (the name might start with “rk3399-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.
Friendlywrt-emmctools2-en.png
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.
Note that if you are burning the FriendlyElec firmware, you need to use an image file with the "-sd-" file name, similar to the one below:

rk3399-sd-friendlywrt-21.02-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-21.02-docker-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-23.05-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-23.05-docker-YYYYMMDD.img.gz

If the file is in 7z, zip or rar format, you will need to extract it first. If the file is too large to write, you can compress it into .gz format and try again.

4.4.2.2 Option 2: Install OS via TF Card
4.4.2.2.1 Install OS to eMMC
  • 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 watch its progress by observing its LEDs as well.

Visit download link to download the needed utilities and image file:

Image File
rk3399-eflasher-friendlywrt-21.02-YYYYMMDD.img.gz FriendlyWrt
Based on OpenWrt 21.02
Kernel version 6.1.y
rk3399-eflasher-friendlywrt-21.02-docker-YYYYMMDD.img.gz FriendlyWrt
Pre-installed Docker
Based on OpenWrt 21.02
Kernel version 6.1.y
rk3399-eflasher-friendlywrt-23.05-YYYYMMDD.img.gz FriendlyWrt
Based on OpenWrt 23.05
Kernel version 6.1.y
rk3399-eflasher-friendlywrt-23.05-docker-YYYYMMDD.img.gz FriendlyWrt
Pre-installed Docker
Based on OpenWrt 23.05
Kernel version 6.1.y
rk3399-eflasher-debian-bookworm-core-4.19-arm64-YYYYMMDD.img.gz Debian 12 Core
No desktop environment, command line only
Kernel version 4.19.y
rk3399-eflasher-debian-bullseye-minimal-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
No pre-installed recommended software
Supports hardware acceleration
Kernel version 4.19.y
rk3399-eflasher-debian-bullseye-desktop-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
Pre-installed mpv, smplayer and chromium brower
Supports hardware acceleration
Kernel version 4.19.y
rk3399-eflasher-ubuntu-noble-core-4.19-arm64-YYYYMMDD.img.gz Ubuntu24.04 Core
No desktop environment, command line only
Kernel version 4.19.y
Flash Utility:
win32diskimager.rar Windows utility. Under Linux users can use "dd"

Here are the steps:

  • Get an SDHC card with a minimum capacity of 8G
  • Download a rk3399-eflasher-OSNAME-YYYYMMDD.img.gz image file and a win32diskimager;
  • Under Windows, run win32diskimager as administrator, select your SD card and extracted EFlasher image file, and click on “Write” to write image file on the SD card; or under Linux, you use the dd command to write the rk3399-eflasher-OSNAME-YYYYMMDD.img file to the SD card.
  • Eject your SD card and insert it to NanoPi-R4SE’s microSD card slot.
  • Turn on NanoPi-R4SE, it will boot from the SD card and automatically run EFlasher to install the OS to the board’s eMMC. You can observer the board’s LEDs to watch its installation progress
Progress SYS LED(Red) LAN LED(Green) WAN LED(Green)
Power On Solid On Off Off
System Boot Slow Flashing Off Off
Installation in Progress Fast Flashing Off Off
Installation Done Slow Flashing Solid On Solid On
  • After installation is done, power off the board, eject the SD card from NanoPi-R4SE, power on the board again, NanoPi-R4SE will load the OS from its eMMC
4.4.2.2.2 Install Flash Image File to eMMC
  • Auto Install (Default Behavior)

1) Download an “eflasher” firmware from network drive, 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 an .img or .gz file to the TF card.
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

Anyone of the files that contain “-sd-” will work. Here is a list:

rk3399-sd-friendlywrt-23.05-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-23.05-docker-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-21.02-YYYYMMDD.img.gz
rk3399-sd-friendlywrt-21.02-docker-YYYYMMDD.img.gz

4) Eject the TF card, insert the TF card to NanoPi-R4SE, power it on it will automatically install your firmware. You can watch the installation progress by observing the LEDs’ status.

4.4.2.3 Option 3: Install OS via USB
4.4.2.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.2.3.2 Step 2: Connect NanoPi-R4SE to PC and Enter Installation Mode

1) Disconnect the connected USB cable and the power cord from NanoPi-R4SE, eject the TF card;
2) Press and hold the “Mask” key, power on the board. After the status LED has been on for at least 3 seconds, release the Mask key.
3) Use a USB A-to-A cable, connect NanoPi-R4SE to a PC as follows. Note: please pay attention to the USB port the USB cable is connected to in the screenshot.
Nanopir4se-usba-to-usba.jpg

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

Image File
rk3399-usb-friendlywrt-21.02-YYYYMMDD.img.gz FriendlyWrt
Based on OpenWrt 21.02
Kernel version 6.1.y
rk3399-usb-friendlywrt-21.02-docker-YYYYMMDD.img.gz FriendlyWrt
Pre-installed Docker
Based on OpenWrt 21.02
Kernel version 6.1.y
rk3399-usb-friendlywrt-23.05-YYYYMMDD.img.gz FriendlyWrt
Based on OpenWrt 23.05
Kernel version 6.1.y
rk3399-usb-friendlywrt-23.05-docker-YYYYMMDD.img.gz FriendlyWrt
Pre-installed Docker
Based on OpenWrt 23.05
Kernel version 6.1.y
rk3399-usb-debian-bullseye-minimal-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
No pre-installed recommended software
Supports hardware acceleration
Kernel version 4.19.y
rk3399-usb-debian-bullseye-desktop-4.19-arm64-YYYYMMDD.img.gz Debian 11(Bullseye) Desktop
Uses LXDE as default desktop
Pre-installed mpv, smplayer and chromium brower
Supports hardware acceleration
Kernel version 4.19.y
rk3399-usb-debian-bookworm-core-4.19-arm64-YYYYMMDD.img.gz Debian 12 Core
No desktop environment, command line only
Kernel version 4.19
rk3399-usb-ubuntu-noble-core-4.19-arm64-YYYYMMDD.img.gz Ubuntu24.04 Core
No desktop environment, command line only
Kernel version 4.19

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.

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.4.1 WiFi models supported

5.4.1.1 M.2 WiFi Module
  • RTL8822CE
5.4.1.2 Usb Dongle
  • RTL8821CU (Vid: 0BDA, Pid: C811) (Test sample:TP-Link TL-WDN5200H)
  • RTL8812AU (Vid: 0BDA, Pid: 8812)
  • MediaTek MT7662 (Vid: 0E8D, Pid: 7612) (Test sample:COMFAST CF-WU782AC V2)

5.5 Install the kernel-header package

sudo dpkg -i /opt/linux-headers-*.deb

5.6 Build kernel-header deb package

Please refre to: https://github.com/friendlyarm/sd-fuse_rk3399/blob/kernel-5.15.y/test/test-build-kernel-header-deb.sh

5.7 Config status LEDs

First determine whether the system already exists the leds initialization service:

sudo systemctl status leds

If the leds service already exists, change the default behavior of the LEDs by editing the following file:

/etc/init.d/leds.sh

Since there is no leds service in the early firmware, you need to refer to the following guide to manually configure the LEDs. First, set the following kernel modules to be automatically loaded at boot:

modprobe ledtrig-netdev
echo ledtrig-netdev > /etc/modules-load.d/ledtrig-netdev.conf

Put the following into the autorun script to associate the status leds with the ethernet interface, and you can configure it to behave in other ways by referring to these content:

echo netdev > /sys/class/leds/wan_led/trigger
echo eth0 > /sys/class/leds/wan_led/device_name
echo 1 > /sys/class/leds/wan_led/link
 
echo netdev > /sys/class/leds/lan_led/trigger
echo eth1 > /sys/class/leds/lan_led/device_name
echo 1 > /sys/class/leds/lan_led/link

5.8 Delete Qt5 and related files

Execute the following commands:

su root
cd /
rm -rf usr/local/Trolltech/Qt-5.10.0-rk64one usr/local/Trolltech/Qt-5.10.0-rk64one-sdk usr/bin/setqt5env* usr/bin/qt5demo etc/qt5
rm -rf opt/{qt5-browser,Qt5_CinematicExperience,qt5-multi-screen-demo,qt5-nmapper,qt5-player,qt5-smarthome,QtE-Demo,qt5-qml-image-viewer,dual-camera}

6 How to Compile

6.1 Setup Development Environment

6.1.1 Method 1: Using docker to cross-compile

Please refre to docker-cross-compiler-novnc

6.1.2 Method 2: Setup build environment on the host machine

6.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
6.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)

6.2 Build Openwrt/Friendlywrt

6.2.1 Download Code

Two versions are available, please choose as required:

6.2.1.1 FriendlyWrt 21.02
mkdir friendlywrt21-rk3399
cd friendlywrt21-rk3399
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 rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle
6.2.1.2 FriendlyWrt 23.05
mkdir friendlywrt23-rk3399
cd friendlywrt23-rk3399
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 rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle

6.2.2 First compilation step

./build.sh rk3399.mk  # or rk3399-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

6.2.3 Secondary compilation steps

cd friendlywrt
make menuconfig
rm -rf ./tmp
make -j${nproc}
cd ../
./build.sh sd-img
./build.sh emmc-img

6.2.4 Build u-boot only

./build.sh uboot

6.2.5 Build kernel only

./build.sh kernel

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

6.3 Build Buildroot

please refer to: Buildroot

6.4 Build Other Linux

6.4.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
lubuntu linux v4.4.y u-boot v2014.10 6.4-aarch64
MBR sd-fuse nanopi4-linux-v4.4.y nanopi4_linux_defconfig nanopi4-v2014.10_oreo rk3399_defconfig

friendlycore-arm64
friendlydesktop-arm64
eflasher
buildroot linux v4.19.y u-boot
v2017.09
11.3-aarch64 GPT sd-fuse nanopi4-v4.19.y nanopi4_linux_defconfig nanopi4-v2017.09 nanopi4_defconfig
ubuntu-focal-desktop-arm64
debian-bullseye-desktop-arm64
debian-bullseye-minimal-arm64
friendlycore-focal-arm64
debian-bookworm-core-arm64
ubuntu-noble-core-arm64
openmediavault-arm64 linux v6.1.y u-boot
v2017.09
11.3-aarch64 GPT
sd-fuse




nanopi-r2-v6.1.y



nanopi4_linux_defconfig
friendlywrt21 GPT nanopi4_linux_defconfig
+friendlywrt.config
friendlywrt21-docker
friendlywrt23
friendlywrt23-docker

6.4.2 Build kernel linux-v4.4.y

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-linux-v4.4.y kernel-rockchip
cd kernel-rockchip
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
touch .scmversion
# Load configuration
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
# Optionally, if you want to change the default kernel config
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig  
# Start building kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
# Start building kernel modules
mkdir -p out-modules
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
[ ! -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)

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

6.4.3 Build u-boot v2014.10

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/uboot-rockchip --single-branch --depth 1 -b nanopi4-v2014.10_oreo
cd uboot-rockchip
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make CROSS_COMPILE=aarch64-linux- rk3399_defconfig
make CROSS_COMPILE=aarch64-linux-

After the compilation, the following files will be generated:

uboot.img trust.img rk3399_loader_v1.22.119.bin (aka MiniLoaderAll.bin)

Installing the u-boot:
Please refre to #Running the build

6.4.4 Build kernel linux-v4.19.y

This section applies to the following operating systems:

ubuntu-focal-desktop-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64 friendlycore-focal-arm64 ubuntu-noble-core-arm64 debian-bookworm-core-arm64 buildroot

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi4-v4.19.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 ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
# Optionally, load configuration for FriendlyWrt
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig friendlywrt.config
# Optionally, if you want to change the default kernel config
# make ARCH=arm64 CROSS_COMPILE=aarch64-linux- menuconfig
# Start building kernel
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images -j$(nproc)
# Start building kernel modules
mkdir -p out-modules
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules -j$(nproc)
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- INSTALL_MOD_PATH="$PWD/out-modules" modules_install
KERNEL_VER=$(make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease)
rm -rf $PWD/out-modules/lib/modules/${KERNEL_VER}/kernel/drivers/gpu/arm/mali400/
[ ! -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)

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

6.4.5 Build kernel linux-v6.1.y

This section applies to the following operating systems:

friendlywrt21 friendlywrt21-docker friendlywrt23 friendlywrt23-docker openmediavault-arm64

Clone the repository to your local drive then build:

git clone https://github.com/friendlyarm/kernel-rockchip --single-branch --depth 1 -b nanopi-r2-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 nanopi4_linux_defconfig
# Optionally, load configuration for FriendlyWrt
# make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 nanopi4_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_rk3399/kernel-6.1.y/tools/mkkrnlimg && chmod 755 mkkrnlimg
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/tools/resource_tool && chmod 755 resource_tool
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/prebuilt/boot/logo.bmp
wget https://raw.githubusercontent.com/friendlyarm/sd-fuse_rk3399/kernel-6.1.y/prebuilt/boot/logo_kernel.bmp
./mkkrnlimg arch/arm64/boot/Image kernel.img
mkdir kernel-dtbs
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev09.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dtb kernel-dtbs/rk3399-nanopi4-rev0a.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4se.dtb kernel-dtbs/rk3399-nanopi4-rev0b.dtb
cp -f arch/arm64/boot/dts/rockchip/rk3399-nanopc-t4.dtb kernel-dtbs/rk3399-nanopi4-rev00.dtb
./resource_tool --dtbname kernel-dtbs/*.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

6.4.6 Build u-boot v2017.09

This section applies to the following operating systems:

ubuntu-focal-desktop-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64 friendlycore-focal-arm64 ubuntu-noble-core-arm64 debian-bookworm-core-arm64 buildroot

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 nanopi4-v2017.09
export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64/bin/:$PATH
cd uboot-rockchip/
./make.sh nanopi4

After the compilation, the following files will be generated:

uboot.img trust.img rk3399_loader_v1.24.126.bin (aka MiniLoaderAll.bin)

Run your build:
Please refre to #Running the build

6.4.7 Running the build

6.4.7.1 Install to target board
6.4.7.1.1 MBR partition

This section applies to the following operating systems:

lubuntu eflasher friendlydesktop-arm64 friendlycore-arm64

The MBR partitioning is only used by the Linux v4.4 kernel. You can check the partition layout by clicking on this link: partmap. To write an image file, you can use the dd command. For example, in the parameter.template file, "0x00014000@0x00014000(kernel)" specifies that the kernel partition starts at 0x00014000, which is equivalent to 81920 in decimal. Therefore, the dd command should be as follows:

dd if=kernel.img of=/dev/mmcblk0 seek=81920
6.4.7.1.2 GPT partition

This section applies to the following operating systems:

ubuntu-focal-desktop-arm64 debian-bookworm-core-arm64 debian-bullseye-desktop-arm64 debian-bullseye-minimal-arm64
friendlycore-focal-arm64 ubuntu-noble-core-arm64 friendlywrt21-kernel4 buildroot
friendlywrt21 friendlywrt21-docker friendlywrt23 friendlywrt23-docker

The OS uses GPT partitions by default which is using the Linux v4.19 and Linux v5.15 kernel, 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.

6.4.7.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 v4.4.y sd-fuse
linux v4.19.y
sd-fuse_rk3399/kernel-4.19
linux v6.1.y
sd-fuse_rk3399/kernel-6.1.y
6.4.7.3 USB flashing

Note: kernel v4.4.y is not supported

6.4.7.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.17_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).

6.5 Build the code using scripts

6.5.1 Download scripts and image files

git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b kernel-4.19
cd sd-fuse_rk3399
wget http://112.124.9.243/dvdfiles/RK3399/images-for-eflasher/friendlycore-focal-arm64-images.tgz
tar xvzf friendlycore-focal-arm64-images.tgz

6.5.2 Compile the kernel

Download the kernel source code and compile it. the relevant image files in the friendlycore-focal-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 nanopi4-v4.19.y kernel-rk3399
KERNEL_SRC=$PWD/kernel-rk3399 ./build-kernel.sh friendlycore-focal-arm64

6.5.3 Compile the kernel headers

git clone https://github.com/friendlyarm/kernel-rockchip --depth 1 -b nanopi4-v4.19.y kernel-rk3399
MK_HEADERS_DEB=1 BUILD_THIRD_PARTY_DRIVER=0 KERNEL_SRC=$PWD/kernel-rk3399 ./build-kernel.sh friendlycore-focal-arm64

6.5.4 Compile the uboot

Download the uboot source code and compile it. the relevant image files in the friendlycore-focal-arm64 directory will be automatically updated:

git clone https://github.com/friendlyarm/uboot-rockchip --depth 1 -b nanopi4-v2017.09
UBOOT_SRC=$PWD/uboot-rockchip ./build-uboot.sh friendlycore-focal-arm64

6.5.5 Generate new image

Repackage the image file in the friendlycore-focal-arm64 directory into sd card image:

./mk-sd-image.sh friendlycore-focal-arm64

After the command is completed, the image is in the out directory, you can use the dd command to make the SD boot card, for example:

dd if=out/rk3399-sd-friendlycore-focal-4.19-arm64-YYYYMMDD.img of=/dev/sdX bs=1M

6.6 Building AOSP from source

6.6.1 Hardware and Software Requirements

  • Your computer should have at least 16GB of RAM and 300GB of disk space. We recommend using a machine with 32GB of RAM and a large-capacity, high-speed SSD, and we do not recommend using virtual machines.
  • If you encounter compilation errors, they may be caused by problems with the compilation environment. We recommend using the following Docker container for compilation: docker-cross-compiler-novnc.

6.6.2 Compile Android10

6.6.2.1 Download Android10 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:"07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz" (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xf "/path/to/netdisk/07_Source codes/rk3399-android-10.git-YYYYMMDD.tar.xz"
cd rk3399-android-10
./sync.sh
  • git clone from gitlab

NanoPi-R4SE source code is maintained in gitlab, You can download it by running the following command:

git clone --recursive https://gitlab.com/friendlyelec/rk3399-android-10.git -b main

Note: If the following error "error: unknown option `recurse-submodules'" appears, please upgrade git to v2.0.0 or above.

6.6.2.2 Generate Image File

You can compile an Android source code and generate an image file (non-root user is recommended):

cd rk3399-android-10
./build-nanopc-t4.sh -F -M

If you need to include google apps, you need to set an environment variable and then compile, as shown below:

cd rk3399-android-10
export INSTALL_GAPPS_FOR_TESTING=yes
./build-nanopc-t4.sh -F -M
6.6.2.3 Make OTA Packages

If you need the support of A/B (Seamless) System Updates, you need to do the following:
a) Build your own update server for http download of update files;
b) Customize the Updater application, the code is located in packages/apps/Updater, let it connect and download file from your server;
c) Use the quick compilation script parameter -O or --ota to compile OTA Packages, as shown below:

cd rk3399-android-10
./build-nanopc-t4.sh -F -O -M

After the compilation is successfully completed, the OTA update related packages are located in the directory: rockdev/otapackage/ ,Please do not delete this directory.
After you have made some changes, compiling again with the parameter -O will generate ota-update-XXXXXXXX.zip, which is an incremental update package.
OTA Packages decides whether to generate incremental update package according to BUILD_NUMBER, for details, please refer to build-nanopc-t4.sh.
To disable the A/B feature, you can refer to the following to modify device/rockchip/rk3399/nanopc-t4/BoardConfig.mk, and then recompile uboot and android:

BOARD_USES_AB_IMAGE := false


6.6.2.4 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 10's source code directory. You can follow the steps below to update the OS in NanoPi-R4SE:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android10 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-R4SE and reflash Android
When flashing Android 10, EFlasher requires v1.3 or above. When flashing with Type-C, please use the tool AndroidTool v2.71 or Linux_Upgrade_Tool v1.49 provided by Rockchip.

6.6.3 Compile Android8.1

6.6.3.1 Download Android8.1 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-8.1.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xvzf /path/to/netdisk/sources/rk3399-android-8.1.git-YYYYMMDD.tgz
cd rk3399-android-8.1
./sync.sh
  • git clone from gitlab

NanoPi-R4SE source code is maintained in gitlab, You can download it by running the following command:

git clone https://gitlab.com/friendlyelec/rk3399-android-8.1 --depth 1 -b master
6.6.3.2 Generate Image File

You can compile an Android source code and generate an image file:

cd rk3399-android-8.1
./build-nanopc-t4.sh -F -M
6.6.3.3 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android 8.1's source code directory. You can follow the steps below to update the OS in NanoPi-R4SE:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-R4SE and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399

6.6.4 Compile Android7

6.6.4.1 Download Android7 Source Code

There are two ways to download the source code:

  • repo archive file on netdisk

Netdisk URL: Click here
File location on netdisk:sources/rk3399-android-7.git-YYYYMMDD.tgz (YYYYMMDD means the date of packaging)
After extracting the repo package from the network disk, you need to execute the sync.sh script, which will pull the latest code from gitlab:

tar xvzf /path/to/netdisk/sources/rk3399-android-7.git-YYYYMMDD.tgz
cd rk3399-nougat
./sync.sh
  • git clone from gitlab

NanoPi-R4SE source code is maintained in gitlab, You can download it by running the following command:

git clone https://gitlab.com/friendlyelec/rk3399-nougat --depth 1 -b nanopc-t4-nougat
6.6.4.2 Generate Image File

You can compile an Android7 source code and generate an image file:

cd rk3399-nougat
./build-nanopc-t4.sh -F -M
6.6.4.3 Update System with New Image

After compilation is done a new image file will be generated in the "rockdev/Image-nanopc_t4/" directory under Android7's source code directory. You can follow the steps below to update the OS in NanoPi-R4SE:
1) Insert an SD card which is processed with EFlasher to an SD card reader and insert this reader to a PC running Ubuntu. The SD card's partitions will be automatically mounted;
2) Copy all the files under the "rockdev/Image-nanopc_t4/" directory to the SD card's android8 directory in the "FRIENDLYARM" partition;
3) Insert this SD card to NanoPi-R4SE and reflash Android
Here is an alternative guide to update OS: sd-fuse_rk3399

7 Using On-Board Hardware Resources

7.1 Access Serial Interface

For now only UART4 is available for users:

Serial Interface Serial Device
UART0 Used by Bluetooth
UART1 Used by Gbps Ethernet
UART2 Used by Serial Debug Port
UART3 Used by Gbps Ethernet
UART4 Available, device name is /dev/ttyS4 (note: this is only applicable for ROM released after 20180618)

8 Backup rootfs and create custom SD image (to burn your application into other boards)

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

8.2 Making a bootable SD card from a root filesystem

Run the following script on your Linux PC host, we'll only mention "debian-bullseye-desktop-arm64 os" for brevity, but you can apply the same process for every linux OS.

su root
git clone https://github.com/friendlyarm/sd-fuse_rk3399 --single-branch -b kernel-4.19
cd sd-fuse_rk3399
tar xvzf /path/to/netdrive/03_Partition\ image\ files/debian-bullseye-desktop-arm64-images.tgz
tar xvzf /path/to/netdrive/03_Partition\ image\ files/emmc-eflasher-images.tgz
scp pi@BOARDIP:/rootfs.tar.gz /rootfs.tar.gz
mkdir rootfs
tar xvzfp rootfs.tar.gz -C rootfs --numeric-owner --same-owner
./build-rootfs-img.sh rootfs debian-bullseye-desktop-arm64
./mk-sd-image.sh debian-bullseye-desktop-arm64
./mk-emmc-image.sh debian-bullseye-desktop-arm64 autostart=yes

9 Configuring kernel command line parameters (only support for kernel4.4)

9.1 eMMC Boot

Here are the steps:
Make an eflahser bootable SD card (use the firmware file starting with rk3xxxx-eflasher-),
Insert the SD card into your computer, go to the SD card's OS-related directory, and edit the file parameter.txt, which is a text file containing command-line parameters,
Then boot from the SD card and burn the system to the eMMC.

9.2 SD Boot

To modify the command line parameters of the SD card, you need to repackage the SD card image file,
you can use the sd-fuse script we provide to assist packaging:

git clone https://github.com/friendlyarm/sd-fuse_rk3399.git -b master --single-branch
cd sd-fuse_rk3399
tar xvzf /path/to/netdrive/03_Partition\ image\ files/friendlydesktop-arm64-images.tgz
tar xvzf /path/to/netdrive/03_Partition\ image\ files/emmc-flasher-images.tgz
vim friendlydesktop-arm64/parameter.txt   # Edit command-line parameters
./mk-sd-image.sh friendlydesktop-arm64    # Repackage sd image file
./mk-emmc-image.sh friendlydesktop-arm64  # Repackage sd-to-emmc image file

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

10.1 Windows Users

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

10.1.2 Enter Maskrom Mode to Erase the Storage Device

  • Start RKDevTool on your computer.
  • Press and hold the “Mask” key, power on the board. After the status LED has been on for at least 3 seconds, release the Mask key
  • Use a USB A-to-A cable, connect NanoPi-R4SE to a PC as follows

Nanopir4se-usba-to-usba.jpg

  • You will see Found One MASKROM Device displayed at the bottom of the RKDevTool interface, as shown below:

Rkdevtool found one maskrom device.png

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

Rkdevtool erase emmc.png

  • At this point, NanoPi-R4SE is restored to its initial state and can be normally booted via SD card or eMMC.

10.2 Linux Users

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

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

10.2.3 Enter Maskrom Mode to Erase the Storage Device

  • Connect NanoPi-R4SE to the computer using a USB data cable.
  • Disconnect the power from NanoPi-R4SE, 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-R4SE has been restored to its initial state and can boot the system normally via SD card or eMMC.

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

11 Link to Rockchip Resources

12 Schematic, PCB CAD File

13 Update Log

13.1 2023-12-01

13.1.1 FriendlyWrt

  • Update to kernel 6.1.63
  • Update to openwrt-23.05.2

13.2 2023-05-26

13.2.1 FriendlyWrt

  • Updated v22.03 to openwrt-22.03.5
  • Updated v21.02 to openwrt-21.02.7

13.3 2023-04-26

13.3.1 FriendlyWrt:

  • Upgrade v22.03 to openwrt-22.03.4
  • Upgrade v21.02 to openwrt-21.02.6

13.4 2023-02-10

13.4.1 Added Debian11

There are three versions:

  • Debian11 Core: Command-line only
  • Debian11 Minimal: With Xfce desktop, lite version
  • Debian11 Desktop: With Xfce desktop, full version

13.5 2023-01-09

13.5.1 FriendlyCore:

  • optimized the systemd service

13.6 2022-12-04

13.6.1 FriendlyWrt:

  • Fix the issue that the storage space cannot be expanded
  • Improve stability of the eMMC Tools

13.7 2022-09-06

13.7.1 FriendlyWrt:

  • Improved eMMC read performance of NanoPi-R4SE
  • Added Fullcone NAT support
  • upgrade to 22.03.0
  • Fix NanoPC-T4 eMMC stability issue

13.8 2022-08-03

13.8.1 FriendlyWrt:

  • Upgrade FriendlyWrt to the latest version 22.03-rc6
  • Fixed the problem that the R4S/R4SE may not recognize the pcie device (lan port) after a soft reboot (small probability)
  • Fixed the issue where the R4SE status led did not reflect the burn progress when burning the system to eMMC
  • Firewall settings adjustment: single-port devices (e.g. NanoPi-T4/NanoPi-M4) are set to allow WAN inbound traffic by default for easy web configuration, while multi-port devices are still denied WAN inbound traffic by default
  • Updated FriendlyWrt firmware with 4.19 kernel to match FriendlyWrt 21.02 docker with 5.15 kernel

13.9 2022-07-27

13.9.1 FriendlyWrt:

  • Beta version 22.03-rc3 is available, you can choose according to your package requirements, stable version 21.02.3 is recommended.
  • Both docker and non-docker versions are available, all features are the same except for docker.
  • Improved compatibility issues with third-party packages
  • Added support for "Soft Factory Reset" function
  • Added web-based tool eMMC-Tools, support install FriendlyElec and some third party firmware to eMMC, besides raw-image also support rockchip package format firmware
  • Other details: default timezone setting to Shanghai, new NAS category menu, remove lcd2usb, improve security settings, tune sysctl parameters, fix docker firewall settings, etc.
  • Add support for new hardware model: NanoPi-R4SE

13.10 2021-10-29

13.10.1 FriendlyWrt:

  • FriendlyWrt has been updated to the official stable version 21.02.1, features are basically the same as 19.07.5, support docker, usb wifi, etc.

13.11 2021-08-31

13.11.1 FriendlyWrt:

  • Upgraded kernel to 5.10.60
  • Add a high-speed 5G USB WiFi support, the network card model is Comfast CF-WU782AC V2, the chip model is MediaTek MT7662
  • Improved USB WiFi compatibility
  • Improved PWM fan support, fan controlled by kernel drive, temperature control support(Please search for "PWM fans" on the R4S WiKi page for details)
  • Improved stability on first boot (previous version, bpfilter error occurred in some cases on first boot)

13.12 2020-12-23

  • FriendlyWrt has been updated to the official stable version 19.07.5