Skip to content

wireless: Reolink E340 (NT98566, RTL8812CU on USB) - #3047

Closed
andrein wants to merge 1 commit into
OpenIPC:masterfrom
andrein:wireless-reolink-e340
Closed

andrein wants to merge 1 commit into
OpenIPC:masterfrom
andrein:wireless-reolink-e340

Conversation

@andrein

@andrein andrein commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Adds the rtl88x2cu-nt98566-reolink-e340 profile for the 5MP Reolink E340 (hardware IPC_566SD664M5MP). Its RTL8812CU Wi-Fi module is on USB and powered from GPIO 133, which the board's U-Boot drives low at boot; the profile raises it and loads 88x2cu.

Needs #3046 for the driver and #3038 for the USB host. The device that sets this profile is OpenIPC/builder#287.

Testing

On the E340 with wlandev=rtl88x2cu-nt98566-reolink-e340: GPIO 133 goes high, the module enumerates as 0bda:c812, 88x2cu loads, and wlan0 joins the network through wlanssid/wlanpass. With the driver from #3046, ping to the AP p50 2.4 ms.

🤖 Generated with Claude Code

https://claude.ai/code/session_014QxEtXGgQaLqvbmbYcd2ZC

The module is powered from GPIO 133, which the board's U-Boot drives
low at boot. The driver is rtl88x2cu-openipc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014QxEtXGgQaLqvbmbYcd2ZC
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

wireless: Add Reolink E340 RTL8812CU USB Wi-Fi profile (NT98566)

✨ Enhancement ⚙️ Configuration changes 🕐 Less than 5 minutes

Grey Divider

AI Description

• Adds rtl88x2cu-nt98566-reolink-e340 wireless profile to the USB Wi-Fi init script.
• Drives GPIO 133 high to power the RTL8812CU module that U-Boot leaves low.
• Loads the 88x2cu kernel module, then exits before the generic device handling.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 1 capability

  • 1 affected end-to-end capability after fault-specific containment; implementation boundaries do not widen its functional scope.
  • The changed branch combines board power sequencing and driver initialization for one end-to-end E340 wireless connectivity behavior.
  • No separate consumer behavior or independent functional scope was found.
Sources

general/overlay/etc/wireless/usb[240-246]

# NT98566 Reolink E340: an RTL8812CU on USB, powered from GPIO 133, which the
# board's U-Boot drives low at boot
if [ "$1" = "rtl88x2cu-nt98566-reolink-e340" ]; then
	set_gpio 133 1
	modprobe 88x2cu
	exit 0
fi
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before, this profile had no E340-specific initialization.
  • After, one exact profile match performs GPIO enablement followed by module loading.
  • The new correctness condition is that the profile, GPIO polarity and module name all match the target board; no new interacting state machine or algorithm is introduced.
Sources

general/overlay/etc/wireless/usb[240-246]

# NT98566 Reolink E340: an RTL8812CU on USB, powered from GPIO 133, which the
# board's U-Boot drives low at boot
if [ "$1" = "rtl88x2cu-nt98566-reolink-e340" ]; then
	set_gpio 133 1
	modprobe 88x2cu
	exit 0
fi
Potential damage 🟡 Medium 🩹 Temporary loss

  • If GPIO activation or driver loading fails, the E340 may lose USB Wi-Fi connectivity.
  • Reverting the script stops future failures, but the active interface may require restarting networking or rebooting.
  • Code revert restores the prior behavior; recovery of an already failed boot requires rerunning initialization or rebooting, with no automatic repair path shown.
Sources

general/overlay/etc/wireless/usb[240-246]

# NT98566 Reolink E340: an RTL8812CU on USB, powered from GPIO 133, which the
# board's U-Boot drives low at boot
if [ "$1" = "rtl88x2cu-nt98566-reolink-e340" ]; then
	set_gpio 133 1
	modprobe 88x2cu
	exit 0
fi
Assessed commit be7d17f
Diagram

graph TD
  UB["U-Boot: GPIO 133 low"] --> WS["wireless/usb script"] --> GP["set_gpio 133 1"] --> MP["modprobe 88x2cu"] --> HW["RTL8812CU 0bda:c812"] --> IF["wlan0 joins AP"]
Loading
High-Level Assessment

Keeping the per-device if-block pattern used by neighboring profiles is the right choice for this script. It matches existing entries such as rtl8188fu-ssc325de-imou-c22ep-s2 and keeps the change to eight lines. A table-driven lookup (profile to GPIO and module) would be cleaner long-term, but it would be a refactor across all profiles and does not belong in this PR.

Files changed (1) +8 / -0

Enhancement (1) +8 / -0
usbAdd NT98566 Reolink E340 RTL8812CU profile branch +8/-0

Add NT98566 Reolink E340 RTL8812CU profile branch

• Adds an if-block for rtl88x2cu-nt98566-reolink-e340 that sets GPIO 133 high, loads the 88x2cu module, and exits. The branch sits before the SSC325DE entry and follows the existing per-device pattern. The comment notes that U-Boot drives GPIO 133 low at boot.

general/overlay/etc/wireless/usb

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. E340 Wi-Fi setup ships in every image 📘 Rule violation ⚙ Maintainability
Description
The shared general/overlay/etc/wireless/usb dispatcher contains an E340-only
rtl88x2cu-nt98566-reolink-e340 arm that sets GPIO 133 high and loads 88x2cu instead of keeping
those steps in the E340 builder overlay. Because S40network uses this dispatcher across boards,
every image ships the arm, although its exact profile match prevents other boards from running it by
default.
Code

general/overlay/etc/wireless/usb[R242-245]

+if [ "$1" = "rtl88x2cu-nt98566-reolink-e340" ]; then
+	set_gpio 133 1
+	modprobe 88x2cu
+	exit 0
Evidence
The added arm matches the E340 profile and contains the GPIO and driver-loading steps, while
S40network invokes the shared dispatcher using the configured wlandev value. The generic root
filesystem includes that overlay, so the exact match limits execution but not distribution;
repository guidance places new retail-model wireless arms in device-specific builder copies.

general/overlay/etc/wireless/usb[242-245]
general/overlay/etc/init.d/S40network[6-7,33-35]
general/overlay/etc/wireless/usb[240-246]
general/openipc.fragment[5-5]
best_practices.md[156-161]
pr_compliance_checklist.yaml[99-106]
Best Practice: Repository guidelines

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 E340-only Wi-Fi profile (`rtl88x2cu-nt98566-reolink-e340`) was added to the shared wireless USB dispatcher, causing every image to ship its GPIO 133 power-up and `88x2cu` driver-loading arm even though the exact profile match limits when it runs.

## Fix Focus Areas
- general/overlay/etc/wireless/usb[240-248]

## Recommended Fix
Remove the E340 arm from the shared script. Put the GPIO 133 power-up and `modprobe 88x2cu` steps in OpenIPC/builder for the E340 device, such as its device-specific wireless USB script or a board-specific package or script selected by its configuration, and coordinate that placement with the device-profile change.

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



Remediation recommended

2. Radio startup failure skips wired fallback 🐞 Bug ☼ Reliability
Description
The E340 arm calls set_gpio and modprobe 88x2cu but unconditionally exits successfully, while
set_gpio itself finishes with sleep rather than the GPIO command's status. If power setup or
module loading fails, S40network treats wireless initialization as successful and takes its Wi-Fi
path instead of its driver-failure wired fallback.
Code

general/overlay/etc/wireless/usb[R243-245]

+	set_gpio 133 1
+	modprobe 88x2cu
+	exit 0
Evidence
The added arm discards both operation results. Network startup uses the USB script's success status
to enter the wireless branch; its driver-failure fallback is reached only when wireless setup
reports failure.

general/overlay/etc/wireless/usb[3-6]
general/overlay/etc/wireless/usb[242-245]
general/overlay/etc/init.d/S40network[32-69]

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 E340 profile reports success even when GPIO power setup or driver loading fails, preventing the network script from taking its wired fallback.

## Fix Focus Areas
- general/overlay/etc/wireless/usb[242-245]
- general/overlay/etc/wireless/usb[3-6]

## Recommended Fix
Make this profile verify that GPIO 133 is driven high and that the module loads; return a nonzero status when either step fails. Do not rely on `set_gpio`'s current return status, because its final `sleep` masks GPIO command failure.

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


Grey Divider

Context sources
Review mode: Auto: ⚖️ Balanced: Shared runtime overlay changes device-specific GPIO and module behavior.

Grey Divider

Tip of the day
💡 Did you know, you can see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@andrein

andrein commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

The other entries in this file end with exit 0 after modprobe as well, and the script's caller does not act on its status; a failed load shows in dmesg and as a missing wlan0. Keeping it consistent with them.

@andrein

andrein commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my earlier reply: S40network does act on the status, and falls back to the cable when the driver does not load. Both points stand, so this entry moves to the E340's own /etc/wireless/usb in OpenIPC/builder#287, where the arm returns modprobe's status. Closing.

@andrein andrein closed this Dec 2, 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.

1 participant