NanoPi R4S-RK3399 is a great new OpenWrt device

Just a quick summary post with info in one post.

Information post

https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R4S updated link for FriendlyElec wiki (they changed their domain)

OpenWRT - NanoPi R4S Overview & Performance Test (NAT, OpenVPN,Wireguard, iPerf) Youtube review

https://www.stupid-projects.com/posts/benchmarking-the-nanopi-r4s/ Benchmarking and comparison to R2S.

https://www.stupid-projects.com/posts/nanopi-r4s-benchmarks-with-networking-optimizations/ -
This covers cpu affinity tweaking.

@walmartshopper Testing / Benchmarks post

And his affinity posts (details are also on the openwrt r4s wiki too.

Reboot patch (SDCard fix) -

1Gb version wont boot -

Apparently the 1gb/4gb issue is down to uboot but there was a patch submitted for uboot - https://github.com/u-boot/u-boot/commit/b69b9f3f54732c303939eb748aad97cd4cf60168

RTC Battery fitting issue post (pics also on openwrt wiki)

Adding NTP logging

Other builds for R4S :

Buying info - Dec 2021 prices.

For the 4 GB RAM - Combo with Metal Case :

America - https://www.friendlyelec.com/index.php?route=product/product&product_id=284 - $82.00
China - https://www.aliexpress.com/item/1005001831487845.html - £88

(sorry about multiple edits. it was alot of scrolling and i had to go fix some wiki links as FriendlyArm/Elec apparently moved their domain)

1 Like

The thing is that if you have applications like docker running from the SD card, the patch that was made for oficial openwrt is not ideal, at least according to @walmartshopper...

1 Like

The guy in this video missed an important fact: he was using IPERF3 server on the WAN side, and client on the LAN side. Since IPERF3 by default send data from client to server, he is in fact testing upload. Client is always the sender by default. This can be reversed if the "-R" option is informed in the IPERF3 client command line.

This mistake does not fully invalidate the overall results, but nevertheless unless I missed something in the video the information he provided is not really accurate.

I've already purchased a NanoPI R4S, and when I receive it I will do a quick performance test with IPERF3 (similar to what I've done with the Redmi AX6S here).

2 Likes

good spot. Be interesting to know just how much this little monster can push. It was one my primary reasons for getting it tbh. When/if they roll fibre out here it would be nice to be able to get 1gb line :slight_smile:

i've now finally finished my massive info post above. Sorry i was a terrible poster and ended up editing multiple times but i think i've fixed all the links now and gathered all the info up. Fixed the wiki links too.

Yes. loosing the 1.8v fast mode is a reasonable compromise, unless you are using a bigger card. However they do have a point. Currently they are forced to use that reset in order to have it recover from both a warm reset or a kernel crash. That is a much better situation to recover from rather than have it sat there hung from kernel crash and having higher speed sdcard. Its something that should be upstreamed and properly fixed. Sadly FriendlyElec are quite bad about that. But with the commit flagged there, people can have a choice to re-enable as they see fit. sort of a "you can do this but understand the issue ok?"

If you use either oficial openwrt or anaelorlinski build or immortal wrt, then by default their cpu affinity is throwing everything on cores 4 and 5 that are the 72 cores, since cores 0 to 4 are the a53 ones!

As you can see here:

They are setting up the irq of each eth on cores 4 and 5 with hex 10 and 20 respectively and are not setting up the queues with anything, which makes openwrt use hex 00 by default for the queues of both eth after booting and the result is that openwrt will throw the queues also on cores 4 and 5 together with the IRQ.

Just do:

cat /sys/class/net/eth0/queues/rx-0/rps_cpus

cat /sys/class/net/eth1/queues/rx-0/rps_cpus

And the result will be 00.

And this is not optimal tbh, cause you can easily saturate a dual core system in my opinion!

I have a 500/250 connection and bellow we have a torrent without sqm:

https://i.imgur.com/aHwI5Y9.png

And here we have the same thing with SQM enabled:

https://i.imgur.com/mjz6SBY.png

But there are plenty of ways to spread the load to all 6 cores of the NanoPi R4S!

  • There is the automatic way, that is enabling Package Steering + Irqbalance(package that you install and enable too).

  • There is the manually way, where you manually spread the load yourself :smiley:! I prefer to do it manually, as many others also confirm that manually is always better than using irqbalance.

https://i.imgur.com/4fPF4pM.png

I am going to the affinity file and doing like the print screen above, in other words, the red arrows are the IRQ and the blue arrows are the queues! In this case the irq of eth0 is using core 4(hex 10) and the irq from eth1 is using core 5(hex 20) and the queues are using all 6 cores with hex 3f.

Now after a reboot, if i do:

cat /sys/class/net/eth0/queues/rx-0/rps_cpus

cat /sys/class/net/eth1/queues/rx-0/rps_cpus

The result will be 3f.

By doing this way using this file, the change is permanently and you dont need to dedicate anything else just to make it like that, like a script that executes at boot or using rc.local and etc.

Now with this setting we have the result for a torrent wihtout SQM:

https://i.imgur.com/xVpr7cA.png

And a torrent with SQM:

https://i.imgur.com/3j3Njyw.png

The beauty of doing it manually is that you can do it the way you want! This above is just an example :smiley:, you can also try another way like dedicating the a72 cores for the queues and the a53 cores for the IRQ.

You can selected the cores by using different hex, as explained here:

and

Just keep in mind that the queues will spread with the correct hex like 3f = 111111 to as many cores as you like, but the IRQ won't! They stick to one core for each IRQ for each eth, so you cant spread them to more than 2 cores...

4 Likes

hah! we were both doing posts on the balancing the same time :slight_smile: i just put that in the summary post

my anaelorlinski build -

root@OpenWrt:~# cat /sys/class/net/eth0/queues/rx-0/rps_cpus
00
root@OpenWrt:~# cat /sys/class/net/eth1/queues/rx-0/rps_cpus
00

I'd prefer it as a separate script you could add in that you copy over as it is a change from the default settings that are provided. That way we know out of the box to expect "x" setting and we can edit/change for our settings. Would you copy yours to the wiki? It was one of the reasons i put wallmarts post into the wiki for others to tinker with.

1 Like

If you remove the lines:

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

From the 40-net-smp-affinity and reboot, then everything goes back to default.

So i still think that changing this file is the best way of doing things, cause then you dont have anything extra doing anything or needing to be executed or hogging any resources even if its minimal!

And for testing you can do you on the fly, just need to use the commands:

IRQ
echo hex > /proc/irq/IRQ-NUMBER/smp_affinity
echo hex > /proc/irq/IRQ-NUMBER/smp_affinity

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

PS: For kernel 5.15 need to use: echo -n hex > /proc/irq/IRQ-NUMBER/smp_affinity

In shell while running your system and then execute like a speedtest, torrent and etc, that way you will see the immediate results and after the testing you go to the 40-net-smp-affinity and change it to the settings you liked the most.

PS: If changing SQM settings(like enable or disable), then the commands in shell for testing on the fly should be done after setting up SQM and not before! In other words, setup sqm first and then do the commands in shell and after that check the results.

2 Likes

For sure i can! Which part do you think i should add there? What would be really relevant there, i mean...

Give me a few. i'm just having a look to re-write it. i think maybe expanding the section to do a general "this is how to set things" and then a "put this here for permanent fix"

Also wondering if to just break it out to else where on wiki as well. as its a more general thing that could be used for other cpus.

(edit) I now have coffee and a quick google shows me the page doesnt exist. I'm going to re-write it all and thus it can be used for any multicore cpu. Question is where to link it. I think initially on the irqbalance page but it should have its own page. and then be cross referanced.

break it into the "how" and "why" and then a permanent "put in this file for persistance" setting.

1 Like

Yeah it's a tradeoff for sure. You either have to choose slower SD card speed and guaranteed reboot, or faster SD card speed and manual reset after a kernel panic. My use case of running docker applications from the SD card is probably not very common, so it makes sense that the official patch went with slower SD and guaranteed reboot. Most people are only running OpenWrt from the SD card and don't need the extra speed.

On the other hand, I have never seen a kernel panic happen on this or any other OpenWrt devices ever. If I was setting up an R4S at a remote location, I would go with the official patch. But for my home router where I can easily do a manual reboot, it's worth the risk.

2 Likes

Another thing that i forgotten to mention, is that the file 40-net-smp-affinity can be changed before building a new img, in other words, you can setup it the way you like it and make a new build!
The moment you boot that new build the affinity will be working the way you setup it in the file before building :smiley:

1 Like

Well, you can check the new patchs that friendlywrt added to their repo, just like i shared above and @Barrakketh said:

They seem to have 2 new patches that are related to the UHS situation and reboot panic, now if they are better or worse than the oficial patch being used in openwrt or the original fix done in immortalwrt, that i honestly dont have a clue about!

Cause i am not an experienced dev yet(maybe in the future xD) so i still cant tell which one is better from these kinda of advanced stuff.

Would be nice if we can make either friendlyelec upstream all the new and better or important patch's for the R2S\R4S to openwrt oficial!

Or if its possible for someone independent who is an experienced dev to make their mission to fix this inconsistency of patch's that exist between friendlywrt and oficial openwrt for the R2S/R4S by making PR's and stuff...

I think this is even more important now, since it seems that there are new and important patches missing in official openwrt for the R2S\R4S.

1 Like

I'm just a web dev with no experience in kernel / uboot stuff, but as far as I can tell, it looks to me like those two friendlywrt patches just disable UHS mode like the official OpenWrt patch. I think one of the patches adds a new flag that allows disabling high speed mode for any rockchip device, and the other patch adds that flag to the R4S. The official OpenWrt patch just explicitly disables it for the R4S. I guess the friendlywrt solution is a bit cleaner because you could disable high speed mode for other devices just by adding the flag, but for the R4S the end result would be the same.

I could be wrong in how I read the patches, but for now I'm going to continue using the immortalwrt patch that leaves high speed enabled.

2 Likes

I agree we need somebody trying to upstream some of these patches if friendlywrt isn't going to. I would consider doing it but I don't feel qualified. All I would be able to do is cherry pick patches that work well for me and submit them as-is upstream. But I wouldn't be able to actually review them or contribute to any discussion about the quality of the code or fixes needed to get accepted upstream.

I have NanoPi R4S, R2C, and Orange Pi R1 Plus. The R2C and R1 Plus are in a similar situation. They are not officially supported, but it's fairly easy to cherry pick a handful of patches from friendlywrt and do a stock openwrt build. Both devices have a PR open for official support, but they are both stuck open with not enough reviewers to get them merged.

2 Likes

@walmartshopper and @Barrakketh

On friendlyelec repo, besides these patchs for uboot and openwrt, do you guys see anything else that should also be add to oficial openwrt?

If im using the R4S with Openwrt only and have the below set up

OpenVPN
SQM
AdGaurd

What would be best way to set up the CPU affinity / IRQs?

Do i need to install any thing or just run a few commands to ballance the loads?

Anyone try the new NanoPi R5S yet? It has 2x 2.5Gbit and 1x 1Gbit. Looks very promising.

1 Like

I'm not familiar with uboot but AFAIK the new changes only disables UHS for part of the boot process.

Part of the changeset (I compared OpenWrt 22.03 with FriendlyWrt 22.03) that I overlooked is that one commit reverted the patch "rockchip: disable UHS modes for NanoPi R4S".

1 Like

Theres a few posts in there and a benchmark post. CNX software are waiting for theres to bench it too.

2 Likes