[RPi2B] Invalid Key/WiFi issues with USB dongle

  • I've set up LibreELEC 12.0.2 on a RaspberryPi 2B (which has no onboard WiFi) with a USB WiFi dongle (Edimax EW-7811Un) for my grandparents.

    The Pi connects to a Jellyfin server via OpenVPN, and when it works, it works great - however it sadly does not work often as the WiFi connection frequently breaks.

    Similar to other threads I experience the same "Invalid Key" error.

    I've written (and continuously expanded) this script to check and fix the WiFi and VPN connection which gets executed every 5m via cron:

    The output of that looks something like this (in the most extreme cases)

    As you can see, connmanctl scan wifi and a subsequent systemctl restart connman do not always fix the issue, only rebooting does in this case.

    I've also seen various mentions about this issue being related to poor reception (with the suggestion to use a USB dongle - which I already do) and that moving the WiFi client closer to the access point helped. While I don't want to dismiss that outright, I am rather skeptical that this is (purely) related to range/reception issues because I've seen all of below:

    • when the connection is present the dB value is "good" and it's fast enough to stream HD movies (~30 Mbit/s in my case)
    • sometimes suddenly no WiFi networks are found and 5-10m later everything is back to normal
    • sometimes WiFi networks from further away are found, but not the closer "target WiFI"
    • no other clients experience connection issues
    • mentions of it working in previous LE versions (where wpa_supplicant was used)
    • mentions of the same hardware working fine under RaspberryPi OS (and others)


    I've found that in another thread iwctl was used to do the reconnect. Is there any (significant) difference between the iwctl and connmanctl?

    Is there anything I can (still) do to improve the WiFi reliability except for buying something like this?

    For now I am looking for a quickish solution to make my grandparents happy, but in the long run I am eager to help debug/improve the issue. Although I think it makes more sense to continue this thread instead.

    Thanks in advance for all the help!

  • Start with updating to an LE13 nightly. There are newer versions of drivers and other wireless plumbing so the first step is to see if anything improves or changes.

  • Start with updating to an LE13 nightly. There are newer versions of drivers and other wireless plumbing so the first step is to see if anything improves or changes.

    Can I update directly from within LibreELEC without reinstalling?
    If so: How?
    If not: Should I just use the latest nightly image, or are there ones that are considered "more stable" than the others? I'd like to avoid introducing new/other issues if possible.

  • As the saying goes: "past performance does not guarantee future performance" but I've been running LE13 nightlies for a year or more (albeit on an RPi5 not RPi2) without drama.

    Download the relevant nightly file to /storage/.update and reboot. If you want to hedge your bets take a backup first as Kodi only handles upgrades not downgrades.

  • Download the relevant nightly file to /storage/.update

    Is "the relevant nightly file" simply the latest img.gz from here? Also do I need to decompress it first?

    I probably won't be able to try it out until Sunday, but I’ll let you know if anything changes (in regards to WiFi) once I do.

    One thought/question: I am using the Estuary MOD V2 skin, do you happen to know if that breaks with LE 13?
    I'll take a backup just to be sure, but it would be good to know beforehand if that skin will break.

    While I have your attention: Is there a way to disable the connected TV from being controlled by the Pi via CEC? Currently the TV sometimes turns (and stays) on in the middle of the night, when the Pi reboots because of my script. I've looked into the settings of the CEC adapter addon, but perhaps I've not found the right knob yet.

    Thanks for all the help so far!

  • I probably won't be able to try it out until Sunday,

    I just got back, here's a quick update:

    Hi,

    Re PI / TV see 15227-tv-turns-on-by-itself it may help

    Thanks! Turns out, I missed the second part (Devices to power on during startup) when I initially looked through the menu. Setting it to none did do the trick - the TV no longer turns on by itself.

    I also tried out the latest nightly build (LibreELEC-RPi2.arm-13.0-nightly-20250426-07a8ef5). The update itself was successful, but I had to downgrade again, because even after multiple reboots the Pi unfortunately did not establish a WiFi connection (and the associated menu in the settings was just empty).

    I also did not have an Ethernet cable for SSH - or other means to open a terminal - at hand, so I wasn't able to diagnose the issue further. The only thing I saw was

    Code
    LibreELEC (community): nightly-20250426-07a8ef5
    waiting on Network to come online...
    [FAILED] Failed to start network-online.service.
    [DEPEND] Dependency failed for openvpn.service.

    during boot before Kodi started.

    Note that both "the associated menu in the settings was just empty" and the above output during startup are usual symptoms under LE 12, when WiFi does not work. Usually it is fixed by a few reboots though - which did not seem to help with LE 13.

    I have the same hardware (same Pi2 and WiFi Dongle) lying around somewhere. If I find them (and some time) I'll try to replicate the failing setup at (my) home for better debugging.

  • Oh also the Enigma2 Client plugin does get disabled under LE 13 because it is incompatible. I suspect it's not actually incompatible, but just marked as such (or only marked to be compatible with LE 12). But that's a smaller secondary issue I noticed with LE 13, as the Pi mainly is used as a Jellyfin client and not for watching TV (that is done with the actual TV itself).

  • Unfortunately the issue is still present.

    I will install a second (identical) Pi with the latest nightly image (2026-02-06) over the weekend to see if the issue also occurs there. I'll report back once I have found out something new

  • As a preparation for tomorrow, I've restored an old backup and updated that to the latest nightly image.

    If I try to connect to WiFi via the GUI I get a generic "Connection timeout" error message.

    If I connect via connmanctl (via SSH) the connection is a little more successful, but I only get a link local IPv4 address (169.254. ...) -- seems like DHCP is broken in the nightly image (?)

  • chewitt (sorry for pinging you directly) Over in this thread, you've mentioned

    Quote

    The challenge is/remains: finding people with the code diagnostics skills to triage the issue, who can also replicate the issue.

    I'm certainly no expert when it comes to LibreELEC, but I have a fair share of 'code diagnostics skills' and spare hardware that will (very likely) be able to reproduce the error. I also don't mind building and testing custom images (and from a quick look at the GitHub repo and build documentation I think doing so in docker should be relatively straightforward).

    What would be a good starting point to help diagnose this issue? In another thread  frakkin64 (again, sorry for the ping) mentioned

    Quote

    The log files are not going to be useful; they will indicate what you already know, and others have posted them already. If you want to know more then you need to re-compile the kernel with mac80211 & MLME debug on, turn on persistent logs, and reproduce the problem.

    Is that the right approach in your opinion?

    Please also tell me if I should rather open up another thread or if you think there is a better place to discuss this issue (e.g. instant messaging, emails, ...) -- although for SEO reasons it's probably best to keep discussion within the forum.

  • Reading through
    https://github.com/pvaret/rtl8192cu-fixes and
    https://www.linuxquestions.org/questions/linux-networking-3/poor-network-performance-with-rtl8xxxu-module-compared-to-rtl8192cu-rtl8192cu-also-behaves-strangely-rtl8188cus-4175735253/

    I just found out that there are two different kernel modules for my dongle called rtl8xxxu and rtl8192cu (the older one). From the second link it appears like kernel version 6.9.x (which LE 12.0.2 does not yet use) fixed some issues for OP of that thread.

    I will try to see how LibreELEC 12.2 (which uses kernel 6.12.x) compares.

  • I'd be interested to see if this patch resolves the invalid-key issue: https://patchwork.kernel.org/project/connma…[email protected]/ .. as the title of the patch sounds promising but the author of the patch has provided zero info on the issue being fixed so that might be a coincidence. If you want to self-build an image to test, this is the change required: https://github.com/chewitt/LibreE…d93d6047769fb94. If you have an RPi5 board this LE13 image contains the patch: https://chewitt.libreelec.tv/testing/LibreE…-12.90.1.img.gz. NB: LE13 nightlies will have newer kernels and latest/correct drivers for the wireless chipset that you're using so I wouldn't bother triaging with LE12/12.2 images.

  • I've also seen various mentions about this issue being related to poor reception (with the suggestion to use a USB dongle - which I already do) and that moving the WiFi client closer to the access point helped.

    The "suggestion to use a USB dongle" was for one with a "normal size" wifi antenna, and not for a "cherry seed size" dongle like the Edimax EW-7811Un is. The "microscopic" antenna could explain the wifi instability like in your case: "sometimes suddenly no WiFi networks are found and 5-10m later everything is back to normal". If you want better and stable wifi you should try something with a better antenna (with the classic 10 cm long antenna). Or if have a possibility, use lan cable and you will forget the all network issues.

  • If you want better and stable wifi you should try something with a better antenna (with the classic 10 cm long antenna). Or if have a possibility, use lan cable and you will forget the all network issues.

    Unfortunately a cable is no option. I have thought about Powerline, but I'd have to buy adapters, and at that point I'd probably just buy a newer Pi. I do in fact also have a "better" dongle (EW-7612UAn) which I want to try out in addition to deploying the second Pi.

    However, I think that there still is some software/driver issue going on as I remember the dongle working without issues when I used it under Raspbian 10+ years ago. Also from reading this forum, the Invalid Key errors started appearing with the switch from wpa_supplicant to iwd.

  • I'd be interested to see if this patch resolves the invalid-key issue: https://patchwork.kernel.org/project/connma…[email protected]/

    Sounds interesting indeed, I'll try to build a image with that for my RPi2 soon.

    NB: LE13 nightlies will have newer kernels and latest/correct drivers for the wireless chipset that you're using so I wouldn't bother triaging with LE12/12.2 images.

    As mentioned above, DHCP does not seem to work via WiFi in LE13 nightlies (at least the latest one 20260206-e536135). I only get a link local address.

    Update: DHCP over WiFi also seems broken with 12.2.1, on 12.0.2 it works

    I have enabled connman debug logging with

    Shell session
    LibreELEC-DEBUG:~ # cat /run/libreelec/debug/connman.conf
    CONNMAN_DEBUG="-d"

    under the latest nightly build and have attached (connman.debug.log) what was logged via journalctl -u connman during connection with the commands

    Shell session
    LibreELEC-DEBUG:~ # connmanctl
    connmanctl> agent on
    Agent registered
    connmanctl> scan wifi
    Scan completed for wifi
    connmanctl> services
    ...
    connmanctl> connect wifi_74da38542906_496f54_managed_psk

    Quick update: The invalid key issue just occurred under LE13 nightly. The output of connman services only showed my wired connection and nothing else.

    Code
    LibreELEC-DEBUG:~ # iw wlan0 station dump
    LibreELEC-DEBUG:~ # connmanctl services
    *AO Wired                ethernet_b827ebf67288_cable
    LibreELEC-DEBUG:~ # connmanctl scan wifi
    Scan completed for wifi
    LibreELEC-DEBUG:~ # connmanctl services
    *AO Wired                ethernet_b827ebf67288_cable

    After reconnecting the dongle I can see WiFi services again and connecting works as well as before (no DHCP, LL address only)

    Edited once, last by GamerBene19: Merged a post created by GamerBene19 into this post. (February 7, 2026 at 3:09 PM).

  • However, I think that there still is some software/driver issue going on as I remember the dongle working without issues when I used it under Raspbian 10+ years ago. Also from reading this forum, the Invalid Key errors started appearing with the switch from wpa_supplicant to iwd.

    Probably is there a software issue (iwd or connman?) too, but probably it's more intense with a weak and unstable signal. I have a RPi3B with wifi connection (and other two with cable). I had a very same wifi issue when tried with the built-in wifi. I managed to make the modification on the RPi to be able to connect an external antenna. After that I didn't had problem with the wifi. Everything remains the same, the only thing was changed, the tiny RPi's antenna was replaced with a "real" one. Try it with the EW-7612UAn, with the better antenna (and if the LE have the driver for it), could be enough... Another thing that could help a bit, if you didn't tried yet, try to check the usage of the wifi channels. Usually the routers have option for channel analyzis (or with a phone and wifi analyzer app), and try set for your wifi to a free channel, to not interfere with other sources.