Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NanoPi R3S #7556

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

EvilOlaf
Copy link
Member

@EvilOlaf EvilOlaf commented Dec 9, 2024

Description

This PR adds support for the NanoPi R3S SBC
https://www.friendlyelec.com/index.php?route=product/product&product_id=303

u-boot patchset borrowed from OpenWRT
Linux dts backported from 6.13

How Has This Been Tested?

Whoever has this board and want to test, plz do and give feedback.
https://fi.mirror.armbian.de/.testing/Armbian-unofficial_24.11.0-trunk_Nanopi-r3s_bookworm_edge_6.12.3_minimal.img.xz
Image with the updated u-boot patchset check comments below

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@github-actions github-actions bot added size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Dec 9, 2024
@EvilOlaf
Copy link
Member Author

EvilOlaf commented Dec 19, 2024

More or less just a note for further improvements:

OpenWRT also made adjustments to led and added some load balancing by setting net-smp-affinity

openwrt/openwrt@2902b0a#diff-f9d4f9cb6007e346ac46a85b5e28121e8bd2b0b18c2f91f5eab28b28b443f425

https://github.com/openwrt/openwrt/pull/16738/files#diff-86143a4e522eb5736b3b087ac4616281018f80fe24df29d3c5292f84616d521c

@rpardini
Copy link
Member

Looks good.

I guess the vendor u-boot doesn't build (it seems to try to use binman-style build with the 2017 vendor u-boot, which is a no-go).

We need to add some bare-DT/bare-defconfig (thus avoiding null-patches) support to mainline (2024.x) u-boot; it is currently implemented for the vendor u-boot but not for mainline. Not your fault, of course, but I guess that would help borrowing patches from openwrt.

@EvilOlaf
Copy link
Member Author

I think its not worth bothering with vendor on this board since all the interesting stuff should be available in both mainline uboot and Linux. The stuff mentioning it are mostly c&p relicts.

@igorpecovnik
Copy link
Member

@azagramac

image

Nobody is happy to do the hard work unless they are stealing absolutely everything. Not sure what advantages you see with Dietpi, but this is comparison from other angle:

https://docs.armbian.com/#key-advantages
armbian/configng#291

tl;dr;

  • we do everything around hardware interface
  • we provide OS without proprietary changes
  • we make build images possible
  • our system config is significantly more advanced

@EvilOlaf
Copy link
Member Author

EvilOlaf commented Jan 4, 2025

@EvilOlaf EvilOlaf marked this pull request as ready for review January 4, 2025 08:52
@EvilOlaf EvilOlaf requested a review from igorpecovnik as a code owner January 4, 2025 08:52
@EvilOlaf
Copy link
Member Author

EvilOlaf commented Jan 4, 2025

Still untested but well, screw it.
Patch header need rework to give proper credit....again

New image for testing: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0-rc5_minimal.img.xz

@shenyunet
Copy link

My current test results show that the indicator lights are abnormal. For each network port, only one of the two indicator lights turns on, while the other does not blink. The system indicator light on the machine itself remains constantly on, whereas on the official firmware, it blinks. Additionally, the WAN and LAN indicator lights on the official firmware turn green when a cable is inserted, but there is no response with your firmware.

@EvilOlaf
Copy link
Member Author

Show uart logs if possible.

@vnca
Copy link

vnca commented Jan 20, 2025

Still untested but well, screw it. Patch header need rework to give proper credit....again

New image for testing: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0-rc5_minimal.img.xz

I am able boot from SD card with this image. But the SYS led is in red, no flashing. Other leds are off.

@EvilOlaf
Copy link
Member Author

Without logs there is nothing I can do.
Since nobody wants to help in that matter I close this case. Was worth a try.

@EvilOlaf EvilOlaf closed this Jan 20, 2025
@xperiazu21
Copy link

Still untested but well, screw it. Patch header need rework to give proper credit....again

New image for testing: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0-rc5_minimal.img.xz

The image has been tested and can boot from both SD and eMMC. USB is functioning normally (speed not tested). The front indicators show only the SYS LED as constantly lit, while the LAN and WAN LEDs do not work.
The two network ports are operating at normal speed, but the LED indicators next to the ports are defined differently from the NanoPi image.

I have created a patch based on the kernel source provided by FriendlyARM. The main changes include modifications to the network port indicators and adjustments to the WAN's phy-mode, rx, and tx delay.
xxx-kernel-r3s-eth-led.patch
xxx-kernel-r3s-dts.patch

@vnca
Copy link

vnca commented Jan 27, 2025

@EvilOlaf

Bootable from SD Card.

Waiting for system to finish booting ...
/usr/lib/armbian/armbian-firstlogin: line 662: /sys/class/graphics/fb0/virtual_size: No such file or directory

When trying sudo apt update and sudo apt upgrade, this is the error messages. I hope that helps!

update-initramfs: Generating /boot/initrd.img-6.13.0-rc5-edge-rockchip64
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8126a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8126a-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125d-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8107e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168g-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168g-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8106e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8106e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8411-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8411-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8402-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168f-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8105e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168e-1.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-2.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168d-1.fw for module r8169
update-initramfs: Armbian: Converting to u-boot format: /boot/uInitrd-6.13.0-rc5-edge-rockchip64
Image Name: uInitrd
Created: Mon Jan 27 13:14:42 2025
Image Type: AArch64 Linux RAMDisk Image (gzip compressed)
Data Size: 17271786 Bytes = 16866.98 KiB = 16.47 MiB
Load Address: 00000000
Entry Point: 00000000
update-initramfs: Armbian: Symlinking /boot/uInitrd-6.13.0-rc5-edge-rockchip64 to /boot/uInitrd
'/boot/uInitrd' -> 'uInitrd-6.13.0-rc5-edge-rockchip64'
update-initramfs: Armbian: done.

@EvilOlaf EvilOlaf reopened this Jan 27, 2025
@EvilOlaf
Copy link
Member Author

EvilOlaf commented Jan 27, 2025

/usr/lib/armbian/armbian-firstlogin: line 662: /sys/class/graphics/fb0/virtual_size: No such file or directory

No idea where that comes from. Unrelated to board support though.

Possible missing firmware

These can be safely be ignored. Also I think a bunch of firmware files have been added to the firmware package quite recently.

I have created a patch based

Thanks.

So overall it seems good enough for merge since it seems to boot.

EvilOlaf added a commit to EvilOlaf/build that referenced this pull request Jan 27, 2025
Source & credits https://patchwork.ozlabs.org/project/uboot/list/?series=438193
I still need to figure out how to convert a patch series from patchwork in a way so the build framework doesn't complain about headers and magic and whatever. So a few hundreds of header lines have been replaced with something generic.

Applies and builds fine now against current stable v2024.10
@EvilOlaf
Copy link
Member Author

Hm I must have made a mistake when applying the dts patch. Doesn't want to build.

[🔨]   Error: arch/arm64/boot/dts/rockchip/rk3566-nanopi-r3s.dts:445.2-18 Properties must precede subnodes
[🔨]   FATAL ERROR: Unable to parse input tree
[🔨]   make[4]: *** [scripts/Makefile.dtbs:134: arch/arm64/boot/dts/rockchip/rk3566-nanopi-r3s.dtb] Error 1
``

@EvilOlaf EvilOlaf marked this pull request as draft January 27, 2025 14:19
@vnca
Copy link

vnca commented Jan 27, 2025

Hm I must have made a mistake when applying the dts patch. Doesn't want to build.

[🔨]   Error: arch/arm64/boot/dts/rockchip/rk3566-nanopi-r3s.dts:445.2-18 Properties must precede subnodes
[🔨]   FATAL ERROR: Unable to parse input tree
[🔨]   make[4]: *** [scripts/Makefile.dtbs:134: arch/arm64/boot/dts/rockchip/rk3566-nanopi-r3s.dtb] Error 1
``

Looking forward to seeing a new build to test.

@EvilOlaf
Copy link
Member Author

Alright looks like the patch needs to be applied after all other patches....which is bad. Patches should not depend on each other.
It builds though. Test image including the patches from @xperiazu21: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0_minimal.img.xz

Due to the patch dependency described above this PR should not be merged until this is resolved. Needs somebody more experienced that me.

@vnca
Copy link

vnca commented Jan 27, 2025

Alright looks like the patch needs to be applied after all other patches....which is bad. Patches should not depend on each other. It builds though. Test image including the patches from @xperiazu21: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0_minimal.img.xz

Due to the patch dependency described above this PR should not be merged until this is resolved. Needs somebody more experienced that me.

It's bootable. SYS led is now flashing, still no WAN or LAN leds.

image

@xperiazu21
Copy link

Alright looks like the patch needs to be applied after all other patches....which is bad. Patches should not depend on each other. It builds though. Test image including the patches from @xperiazu21: https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0_minimal.img.xz
Due to the patch dependency described above this PR should not be merged until this is resolved. Needs somebody more experienced that me.

It's bootable. SYS led is now flashing, still no WAN or LAN leds.

image

Yes, I have not yet fixed the front WAN and LAN indicator lights.
But are the green and orange LEDs next to the network port functioning properly?

@xperiazu21
Copy link

@EvilOlaf
I have adjusted the patch, which should resolve the compilation errors and also fixed the front WAN and LAN LEDs.
board-nanopi-r3s-fix-leds.patch

@EvilOlaf
Copy link
Member Author

EvilOlaf commented Jan 28, 2025

Thanks. Locally applied
https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0_minimal.img.xz

Please test

@shenyunet
Copy link

Could you research how to adapt the NanoPi R3S to the current kernel? I want a stable kernel.

@xperiazu21
Copy link

Thanks. Locally applied https://fi.mirror.armbian.de/.testing/Armbian-unofficial_25.02.0-trunk_Nanopi-r3s_bookworm_edge_6.13.0_minimal.img.xz

Please test

Using SD and eMMC for booting, as expected, the front WAN and LAN LEDs are working, and the indicator lights on the rear network ports are also functioning properly.

@EvilOlaf EvilOlaf marked this pull request as ready for review January 28, 2025 06:51
@EvilOlaf
Copy link
Member Author

I'd say its good now.

Next step, once merged, I'd say is backport to 6.12 to provide LTS kernel with current.

@shenyunet
Copy link

shenyunet commented Jan 28, 2025

dmesg.txt
is OK!!!

@EvilOlaf EvilOlaf added Ready to merge Reviewed, tested and ready for merge and removed Needs review Seeking for review labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

6 participants