NanoPi R4S

From FriendlyARM WiKi
Jump to: navigation, search



1 Introduction

  • The NanoPi R4S(as "R4S") is an open source platform with dual-Gbps Ethernet ports designed and developed by FriendlyElec for IoT applications.
  • The NanoPi R4S uses the RK3399 SoC. It has two Gbps Ethernet ports and 1G/4G DDR4 RAM. FriendlyElec ported an OpenWrt system for it. It works with Docker CE. It is a good platform for developing IoT applications, NAS applications, smart home gateways etc.

2 Hardware Spec

  • SoC: Rockchip RK3399
    • 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
  • Flash: no Onboard eMMC
  • Ethernet: one Native Gigabit Ethernet, and one PCIe Gigabit Ethernet
  • USB: two USB 3.0 Type-A ports
  • Pin header extension interface
    • 2x5-pin header: SPI x 1, I2C x 1
    • 4-pin header: USB 2.0
  • 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 5V Fan connector
  • Power supply: DC 5V/3A, via USB-C connector or Pin header
  • PCB: 8 Layer, 66 mm x 66 mm
  • Temperature measuring range: 0℃ to 80℃

3 Diagram, Layout and Dimension

3.1 Layout

NanoPi R4S Layout
NanoPi R4S Layout
  • 2x5-pin header
Pin# Assignment Pin# Assignment
1 VDD_5V 2 VDD_3.3V
3 VDD_5V 4 I2C3_SDA
5 GND 6 I2C3_SCL
  • 4-pin header
1 2 3 4
  • 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
  1. Power Input : 5V/3A, via USB Type-C(USB PD Specification is not supported) or Pin1&Pin2 of the 2x5-pin header

4 Get Started

4.1 Essentials You Need

Before starting to use your NanoPi R4S get the following items ready

  • NanoPi R4S
  • 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 18.04 64-bit system and use the following script to initialize the development environment:

4.2 Install OS

4.2.1 Download Image Files

Go to download link to download the image files under the officail-ROMs directory and the flashing utility under the tools directory:

Image Files: Based on UbuntuCore 20.04 and Linux-4.19 Kernel Based on OpenWrt and Linux-5.4 Kernel
Flashing Utility:
win32diskimager.rar Windows utility. Under Linux users can use "dd"

4.2.2 Linux Flash to TF
  • FriendlyCore / Debian / Ubuntu / OpenWrt / DietPi are all based on a same Linux distribution and their installation methods are the same.
  • Extract the Linux image and win32diskimager.rar files. Insert a TF card(at least 8G) into a Windows PC and run the win32diskimager utility as administrator. On the utility's main window select your TF card's drive, the wanted image file and click on "write" to start flashing the TF card.

After it is installed you will see the following window:

  • Insert this card into your board's BOOT slot and power on (with a 5V/2A power source). If the PWR LED is on and the STAT LED is blinking this indicates your board has successfully booted.

5 Work with FriendlyWrt

5.1 Introduction to FriendlyWrt

FriendlyWrt is a customized system made by FriendlyElec based on an OpenWrt distribution. It is open source and well suitable for developing IoT applications, NAS applications, smart home gateways etc.

5.2 Account & Password

By default the password is NULL. You can set a password for root for web and SSH login.

5.3 Network Connection

Use a network cable to connect NanoPi-R4S's WAN to a master router and the board will get an IP address via DHCP. Login into the router and check NanoPi-R4S's IP address.

5.4 Login FriendlyWrt

Type NanoPi-R4S's IP address or http://friendlywrt/ in a browser's address bar and enter to open FriendlyWrt's administration page or you can login into FriendlyWrt's administration page via SSH.
By default, the IP address of the LAN port is, and the WAN will dynamically obtain the IP address from your main router.

5.5 Install Software Packages

5.5.1 Update Package List

Before install software packages update the package list:

$ opkg update

5.5.2 List Available Packages

$ opkg list

5.5.3 List Installed Packages

$ opkg list-installed

5.5.4 Install Packages

$ opkg install <package names>

5.5.5 Remove Packages

$ opkg remove <package names>

5.6 Work with USB WiFi Device

5.6.1 Check USB WiFi Device with Command Line Utility

(1) Click on "services>ttyd" to start the command line utility

(2) Make sure no USB devices are connected to your board and run the following command to check if any USB devices are connected or not


(3) Connect a USB WiFi device to the board and run the command again


You will see a new device is detected. In our test the device's ID was 0BDA:C811

(4) Type your device's ID (in our case it was "0BDA:C811" or "VID_0BDA&PID_C811") in a search engine and you may find a device that matches the ID. In our case the device we got was Realtek 8811CU.

5.6.2 Configure a USB WiFi Device as AP

(1) Connect a USB WiFi device to the NanoPi-R4S. We recommend you to use the following devices:
Note: devices that match these VID&PIDs would most likely work.
(2) Click on "System>Reboot" and reboot your NanoPi-R4S

(3) Click on "Network>Wireless" to enter the WiFi configuration page

(4) Click on "Edit" to edit the configuration

(5) On the "Interface Configuration" page you can set the WiFi mode and SSID, and then go to "Wireless Security" to change the password. By default the password is "password". After you make your changes click on "Save" to save

(6) After you change the settings you can use a smartphone or PC to search for WiFi

5.7 Work with Docker Applications

5.7.1 Work with Docker: Install JellyBin

mkdir -p /jellyfin/config
mkdir -p /jellyfin/videos
docker run --restart=always -d -p 8096:8096 -v /jellyfin/config:/config -v /jellyfin/videos:/videos jellyfin/jellyfin:10.1.0-arm64 -name myjellyfin

After installation, visit port 8096 and here is what you would find:

5.7.2 Work with Docker: Install Personal Nextcloud

mkdir /nextcloud -p
docker run -d -p 8888:80  --name nextcloud  -v /nextcloud/:/var/www/html/ --restart=always --privileged=true  arm64v8/nextcloud

After installtion, visit port 8888.

5.8 Mount smbfs

mount -t cifs // /movie -o username=xxx,password=yyy,file_mode=0644

6 Work with FriendlyCore

6.1 FriendlyCore User Account

  • Non-root User:
   User Name: pi
   Password: pi
  • Root:
   User Name: Root
   Password: fa

6.2 Update Software Packages

$ sudo apt-get update

6.3 Setup Network Configurations

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

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.

6.4 Serial port debug

Connect to NanoPi R4S with screen :

screen /dev/ttyUSB0 1500000 8N1

7 Compile FriendlyWrt

7.1 Download Code

mkdir friendlywrt-rk3399
cd friendlywrt-rk3399
repo init -u -b master-v19.07.4 -m rk3399.xml --repo-url=  --no-clone-bundle
repo sync -c  --no-clone-bundle

7.2 1-key Compile


All the components (including u-boot, kernel, and friendlywrt) are compiled and the sd card image will be generated.

7.3 Recompile u-boot, kernel or friendlywrt

./ uboot
./ kernel
./ friendlywrt

7.4 Repackaged into firmware

./ sd-img

8 Compile FriendlyCore-Focal

8.1 Setup Development Environment

We suggest you do it on a 64 bit Ubuntu 18.04 system and install the following packages:

sudo apt-get -y install bison g++-multilib git gperf libxml2-utils make python-networkx zip
sudo apt-get -y install flex curl libncurses5-dev libssl-dev zlib1g-dev gawk minicom
sudo apt-get -y install openjdk-8-jdk
sudo apt-get -y install exfat-fuse exfat-utils device-tree-compiler liblz4-tool
sudo apt-get -y install android-tools-fsutils
sudo apt-get -y install swig
sudo apt-get -y install python-dev python3-dev

8.2 Install Cross Compiler

8.2.1 Install aarch64-linux-gcc 6.4

This compiler can be used to compile a Linux kernel and u-boot. You can do it by running the following commands:

git clone -b master --depth 1
cd prebuilts/gcc-x64
cat toolchain-6.4-aarch64.tar.gz* | sudo tar xz -C /

Add the compiler's directory to the PATH variable by appending the following lines to the ~/.bashrc file:

export PATH=/opt/FriendlyARM/toolchain/6.4-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

This is a 64 bit compiler and cannot work on a 32 bit Linux system. You can test if your compiler is installed correctly by running the following commands:

aarch64-linux-gcc -v
Using built-in specs.
Target: aarch64-cortexa53-linux-gnu
Configured with: /work/toolchain/build/aarch64-cortexa53-linux-gnu/build/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/6.4-aarch64
--with-sysroot=/opt/FriendlyARM/toolchain/6.4-aarch64/aarch64-cortexa53-linux-gnu/sysroot --enable-languages=c,c++
--enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419 --with-cpu=cortex-a53
Thread model: posix
gcc version 6.4.0 (ctng-1.23.0-150g-FA)

8.3 Easy way to compile kernel and uboot for FriendlyCore-Focal OS

8.3.1 Download tools and firmware

git clone -b kernel-4.19
cd sd-fuse_rk3399
tar xvzf friendlycore-focal-arm64-images.tgz

8.3.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 --depth 1 -b nanopi4-v4.19.y kernel-rk3399
KERNEL_SRC=$PWDkernel-rk3399 ./ friendlycore-focal-arm64

8.3.3 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
(cd rkbin && git reset 25de1a8bffb1e971f1a69d1aa4bc4f9e3d352ea3 --hard)
git clone --depth 1 -b nanopi4-v2017.09
UBOOT_SRC=$PWD/uboot-rockchip ./ friendlycore-focal-arm64

8.3.4 Generate new firmware

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

./ friendlycore-focal-arm64

After the command is completed, the firmware 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

8.4 Compile kernel and uboot for FriendlyCore-Focal OS in normal way

8.4.1 Compile FriendlyCore-Focal's Kernel-4.19 Source Code

git clone --depth 1 -b nanopi4-v4.19.y kernel-rockchip
cd kernel-rockchip
make distclean
touch .scmversion
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4_linux_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux- nanopi4-images

After compilation is done a kernel.img and a resource.img will be generated.

8.4.2 Compile FriendlyCore-Focal's uboot-2017.09 Source Code

git clone
(cd rkbin && git reset 25de1a8bffb1e971f1a69d1aa4bc4f9e3d352ea3 --hard)
git clone --depth 1 -b nanopi4-v2017.09
cd uboot-rockchip
make distclean
export PATH=/opt/FriendlyARM/toolchain/6.4-aarch64/bin/:$PATH
./ nanopi4

After compilation is done a uboot.img, a trust.img and a rk3399_loader_v1.24.126.bin will be generated. You need to rename the rk3399_loader_v1.24.126.bin to "MiniLoaderAll.bin".

8.5 Make Bootable SD Card for Mass Production

If you need to make a bootable SD card for mass production you can refer to this github link:

9 Link to Rockchip Resources

10 Schematic, PCB CAD File

11 Known Issues List

    • Q: UGREEN 18W QC power adapter cannot power R4S?
    • A: It needs to wait for a few seconds to work normally.

12 Update Log

First time release