Skip to content

Conversation

@SuperKali
Copy link
Member

@SuperKali SuperKali commented Dec 8, 2025

Description

This PR fixes RTL8822CS WiFi initialization failures on kernel 6.18 by adding the missing rtw88 driver patches directory.

Problem:

  • RTL8822CS WiFi failed consistently on kernel 6.18 (0/10 boots)
  • SDIO timeout errors (-110) during chip initialization
  • Missing patch/misc/rtw88/6.18/ directory prevented upstream driver patches from being applied

Solution:

  • Created patch/misc/rtw88/6.18/ directory with upstream driver patches
  • Cleaned up patch logic in drivers_network.sh by removing obsolete kernel 6.16 reference
  • Updated comment to clarify that RF path detection fix (patch 004) is only needed for kernel 6.1.x (upstreamed in 6.18+)

Technical Details:
The RTL8822CS SDIO RF path detection fix was upstreamed in kernel 6.18, so patch 004 is not needed. However, the upstream rtw88 driver updates in patch 001 are still required and must be applied via the version-specific directory structure.

How Has This Been Tested?

  • Built kernel 6.18 with changes and verified RTL8822CS WiFi initializes correctly
  • Tested WiFi connectivity - interface appears, can scan and connect to networks
  • Tested Bluetooth functionality - works correctly
  • Verified build succeeds without patch application errors
  • Confirmed fix is stable across multiple reboots (10/10 successful boots)

Test Hardware:

  • Rockchip-based NanoPi M5 with RTL8822CS WiFi/BT combo chip
  • Kernel: 6.18 (edge branch)

Before fix:
[ 9.231300] rtw88_8822cs mmc1:0001:1: sdio read32 failed (0x11080): -110
[ 9.235262] rtw88_8822cs mmc1:0001:1: failed to download firmware
[ 9.242788] rtw88_8822cs mmc1:0001:1: failed to setup chip information

After fix:

  • No SDIO errors in dmesg
  • WiFi and Bluetooth fully operational

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

Summary by CodeRabbit

  • Bug Fixes

    • Ensure the RTW88 SDIO RF path patch is applied only for kernel 6.1.x so it’s not erroneously applied to newer kernels where the fix exists upstream.
  • Documentation

    • Updated inline guidance to clarify the patch is specific to kernel 6.1.x and unnecessary for 6.18+.

✏️ Tip: You can customize this high-level summary in your review settings.

@SuperKali SuperKali requested review from a team and igorpecovnik as code owners December 8, 2025 13:59
@github-actions github-actions bot added the size/large PR with 250 lines or more label Dec 8, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

Restricted the RTW88 SDIO RF-path detection patch application to kernel 6.1 only and updated the inline comment to state the patch is not needed for kernels >= 6.18 (handled upstream).

Changes

Cohort / File(s) Summary
rtw88 patch version gating
lib/functions/compilation/patch/drivers_network.sh
Changed conditional for 004-rtw88-sdio-rf-path-detection-fix.patch from (6.1|6.16) to 6.1 only; updated comment to indicate the patch is intended for kernel 6.1.x and is upstreamed in later kernels.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file with a straightforward conditional change and comment update
  • Verify other PRs that touch the same patch logic and confirm kernel-version intent

Possibly related PRs

Suggested labels

11

Suggested reviewers

  • rpardini
  • EvilOlaf
  • igorpecovnik

Poem

🐰 A tiny patch I hop to mend,
From broad to small the versions bend.
Six-dot-one now holds the key,
Newer kernels roam patch-free.
Hooray — upstream saved the day! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding kernel 6.18 support and cleaning up patch logic, which directly corresponds to the PR objectives and code changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a7ce5a and ecbff1f.

📒 Files selected for processing (1)
  • lib/functions/compilation/patch/drivers_network.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: SuperKali
Repo: armbian/build PR: 8608
File: lib/functions/compilation/patch/drivers_network.sh:361-363
Timestamp: 2025-09-11T06:06:52.328Z
Learning: For the RTW88 SDIO RF path detection fix patch (004-rtw88-sdio-rf-path-detection-fix.patch), SuperKali prefers using exact version matching (eq 6.1 || eq 6.16) rather than range checks, as the patch has only been tested on those specific kernel versions and may be mainstreamed soon.
Learnt from: amazingfate
Repo: armbian/build PR: 8453
File: lib/functions/compilation/patch/drivers_network.sh:213-216
Timestamp: 2025-08-02T14:59:28.145Z
Learning: The wireless driver patches wireless-rtl8812au-Fix-6.16.patch, wireless-rtl8811cu-Fix-6.16.patch, and wireless-rtl88x2bu-Fix-6.16.patch in the Armbian build system are backward compatible and can be applied unconditionally without version checks, even though they're named for 6.16+ fixes.
Learnt from: amazingfate
Repo: armbian/build PR: 8595
File: lib/functions/compilation/patch/drivers_network.sh:0-0
Timestamp: 2025-09-09T07:30:22.419Z
Learning: RTW_WARN_LMT sed workaround in driver_rtl8852bs() function in lib/functions/compilation/patch/drivers_network.sh is necessary for kernel 6.1 compatibility, even when the upstream wifi-rtl8852bs driver has the macro defined for newer kernels. The workaround ensures cross-kernel compatibility from 6.1 to 6.16+.
Learnt from: igorpecovnik
Repo: armbian/build PR: 8408
File: lib/functions/compilation/patch/drivers_network.sh:258-260
Timestamp: 2025-07-22T07:02:58.863Z
Learning: In the Armbian build system, RTL8811CU/RTL8821C wireless driver deprecation starting with kernel 6.12+ is not due to build failures but because support is being integrated into the upstream RTW88 driver. The deprecated drivers still build and function correctly during the transition period.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8968
File: patch/u-boot/u-boot-sunxi/arm64-dts-sun50i-h6-orangepi.dtsi-Rollback-r_rsb-to-r_i2c.patch:36-36
Timestamp: 2025-11-20T18:20:11.985Z
Learning: The rewrite-patches tool (REWRITE_PATCHES=yes) in the Armbian build system can inadvertently introduce semantic changes when the u-boot/kernel git base revision differs from expected state. The tool applies patches, commits them, and re-exports them using git format-patch, which can cause the re-exported patch to reflect the base revision's state rather than preserving the original patch intent. This is particularly problematic for device tree changes like interrupt specifications. The tool currently lacks validation mechanisms to detect such semantic drift, and affected patches must be manually corrected after rewriting.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub API (https://api.github.com/repos/armbian/build/pulls/{pr_number}/files) to get the complete picture of what files are being added or modified, especially for U-Boot patches that will be applied during the build process.
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.
Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:76-86
Timestamp: 2025-03-31T22:20:48.475Z
Learning: For the Armbian build project, maintaining consistency with existing patches across U-Boot versions (such as between 2025.01 and 2025.04) is prioritized over refactoring individual patches for code improvements.
Learnt from: EvilOlaf
Repo: armbian/build PR: 8428
File: config/boards/lckfb-taishanpi.csc:5-9
Timestamp: 2025-07-25T03:51:50.830Z
Learning: When reviewing PRs in the Armbian build system, U-Boot defconfig files and patches may be added as part of the PR changes but might not be visible in the current repository clone state during review. It's important to check the actual PR file changes directly via GitHub or the PR API to get the complete picture of what files are being added or modified.
Learnt from: igorpecovnik
Repo: armbian/build PR: 8408
File: lib/functions/compilation/patch/drivers_network.sh:303-305
Timestamp: 2025-07-22T07:03:01.165Z
Learning: RTL88x2bu driver support is being integrated into the mainline RTW88 driver, which is why the out-of-tree RTL88x2bu driver is being deprecated starting with kernel 6.12+. The external driver still builds and functions, but the deprecation is due to upstream mainline support becoming available.
Learnt from: pyavitz
Repo: armbian/build PR: 8421
File: config/kernel/linux-sunxi64-edge.config:2168-2173
Timestamp: 2025-07-27T15:54:35.119Z
Learning: In the Armbian build system, staging 802.11 drivers like CONFIG_RTLLIB, CONFIG_RTL8192E, CONFIG_R8712U are kept enabled alongside upstream rtw88 drivers because rtw88 is still under development and suffers from reliability issues. The staging drivers serve as necessary fallbacks when upstream drivers are unstable, prioritizing working hardware over avoiding technical conflicts.
Learnt from: igorpecovnik
Repo: armbian/build PR: 8812
File: config/kernel/linux-sm8250-edge.config:498-501
Timestamp: 2025-10-23T19:48:42.980Z
Learning: For Armbian EDGE kernel configs, CONFIG_ATH12K=m alone is sufficient for PCI-based Wi-Fi 7 devices (e.g., WCN785x/QCN9274). A separate CONFIG_ATH12K_PCI option is not required, as confirmed by maintainer testing.
📚 Learning: 2025-09-09T07:30:22.419Z
Learnt from: amazingfate
Repo: armbian/build PR: 8595
File: lib/functions/compilation/patch/drivers_network.sh:0-0
Timestamp: 2025-09-09T07:30:22.419Z
Learning: RTW_WARN_LMT sed workaround in driver_rtl8852bs() function in lib/functions/compilation/patch/drivers_network.sh is necessary for kernel 6.1 compatibility, even when the upstream wifi-rtl8852bs driver has the macro defined for newer kernels. The workaround ensures cross-kernel compatibility from 6.1 to 6.16+.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-09-11T06:06:52.328Z
Learnt from: SuperKali
Repo: armbian/build PR: 8608
File: lib/functions/compilation/patch/drivers_network.sh:361-363
Timestamp: 2025-09-11T06:06:52.328Z
Learning: For the RTW88 SDIO RF path detection fix patch (004-rtw88-sdio-rf-path-detection-fix.patch), SuperKali prefers using exact version matching (eq 6.1 || eq 6.16) rather than range checks, as the patch has only been tested on those specific kernel versions and may be mainstreamed soon.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-08-02T14:59:28.145Z
Learnt from: amazingfate
Repo: armbian/build PR: 8453
File: lib/functions/compilation/patch/drivers_network.sh:213-216
Timestamp: 2025-08-02T14:59:28.145Z
Learning: The wireless driver patches wireless-rtl8812au-Fix-6.16.patch, wireless-rtl8811cu-Fix-6.16.patch, and wireless-rtl88x2bu-Fix-6.16.patch in the Armbian build system are backward compatible and can be applied unconditionally without version checks, even though they're named for 6.16+ fixes.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-07-22T07:02:58.863Z
Learnt from: igorpecovnik
Repo: armbian/build PR: 8408
File: lib/functions/compilation/patch/drivers_network.sh:258-260
Timestamp: 2025-07-22T07:02:58.863Z
Learning: In the Armbian build system, RTL8811CU/RTL8821C wireless driver deprecation starting with kernel 6.12+ is not due to build failures but because support is being integrated into the upstream RTW88 driver. The deprecated drivers still build and function correctly during the transition period.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-11-20T18:20:11.985Z
Learnt from: EvilOlaf
Repo: armbian/build PR: 8968
File: patch/u-boot/u-boot-sunxi/arm64-dts-sun50i-h6-orangepi.dtsi-Rollback-r_rsb-to-r_i2c.patch:36-36
Timestamp: 2025-11-20T18:20:11.985Z
Learning: The rewrite-patches tool (REWRITE_PATCHES=yes) in the Armbian build system can inadvertently introduce semantic changes when the u-boot/kernel git base revision differs from expected state. The tool applies patches, commits them, and re-exports them using git format-patch, which can cause the re-exported patch to reflect the base revision's state rather than preserving the original patch intent. This is particularly problematic for device tree changes like interrupt specifications. The tool currently lacks validation mechanisms to detect such semantic drift, and affected patches must be manually corrected after rewriting.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-07-22T07:03:01.165Z
Learnt from: igorpecovnik
Repo: armbian/build PR: 8408
File: lib/functions/compilation/patch/drivers_network.sh:303-305
Timestamp: 2025-07-22T07:03:01.165Z
Learning: RTL88x2bu driver support is being integrated into the mainline RTW88 driver, which is why the out-of-tree RTL88x2bu driver is being deprecated starting with kernel 6.12+. The external driver still builds and functions, but the deprecation is due to upstream mainline support becoming available.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-09-25T18:37:00.330Z
Learnt from: tabrisnet
Repo: armbian/build PR: 8661
File: lib/functions/compilation/armbian-kernel.sh:194-199
Timestamp: 2025-09-25T18:37:00.330Z
Learning: In PR armbian/build#8661, line 235 of lib/functions/compilation/armbian-kernel.sh already contains the corrected comment "BPF link support for netfilter hooks" for NETFILTER_BPF_LINK, not the misleading "BPF_SYSCALL" comment that was flagged during review.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-03-31T22:20:41.849Z
Learnt from: rpardini
Repo: armbian/build PR: 8044
File: patch/u-boot/v2025.04/cmd-fileenv-read-string-from-file-into-env.patch:73-75
Timestamp: 2025-03-31T22:20:41.849Z
Learning: When porting patches between U-Boot versions (like from 2025.01 to 2025.04), rpardini prefers to maintain patches as-is rather than introducing refactoring changes, even when potential improvements are identified. This approach prioritizes consistency and reduces the risk of introducing new issues.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
📚 Learning: 2025-07-27T15:54:35.119Z
Learnt from: pyavitz
Repo: armbian/build PR: 8421
File: config/kernel/linux-sunxi64-edge.config:2168-2173
Timestamp: 2025-07-27T15:54:35.119Z
Learning: In the Armbian build system, staging 802.11 drivers like CONFIG_RTLLIB, CONFIG_RTL8192E, CONFIG_R8712U are kept enabled alongside upstream rtw88 drivers because rtw88 is still under development and suffers from reliability issues. The staging drivers serve as necessary fallbacks when upstream drivers are unstable, prioritizing working hardware over avoiding technical conflicts.

Applied to files:

  • lib/functions/compilation/patch/drivers_network.sh
🔇 Additional comments (1)
lib/functions/compilation/patch/drivers_network.sh (1)

369-371: Clarify patch applicability across kernel versions.

The condition now restricts patch 004 to kernel 6.1 only. However, the comment states "Not needed for 6.18+ (already upstream)" without explicitly addressing whether 6.16/6.17 still require this patch. Per the PR objective to remove the "obsolete kernel 6.16 reference," this suggests 6.16 support is being dropped, but it's unclear from the comment alone.

To align with the learnings (where SuperKali previously tested this patch on 6.1 and 6.16 specifically), consider clarifying the comment to explicitly state:

  • The patch is needed for 6.1.x because [specific reason]
  • It was upstreamed in 6.18 (and 6.16/6.17 status, if applicable)

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 02 Milestone: First quarter release Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Framework Framework components Patches Patches related to kernel, U-Boot, ... labels Dec 8, 2025
- Created patch/misc/rtw88/6.18/ directory with upstream driver patches
- Removed obsolete kernel 6.16 reference from patch conditions
- Updated comment to clarify that RF path detection fix is only needed
  for kernel 6.1.x (upstreamed in 6.18+)

This fixes RTL8822CS WiFi initialization failures on kernel 6.18 where
the driver was not being properly patched due to missing version directory.

Fixes SDIO timeout errors during chip initialization.
@SuperKali SuperKali force-pushed the rtw88-kernel-6.18-support branch from 5a7ce5a to ecbff1f Compare December 8, 2025 21:20
Copy link
Collaborator

@leggewie leggewie left a comment

Choose a reason for hiding this comment

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

looks good to me

@github-actions github-actions bot added the Ready to merge Reviewed, tested and ready for merge label Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

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

@github-actions github-actions bot removed the Needs review Seeking for review label Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Framework Framework components 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.

2 participants