NanoPi R4S-RK3399 is a great new OpenWrt device

Yes, I'm sure there is room for improvement, I just played around with it for 1 day as we're not permanently at the new home yet. Just had to make sure it will be fine after we move there soon. For the config which I liked the most for the speed tests with pppoe+sqm I haven't even changed much from the defaults.

By default the IRQ's are going on the big cores, I haven't changed that. Also I left the default schedutil scheduler, as performance always keeps the freqs (and thus the consumption and temp) at max, while powersave keeps them fixed on the lowest. I just add these lines to set the queues to spread among the small cores in /etc/rc.local.

echo f > /sys/class/net/eth0/queues/rx-0/rps_cpus
echo f > /sys/class/net/eth1/queues/rx-0/rps_cpus

For SQM settings I just specified the limits like 800000 down / 290000 up and had cake/piece of cake set which are the defaults.

3 Likes

Thanks alot for that. I just got my R4S last week and couldnt get over 550mbps with SQM. I made the same chnages as you and im getting ~750mbps now with comfortable CPU usage.

1 Like

I got an answer from support. Wanted to share here if anyone is curious.


Hi,

Related to the kernel version, 5.15 mainline kernel does not have mpp and other driver support, but the 4.19 kernel does, so you can try the 4.19 version of the kernel.

https://dl.friendlyelec.com/nanopir4s

image filename:
01_Official images/01_SD card images/rk3399-sd-friendlywrt-21.02-kernel4-20230527.img.gz

Question e-mail:

Dear Tech Support,
 
I hope you are doing well. I am writing to seek your help regarding hardware-enabled video encoding on the R4S router. I have been exploring the possibility of using H264 hardware encoding capabilities on this device, as mentioned on the FriendlyARM website.
 
During my research, I came across a GitHub repository called https://github.com/jjm2473/ffmpeg-rk. It seems that there is potential for achieving hardware-accelerated video encoding using the Rockchip platform. However, I encountered an issue where I am unable to find the following device nodes on my R4S router:
"/dev/hevc_service"
"/dev/hevc-service"
"/dev/mpp_service"
 
I would like to inquire about the current progress regarding hardware-accelerated video encoding on the R4S router in May 2023. I am particularly interested in utilizing the Mali-T864 GPU, which supports OpenGL® ES1.1/2.0/3.0/3.1, OpenCL™, DX11, and AFBC.
 
Could you kindly provide me with any information, guidance, or resources that can help me enable hardware-accelerated video encoding on my R4S router? I would greatly appreciate any insights or assistance you can provide in this matter.
I am eagerly looking forward to your support and guidance to enable H264 hardware-supported encoding on my R4S router. It would significantly enhance the performance of my device and enable it to handle video encoding tasks more efficiently.
 
Thank you in advance for your attention to this matter. I appreciate any assistance or information you can provide. Please let me know if you need any additional details or if there is any further information that would be useful in addressing this issue.
Best regards,

This week Tianling Shen pushed kernel 6.1 support for Rockchip to git. I built master with kernel 6.1.29 yesterday. So far everything I use works great (uptime about 12 hours).

3 Likes

Hello there!

I hope you're all doing well. I recently acquired a Nanopi R4S and have been experimenting with OpenWrt using the images provided by anaelorlinski. Specifically, I'm using the ext4 version for my 128GB SD card. While I've made some progress, there are a few aspects that I'm still trying to figure out, and I could use some guidance from experienced users.

Firstly, the basic layout of my SD card consists of two partitions, and there is an unpartitioned residual space remaining. I've come across a recommendation from Mercy to partition and format this residual space, adding it as a third partition to my SD card. I'm wondering if it would be advisable to delete the second partition that currently houses the /opt/ folder for Docker. My goal is to use the third partition for Docker and storing my files. What would be the recommended approach in this case?

Additionally, the image I'm using already includes AdguardHome. I was able to access the dashboard using port 3000, but I'm uncertain about the complete installation process. I understand that I need to specify a port for the admin dashboard and another port for the DNS listening server. Could someone please advise which ports I should use and how I can integrate it with the DNS settings on OpenWrt?

One concern that has caught my attention is the presence of legacy iptables rules in the firewall. The system warns against mixing iptables and nftables rules, as it may lead to incomplete traffic filtering. Considering my goal of enforcing DNS over HTTPS and DNS over TLS, as well as hijacking all DNS traffic to force it through AdguardHome, should I be worried about this warning? Previously, on a regular router without AdguardHome, I used the HTTPS DNS Encrypt package and added an adblock using dnsmasq to achieve similar functionality.

I'm curious if anyone else in the community uses AdguardHome and has successfully reinforced it for all their DNS-related needs. I would greatly appreciate hearing about your experiences and any recommendations you may have.

  • To use the unpartitioned space, if you use ext4 then this is similar to a standard linux distribution and you can use fdisk to create the partition, mkfs to format it and add it to the fstab to mount it at boot
  • For AdGuardHome if you want to replace the DNS server with AdGuardHome follow this guide : [How-To-Updated 2021] Installing AdGuardHome on OpenWrt [Manual and opkg method] , it has all information provided and this is how my setup works
1 Like

well, while I'm still learning how to implement my R4S does anyone have issues when restarting your device? it seems when it shutdowns or I restart it doesn't detect the ethernet cable to my laptop, I mean the led with the LAN is on and I see there is like IP assigned but is nothing transmitted, so in order to fix it I need to plug out/in the ethernet cable, is this a common issue or I need to install anything extra?

I know that happened to me once at a power outrage where the LAN won't reconnect to my switch.... I think that was with the initial release of openwrt 22.x .....currently on 22.03.4

It doesn't happen on my R4S, however I am only using the stock version from OpenWrt team, not any other variants.

1 Like

wanted to share some insights with you all. Recently, I came across a useful tool called taskset that allows you to assign specific CPU cores to tasks, enabling better control over resource allocation. If you're looking to optimize CPU utilization for specific tasks or services, taskset can be a handy tool to have in your toolkit.

For instance, if you have a big.LITTLE architecture with a mix of Cortex-A72/A73 (big) and Cortex-A53 (LITTLE) cores, you can use taskset to distribute tasks accordingly. By assigning performance-intensive tasks to the high-performance cores and less CPU-intensive tasks to the energy-efficient cores, you can achieve better performance and power efficiency.

I found something unexpected, ffmpeg seems more performant on the R4S A53 CPU's! It might be affected by other processes, but I tried twice with similar results. I thought it was worth sharing here.

time taskset -c 0-3 ffmpeg -i 23-06-17_12-40-00camera-1.mp4 -c:v mpeg4 output.mp4 -y

real 0m 42.45s
user 1m 23.08s
sys 0m 1.58s

time taskset -c 4-5 ffmpeg -i 23-06-17_12-40-00camera-1.mp4 -c:v mpeg4 output.mp4 -y

real 0m 32.13s
user 0m 39.79s
sys 0m 0.90s

Edit: It seems all CPU's are clocked at the same speed:

Processor	: 0
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 1
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 2
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 3
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd03
CPU revision	: 4

processor	: 4
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 2

processor	: 5
BogoMIPS	: 48.00
Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 2

Online I read: " The Nanopi-R4S is based on the RK3399 SoC which is a dual Cortex-A72 core and a quad Cortex-A53. In FriendlyWRT the A72 is clocked at 1.8GHz and the A53 at 1.4GHz." - Could it be that the A72 is not running at 1.8GHz in OpenWRT?

Edit: The moment that I switched my ffmpeg stream to CPU 4,5 led to a nice reduction on my 5m CPU load chart. :grinning:
Screenshot from 2023-06-17 21-05-29

1 Like

Where are you getting CPU clock speed info from in that output?
BogoMIPS ?

I'm no expert but I've seen others post that BogoMIPS doesn't indicate CPU clock speed.

OpenWrt supports the standard frequencies of 1.4 GHz and 1.8 GHz.

The RK3399 processor can slow down from max speed when demand is low unless it is set to stay at high frequency.
You may find the info from the output of
grep "." /sys/devices/system/cpu/cpu?/cpufreq/cpuinfo* interesting.
Here is the output from my R4S with very little load on it:

/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq:1008000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq:1416000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency:40000
/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_cur_freq:1008000
/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_max_freq:1416000
/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu1/cpufreq/cpuinfo_transition_latency:40000
/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_cur_freq:1008000
/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_max_freq:1416000
/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu2/cpufreq/cpuinfo_transition_latency:40000
/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_cur_freq:1008000
/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_max_freq:1416000
/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu3/cpufreq/cpuinfo_transition_latency:40000
/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_cur_freq:408000
/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_max_freq:1800000
/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu4/cpufreq/cpuinfo_transition_latency:440000
/sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_cur_freq:408000
/sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_max_freq:1800000
/sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_min_freq:408000
/sys/devices/system/cpu/cpu5/cpufreq/cpuinfo_transition_latency:440000

...or other info such as
grep "." /sys/devices/system/cpu/cpu?/cpufreq/scaling_available_frequencies

/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 
/sys/devices/system/cpu/cpu1/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 
/sys/devices/system/cpu/cpu2/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 
/sys/devices/system/cpu/cpu3/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 
/sys/devices/system/cpu/cpu4/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 1608000 1800000 
/sys/devices/system/cpu/cpu5/cpufreq/scaling_available_frequencies:408000 600000 816000 1008000 1200000 1416000 1608000 1800000

I hope that helps. :-)

1 Like

it seems is stable now, I'm using the minimal image from anaelorlinski, I just removed the default adguard package and installed the edge version of adguard following the script from mercy, it seems stable at the moment, very happy with the r4s although maybe is an overkill.

I didn't use AdGuard so I can't tell, I actually use LXC to run PiHole on top of it (plugged an old 8GB USB stick), R4S has plenty of resources for that.

@anaelorlinski Does your build version support Rockchips video hardware acceleration by any chance?

Nope, display support is disabled in my R2S / R4S builds.

1 Like

I'm having issues with my R4S and a USB Ethernet adapter (TP-Link UE300). If the router boots up with the device plugged in, it doesn't work initially, needs to be replugged and then it's all fine. Did anyone face similar issue, any suggestions how could this be solved or a workaround for a soft usb reset? I tried usbreset and unlinking/linking the usb device but without success.

I hope you get an answer that is more specific but I'll mention the following.

I think I recall that the dynamic usb networking setup is initiated as a hotplug event and that you can add or adjust the settings to get specific network settings. Also a delayed startup script can trigger a hotplug event so that the services that are depended on are running before activating the usb adapter. Some ideas to stimulate some searches in the forum and doc wiki.

Good luck.

1 Like

Thanks for the tip. In the end the solution was much simpler, I got the idea from another forum. The issue was caused by a weak power supply. SInce I changed it to a beefier one, the USB Ethernet stick works fine after every reboot.

3 Likes

hi guys,

I am trying to make my modem connected to the WAN port of the R4S work. my ISP requires VLAN 7 to be tagged on the WAN port, so I did just that:

config interface 'wan'
  option proto 'pppoe'
  option ipv6 'auto'
  option pppd_options 'debug'
  option username 'myusername'
  option password 'mypassword'
  option device 'eth0.7'

However, I cannot seem to make it work:

Sun Jul 23 11:38:24 2023 daemon.warn pppd[5844]: Timeout waiting for PADO packets
Sun Jul 23 11:38:24 2023 daemon.err pppd[5844]: Unable to complete PPPoE Discovery

On my R7800, this just works, although there I had some more switch config regarding the VLAN.
I tried every combination, also switching eth0 & eth1 on the R4S, different OpenWRT versions (builds from anaelorlinski), promiscuous mode, etc. Always the same issue.

I hope someone is able to point out what I am doing wrong? would be greatly appreciated!

try

option ifname 'wan.7'

instead of "option device". You can read it here