Difference between revisions of "NanoPi R4S"

From FriendlyARM WiKi
Jump to: navigation, search
(updated by API)
(Introduction)
Line 2: Line 2:
  
 
==Introduction==
 
==Introduction==
[[File:NanoPi_R4S-01B.jpg|thumb|Overview]]
+
[[File:NanoPi_R4S-1GB_Overview.jpg|thumb|Overview]]
[[File:NanoPi_R4S-A01.jpg|thumb|Front]]
+
[[File:NanoPi_R4S-1GB_01B.jpg|thumb|Front]]
[[File:NanoPi_R4S-B01.jpg|thumb|Back]]
+
[[File:NanoPi_R4S-1GB_Back.jpg|thumb|Back]]
*The NanoPi R4S is a RK3399 SoC based ARM board.  
+
[[File:NanoPi_R4S-4GB_Overview.jpg|thumb|Overview]]
 +
[[File:NanoPi_R4S-4GB_Front.jpg|thumb|Front]]
 +
[[File:NanoPi_R4S-4GB_Back.jpg|thumb|Back]]
 +
*The NanoPi R4S is a RK3399 SoC based ARM board.
  
 
==Hardware Spec==
 
==Hardware Spec==

Revision as of 03:13, 1 December 2020

查看中文

1 Introduction

Overview
Front
Back
Front
Back
  • The NanoPi R4S is a RK3399 SoC based ARM board.

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
  • RAM: 1GB DDR3/4GB LPDDR4
  • 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 UserKey
    • one 5V Fan connector
  • Power supply: DC 5V/3A, via USB-C connector or Pin header
  • PCB: 8 Layer, 66 mm x 66 mm
  • Ambient Operating Temperature: -20℃ to 70℃

3 Diagram, Layout and Dimension

3.1 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
7 SPI1_CLK 8 SPI1_MOSI
9 SPI1_CS 10 SPI1_MISO
  • 4-pin header
1 2 3 4
VDD_5V USB_DM USB_DP GND
  • 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) 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
  • MicroUSB 5V/2A power adapter
  • A host computer running Ubuntu 18.04 64-bit system

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:
rk3399-sd-friendlycore-focal-4.19-arm64-YYYYMMDD.img.zip Based on UbuntuCore 20.04 and Linux-4.19 Kernel
rk3399-sd-friendlywrt-5.4-YYYYMMDD.img.zip Based on OpenWrt and Linux-5.4 Kernel
Flashing Utility:
win32diskimager.rar Windows utility. Under Linux users can use "dd"

4.2.2 Linux

4.2.2.1 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:
win32disk-finish

  • 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 First boot

For the first boot, the system needs to do the following initialization work:
1)Extended root file system
2)Initial setup(will execute /root/setup.sh)
So you need to wait for a while (about 2~3 minutes) to boot up for the first time, and then set FriendlyWrt, you can enter the ttyd terminal on the openwrt webpage, when the prompt is displayed as root@FriendlyWrt, it means the system has been initialized.

root@FriendlyWrt

5.3 Account & Password

The default password is password (empty password in some versions). Please set or change a safer password for web login and ssh login. It is recommended to complete this setting before connecting NanoPi-R4S to the Internet.

5.4 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.5 Login FriendlyWrt

Connect the PC to the LAN port of NanoPi-R4S. If your PC without a built-in ethernet port, connect the LAN port of the wireless AP to the LAN port of NanoPi-R4S, and then connect your PC to the wireless AP via WiFi , Enter the following URL on your PC's browser to access the admin page:

The above is the LAN port address of NanoPi-R4S. The IP address of the WAN port will be dynamically obtained from your main router through DHCP.

5.6 Recommended security settings

The following settings are highly recommended to complete before connecting NanoPi-R4S to the Internet。

  • Set a secure password
  • Only allow access to ssh from lan, change the port
  • Only allow local devices to access luci

Edit /etc/config/uhttpd,Change the original 0.0.0.0 and [::] addresses to the local lan address, for example:

	# HTTP listen addresses, multiple allowed
	list listen_http	192.168.2.1:80
	list listen_http	[fd00:ab:cd::1]:80
 
	# HTTPS listen addresses, multiple allowed
	list listen_https	192.168.2.1:443
	list listen_https	[fd00:ab:cd::1]:443

Restart the service:

/etc/init.d/uhttpd restart

5.7 Safe shutdown operation

Enter the ttyd terminal, enter the poweroff command and hit enter, wait until the led light is off, and then unplug the power supply.

5.8 Install Software Packages

5.8.1 Update Package List

Before install software packages update the package list:

$ opkg update

5.8.2 List Available Packages

$ opkg list

5.8.3 List Installed Packages

$ opkg list-installed

5.8.4 Install Packages

$ opkg install <package names>

5.8.5 Remove Packages

$ opkg remove <package names>

5.9 Disable IPv6

sed -i -e "s/DISABLE_IPV6=0/DISABLE_IPV6=1/g" /root/setup.sh
rm -f /etc/board.json /etc/config/system /etc/config/network /etc/config/wireless /etc/firstboot_*
reboot

5.10 Some common issues of FriendlyWrt

  • Unable to dial up
    • Go to "Network" -> "Firewall" and set "Inbound Data", "Outbound Data" and "Forwarding" in "WAN Zone" to "Accept";
    • If you still cannot access the Internet, you can try to turn off IPV6;
  • Unable to power on
    • Try to replace the power adapter and cable. It is recommended to use a power supply with specifications above 5V/2A;
    • Note that some fast chargers with Type-C interface will have a delay, it may take a few seconds to start providing power;
  • When doing secondary routing, the computer cannot connect to the Internet
    • If your main network is IPv4, and NanoPi-R4S works in IPv6, the computer may not be able to connect to the Internet. It is recommended to turn off IPv6 (the method is described later in this WiKi), or switch the main route to IPv6;
  • If you have questions or have better suggestions, please send an email to techsupport@friendlyarm.com;

5.11 Let FriendlyWrt regenerate network settings

This method will trigger FriendlyWrt to re-identify the hardware model and generate the network configuration under /etc/config, which is similar but not completely equivalent to restoring factory settings:

rm -f /etc/board.json /etc/config/system /etc/config/network /etc/config/wireless /etc/firstboot_*
reboot

The /root/setup.sh initialization script will be executed again at the next boot, so you can debug the /root/setup.sh script through this method.

5.12 Use USB2LCD to view IP and temperature

Plug the USB2LCD module to the USB interface ofNanoPi-R4S and power on, the IP address and CPU temperature will be displayed on the LCD:


5.13 Work with USB WiFi Device

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

lsusb


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

lsusb

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.13.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:
R2swrt+usbwifi-08.jpg
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.14 Work with Docker Applications

5.14.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:
FriendlyWrt+JerryFin

5.14.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.15 Mount smbfs

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

5.16 Use sdk to compile the package

5.16.1 Install the compilation environment

Download and run the following script on 64-bit Ubuntu (version 18.04+): How to setup the Compiling Environment on Ubuntu bionic

5.16.2 Download and decompress sdk from the network disk

The sdk is located in the toolchain directory of the network disk:

tar xvf ~/dvd/FriendlyELEC-NanoPiR4S/toolchain/friendlywrt-kernel-5.x.y/openwrt-sdk-19.07.5-rockchip-rk3399_gcc-7.5.0_musl.Linux-x86_64.tar.xz
# If the path is too long, it will cause some package compilation errors, so change the directory name here
mv openwrt-sdk-19.07.5-rockchip-rk3399_gcc-7.5.0_musl.Linux-x86_64 sdk
cd sdk
./scripts/feeds update -a
./scripts/feeds install -a

5.16.3 Compile the package

download the source code of the example (a total of 3 examples are example1, example2, example3), and copy to the package directory:

git clone https://github.com/mwarning/openwrt-examples.git
cp -rf openwrt-examples/example* package/
rm -rf openwrt-examples/

Then enter the configuration menu through the following command:

make menuconfig

In the menu, select the following packages we want to compile (actually selected by default):

"Utilities" => "example1"
"Utilities" => "example3"
"Network" => "VPN" => "example2"

execute the following commands to compile the three software packages:

make package/example1/compile V=99
make package/example2/compile V=99
make package/example3/compile V=99

After the compilation is successful, you can find the ipk file in the bin directory, as shown below:

$ find ./bin -name example*.ipk
./bin/packages/aarch64_cortex-a53/base/example2_0.1-1_aarch64_cortex-a53.ipk
./bin/packages/aarch64_cortex-a53/base/example3_0.1-1_aarch64_cortex-a53.ipk
./bin/packages/aarch64_cortex-a53/base/example1_0.1-1_aarch64_cortex-a53.ipk

5.16.4 Install the ipk to NanoPi

You can use the scp command to upload the ipk file to NanoPi:

cd ./bin/packages/aarch64_cortex-a53/base/
scp example*.ipk root@192.168.2.1:/root/

Then use the opkg command to install them:

cd /root/
opkg install example2_0.1-1_aarch64_cortex-a53.ipk
opkg install example3_0.1-1_aarch64_cortex-a53.ipk
opkg install example1_0.1-1_aarch64_cortex-a53.ipk

5.17 Serial port debug

Connect to NanoPi R4S with screen :

screen /dev/ttyUSB0 1500000 8N1

6 Compile FriendlyWrt

6.1 Download Code

mkdir friendlywrt-rk3399
cd friendlywrt-rk3399
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v19.07.4 -m rk3399.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
repo sync -c  --no-clone-bundle

6.2 1-key Compile

./build.sh nanopi_r4s.mk

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

7 Work with FriendlyCore

7.1 FriendlyCore User Account

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

7.2 Update Software Packages

$ sudo apt-get update

7.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
    address 192.168.1.231
    netmask 255.255.255.0
    gateway 192.168.1.1

You also need to modify the following file to add the DNS configuration:

vi /etc/systemd/resolved.conf

例如设置为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

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.

8 Make Your Own OS Image

9 Link to Rockchip Resources

10 Schematic, PCB CAD File