Skip to content

orangepizero2w: fix ethernet using sunxi-gmac driver#9815

Closed
EvilOlaf wants to merge 3 commits into
armbian:mainfrom
EvilOlaf:sunxi-network-mess
Closed

orangepizero2w: fix ethernet using sunxi-gmac driver#9815
EvilOlaf wants to merge 3 commits into
armbian:mainfrom
EvilOlaf:sunxi-network-mess

Conversation

@EvilOlaf
Copy link
Copy Markdown
Member

@EvilOlaf EvilOlaf commented May 12, 2026

Description

Micha did some cleanup after my mess with the sunxi patchset. Well, it is what it is when no professional wants to tackle an issue but leave it to an amateur like myself to do it 😁 . Anyway below is the commit message.

It is patched into Armbian kernel sources, and was enabled in Linux 6.12, but has not been enabled anymore with Linux 6.18 and above.

Additionally, a possible attempt to split the AC200 related patch ended up with half of sunxi-gmac dependencies missing, including such which are explicitly enabled in defconfs, including e.g. CONFIG_AC200_PHY_SUNXI.

The mainline driver dwmac-sun8i, that might have been seen as possible replacement for sunxi-gmac, does not support the Ethernet chip of the Orange Pi Zero 2W expansion board yet.

How Has This Been Tested?

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

Summary by CodeRabbit

Release Notes

  • New Features
    • Added Gigabit Ethernet (GMAC) driver support for H618 and related Allwinner hardware platforms
    • Enabled AC200 PHY and multi-function device drivers
    • Improved device-tree GPIO handling for enhanced hardware compatibility

Review Change Stack

It is patched into Armbian kernel sources, and was enabled in Linux 6.12, but has not been enabled anymore with Linux 6.18 and above.

Additionally, a possible attempt to split the AC200 related patch ended up with half of sunxi-gmac dependencies missing, including such which are explicitly enabled in defconfs, including e.g. CONFIG_AC200_PHY_SUNXI.

The mainline driver dwmac-sun8i, that might have been seen as possible replacement for sunxi-gmac, does not support the Ethernet chip of the Orange Pi Zero 2W expansion board yet.

Signed-off-by: MichaIng <micha@dietpi.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

This pull request integrates H618 GMAC Ethernet and AC200 PHY/MFD hardware support for Sunxi-based systems. It adds kernel module configurations to enable the drivers, registers the corresponding patches in kernel series, and ensures proper build dependencies are declared in Kconfig.

Changes

H618 GMAC and AC200 Support

Layer / File(s) Summary
Kernel configuration for GMAC and AC200 modules
config/kernel/linux-sunxi64-current.config, config/kernel/linux-sunxi64-edge.config
Adds CONFIG_SUNXI_GMAC=m, CONFIG_AC200_PHY_SUNXI=m, and CONFIG_MFD_AC200_SUNXI=m as loadable modules in both current and edge kernel defconfigs for consistent hardware driver availability.
Kernel patch series registration
patch/kernel/archive/sunxi-6.18/series.conf, patch/kernel/archive/sunxi-7.0/series.conf
Registers patches.armbian/drv-mfd-ac200-add-support.patch and patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch in kernel patch series for both 6.18 and 7.0 versions, ensuring patches are applied during kernel build.
GMAC driver Kconfig and build dependencies
patch/kernel/archive/sunxi-6.18/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch, patch/kernel/archive/sunxi-7.0/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch
SUNXI_GMAC Kconfig selects PHYLIB library for both kernel versions, providing the necessary PHY management subsystem dependency when the driver patches are applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • armbian/build#9814: Re-enables SUNXI_GMAC driver and related AC200 PHY/MFD support that was previously removed, restoring H618 GMAC hardware enablement.

Possibly related PRs

  • armbian/build#9609: Removes legacy BSP GMAC/EPHY variants and refactors to in-tree SUNXI_GMAC driver—this PR complements that refactoring by completing the H618 GMAC and AC200 support integration.

Suggested reviewers

  • chraac
  • pyavitz
  • PanderMusubi
  • janprunk

Poem

🐰 A rabbit hops through kernel configs,
With GMAC and AC200 to unlock,
Patches registered, dependencies true,
H618 Ethernet now rings anew! 🌐

🚥 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 accurately summarizes the main objective of the PR: fixing Ethernet support for the Orange Pi Zero 2W by re-enabling the sunxi-gmac driver.
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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 05 Milestone: Second quarter release 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 May 12, 2026
coderabbitai[bot]

This comment was marked as low quality.

@EvilOlaf

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@USAVault
Copy link
Copy Markdown

USAVault commented May 13, 2026

Tested the patch on an OrangePi Zero 2W. Unfortunately, with kernel 7.0+ the board hangs after loading bcachefs during the filesystem check stage. On kernel 6.18.29 the network works fully, but I had to enable the following config options manually, otherwise the GMAC module would not compile

CONFIG_PWM_SUNXI_ENHANCE=m
CONFIG_MFD_AC200_SUNXI=m
CONFIG_AC200_PHY_SUNXI=m

(Not entirely sure why this was required)

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.

Actionable comments posted: 3

🤖 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.

Inline comments:
In `@config/kernel/linux-sunxi64-edge.config`:
- Line 763: Replace the manual addition of the CONFIG_AC200_PHY_SUNXI entry by
regenerating the kernel config with Armbian’s tool: run the Armbian kernel
config rewrite command (compile.sh rewrite-kernel-config) so the
CONFIG_AC200_PHY_SUNXI symbol is added via the official toolchain and dependency
resolution rather than hardcoding "CONFIG_AC200_PHY_SUNXI=m" in the config file;
verify the regenerated config contains CONFIG_AC200_PHY_SUNXI and commit the
regenerated config instead of the manual change.
- Line 1469: Regenerate the kernel config instead of manually adding
CONFIG_MFD_AC200_SUNXI by running the kernel-config rewrite step (./compile.sh
rewrite-kernel-config BOARD=orangepizero2w BRANCH=edge) so the MFD_AC200_SUNXI
Kconfig is picked up as an overlay; then verify the symbol exists in the kernel
patches and references by searching for "config MFD_AC200_SUNXI" and
"MFD_AC200_SUNXI" (e.g., with rg/fd across patch/kernel/archive/sunxi-7.0 and
sunxi-6.18) and confirm the patch that adds the AC200 MFD driver (0201.*ac200)
defines the symbol, ensuring armbian/build kernel config overlays remain minimal
and regenerated.
- Line 696: The patch manually adds CONFIG_SUNXI_GMAC=m which violates the repo
policy that kernel configs under config/kernel/* must be minimal overlays
generated by the official tool; regenerate the overlay instead by running the
rewrite command (./compile.sh rewrite-kernel-config BOARD=orangepizero2w
BRANCH=edge) so Kconfig resolves dependencies automatically, and verify the
SUNXI_GMAC Kconfig symbol exists in the kernel sources/patches (search for
"config SUNXI_GMAC" or "SUNXI_GMAC") before committing the regenerated overlay.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 34d0c290-ff92-4e2d-a352-f44de4a4e33f

📥 Commits

Reviewing files that changed from the base of the PR and between 02c3e9e and d434ae4.

📒 Files selected for processing (2)
  • config/kernel/linux-sunxi64-current.config
  • config/kernel/linux-sunxi64-edge.config
✅ Files skipped from review due to trivial changes (1)
  • config/kernel/linux-sunxi64-current.config

Comment thread config/kernel/linux-sunxi64-edge.config
Comment thread config/kernel/linux-sunxi64-edge.config
Comment thread config/kernel/linux-sunxi64-edge.config
@EvilOlaf
Copy link
Copy Markdown
Member Author

Test images for various sunxi64 boards, randomly selected edge or current: https://testing.armbian.de/

@igorpecovnik
Copy link
Copy Markdown
Member

igorpecovnik commented May 14, 2026

No network on Inovatto quadra. https://paste.armbian.com/fupuralaga

@EvilOlaf
Copy link
Copy Markdown
Member Author

Do you have a armbianmonitor report handy without the changes of this pr?

@github-actions github-actions Bot added size/small PR with less then 50 lines and removed size/large PR with 250 lines or more labels May 14, 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.

🧹 Nitpick comments (1)
patch/kernel/archive/sunxi-7.0/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch (1)

81-88: ⚡ Quick win

Kconfig design concern: hidden dependency on AC200_PHY_SUNXI not expressed in config rules.

The driver unconditionally calls gmac_ephy_shutdown() and ephy_is_enable() (wrapped in #if 1 // defined(CONFIG_SUNXI_EPHY) guards that always evaluate true) — both are EXPORT_SYMBOL_GPL from sunxi-ephy, which depends on AC200_PHY_SUNXI/MFD_AC200_SUNXI. The Kconfig now only selects PHYLIB/CRC32/MII, with no explicit dependency on those AC200 symbols.

Current defconfigs (linux-sunxi64-current.config and linux-sunxi64-edge.config) do enable both AC200_PHY_SUNXI=m and MFD_AC200_SUNXI=m wherever SUNXI_GMAC=m is set, so in practice there is no immediate load-failure risk. However, the Kconfig does not express this dependency, creating a latent maintainability issue: a developer unaware of this hidden coupling could misconfigure SUNXI_GMAC without the required AC200 modules and hit unresolved symbols at module load time.

Consider adding depends on AC200_PHY_SUNXI to the SUNXI_GMAC config block to make the dependency explicit. This preserves the "relaxed" spirit of the change (no longer hard-failing the build of the rest of the kernel) while preventing accidentally unloadable configurations.

🤖 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/sunxi-7.0/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch`
around lines 81 - 88, The SUNXI_GMAC Kconfig introduces a hidden runtime
dependency on symbols from sunxi-ephy (gmac_ephy_shutdown, ephy_is_enable) which
come from AC200_PHY_SUNXI / MFD_AC200_SUNXI; make this dependency explicit by
adding a Kconfig dependency (e.g., "depends on AC200_PHY_SUNXI") to the
SUNXI_GMAC stanza so the config system prevents selecting SUNXI_GMAC without the
AC200 PHY module while retaining the module-style behavior (keep
tristate/selects as-is).
🤖 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.

Nitpick comments:
In
`@patch/kernel/archive/sunxi-7.0/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch`:
- Around line 81-88: The SUNXI_GMAC Kconfig introduces a hidden runtime
dependency on symbols from sunxi-ephy (gmac_ephy_shutdown, ephy_is_enable) which
come from AC200_PHY_SUNXI / MFD_AC200_SUNXI; make this dependency explicit by
adding a Kconfig dependency (e.g., "depends on AC200_PHY_SUNXI") to the
SUNXI_GMAC stanza so the config system prevents selecting SUNXI_GMAC without the
AC200 PHY module while retaining the module-style behavior (keep
tristate/selects as-is).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f24c655-c4e0-4980-b601-adc65f9b3783

📥 Commits

Reviewing files that changed from the base of the PR and between d434ae4 and 913894b.

📒 Files selected for processing (4)
  • patch/kernel/archive/sunxi-6.18/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch
  • patch/kernel/archive/sunxi-6.18/series.conf
  • patch/kernel/archive/sunxi-7.0/patches.armbian/drv-net-stmmac-sun8i-add-h618-emac.patch
  • patch/kernel/archive/sunxi-7.0/series.conf

@EvilOlaf
Copy link
Copy Markdown
Member Author

Let's put this aside for now, I don't see (yet) how to combine both worlds. AI has some idea but without hw on hand testing this is quite annoying for multiple parties....

@EvilOlaf EvilOlaf closed this May 14, 2026
@igorpecovnik
Copy link
Copy Markdown
Member

Do you have a armbianmonitor report handy without the changes of this pr?

It works. https://paste.armbian.com/kifiyegago

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, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

4 participants