Skip to content

gk7102: rtl8xxxu Wi-Fi + -mno-unaligned-access - #2256

Closed
shipa-2 wants to merge 5 commits into
OpenIPC:masterfrom
shipa-2:gk7102-wifi-rtl8xxxu
Closed

gk7102: rtl8xxxu Wi-Fi + -mno-unaligned-access#2256
shipa-2 wants to merge 5 commits into
OpenIPC:masterfrom
shipa-2:gk7102-wifi-rtl8xxxu

Conversation

@shipa-2

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

Copy link
Copy Markdown

Summary

  • Add rtl8xxxu-openipc (RTL8188FTV / 0bda:f179) with RCR_APPEND_FCS so RX FCS stripping does not corrupt EAPOL
  • Add rtl8188fufw.bin to linux-firmware-openipc
  • Enable on gk7102_lite / gk7102s_lite: overlay rtl8xxxu-gk7102 (GPIO9), WPA crypto options, BR2_TARGET_OPTIMIZATION="-mno-unaligned-access"
  • Fix mbedtls-openipc configure on newer host CMake (CMAKE_POLICY_VERSION_MINIMUM=3.5)

Toolchain note

BR2_TARGET_OPTIMIZATION alone is not enough while packages use the prebuilt external SDK: rebuild/publish toolchain.goke-gk710x.tgz with the same flag (make BOARD=gk7102_lite toolchain, or temporarily comment out BR2_TOOLCHAIN_EXTERNAL*), and drop musl src/string/arm/memcpy.S so libc does not use unaligned LDR/STR. With that SDK, Wi-Fi + SSH work without wpa/Dropbear alignment workarounds.

Test plan

  • Flash gk7102_lite uImage + rootfs
  • wlandev=rtl8xxxu-gk7102, WPA2 connect, DHCP, outbound network
  • SSH login without Dropbear byte-copy workaround

Made with Cursor

shipa-2 and others added 4 commits August 11, 2026 21:59
Backport mainline rtl8xxxu for older Goke kernels and set RCR_APPEND_FCS
so firmware RX trimming drops FCS instead of payload bytes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Provide rtl8188fufw.bin for RTL8188FTV (0bda:f179) used on GK7102 boards.

Co-authored-by: Cursor <cursoragent@cursor.com>
Switch boards to rtl8xxxu + RTL8188FU firmware, enable WPA crypto options,
GPIO9 Wi-Fi power in the usb overlay, and -mno-unaligned-access for the
ARMv6 userspace corruption seen on some GK710x boards.

Co-authored-by: Cursor <cursoragent@cursor.com>
Pass CMAKE_POLICY_VERSION_MINIMUM=3.5 so the package configures with
current host CMake releases.

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

Copy link
Copy Markdown

PR Summary by Qodo

GK7102: enable rtl8xxxu (RTL8188FTV) Wi‑Fi + unaligned-access workaround

✨ Enhancement 🐞 Bug fix ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add a backported mac80211 rtl8xxxu module for RTL8188FTV (0bda:f179) on 3.4.43.
• Install RTL8188FU firmware and switch GK7102/GK7102S Lite to new Wi‑Fi overlay.
• Enable WPA kernel crypto and -mno-unaligned-access to prevent userspace corruption.
Diagram

graph TD
  A["gk7102(_s)_lite defconfig"] --> B["rtl8xxxu-openipc pkg"] --> C["rtl8xxxu.ko module"] --> D["/etc/wireless/usb"] --> E["modprobe rtl8xxxu"]
  B --> F[("rtl8188fufw.bin")]
  A --> G["Kernel crypto opts"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep vendor 8188fu driver + targeted RX/FCS workaround
  • ➕ Smaller change; avoids maintaining a large upstream backport
  • ➕ Lower regression risk outside the WPA/EAPOL path
  • ➖ Vendor driver behavior issues may persist (WPA2 handshake failures cited)
  • ➖ Workarounds can be brittle across firmware/board variants
2. Upgrade to a kernel with in-tree rtl8xxxu (avoid backport)
  • ➕ Eliminates long-term maintenance of a private driver backport
  • ➕ Gets upstream mac80211/driver fixes and security updates
  • ➖ Much larger platform change on GK710x BSPs
  • ➖ Higher integration and peripheral validation effort
3. Bake -mno-unaligned-access into the external SDK toolchain + libc
  • ➕ Makes the alignment fix consistent when using the external SDK
  • ➕ Reduces reintroductions via prebuilt components
  • ➖ Requires rebuilding/publishing the SDK; impacts all users of that toolchain
  • ➖ Potential performance impact vs permitting unaligned accesses

Recommendation: The PR’s strategy is sound for near-term stability: switching to a mainline-derived mac80211 rtl8xxxu backport addresses the reported WPA2 handshake failures, and explicitly setting RCR_APPEND_FCS targets the RX FCS-trimming corruption described for EAPOL. The main downside is the long-term maintenance cost of a large backport; if feasible, plan a kernel upgrade path longer term. Also treat -mno-unaligned-access as a toolchain-wide requirement when the external SDK is in play, otherwise the mitigation may be incomplete.

Files changed (18) +11947 / -13

Enhancement (11) +11921 / -2
usbAdd GK7102/GK7102S Wi‑Fi overlay entries (GPIO9 power/reset) +17/-1

Add GK7102/GK7102S Wi‑Fi overlay entries (GPIO9 power/reset)

• Adds GK7102-specific options that toggle GPIO9 and load either the legacy 8188fu module or the new mac80211 rtl8xxxu module.

general/overlay/etc/wireless/usb

ircut_demoAdd GK7102/GK7102S GPIO mapping for IR-cut demo script +11/-1

Add GK7102/GK7102S GPIO mapping for IR-cut demo script

• Documents GK7102/GK7102S GPIO usage and adds chip selection mapping to GPIO44/GPIO39 for IR-cut control.

general/package/goke-osdrv-gk710x/files/script/ircut_demo

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

Install rtl8188fufw.bin under /lib/firmware/rtlwifi

• Adds a gated install step that creates /lib/firmware/rtlwifi and installs rtl8188fufw.bin when the RTL8188FU option is enabled.

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

Config.inDefine rtl8xxxu-openipc package (mac80211 backport) +9/-0

Define rtl8xxxu-openipc package (mac80211 backport)

• Introduces a Buildroot package for a mainline rtl8xxxu backport targeting kernel 3.4.43, selecting RTL8188FU firmware and documenting the WPA2 handshake motivation.

general/package/rtl8xxxu-openipc/Config.in

rtl8xxxu-openipc.mkBuildroot kernel-module packaging for rtl8xxxu backport +21/-0

Buildroot kernel-module packaging for rtl8xxxu backport

• Implements a local-source kernel-module package, passing kernel version and source dir via KVER/KSRC.

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

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

Add Kbuild Makefile for out-of-tree rtl8xxxu.ko build

• Defines obj-m and object list for rtl8xxxu_core.o and rtl8xxxu_8188f.o for Buildroot’s kernel-module infrastructure.

general/package/rtl8xxxu-openipc/src/Makefile

rtl8xxxu.hAdd rtl8xxxu driver header (structures/constants) +1628/-0

Add rtl8xxxu driver header (structures/constants)

• Adds the primary rtl8xxxu header used across the backported driver implementation.

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

rtl8xxxu_8188f.cAdd RTL8188F/8188FU chip support implementation +1766/-0

Add RTL8188F/8188FU chip support implementation

• Introduces the RTL8188F-family implementation used by the backported rtl8xxxu driver for RTL8188FU/FTV devices.

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

rtl8xxxu_compat.hAdd compatibility layer for kernel 3.4.43 APIs +234/-0

Add compatibility layer for kernel 3.4.43 APIs

• Provides kernel-version compatibility shims so the mainline-derived rtl8xxxu code builds on the older GK710x kernel.

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

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

Add rtl8xxxu mac80211 USB driver core (RTL8188FU-only table)

• Adds the core rtl8xxxu driver backport and restricts the USB ID table to 0bda:f179 with RTL8188FU fops. Sets RCR_APPEND_FCS to prevent RX FCS handling from corrupting EAPOL payloads during WPA handshake.

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

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

Add rtl8xxxu register/bitfield definitions (incl. RCR_APPEND_FCS)

• Introduces the register map and bit definitions used by the rtl8xxxu backport, including the RCR_APPEND_FCS bit.

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

Bug fix (1) +2 / -1
mbedtls-openipc.mkFix mbedTLS configure with modern host CMake +2/-1

Fix mbedTLS configure with modern host CMake

• Adds -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to avoid CMake policy-related configure failures.

general/package/mbedtls-openipc/mbedtls-openipc.mk

Other (6) +24 / -10
gk710x.generic.configEnable WPA-required kernel crypto primitives +4/-4

Enable WPA-required kernel crypto primitives

• Enables CCM, CTR, SEQIV, and SHA256 in the GK710x kernel config to satisfy WPA/WPA2 algorithm requirements.

br-ext-chip-goke/board/gk710x/gk710x.generic.config

gk710xs.generic.configEnable WPA-required kernel crypto primitives (GK710XS) +4/-4

Enable WPA-required kernel crypto primitives (GK710XS)

• Applies the same CCM/CTR/SEQIV/SHA256 enables for GK710XS to support WPA/WPA2.

br-ext-chip-goke/board/gk710x/gk710xs.generic.config

gk7102_lite_defconfigEnable rtl8xxxu Wi‑Fi path and -mno-unaligned-access (GK7102 Lite) +5/-1

Enable rtl8xxxu Wi‑Fi path and -mno-unaligned-access (GK7102 Lite)

• Adds BR2_TARGET_OPTIMIZATION=-mno-unaligned-access, enables wpa_supplicant WEXT, selects RTL8188FU firmware, and enables the rtl8xxxu-openipc package.

br-ext-chip-goke/configs/gk7102_lite_defconfig

gk7102s_lite_defconfigEnable rtl8xxxu Wi‑Fi path and -mno-unaligned-access (GK7102S Lite) +5/-1

Enable rtl8xxxu Wi‑Fi path and -mno-unaligned-access (GK7102S Lite)

• Mirrors the GK7102 Lite settings: -mno-unaligned-access, wpa_supplicant WEXT, RTL8188FU firmware, and rtl8xxxu-openipc.

br-ext-chip-goke/configs/gk7102s_lite_defconfig

Config.inExpose rtl8xxxu-openipc package in Buildroot menus +1/-0

Expose rtl8xxxu-openipc package in Buildroot menus

• Registers the new rtl8xxxu-openipc package Config.in in the external tree.

general/package/Config.in

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

Add selectable RTL8188FU firmware option

• Adds BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU to control installing RTL8188FU/RTL8188FTV firmware.

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

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

qodo-free-for-open-source-projects Bot commented Aug 11, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Firmware select misses parent ✓ Resolved 🐞 Bug ≡ Correctness
Description
rtl8xxxu-openipc selects BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU without selecting
BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC, so enabling rtl8xxxu-openipc alone can result in
rtlwifi/rtl8188fufw.bin not being installed and the kernel module failing to load firmware at
runtime.
Code

general/package/rtl8xxxu-openipc/Config.in[R3-4]

+	depends on BR2_LINUX_KERNEL
+	select BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU
Evidence
The rtl8xxxu-openipc package only selects the firmware sub-option, but the firmware option is
defined under an if BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC block and the installation logic for
rtl8188fufw.bin lives in linux-firmware-openipc.mk, which only runs when the parent firmware package
is enabled. The driver declares it needs rtlwifi/rtl8188fufw.bin, so missing installation leads to
runtime firmware load failures.

general/package/rtl8xxxu-openipc/Config.in[1-9]
general/package/linux-firmware-openipc/Config.in[1-41]
general/package/linux-firmware-openipc/linux-firmware-openipc.mk[27-54]
general/package/rtl8xxxu-openipc/src/rtl8xxxu_core.c[44-57]

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

## Issue description
`general/package/rtl8xxxu-openipc/Config.in` selects `BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC_RTL_8188FU` but does not enable/select `BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC`. Since the firmware sub-options are gated under `if BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC`, configurations that enable `rtl8xxxu-openipc` without also enabling `linux-firmware-openipc` will not install `rtlwifi/rtl8188fufw.bin`, and the driver can fail at runtime due to missing firmware.
### Issue Context
- `linux-firmware-openipc` is the package that actually installs firmware files into `$(TARGET_DIR)`.
- The rtl8xxxu driver declares/requests `rtlwifi/rtl8188fufw.bin`.
### Fix Focus Areas
- general/package/rtl8xxxu-openipc/Config.in[1-6]
- Add `select BR2_PACKAGE_LINUX_FIRMWARE_OPENIPC` (or change to `depends on`), so selecting the driver guarantees the firmware package is built.
- Keep selecting the specific `..._RTL_8188FU` sub-option as needed.

ⓘ 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 thread general/package/rtl8xxxu-openipc/Config.in
Selecting only RTL_8188FU left the parent package unset, so the firmware
blob could be missing when rtl8xxxu-openipc is enabled alone.

Co-authored-by: Cursor <cursoragent@cursor.com>
@flyrouter

flyrouter commented Aug 11, 2026

Copy link
Copy Markdown
Member

Good afternoon

Thank you for your interest in our project and for the corrections you sent.

Unfortunately, we can't accept them in a single PR because it goes against our basic step-by-step principles: you're simultaneously making changes to the toolchain configuration with specific options, modifying the kernel configs, adding a new RTL driver package, editing the core mbedtls package, and altering third-party files which aren't meant to be edited....

The proposed PR is on hold until it is split into parts and discussed.

@flyrouter flyrouter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Split into several themes

@shipa-2

shipa-2 commented Aug 11, 2026

Copy link
Copy Markdown
Author

Split per review feedback into separate PRs:

Board enablement / builder Wi-Fi profile are follow-ups. This PR can stay closed or superseded.

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