OpenWrt support for NanoPi R2C

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:

2 Likes

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:

I emailed FriendlyElec 4 days ago and they still have yet to respond. I'm a bit discouraged purchasing from them again; all their forums / community has very old posts and is unmaintained - seemly support is non-existent. I think my next SBC purchase will be a radxa board.

I will post back if they ever respond; at the moment I think I corrupted my eMMC and I cant seem to get the board to boot from SD. I did try to short circuit the Maskrom round silver holes with the GRN hole from my picture here: Guidance on UART debugging "Card did not respond to voltage select" - #3 by robhancock

How are you shorting the maskrom; you turn off usb power then connect GRN to the "MASK" holes then plug it back in?

I just short the two mask rom contacts then apply power to the board and it boots from sd-card.( Holding it until it starts booting)
I had the same problem I flashed a rom following the user guide to install a third party rom.
I used e-flasher edited the config so it installs the selected ROM.
And after that the devices did not boot.
Downloaded the e-flasher friendly-wrt installed on the sd-card inserted the sd-card.
Shorted the 2 contacts applied power and the board starts with flashing the emmc.
Wait untill it blinks constantly and reboot the board using the power cord.

1 Like

Thanks! What I was missing is that I had flashed my SD card with the eFlasher friendlywrt image. Your comment led me to using rk3328-sd-friendlywrt-5.15-20220125.img which did boot from SD card after shorting MASK and from there I wiped out the mmblk2 eMMC storage. Now it's back :slight_smile:

I was trying to build armbian for R2C since there's a motorcom driver issue - I tried your build today on the R2C and the motorcom NIC works there. I didn't do a lot more testing than that :slight_smile:

@anaelorlinski I contacted you a while ago for support for the R2C.
I thought I had a standard R2C but received the plus.
I tested your build and i was not able to boot from a sd-card. (only by shortig the mask-rom contacts)
Today i gave it another shot and with the method discribed in the wiki it works i now can boot your latest build.
What i dit was this:
The following situations will always start from eMMC:
If the system in the eMMC, or the system in the TF card uses the first Loader type U-Boot TPL/SPL, it will always boot from the eMMC;
If you want to boot from the TF card, there are the following methods:
Method 1: Clear the Loader on the eMMC, the clearing method is as follows, after starting from the eMMC, enter the following command on the command line to clear the Loader on the eMMC:

dd if=/dev/zero of=/dev/mmcblk2 bs=8M count=1

In serted the sd-card and then powerd the device.

Thank you for this build I can now finally get rid off openwrt lol.

!An update!
I installed everything what i normally use with my R4S and everything works.
The R2C is my backup unit and i use it to experiment. Will use the R2C overnight to see if it is usable as a dailly router (and for me to see if i can use it as a reliable backup solution).

Orderd the R5S hope to see support for this device aswell in the future. :slight_smile:

Ohh @TheLinuxGuy i do not know why but i am able to boot from sd-card suddenly.
I booted from the buildin storage - used putty and enterd the code to clear the loader -then powerd off the device (pulled the plug) - then tested if could boot from sd with the friendly-wrt sd version. that worked - then booted the @anaelorlinski build. Witch booted and also when i reboot etc.

1 Like

It's 2023 now, anybody still uses this board?
I have created a PR for it, I'd be glad if you can test it :wink:

OK, thank you for snapshot, will it be in next official release?

Yep, it will be included in recent 23.05 release.

How to flash it correctly? I have tried squashfs image with Balena Etcher, it does not work: initially sys led blinks, after that device hangs, both lan, and sys are glowing with constant light. 'Native' image from FriendlyElec works normally. r4s image from OpenWRT works normally for r4s.

give me system log, or i can do nothing with it.
you may need a TTL serial cable to catch log.