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
    • Corrected the RTW88 SDIO RF path detection patch to apply only to kernel 6.1.x, preventing unnecessary application to newer kernel versions where the fix is already available upstream.

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

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

A conditional restriction narrows the rtw88 SDIO RF-path detection patch application from kernel 6.1 or 6.16 to kernel 6.1 only. The associated comment is updated to reflect this constraint, with the patch being marked as handled upstream for newer kernels.

Changes

Cohort / File(s) Summary
rtw88 patch version gating
lib/functions/compilation/patch/drivers_network.sh
Narrowed the kernel version condition for patch 004-rtw88-sdio-rf-path-detection-fix.patch from (6.1|6.16) to 6.1 only; updated the associated comment to clarify that the patch is for kernel 6.1.x and is handled upstream for later versions

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file with straightforward conditional narrowing and comment update
  • Low logic complexity; no new functionality or complex refactoring
  • May warrant cross-reference verification with related kernel version patches and kernel 6.16+ build pipelines

Possibly related PRs

Suggested reviewers

  • EvilOlaf
  • rpardini
  • igorpecovnik

Poem

🐰 A kernel version tamed with care,
From wide to narrow, patch declare—
Six-point-one now owns the prize,
While six-sixteen wears disguise!
Upstream handles the rest divine, 🌱

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
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.
Title check ❓ Inconclusive The title mentions 'Add kernel 6.18 support' which aligns with the PR's primary objective, but the raw summary indicates the actual code change is narrowing a patch conditional from 6.1/6.16 to only 6.1, which is not the main focus of the title. Clarify whether the title should emphasize the patch narrowing to 6.1, or if other changes (like adding the 6.18 directory) are more significant and better represent the changeset scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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 ffd4257 and 5a7ce5a.

📒 Files selected for processing (1)
  • lib/functions/compilation/patch/drivers_network.sh (1 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 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: 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: 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: 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-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-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-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-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-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-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-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
🔇 Additional comments (1)
lib/functions/compilation/patch/drivers_network.sh (1)

369-370: Good change: Refined patch 004 to target only 6.1.x, with clarity on upstream integration.

The narrowing of the conditional from eq 6.1 || eq 6.16 to eq 6.1 is correct—the SDIO RF-path detection fix has been upstreamed by 6.18 and is no longer needed for newer kernels. The updated comment clearly documents this version constraint, making it easier for future maintainers to understand the patch's scope.

This aligns with your established pattern of using exact version matching (eq) for patches tested on specific kernel versions, as documented in your work on PR #8608.


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
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, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

1 participant