Skip to content

arm64: dts: rockchip: nanopi-m5: fix GMAC rgmii-id causing broken gig…#9901

Open
dva108 wants to merge 1 commit into
armbian:mainfrom
dva108:main
Open

arm64: dts: rockchip: nanopi-m5: fix GMAC rgmii-id causing broken gig…#9901
dva108 wants to merge 1 commit into
armbian:mainfrom
dva108:main

Conversation

@dva108
Copy link
Copy Markdown

@dva108 dva108 commented May 26, 2026

RTL8211F in rgmii-id mode applies its own internal RX delay. Setting rx_delay on top of that causes double delay which breaks gigabit RX entirely (RX counters stuck at zero, DHCP never receives OFFER).

Change phy-mode to rgmii-rxid and drop rx_delay for both gmac0 and gmac1. Tested on NanoPi M5 with kernel 6.18.33-current-rockchip64.

Description

Without this fix, gigabit RX is completely non-functional on NanoPi M5 with kernel 6.18. The interface comes up at 1000Mb/s, TX works, but no packets are ever received. DHCP never gets an OFFER, ethtool -S shows RX counters stuck at zero.

Root cause: the DTB sets phy-mode = "rgmii-id" which means the RTL8211F PHY applies its own internal RX delay. The driver then also applies an additional hardware rx_delay = <0x3f> on top of it. The double delay breaks gigabit RX entirely.

Workaround that confirmed the root cause: forcing 100Mbps via ethtool -s end0 speed 100 duplex full autoneg off made RX work immediately.

Fix: change phy-mode to rgmii-rxid (PHY handles RX delay internally) and remove rx_delay for both gmac0 and gmac1.

Forum thread: https://forum.armbian.com/topic/59912-nanopi-m5-rk3576-gigabit-rx-broken-due-to-double-rgmii-delay-in-dtb/

How Has This Been Tested?

  • Booted NanoPi M5 with kernel 6.18.33-current-rockchip64 on SD card. Without fix: gigabit RX non-functional, DHCP OFFER never received, RX counters at zero. With fix: both gmac0 and gmac1 work correctly at 1Gbps full duplex.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

Summary by CodeRabbit

  • New Features
    • Enabled UFS storage controller support with proper voltage regulation
    • Enabled Wi-Fi and Bluetooth connectivity (RTL8822CS chipset)
    • Improved Ethernet configuration with optimized timing
    • Restored hardware BACK button functionality
    • Enabled additional serial ports for device connectivity
    • Changed USB port to operate as host device

Review Change Stack

…abit RX

RTL8211F in rgmii-id mode applies its own internal RX delay. Setting
rx_delay on top of that causes double delay which breaks gigabit RX
entirely (RX counters stuck at zero, DHCP never receives OFFER).

Change phy-mode to rgmii-rxid and drop rx_delay for both gmac0 and
gmac1. Tested on NanoPi M5 with kernel 6.18.33-current-rockchip64.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

This PR patches the NanoPi M5 board device tree for kernel 6.18, enabling multiple on-board peripherals: UFS storage with voltage regulators, Wi-Fi/Bluetooth via SDIO and UART5, Ethernet MAC timing, SARADC input buttons, auxiliary serial ports, and USB host-only mode.

Changes

NanoPi M5 Peripheral Enablement

Layer / File(s) Summary
Fixed Regulators & Input Devices
patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch
Adds fixed 1.2V and 1.8V UFS voltage regulators, introduces SARADC-based input for the BACK button, and defines GPIO-based SDIO power-cycle sequencing for the Wi-Fi module.
Ethernet MAC Timing Configuration
patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch
Sets phy-mode = "rgmii-rxid" timing mode on both Ethernet MACs and configures board-specific transmit delays (0x21 for gmac0, 0x20 for gmac1).
Wireless (Wi-Fi) Support
patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch
Adds wireless pinctrl groups for UART5 and Wi-Fi GPIO control (host-wake, power-enable); fully configures the SDIO host controller with power sequencing, supply bindings, 4-bit mode, SDIO IRQ, and UHS SDR104 capabilities for RTL8822CS.
Serial Interfaces, Storage & USB Host Mode
patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch
Enables UART3, UART5 (with Bluetooth child node using realtek,rtl8822cs-bt driver and BT_REG_ON/wake GPIO controls), UART8 with pinctrl; enables UFS controller with supply bindings; switches USB DRD port from OTG to fixed host mode by removing extcon wiring.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • armbian/build#9844: Also forces &usb_drd0_dwc3 into dr_mode = "host" mode and removes OTG extcon wiring, applying the same USB mode change pattern.

Suggested reviewers

  • joekhoobyar
  • brentr
  • prahal
  • rpardini

Poem

🐰 With Wi-Fi wings and Bluetooth cheer,
UFS and Ethernet crystal clear,
UART's flowing, USB's set to host,
The NanoPi M5 shines the most! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title focuses on fixing GMAC rgmii-id causing broken gigabit RX, which is the primary issue addressed in the PR, but the changeset includes extensive additional hardware enablement beyond the core networking fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size/small PR with less then 50 lines 05 Milestone: Second quarter release labels May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey @dva108! 👋

Thanks for submitting your first pull request to the Armbian project — we're excited to have you contributing! 🧡
Your effort doesn’t just improve Armbian — it benefits the entire community of users and developers.

If you'd like to stay informed about project updates or collaborate more closely with the team,
you can optionally share some personal contact preferences at armbian.com/update-data.
This helps us keep in touch without relying solely on GitHub notifications.

Also, don’t forget to ⭐ star the repo if you haven’t already — and welcome aboard! 🚀

@github-actions github-actions Bot added Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels May 26, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch (1)

194-205: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add uart-has-rtscts; to &uart5 (DT binding correctness for serdev HW flow control)

For UART-based serdev devices, uart-has-rtscts; is the serial DT binding flag that declares the UART host has dedicated, pinmux-enabled RTS/CTS hardware flow-control lines. Having only the pinctrl entries for *_ctsn / *_rtsn doesn’t provide the explicit binding signal expected by serial-attached-device/serdev setups. [1] So add uart-has-rtscts; under &uart5.

🔧 Proposed fix
 &uart5 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart5m0_xfer>, <&uart5m0_ctsn>, <&uart5m0_rtsn>;
+	uart-has-rtscts;
 	status = "okay";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch`
around lines 194 - 205, The DT node &uart5 is missing the serial-binding flag
uart-has-rtscts which explicitly declares that the UART supports dedicated
RTS/CTS pins for serdev hw flow control; to fix, add the property
uart-has-rtscts; inside the &uart5 node (near pinctrl-0 / status) so the
serial-attached-device/serdev bindings recognize the *_rtsn / *_ctsn pinctrl
entries and enable hardware flow control for devices like the bluetooth child
(compatible = "realtek,rtl8822cs-bt").
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch`:
- Around line 194-205: The DT node &uart5 is missing the serial-binding flag
uart-has-rtscts which explicitly declares that the UART supports dedicated
RTS/CTS pins for serdev hw flow control; to fix, add the property
uart-has-rtscts; inside the &uart5 node (near pinctrl-0 / status) so the
serial-attached-device/serdev bindings recognize the *_rtsn / *_ctsn pinctrl
entries and enable hardware flow control for devices like the bluetooth child
(compatible = "realtek,rtl8822cs-bt").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d0984c6b-9b76-4adc-8e9b-fa0c3c7e43c9

📥 Commits

Reviewing files that changed from the base of the PR and between 45561f2 and e966fdd.

📒 Files selected for processing (1)
  • patch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patch

@EvilOlaf
Copy link
Copy Markdown
Member

EvilOlaf commented May 26, 2026

did you actually try to build with this particular adjustment? I predict the patch will fail.

@dva108
Copy link
Copy Markdown
Author

dva108 commented May 26, 2026

did you actually try to build with this particular adjustment? I predict the patch will fail.

No, I did not build a full image. I applied the fix directly on a running NanoPi M5:

  1. Decompiled the DTB: dtc -I dtb -O dts -o /tmp/nanopi.dts /boot/dtb/rockchip/rk3576-nanopi-m5.dtb
  2. Changed phy-mode from rgmii-id to rgmii-rxid and removed rx_delay
  3. Recompiled and replaced the DTB
  4. Rebooted

After reboot gigabit RX works correctly at 1Gbps. Before the fix RX counters were stuck at zero and DHCP never received an OFFER.

I understand the patch format may need adjustment - happy to fix if you can point out what would break.

https://forum.armbian.com/topic/59912-nanopi-m5-rk3576-gigabit-rx-broken-due-to-double-rgmii-delay-in-dtb/#comment-238034

Copy link
Copy Markdown
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@igorpecovnik
Copy link
Copy Markdown
Member

I understand the patch format may need adjustment

That yes.

@github-actions github-actions Bot added the Ready to merge Reviewed, tested and ready for merge label May 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions Bot removed the Needs review Seeking for review label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

3 participants