Skip to content

Add rtl8xxxu-openipc package and RTL8188FU firmware - #2259

Closed
shipa-2 wants to merge 1 commit into
OpenIPC:masterfrom
shipa-2:pr/rtl8xxxu-openipc
Closed

Add rtl8xxxu-openipc package and RTL8188FU firmware#2259
shipa-2 wants to merge 1 commit into
OpenIPC:masterfrom
shipa-2:pr/rtl8xxxu-openipc

Conversation

@shipa-2

@shipa-2 shipa-2 commented Aug 11, 2026

Copy link
Copy Markdown

Summary

  • Add rtl8xxxu-openipc (mac80211 backport for RTL8188FTV 0bda:f179, including RCR_APPEND_FCS).
  • Add rtl8188fufw.bin option to linux-firmware-openipc; package selects parent firmware + RTL8188FU blob.

Test plan

  • Enable BR2_PACKAGE_RTL8XXXU_OPENIPC on a GK710x board config and build
  • Module loads firmware from /lib/firmware/rtlwifi/rtl8188fufw.bin
  • WPA2 handshake succeeds vs vendor 8188fu path

Part of splitting #2256. Board enablement / toolchain flag / overlay are separate.

Made with Cursor

mac80211 rtl8xxxu backport for RTL8188FTV (0bda:f179) on old kernels,
plus rtl8188fufw.bin install option in linux-firmware-openipc.

Co-authored-by: Cursor <cursoragent@cursor.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Add rtl8xxxu-openipc backport package and RTL8188FU firmware option

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add buildroot package for mac80211-based rtl8xxxu (RTL8188F/FTV) on kernel 3.4.43.
• Add linux-firmware-openipc option to install rtl8188fufw.bin under /lib/firmware/rtlwifi.
• Wire package into external tree menu and auto-select required firmware.
Diagram

graph TD
A["Buildroot config"] --> B["rtl8xxxu-openipc pkg"] --> C["rtl8xxxu.ko"] --> D["mac80211 stack"] --> G{{"RTL8188FU USB"}}
A --> E["linux-firmware-openipc"] --> F[("Firmware dir")]
C --> F
subgraph Legend
  direction LR
  _pkg["Package"] ~~~ _fs[("Filesystem")] ~~~ _hw{{"Hardware"}}
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Patch vendor rtl8188fu driver
  • ➕ Much smaller code drop vs vendoring rtl8xxxu backport
  • ➕ Avoids mac80211 behavior differences on very old kernels
  • ➖ Handshake/crypto issues can be hard to fix and maintain
  • ➖ Continues reliance on vendor driver architecture instead of upstream mac80211
2. Upgrade to a kernel with in-tree rtl8xxxu
  • ➕ Eliminates ongoing backport maintenance
  • ➕ Improves long-term security and Wi‑Fi stack compatibility
  • ➖ Likely significant GK710x enablement effort
  • ➖ Higher platform-wide regression risk
3. Use a standardized wireless backports framework
  • ➕ Reusable approach if more mac80211 drivers are needed
  • ➕ Clearer patch provenance vs a local source drop
  • ➖ Heavier Buildroot integration/configuration overhead
  • ➖ May still require 3.4.x-specific shims

Recommendation: Given the constraint of kernel 3.4.43 and the stated WPA2 4-way handshake failures with the vendor driver, shipping a focused rtl8xxxu/mac80211 backport plus explicit firmware installation is a pragmatic reliability win. To reduce future maintenance risk, consider documenting the exact upstream source (tag/commit) and explicitly listing any local deltas (e.g., RCR_APPEND_FCS behavior, supported USB IDs).

Files changed (11) +11900 / -0

Enhancement (5) +11623 / -0
Config.inAdd rtl8xxxu-openipc package config and firmware selects +10/-0

Add rtl8xxxu-openipc package config and firmware selects

• Defines BR2_PACKAGE_RTL8XXXU_OPENIPC, depends on BR2_LINUX_KERNEL, and selects linux-firmware-openipc plus the RTL8188FU firmware option to ensure the blob is present at runtime.

general/package/rtl8xxxu-openipc/Config.in

rtl8xxxu.hAdd rtl8xxxu driver header (types, structs, APIs) +1628/-0

Add rtl8xxxu driver header (types, structs, APIs)

• Adds the main rtl8xxxu header with debug flags, chip enums, descriptor formats, and shared structures/prototypes used across the backport.

general/package/rtl8xxxu-openipc/src/rtl8xxxu.h

rtl8xxxu_8188f.cAdd RTL8188F/U subdriver implementation +1766/-0

Add RTL8188F/U subdriver implementation

• Adds RTL8188F/U-specific init/calibration tables and logic, including selecting firmware name rtlwifi/rtl8188fufw.bin.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_8188f.c

rtl8xxxu_core.cAdd rtl8xxxu core mac80211 USB driver backport (RTL8188FU focused) +6983/-0

Add rtl8xxxu core mac80211 USB driver backport (RTL8188FU focused)

• Vendors the rtl8xxxu core driver, registers the USB ID 0bda:f179 with RTL8188FU file-ops, and declares firmware dependency on rtlwifi/rtl8188fufw.bin; includes receive-path configuration such as RCR_APPEND_FCS support.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c

rtl8xxxu_regs.hAdd rtl8xxxu register definitions (incl. RCR_APPEND_FCS) +1236/-0

Add rtl8xxxu register definitions (incl. RCR_APPEND_FCS)

• Adds register addresses and bit definitions required by the backported driver, including RCR_APPEND_FCS in the Receive Configuration Register.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_regs.h

Refactor (1) +234 / -0
rtl8xxxu_compat.hAdd Linux 3.4.43 compatibility shims for rtl8xxxu/mac80211 APIs +234/-0

Add Linux 3.4.43 compatibility shims for rtl8xxxu/mac80211 APIs

• Introduces version-guarded macros and helpers to map newer mac80211/cfg80211/kernel APIs onto the older 3.4.43 interfaces (flags, enums, bitfield helpers, chandef helpers).

general/package/rtl8xxxu-openipc/src/rtl8xxxu_compat.h

Other (5) +43 / -0
Config.inExpose rtl8xxxu-openipc in external package menu +1/-0

Expose rtl8xxxu-openipc in external package menu

• Adds rtl8xxxu-openipc to the external Buildroot package include list so it appears in menuconfig.

general/package/Config.in

Config.inAdd RTL8188FU firmware selection option +5/-0

Add RTL8188FU firmware selection option

• Introduces BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU to optionally include firmware for RTL8188FU/RTL8188FTV.

general/package/linux-firmware-openipc/Config.in

linux-firmware-openipc.mkInstall rtl8188fufw.bin into /lib/firmware/rtlwifi +8/-0

Install rtl8188fufw.bin into /lib/firmware/rtlwifi

• Adds an install snippet guarded by BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU that creates the rtlwifi directory and installs rtl8188fufw.bin.

general/package/linux-firmware-openipc/linux-firmware-openipc.mk

rtl8xxxu-openipc.mkAdd Buildroot package to build rtl8xxxu as a kernel module +21/-0

Add Buildroot package to build rtl8xxxu as a kernel module

• Implements a local-source Buildroot package using kernel-module infrastructure, passing KSRC/KVER for out-of-tree builds and declaring GPL-2.0 licensing.

general/package/rtl8xxxu-openipc/rtl8xxxu-openipc.mk

MakefileAdd out-of-tree Kbuild Makefile for rtl8xxxu +8/-0

Add out-of-tree Kbuild Makefile for rtl8xxxu

• Defines the rtl8xxxu module objects (core + 8188f) and relaxes compilation with -Wno-error for older kernel/toolchain combinations.

general/package/rtl8xxxu-openipc/src/Makefile

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. C2H skb leak 🐞 Bug ☼ Reliability
Description
rtl8xxxu_c2hcmd_callback() drains priv->c2hcmd_queue but only frees a single skb at the end, leaking
every dequeued skb except the last. This will steadily increase kernel memory usage when C2H events
are frequent.
Code

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[R5588-5591]

+	}
+
+out:
+	dev_kfree_skb(skb);
Evidence
The callback loops until the queue is empty, overwriting skb each iteration, but only frees skb
once after the loop, so earlier dequeued SKBs are never freed.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5538-5592]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`rtl8xxxu_c2hcmd_callback()` dequeues potentially multiple SKBs from `priv->c2hcmd_queue`, but only calls `dev_kfree_skb(skb)` once after the loop. This leaks SKBs.

### Issue Context
This is a kernel driver; leaking SKBs in an event path can create sustained memory growth.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5538-5592]

### What to change
- Change the loop to dequeue-and-process in a way that frees **each** dequeued skb exactly once, e.g.:
 - `while ((skb = skb_dequeue(&priv->c2hcmd_queue)) != NULL) { ...; dev_kfree_skb(skb); }`
- Ensure `skb` is not double-freed on exit paths (set to `NULL` after freeing if keeping an `out:` label).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Stop workqueue race 🐞 Bug ☼ Reliability
Description
rtl8xxxu_stop() frees RX/TX resources after setting shutdown, but it does not cancel/flush rx_urb_wq
(and c2hcmd_work), so already-queued work can still run and submit URBs or touch driver state after
teardown. This can cause use-after-free, re-arming URBs after stop, or crashes on disconnect.
Code

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[R6634-6637]

+	cancel_delayed_work_sync(&priv->ra_watchdog);
+
+	rtl8xxxu_free_rx_resources(priv);
+	rtl8xxxu_free_tx_resources(priv);
Evidence
The RX path schedules rx_urb_wq, the worker resubmits URBs, and stop() frees resources after only
canceling the delayed watchdog—there is no cancellation/flush of the scheduled work items.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5261-5327]
general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5638-5641]
general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[6605-6638]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`rtl8xxxu_stop()` sets `priv->shutdown = true`, kills anchored URBs, and then frees RX/TX resources, but it does not synchronously cancel/flush work items that can still run (`rx_urb_wq`, `c2hcmd_work`). `rtl8xxxu_rx_urb_work()` also does not check `priv->shutdown` before resubmitting URBs.

### Issue Context
- `rtl8xxxu_queue_rx_urb()` schedules `rx_urb_wq`.
- `rtl8xxxu_rx_urb_work()` resubmits URBs.
- `rtl8723bu_handle_c2h()` schedules `c2hcmd_work`.
- `rtl8xxxu_stop()` frees resources without canceling those works.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5261-5328]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5538-5641]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[6605-6638]

### What to change
- In `rtl8xxxu_stop()` (before freeing RX/TX resources):
 - `cancel_work_sync(&priv->rx_urb_wq);`
 - `cancel_work_sync(&priv->c2hcmd_work);`
 - purge `priv->c2hcmd_queue` (dequeue + `dev_kfree_skb()` until empty).
- Add a shutdown guard in `rtl8xxxu_rx_urb_work()` to avoid resubmitting URBs if `priv->shutdown` became true (free the URB/SKB instead).
- Ensure ordering: prevent new scheduling first (set shutdown), then cancel work, then kill URBs, then free resources.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. EFUSE debug default enabled 🐞 Bug ◔ Observability
Description
rtl8xxxu_debug defaults to RTL8XXXU_DEBUG_EFUSE, and rtl8188fu_parse_efuse() dumps raw efuse content
via dev_info when that flag is set. This will spam kernel logs on every probe by default and can
expose device-specific values (e.g., calibration data/MAC-related fields) unnecessarily.
Code

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[R38-41]

+int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE;
+static bool rtl8xxxu_ht40_2g;
+static bool rtl8xxxu_dma_aggregation;
+static int rtl8xxxu_dma_agg_timeout = -1;
Evidence
The driver sets the debug mask to EFUSE by default, and the EFUSE parser prints a full dump when
that bit is set, meaning the dump happens on every probe unless the parameter is overridden.

general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[36-42]
general/package/rtl8xxxu-openipc/src/rtl8xxxu_8188f.c[716-749]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The module debug mask is initialized to `RTL8XXXU_DEBUG_EFUSE`, which enables verbose EFUSE dumping at `dev_info()` level during normal operation.

### Issue Context
`rtl8188fu_parse_efuse()` prints the EFUSE dump when the EFUSE debug bit is enabled.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[36-42]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_8188f.c[716-749]

### What to change
- Change the default to `int rtl8xxxu_debug = 0;` (or another non-verbose default).
- Keep EFUSE dumping behind the module param so it is only enabled intentionally.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. No vendor-driver exclusion 🐞 Bug ⚙ Maintainability
Description
The new rtl8xxxu-openipc package help text says it replaces the vendor rtl8188fu driver, but
Buildroot allows enabling both rtl8188fu-openipc and rtl8xxxu-openipc simultaneously. This creates
an inconsistent configuration where two competing solutions for the same chipset can be built into
the image.
Code

general/package/rtl8xxxu-openipc/Config.in[R7-10]

+	  Mainline rtl8xxxu mac80211 driver (RTL8188F backport to
+	  kernel 3.4.43). Replaces the vendor rtl8188fu driver and
+	  fixes the WPA2 4-way handshake failure seen with the
+	  vendor driver on the GK7102.
Evidence
The package list includes both drivers, and rtl8xxxu-openipc explicitly claims to replace the vendor
rtl8188fu driver, but its Config.in has no constraint preventing both from being enabled.

general/package/Config.in[91-95]
general/package/rtl8xxxu-openipc/Config.in[7-10]
general/package/rtl8188fu-openipc/Config.in[1-4]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`rtl8xxxu-openipc` is described as replacing the vendor `rtl8188fu` driver, but nothing in Kconfig prevents selecting both packages.

### Issue Context
Both packages are present in `general/package/Config.in`, so they are independently selectable.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/Config.in[1-10]
- general/package/rtl8188fu-openipc/Config.in[1-4]
- general/package/Config.in[91-95]

### What to change
- Add a dependency to prevent simultaneous selection, e.g. in `rtl8xxxu-openipc/Config.in`:
 - `depends on !BR2_PACKAGE_RTL8188FU_OPENIPC`
 - and/or add a reciprocal comment in the vendor driver config.
- Alternatively, document and enforce which one should be used via a `choice` block if that matches project conventions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can group findings by type and pick your Finding display, from Minimal to Full

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment on lines +5588 to +5591
}

out:
dev_kfree_skb(skb);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. C2h skb leak 🐞 Bug ☼ Reliability

rtl8xxxu_c2hcmd_callback() drains priv->c2hcmd_queue but only frees a single skb at the end, leaking
every dequeued skb except the last. This will steadily increase kernel memory usage when C2H events
are frequent.
Agent Prompt
### Issue description
`rtl8xxxu_c2hcmd_callback()` dequeues potentially multiple SKBs from `priv->c2hcmd_queue`, but only calls `dev_kfree_skb(skb)` once after the loop. This leaks SKBs.

### Issue Context
This is a kernel driver; leaking SKBs in an event path can create sustained memory growth.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5538-5592]

### What to change
- Change the loop to dequeue-and-process in a way that frees **each** dequeued skb exactly once, e.g.:
  - `while ((skb = skb_dequeue(&priv->c2hcmd_queue)) != NULL) { ...; dev_kfree_skb(skb); }`
- Ensure `skb` is not double-freed on exit paths (set to `NULL` after freeing if keeping an `out:` label).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +6634 to +6637
cancel_delayed_work_sync(&priv->ra_watchdog);

rtl8xxxu_free_rx_resources(priv);
rtl8xxxu_free_tx_resources(priv);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

2. Stop workqueue race 🐞 Bug ☼ Reliability

rtl8xxxu_stop() frees RX/TX resources after setting shutdown, but it does not cancel/flush rx_urb_wq
(and c2hcmd_work), so already-queued work can still run and submit URBs or touch driver state after
teardown. This can cause use-after-free, re-arming URBs after stop, or crashes on disconnect.
Agent Prompt
### Issue description
`rtl8xxxu_stop()` sets `priv->shutdown = true`, kills anchored URBs, and then frees RX/TX resources, but it does not synchronously cancel/flush work items that can still run (`rx_urb_wq`, `c2hcmd_work`). `rtl8xxxu_rx_urb_work()` also does not check `priv->shutdown` before resubmitting URBs.

### Issue Context
- `rtl8xxxu_queue_rx_urb()` schedules `rx_urb_wq`.
- `rtl8xxxu_rx_urb_work()` resubmits URBs.
- `rtl8723bu_handle_c2h()` schedules `c2hcmd_work`.
- `rtl8xxxu_stop()` frees resources without canceling those works.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5261-5328]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[5538-5641]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[6605-6638]

### What to change
- In `rtl8xxxu_stop()` (before freeing RX/TX resources):
  - `cancel_work_sync(&priv->rx_urb_wq);`
  - `cancel_work_sync(&priv->c2hcmd_work);`
  - purge `priv->c2hcmd_queue` (dequeue + `dev_kfree_skb()` until empty).
- Add a shutdown guard in `rtl8xxxu_rx_urb_work()` to avoid resubmitting URBs if `priv->shutdown` became true (free the URB/SKB instead).
- Ensure ordering: prevent new scheduling first (set shutdown), then cancel work, then kill URBs, then free resources.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +38 to +41
int rtl8xxxu_debug = RTL8XXXU_DEBUG_EFUSE;
static bool rtl8xxxu_ht40_2g;
static bool rtl8xxxu_dma_aggregation;
static int rtl8xxxu_dma_agg_timeout = -1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

3. Efuse debug default enabled 🐞 Bug ◔ Observability

rtl8xxxu_debug defaults to RTL8XXXU_DEBUG_EFUSE, and rtl8188fu_parse_efuse() dumps raw efuse content
via dev_info when that flag is set. This will spam kernel logs on every probe by default and can
expose device-specific values (e.g., calibration data/MAC-related fields) unnecessarily.
Agent Prompt
### Issue description
The module debug mask is initialized to `RTL8XXXU_DEBUG_EFUSE`, which enables verbose EFUSE dumping at `dev_info()` level during normal operation.

### Issue Context
`rtl8188fu_parse_efuse()` prints the EFUSE dump when the EFUSE debug bit is enabled.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[36-42]
- general/package/rtl8xxxu-openipc/src/rtl8xxxu_8188f.c[716-749]

### What to change
- Change the default to `int rtl8xxxu_debug = 0;` (or another non-verbose default).
- Keep EFUSE dumping behind the module param so it is only enabled intentionally.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +7 to +10
Mainline rtl8xxxu mac80211 driver (RTL8188F backport to
kernel 3.4.43). Replaces the vendor rtl8188fu driver and
fixes the WPA2 4-way handshake failure seen with the
vendor driver on the GK7102.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

4. No vendor-driver exclusion 🐞 Bug ⚙ Maintainability

The new rtl8xxxu-openipc package help text says it replaces the vendor rtl8188fu driver, but
Buildroot allows enabling both rtl8188fu-openipc and rtl8xxxu-openipc simultaneously. This creates
an inconsistent configuration where two competing solutions for the same chipset can be built into
the image.
Agent Prompt
### Issue description
`rtl8xxxu-openipc` is described as replacing the vendor `rtl8188fu` driver, but nothing in Kconfig prevents selecting both packages.

### Issue Context
Both packages are present in `general/package/Config.in`, so they are independently selectable.

### Fix Focus Areas
- general/package/rtl8xxxu-openipc/Config.in[1-10]
- general/package/rtl8188fu-openipc/Config.in[1-4]
- general/package/Config.in[91-95]

### What to change
- Add a dependency to prevent simultaneous selection, e.g. in `rtl8xxxu-openipc/Config.in`:
  - `depends on !BR2_PACKAGE_RTL8188FU_OPENIPC`
  - and/or add a reciprocal comment in the vendor driver config.
- Alternatively, document and enforce which one should be used via a `choice` block if that matches project conventions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@widgetii

Copy link
Copy Markdown
Member

This thread is closed as no response has been received

@widgetii widgetii closed this Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants