OpenWrt support for NanoPi R2C

I'm using a NanoPi R2S without any problems so far.
Now I would like to use another one at my parents home and to connect them via wireguard. But the R2S is hard to get for little money, since it is replaced by the R2C

As I understood the only difference is that a MotorComm YT8521S Gigabit Ethernet transceiver is used (replacing the Realtek RTL8211E from the R2S)

So I'm wondering if its possible to get the R2C working with Openwrt, by just replacing the the lan driver module.

Henning

good news - it should work out of the box with r2s image but
bad news - no driver in openwrt for motorcomm YT8521S - you have to compile it
i only know of these sources https://github.com/cnxsoft/YT8521S/

Motorcom YT8511 support has been merged for v5.14, it's probably not too difficult to extend that work for YT8521S and then backport it for v5.10.

I think it will be very helpful if a developer can add support. I'm no developer and building the drivers is nearly impossible for noobs at this point. Too many knowledge is assumed.
And already the english docu is hard to understand for non native speakers....
I'm missing a ready to go developer environment as LXC container.

But I'm happy that I have found an R2S with passive cooled aluminium case at 50% discount for "only" 60€ at aliexpress. Just 10€ more exprensive than a R2C, but 100% more expensive than in january.
Hope it will be deliverd until christmas ...

I ordered an R2C to play around with. When it gets here in about a month, I'm willing to test drivers / builds / etc. It looks like the latest version of FriendlyWRT released on 2021-10-29 supports the R2C and is based on OpenWRT 21.02.1 with kernel 5.10. So I wonder if we could just use the YT8521S driver from FriendlyWRT and use it with OpenWRT master branch.

I was able to take FriendlyWRT's patch that adds support for the R2C and apply it to OpenWRT master. So I built an OpenWRT image for the R2C with kernel 5.10.82, and in theory it should include a driver for the YT8521S. Would anyone be willing to test this build while I'm waiting for mine to arrive? It includes the following extras:

  • luci-app-adblock
  • luci-app-banip
  • luci-app-sqm
  • luci-app-minidlna
  • luci-app-openvpn
  • luci-app-wireguard
  • dnscrypt-proxy2
  • curl
  • nano
  • 256MB root partition

Version string is r18245-7a48dfc90c

squashfs:
https://drive.google.com/file/d/1F4u42zHznU5uC14j2tbv8f4fAGWe7llq/view?usp=sharing

ext4:
https://drive.google.com/file/d/1GmUiOouWa2oFwYUflWL2B7HpEdVfh4XF/view?usp=sharing

If anyone gives it a try, let me know how it goes.

Your load works. I haven't iperf performances test yet but its passing traffic and looks good. Can you post the driver patch/source you used for this so I can make sure we are looking at the same. Thank you!

I applied this friendlywrt commit to openwrt master:

You can add .patch to the end of the url above and then apply it to openwrt using git apply.

The problem is that they modified the R2S profile instead of making it a separate device. But good to hear it works. Maybe we can take some of the work from this commit and put it into a new device profile for R2C. Devs on the openwrt github don't like that it's not an upstream driver, and I'm not sure if friendlyarm will submit the motorcomm driver upstream or if someone else needs to.

3 Likes

When I checked with them, they seemed very uninterested in doing too much work to get this integrated in openwrt.

I finally got my R2C and did a new build today by applying the same patch above to openwrt master. Only issue was that the patch tries to modify some kernel 5.4 stuff that is no longer present in openwrt master. But the build is working and I'm currently using it as my main router. Using cake SQM at 100Mb gives me about 0.25 cpu load, so if scaling is linear I would guess it could handle somewhere around 400Mb/s with cake.

My new build is below and includes the following packages:

  • luci-app-adblock
  • luci-app-banip
  • luci-app-sqm
  • luci-app-minidlna
  • luci-app-wireguard
  • dnscrypt-proxy2
  • curl
  • nano
  • 256MB root partition

Version string: r18437-92820cc5b9
Kernel: 5.10.88

squashfs:
https://drive.google.com/file/d/1kw7UQ5K5foZ_44FrAsgHFpHFt0hlCdZy/view?usp=sharing

ext4:
https://drive.google.com/file/d/1nKgfhSGs1QxT5cHse5kqrmTrxMEW0dJz/view?usp=sharing

FriendlyWrt has merged R2C support into their master branch and now it's set up properly as a separate device from the R2S, so I did a new build today. I have been using the squashfs image with no issues so far.

Info:

  • Vanilla OpenWrt master + patches from FriendlyWrt for R2C support
  • ImmortalWrt patch for 1.6ghz overclock.
  • microSD soft reboot patch
  • 512MB root partition
  • openwrt master just switched to firewall4 / nftables by default, but it breaks banip so I built this with firewall / iptables
  • kernel 5.10.92
  • version string r18614-46ce629fe0

Packages:

  • luci-app-adblock
  • luci-app-banip
  • luci-app-ddns
  • luci-app-sqm
  • luci-app-wireguard
  • curl
  • nano

squashfs:
https://drive.google.com/file/d/1aOE8vgfTQhmtRwn1kOa3YrcOl4VHwKDn/view?usp=sharing

ext4:
https://drive.google.com/file/d/16aUZF56T08t234rc5PrQ8gZAEfmAgb-E/view?usp=sharing

2 Likes

Just did some SQM testing on this with iperf3 using my own build from the previous post (with 1.6ghz OC). All tests done with cake / piece_of_cake.

//////// STOCK SETTINGS //////////

Cake set to 1Gb up/down

  • egress: 836Mb / 1 core @ 100%
  • ingress: 525Mb / 1 core @ 100%

Cake set to 500Mb up/down

  • egress: 475Mb / 1 core @ 75%
  • ingress: 475Mb / 1 core @ 93%

Cake set to 500Mb up/down, Bidirectional test

  • egress: 442Mb / 1 core @ 100%
  • ingress: 194Mb / 1 core @ 100%

//////// MANUAL TUNED SETTINGS
//////// (eth0 IRQ on core 0, eth0 queue on core 1, eth1 queue on core 2)

Cake set to 1Gb up/down

  • egress: 830Mb / 1 core @ 100%
  • ingress: 762Mb / 1 core @ 100% + 1 core @ 75%

Cake set to 500Mb up/down

  • egress: 475Mb / 1 core @ 75%
  • ingress: 475Mb / 1 core @ 93%

Cake set to 500Mb up/down, Bidirectional test

  • egress: 458Mb / 3 cores @ 70-90%
  • ingress: 412Mb / 3 cores @ 70-90%

Assigning the IRQs and queues manually to specific cores made a huge difference. Egress was about the same, but ingress went from 525 to 762Mb. And bidirectional went from 442/194 to 458/412.

In summary I would say this device is good for up to a symmetrical 400Mb connection, or an asymmetrical connection up to 500/400, assuming you are willing to do some manual tuning. At stock clocks and settings, max recommended connection would be around 400/200.

The commands I used for manual tuning:

#eth0 IRQ on core 0
echo 1 > /proc/irq/35/smp_affinity
#eth1 has no IRQ?
#eth0 queue on core 1
echo 2 > /sys/class/net/eth0/queues/rx-0/rps_cpus
#eth1 queue on core 2
echo 4 > /sys/class/net/eth1/queues/rx-0/rps_cpus

Edit:
Just an FYI that the r8152 interface can be unstable at high throughput. I have been able to make the r8152 driver crash a couple times when running an iperf3 bidirectional test with SQM on and set to gigabit speeds. However, that's not really a realistic workload for this device. The interface reset and came back online within a few seconds.

It never crashed with SQM set to 500Mb up/down which is about the max it could handle realistically anyway, so I would call it stable under normal circumstances.

1 Like

OK, waiting for official support for NanoPI R2C.

I have one question concerning OpenVPN running with FriendlyWRT. The issue is that default gateway is not restored after stopping openvpn-instance. It is restored after restarting network service. In original OpenWRT is behavior the same?

Can you guide how to apply patch to official openwrt git

Same here. I bought an R2C Plus with emmc and had to install friendlywrt. It's horrible, it comes with several packages that I don't use, it's almost bloatware.

I cherry picked 5 patches from FriendlyWRT and applied them to vanilla OpenWRT. I just tried now and the patches still apply cleanly to openwrt master. @gabrielflach this might work for you too as one of the patches supposedly adds support for the R2C Plus. I don't have the Plus so I can't test it. Also not sure if the compiled image will boot from emmc or only microSD. My build from Jan 19th uses the same patches as below so it may already support the Plus. You could try my build just to see if it works or not. If it does, you can follow the directions below to build your own image with whatever packages you want.

Here are the build instructions:

1 Like

Thanks. I build a patched image and use the friendly core eflasher image to install openwrt on emmc. Instructions are on the R2C wiki.
The only change when I made it was in the LED settings.

config led 'led_wan'
        option name 'WAN'
        option sysfs 'nanopi-r2s:green:wan'
        option trigger 'netdev'
        option dev 'eth0'
        list mode 'link'
        list mode 'tx'
        list mode 'rx'

config led 'led_lan'
        option name 'LAN'
        option sysfs 'nanopi-r2s:green:lan'
        option trigger 'netdev'
        option dev 'eth1'
        list mode 'link'
        list mode 'tx'
        list mode 'rx'

I added a R2C build in my custom releases : https://github.com/anaelorlinski/OpenWrt-NanoPi-R2S-R4S-Builds right now only for 21.02 stable branch, but later will also add 22.03.

Since I don't own a R2C don't hesitate to give a try and report if you get success with the images

1 Like

I just purchased a nanopi r2c plus... how are you guys flashing the .img file to eMMC 8gb?

I have tried to use the FriendlyElec eFlasher tool, edit the /mnt/sdcard/eflasher.conf file and changing
autoStart=/mnt/sdcard/source.img and rebooting but this does not seem to achieve what I am looking for... the r2c is not bootable.

Any tips would be helpful... unless everyone here is booting off a SD card and not the onboard eMMC?

I have the rc2 here. I have the same difficulties installing on the emmc storage.
Send a email to friendlyelec on how to change the boot from Rockchip MiniLoader to U-Boot TPL/SPL.
But more to configure the device so it boots from a sd-card i tried al what is mentioned here .
https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R2C_Plus#The_Boot_order_between_eMMC_and_SD_card
But the only thing that lets me boot to the sd-card is to short the Maskrom contacts and that is not a very convenient way to boot from the sd-card.
Hope you can tell me how to boot from a sd-card without using the Maskrom contacts.
If i get an answer from friendlyelec i will post :slight_smile: