Difference between revisions of "NanoPi R2S"

From FriendlyELEC WiKi
Jump to: navigation, search
(Created page with "查看中文 ==Introduction==")
 
(updated by API)
(44 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
==Introduction==
 
==Introduction==
 +
[[File:NanoPi R2S-1.jpg|thumb|frameless|250x250px|Overview]]
 +
[[File:NanoPi R2S_TOP.jpg|thumb|frameless|250x250px|Front]]
 +
[[File:NanoPi R2S-BOT.jpg|thumb|frameless|250x250px|Back]]
 +
[[File:NanoPi_R2S-case1.jpg|thumb|frameless|250x250px|Case]]
 +
[[File:R2sc-02.jpg|thumb|frameless|250x250px|Case]]
 +
[[File:R2sc-03.jpg|thumb|frameless|250x250px|Case]]
 +
[[File:R2sc-04.jpg|thumb|frameless|250x250px|Case]]
 +
[[File:R2sc-05.jpg|thumb|frameless|250x250px|Case]]
 +
* The NanoPi R2S(as "R2S") is an open source platform with dual-Gbps Ethernet ports designed and developed by FriendlyElec for IoT applications.
 +
* The NanoPi R2S uses the RK3328 SoC. It has two Gbps Ethernet ports and 1G 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 =etc.
 +
 +
==Hardware Spec==
 +
* CPU: Rockchip RK3328, Quad-core Cortex-A53
 +
* DDR4 RAM: 1GB         
 +
* Network:
 +
**Internal 10/100/1000M Ethernet Port x 1
 +
**USB3.0 converted 10/100/1000M Ethernet Port x 1<br />
 +
* USB2.0 Host: Type-A x1
 +
* MicroSD Slot x 1
 +
* MicroUSB: power input and USB Slave
 +
* Debug Serial Port: 3.3V TTL, 3-pin 2.54mm pitch connector, 1500000 bauds
 +
* LED: LED x 3
 +
* KEY: KEY x 1 programmable
 +
* PC Size: 55.6 x 52mm
 +
* Power Supply: DC 5V/2A
 +
* Temperature measuring range: 0℃ to 80℃
 +
* OS/Software: U-boot,Ubuntu-Core,OpenWrt <br />
 +
<br />
 +
* '''Network Transmission Rates'''
 +
::{| class="wikitable"
 +
|-
 +
! width=100px style="background: Light grey; color: black" |
 +
! width=150px style="background: Light grey; color: black" align="center" | TX
 +
! width=150px style="background: Light grey; color: black" align="center" | RX         
 +
|-
 +
|WAN      ||align="center" | 941 Mbps  ||align="center" |  941 Mbps 
 +
|-
 +
|LAN      ||align="center" | 941 Mbps  ||align="center" |  941 Mbps 
 +
|-
 +
|Notes:  ||colspan="2" |  1. test utility: iperf <br />  2. use indepedent IP address section and test with a PC in simplex communication mode
 +
|}
 +
 +
==Diagram, Layout and Dimension==
 +
===Layout===
 +
[[File:NanoPi R2S-layout.jpg |frameless|550px|NanoPi R2S Layout]]
 +
* '''GPIO 24-Pin Spec'''
 +
::{| class="wikitable"
 +
|-
 +
| style="background: PaleTurquoise; color: black" colspan="1"| '''Pin#''' || style="background: PaleTurquoise; color: black" colspan="1"| '''Name'''|| style="background: PaleTurquoise; color: black" colspan="1"| '''Linux gpio'''|| style="background: PaleTurquoise; color: black" colspan="1"| '''Pin#'''|| style="background: PaleTurquoise; color: black" colspan="1"| '''Name'''|| style="background: PaleTurquoise; color: black" colspan="1"| '''Linux gpio'''   
 +
|-
 +
|1    || SYS_3.3V              ||    ||2    || VDD_5V              ||
 +
|-
 +
|3    || I2C0_SDA / GPIO2_D1  || 89  ||4    || VDD_5V              ||
 +
|-
 +
|5    || I2C0_SCL / GPIO2_D0  || 88  ||6    || GND                  ||
 +
|-
 +
|7    || GPIO2_A2 / IR_RX        || 66  ||8  || UART1_TX / GPIO3_A4  || 100
 +
|-
 +
|9    || GND                  ||    ||10    || UART1_RX / GPIOG3_A6 || 102
 +
|}
 +
 +
:For more details refer to:[http://wiki.friendlyelec.com/wiki/images/5/59/SCH_NanoPi_R2S_V1.0-1912.pdf NanoPi_R2S_V1.0_1912-Schematic.pdf]
 +
:Dimensional Diagram:[http://wiki.friendlyelec.com/wiki/index.php/File:Dimension_NanoPi_R2S_V1.0-1912_PCB.rar NanoPi R2S PCB file in dxf format]
 +
 +
==Get Started==
 +
===Essentials You Need===
 +
Before starting to use your NanoPi R2S get the following items ready
 +
* NanoPi R2S
 +
* MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
 +
* MicroUSB 5V/2A 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: <br />
 +
**[https://github.com/friendlyarm/build-env-on-ubuntu-bionic How to setup the Compiling Environment on Ubuntu bionic]<br />
 +
 +
 +
===TF Cards We Tested===
 +
Refer to: [[Template:TFCardsWeTested/zh|TFCardsWeTested]]
 +
{{1500000SerialPortDebugSetting}}
 +
===Install OS===
 +
{{BurnLinuxToSD-Rockchip|NanoPi-R2S}}
 +
{{FriendlyWrt21|NanoPi-R2S}}
 +
{{OfficialUbuntuCore|NanoPi-R2S}}
 +
{{OfficialDebianCore|NanoPi-R2S}}
 +
==Buildroot Linux==
 +
{{RK3399 Buildroot Intro|NanoPi-R2S}}
 +
<br />
 +
For a more detailed description of the Buildroot system, please refer to: [[Buildroot|Buildroot]]<br />
 +
==How to Compile==
 +
===Build Openwrt/Friendlywrt===
 +
====Download Code====
 +
Two versions are available, please choose as required:
 +
=====FriendlyWrt 21.02=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt21-rk3328
 +
cd friendlywrt21-rk3328
 +
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 rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
=====FriendlyWrt 22.03.2=====
 +
<syntaxhighlight lang="bash">
 +
mkdir friendlywrt22-rk3328
 +
cd friendlywrt22-rk3328
 +
git clone https://github.com/friendlyarm/repo --depth 1 tools
 +
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v22.03 \
 +
        -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
 +
tools/repo sync -c  --no-clone-bundle
 +
</syntaxhighlight>
 +
====First compilation step====
 +
<syntaxhighlight lang="bash">
 +
./build.sh rk3328.mk  # or rk3328-docker.mk
 +
</syntaxhighlight>
 +
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:
 +
<syntaxhighlight lang="bash">
 +
./build.sh emmc-img
 +
</syntaxhighlight>
 +
After making changes to the project, the sd card image needs to be repackaged by running the following command:
 +
<syntaxhighlight lang="bash">
 +
./build.sh sd-img
 +
</syntaxhighlight>
 +
====Secondary compilation steps====
 +
<syntaxhighlight lang="bash">
 +
cd friendlywrt
 +
make menuconfig
 +
rm -rf ./tmp
 +
make -j${nproc}
 +
cd ../
 +
./build.sh sd-img
 +
./build.sh emmc-img
 +
</syntaxhighlight>
 +
===Build u-boot only===
 +
<syntaxhighlight lang="bash">
 +
./build.sh uboot
 +
</syntaxhighlight>
 +
===Build kernel only===
 +
<syntaxhighlight lang="bash">
 +
./build.sh kernel
 +
</syntaxhighlight>
 +
===Build friendlywrt only===
 +
<syntaxhighlight lang="bash">
 +
./build.sh friendlywrt
 +
</syntaxhighlight>
 +
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:
 +
<syntaxhighlight lang="bash">
 +
cd friendlywrt
 +
make -j1 V=s
 +
</syntaxhighlight>
 +
{{RockchipMiscCustome}}
 +
==Make Your Own OS Image==
 +
* Please refre this link:
 +
** [https://github.com/friendlyarm/sd-fuse_rk3328/tree/kernel-5.15.y sd-fuse_rk3328]
 +
** [[How to Build FriendlyWrt]]
 +
{{MoreOS}}
 +
==Resources==
 +
===Datasheets and Schematics===
 +
* Schematics
 +
** [http://wiki.friendlyelec.com/wiki/images/5/59/SCH_NanoPi_R2S_V1.0-1912.pdf NanoPi_R2S_V1.0_1912-Schematic.pdf]
 +
** [https://wiki.friendlyelec.com/wiki/images/0/0f/NanoPi-R2S-V1.1-2009-Schematic.pdf NanoPi-R2S-V1.1-2009-Schematic.pdf]
 +
 +
* PCB Dimensional Diagram
 +
** [http://wiki.friendlyelec.com/wiki/index.php/File:Dimension_NanoPi_R2S_V1.0-1912_PCB.rar NanoPi_R2S_V1.0_1912 PCB file in dxf format]
 +
* Datasheet
 +
** RK3328 Datasheet [http://wiki.friendlyelec.com/wiki/images/d/d7/Rockchip_RK3328_Datasheet_V1.1-20170309.pdf Rockchip_RK3328_Datasheet.pdf]
 +
 +
==Update Logs==
 +
{{RK3328-UpdateLog|NanoPi-R2S}}

Revision as of 11:41, 15 February 2023

查看中文

Contents

1 Introduction

Overview
Front
Back
Case
Case
Case
Case
Case
  • The NanoPi R2S(as "R2S") is an open source platform with dual-Gbps Ethernet ports designed and developed by FriendlyElec for IoT applications.
  • The NanoPi R2S uses the RK3328 SoC. It has two Gbps Ethernet ports and 1G 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 =etc.

2 Hardware Spec

  • CPU: Rockchip RK3328, Quad-core Cortex-A53
  • DDR4 RAM: 1GB
  • Network:
    • Internal 10/100/1000M Ethernet Port x 1
    • USB3.0 converted 10/100/1000M Ethernet Port x 1
  • USB2.0 Host: Type-A x1
  • MicroSD Slot x 1
  • MicroUSB: power input and USB Slave
  • Debug Serial Port: 3.3V TTL, 3-pin 2.54mm pitch connector, 1500000 bauds
  • LED: LED x 3
  • KEY: KEY x 1 programmable
  • PC Size: 55.6 x 52mm
  • Power Supply: DC 5V/2A
  • Temperature measuring range: 0℃ to 80℃
  • OS/Software: U-boot,Ubuntu-Core,OpenWrt


  • Network Transmission Rates
TX RX
WAN 941 Mbps 941 Mbps
LAN 941 Mbps 941 Mbps
Notes: 1. test utility: iperf
2. use indepedent IP address section and test with a PC in simplex communication mode

3 Diagram, Layout and Dimension

3.1 Layout

NanoPi R2S Layout

  • GPIO 24-Pin Spec
Pin# Name Linux gpio Pin# Name Linux gpio
1 SYS_3.3V 2 VDD_5V
3 I2C0_SDA / GPIO2_D1 89 4 VDD_5V
5 I2C0_SCL / GPIO2_D0 88 6 GND
7 GPIO2_A2 / IR_RX 66 8 UART1_TX / GPIO3_A4 100
9 GND 10 UART1_RX / GPIOG3_A6 102
For more details refer to:NanoPi_R2S_V1.0_1912-Schematic.pdf
Dimensional Diagram:NanoPi R2S PCB file in dxf format

4 Get Started

4.1 Essentials You Need

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

  • NanoPi R2S
  • MicroSD Card/TF Card: Class 10 or Above, minimum 8GB SDHC
  • MicroUSB 5V/2A 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 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 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-R2S's microSD card slot;
  • Power on NanoPi-R2S and it will be booted from your TF card, some models may require pressing the Power button to start;

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 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-R2S to the Internet.

5.4 Login FriendlyWrt

Connect the PC to the LAN port of NanoPi-R2S. If your PC without a built-in ethernet port, connect the LAN port of the wireless AP to the LAN port of NanoPi-R2S, 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-R2S. The IP address of the WAN port will be dynamically obtained from your main router through DHCP.

5.5 Recommended security settings

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

  • Set a secure password
  • Only allow access to ssh from lan, change the port
  • Check the firewall settings

Set up as you wish.

5.6 Change LAN IP in LuCI

1) Click on Network → Interfaces, then click on the Edit button of the LAN Network;
2) In General Setup tab, input new IP address (for example: 192.168.11.1), click "Save" and then click "Save & Apply";
3) On the pop-up window with the title “Connectivity change“, click "Apply and revert on connectivity loss";
4) Wait a moment, enter the new address in your computer's browser and login to FriendlyWrt;

5.7 Safe shutdown operation

Enter the "Services" -> "Terminal", enter the "poweroff" command and hit enter, wait until the led light is off, and then unplug the power supply.

5.8 Soft Factory Reset

Enter "System"->"Backup/Flash firmware",Click “Perform reset“ Button, Your device's settings will be reset to defaults like when FriendlyWrt was first installed.
You can also do this in the terminal:

firstboot && reboot

5.9 Install Software Packages

5.9.1 Set up openwrt official opkg source

sed -i -e 's/mirrors.cloud.tencent.com/downloads.openwrt.org/g' /etc/opkg/distfeeds.conf
opkg update

5.9.2 Update Package List

Before install software packages update the package list:

$ opkg update

5.9.3 List Available Packages

$ opkg list

5.9.4 List Installed Packages

$ opkg list-installed

5.9.5 Install Packages

$ opkg install <package names>

5.9.6 Remove Packages

$ opkg remove <package names>

5.10 Disable IPv6

. /root/setup.sh
disable_ipv6
reboot

5.11 Configure the function of the user button

By default, the user button is configured to reboot the device, as shown below:

echo 'BTN_1 1 /sbin/reboot' >> /etc/triggerhappy/triggers.d/example.conf

You can change its behavior by changing the configuration file above.

5.12 Configuring Quectel EC20 (4G module) dial-up networking

  • Go to "Network" -> "Interfaces"
  • Click "Delete" next to "WAN6", then click "Save & Apply"
  • Click "Edit" next to "WAN", in the "Device" drop-down menu, select "Ethernet Adapter: wwan0", in the "Protocol" drop-down menu, select "QMI Cellular" and click "Switch Protocol"
  • Click the "Modem Device" drop-down menu, select "/dev/cdc-wdm0", fill in the APN information (e.g. for China Mobile, enter "cmnet")
  • Click "Save" to close the dialog, Finally, click "Save & Apply" at the bottom of the page to initiate the dial-up process
  • Devices connected to LAN will have access to the Internet, If your device has a WiFi module, you can enable wireless AP functionality on the "Wireless" page and connect to the Internet via devices connected wirelessly

5.13 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;
  • Dial-up successful, but no outgoing traffic
    • Go to "Services" -> "Terminal" and type "fw4 reload" to try to reload the firewall settings again;
  • 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-R2S 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.14 Use USB2LCD to view IP and temperature

Plug the USB2LCD module to the USB interface ofNanoPi-R2S and power on, the IP address and CPU temperature will be displayed on the LCD:
R2S-usb2lcd-01.jpg


5.15 How to use USB WiFi

5.15.1 Check USB WiFi Device with Command Line Utility

(1) Click on "services>ttyd" to start the command line utility
R2s-wrt-jellyfin-002.jpg
(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

R2swrt+usbwifi-09.jpg
(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
R2swrt+usbwifi-10.jpg
(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.15.2 Configure a USB WiFi Device as AP

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

R2swrt+usbwifi-02.jpg
(3) Click on "Network>Wireless" to enter the WiFi configuration page
R2swrt+usbwifi-03.jpg
(4) Click on "Edit" to edit the configuration
R2swrt+usbwifi-04.jpg
(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
R2swrt+usbwifi-05.jpg

R2swrt+usbwifi-06.jpg
(6) After you change the settings you can use a smartphone or PC to search for WiFi
R2swrt+usbwifi-07.png

5.15.3 Common USB WiFi issues

1) It is recommended to plug in the usb wifi in the off state, then power it on, FriendlyWrt will automatically generate the configuration file /etc/config/wireless, if not, see if there is wlan0 by ifconfig -a, if there is no wlan0, usually there is no driver.
2) If ifconfig -a sees wlan0, but the hotspot is not working properly, try changing the channel and country code, an inappropriate country code can also cause the WiFi to not work.
3) Some USB WiFis (e.g. MTK MT7662) work in CD-ROM mode by default and need to be switched by usb_modeswitch, you can try to add usb_modeswitch configuration to the following directory: /etc/usb_modeswitch.d.

5.15.4 Change the default WiFi hotspot configuration

FriendlyWrt sets the country, hotspot name and other parameters for USB WiFi by default, with the aim of being as plug-and-play as possible, but this does not guarantee that all modules will be compatible with this setting, you can change these behaviors by modifying the following file:

/lib/wifi/mac80211.sh

5.16 Work with Docker Applications

5.16.1 Work with Docker: Install JellyFin

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.16.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.16.3 Expand Docker Storage

  • Stop docker service first:
/etc/init.d/dockerd stop
  • Rename the original /opt directory, create an empty /opt directory:
mv /opt /opt-old && mkdir /opt
  • Format your drive as ext4, and mount it to the /opt directory:

Friendlywrt mount nvme opt-en.jpg

  • Enter the command "mount | grep /opt" to check the mount status:
root@FriendlyWrt:~# mount | grep /opt
/dev/nvme0n1p1 on /opt type ext4 (rw,relatime)
root@FriendlyWrt:~#
  • Copy the files from the original /opt directory to the new /opt directory:
cp -af /opt-old/* /opt/ && rm -rf /opt-old
  • Reboot the device
reboot
  • After reboot, go to the "Docker" -> "Overview" page, check the information in the "Docker Root Dir" line, you can see that the Docker space has been expanded:

Friendlywrt docker info-en.jpg

5.16.4 Docker FAQ and solutions

5.16.4.1 Unable to access the network services provided by the Docker container

Solution:

  • Go to the "Firewall" settings and set "Forwarding" to "Accept";
  • Turn off "Software Offload";

5.17 Mount smbfs

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

5.18 Use sdk to compile the package

5.18.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.18.2 Download and decompress sdk from the network disk

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

tar xvf openwrt-sdk-*-rockchip-armv8_gcc-11.2.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-*-rockchip-armv8_gcc-11.2.0_musl.Linux-x86_64 sdk
cd sdk
./scripts/feeds update -a
./scripts/feeds install -a

5.18.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_generic/base/example3_1.0.0-220420.38257_aarch64_generic.ipk
./bin/packages/aarch64_generic/base/example1_1.0.0-220420.38257_aarch64_generic.ipk
./bin/packages/aarch64_generic/base/example2_1.0.0-220420.38257_aarch64_generic.ipk

5.18.4 Install the ipk to NanoPi

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

cd ./bin/packages/aarch64_generic/base/
scp example*.ipk root@192.168.2.1:/root/

Then use the opkg command to install them:

cd /root/
opkg install example3_1.0.0-220420.38257_aarch64_generic.ipk
opkg install example1_1.0.0-220420.38257_aarch64_generic.ipk
opkg install example2_1.0.0-220420.38257_aarch64_generic.ipk

5.19 Build FriendlyWrt using GitHub Actions

Please refre this link: https://github.com/friendlyarm/Actions-FriendlyWrt

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

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

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

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

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

6.4.1 WiFi models supported

6.4.1.1 M.2 WiFi Module
  • RTL8822CE
6.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)

6.5 Install the kernel-header package

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

6.6 Build kernel-header deb package

Please refre to: https://github.com/friendlyarm/sd-fuse_rk3328/blob/master/test/test-build-kernel-header-deb.sh

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

7 Work with Debian Core

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

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

7.3 Connect to Debian via SSH

Run the following commandssh pi@NanoPi-R2S
The default password is: pi

7.4 Update Software Packages

$ sudo apt-get update

7.5 Change time zone

7.5.1 Check the current time zone

timedatectl

7.5.2 List all available time zones

timedatectl list-timezones

7.5.3 Set the time zone (e.g. Shanghai)

sudo timedatectl set-timezone Asia/Shanghai

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_rk3328.git -b kernel-4.19 --single-branch
cd sd-fuse_rk3328
  • 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-bullseye-core-arm64
sudo ./mk-sd-image.sh debian-bullseye-core-arm64
sudo ./mk-emmc-image.sh debian-bullseye-core-arm64


7.7 Soft Factory Reset

Execute the following command in a terminal:

sudo firstboot && sudo reboot

7.8 Install Docker on Debian

Please refer to: How to Install Docker on Debian

8 Buildroot Linux

Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux systems through cross-compilation. It contains a boot-loader, kernel, rootfs, various libraries and utilities(e.g. qt, gstreamer, busybox etc).

FriendlyELEC's Buildroot is based on Rockchip's version which is made with linux-sdk and maintained with git. FriendlyELEC's version is synced with Rockchip's version;


For a more detailed description of the Buildroot system, please refer to: Buildroot

9 How to Compile

9.1 Build Openwrt/Friendlywrt

9.1.1 Download Code

Two versions are available, please choose as required:

9.1.1.1 FriendlyWrt 21.02
mkdir friendlywrt21-rk3328
cd friendlywrt21-rk3328
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 rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle
9.1.1.2 FriendlyWrt 22.03.2
mkdir friendlywrt22-rk3328
cd friendlywrt22-rk3328
git clone https://github.com/friendlyarm/repo --depth 1 tools
tools/repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v22.03 \
        -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo  --no-clone-bundle
tools/repo sync -c  --no-clone-bundle

9.1.2 First compilation step

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

9.1.3 Secondary compilation steps

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

9.2 Build u-boot only

./build.sh uboot

9.3 Build kernel only

./build.sh kernel

9.4 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

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

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

10.2 Making a bootable SD card from a root filesystem

Only support RK3328/RK3399/RK3568/RK3588

11 Configuring kernel command line parameters

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

11.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:


Only support RK3328/RK3399/RK3568/RK3588

12 Make Your Own OS Image

13 More OS Support

13.1 DietPi

Dietpi-logo.png
DietPi is a highly optimised & minimal Debian-based Linux distribution. DietPi is extremely lightweight at its core, and also extremely easy to install and use.
Setting up a single board computer (SBC) or even a computer, for both regular or server use, takes time and skill. DietPi provides an easy way to install and run favourite software you choose.
For more information, please visit this link https://dietpi.com/docs/.

DietPi supports many of the NanoPi board series, you may download the image file from here:

14 Resources

14.1 Datasheets and Schematics

15 Update Logs

15.1 2024-01-31

15.1.1 Debian/Ubuntu/FriendlyCore/Buildroot

  • Add adb support

15.2 2023-12-01

15.2.1 FriendlyWrt

  • Update to kernel 6.1.63
  • Update to openwrt-23.05.2

15.3 2023-10-31

15.3.1 Add a new system

  • Add NAS system OpenMediaVault, base on Debian 11 with kernel 6.1

15.3.2 Debian Core/FriendlyCore-Lite-Core

  • Update to kernel 6.1

15.3.3 FriendlyWrt

  • Update to kernel 6.1
  • Update to openwrt-23.05

15.4 2023-05-29

15.4.1 Debian11 Core

  • Fixed the issue that R2C Plus cannot boot

15.5 2023-05-26

15.5.1 FriendlyWrt

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

15.6 2023-04-26

15.6.1 FriendlyWrt:

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

15.7 2023-02-10

  • Added Debian11 Core

15.8 2023-01-09

15.8.1 FriendlyCore:

  • optimized the systemd service

15.9 2022-12-04

15.9.1 FriendlyWrt:

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

15.10 2022-09-06

15.10.1 FriendlyWrt:

  • Added Fullcone NAT support
  • upgrade to 22.03.0

15.11 2022-08-03

15.11.1 FriendlyWrt:

  • Upgrade FriendlyWrt to the latest version 22.03-rc6

15.12 2022-08-01

15.12.1 FriendlyWrt:

  • Firewall settings adjustment: single-port devices (e.g. NEO3) 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

15.13 2022-07-27

15.13.1 FriendlyWrt:

  • Both docker and non-docker versions are available, all features are the same except for docker.
  • Beta version 22.03-rc3 is available, you can choose according to your package requirements, stable version 21.02.3 is recommended.
  • 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.

15.14 2021-12-02

  • Improved the compatibility of the FriendlyWrt software package installation
  • Fixed the issue that some sd cards would cause the reboot command to not respond (updated the 5.10 kernel)
  • Configure the USB header on NanoPi-NEO3 to host mode by default

15.15 2021-10-29

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

15.16 2021-08-30

15.16.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 stability on first boot (previous version, bpfilter error occurred in some cases on first boot)

15.16.2 FriendlyCore:

  • upgraded kernel to 5.10.60

15.17 2021-03-05

  • Upgrade FriendlyCore to 20.04 (base on ubuntu focal)

15.18 2021-01-15

  • upgraded kernel to 5.10
  • upgraded friendlywrt to 19.07.5

15.19 2020-09-04

  • Improved the stability of the usb3.0 driver (integrated with official Rockchip updates) and the stability of the r8153 ethernet card
  • Update the driver of the 8153 ethernet card, using mainline kernel's version, the version is v1.11.11
  • Enable serial port UART1 for R2S and NEO3

15.20 2020-08-31

  • Kernel updated to 5.4.61
  • Use the driver r8152-2.13.0 downloaded from Realtek official website (https://www.realtek.com/en/downloads)
  • Improve the USB network card driver, WLAN<->LAN bridge speed can reach 700/500 Mbits/sec
  • Add rockhip rng (hardware random number) driver

15.21 2020-07-10

15.21.1 FriendlyWrt

  • upgraded kernel to 5.4.50
  • added support for NanoPi-NEO3

15.22 2020-05-14

15.22.1 FriendlyWrt

  • upgraded kernel to 5.4.40,fixed bpfilter issue
  • added new usb wifi(rtl8812au)
  • fixed overlayfs issue

15.23 2020-02-25

15.23.1 FriendlyWrt

15.23.1.1 update to v19.07.1,please use branch master-v19.07.1:
mkdir friendlywrt-rk3328
cd friendlywrt-rk3328
repo init -u https://github.com/friendlyarm/friendlywrt_manifests -b master-v19.07.1 -m rk3328.xml --repo-url=https://github.com/friendlyarm/repo --no-clone-bundle
repo sync -c --no-clone-bundle
15.23.1.2 fixed some issues:
  • fixed bpfilter module issue
  • updated feeds to the latest commit
  • removed modemmanager and mwan3 plugins
  • adjusted cpu scaling governor, optimized startup speed

15.24 2020-02-20

15.24.1 FriendlyWrt

  • Optimized openssl performance
  • Added support for PWM fan, support fan speed control (platform: rk33xx)

15.25 2020-01-18

Initial Release