RPi 3B memory leakage using OSMC wifi adapter

Well, the Pi is now – magically, I guess – reconnecting wirelessly after rebooting with the new SD card and fresh installation. Further good news is that memory leakage is apparently much less, perhaps close enough to zero, with the fresh installation. Maybe there’s nothing wrong with the driver, and the problem was some kind of corruption in the previous installation?

I’ll note that I’ve configured my SMB shares and installed iperf3 and crontab.

There are a couple curiosities, at least to me, in the most recent data from free -m and meminfo. To illustrate, here is a graph of available memory for the the period 0330 and 1230 today:

image

Note the relatively sharp decline in available memory at periods 11 and 15 of approximately 20MB and 40MB respectively. These occurred at 0830 and 1030 this morning. To try to understand what was driving these drops in available memory, I compared meminfo at 0830 and 0900 and at 1030 and 1100. Three entries stood out in these files as increasing by about 40MB between 1030 and 1100 this morning: Active(anon), AnonPages, and Committed_AS. Between 0830 and 0900, two entries stood out as increasing by about 20MB: Active(anon) and AnonPages. For this period, Committed_AS increased by only just over 5MB.

In glancing over the data over a broader time range, this appears to be the typical pattern with the new SD card – relatively long periods of almost constant available memory punctuated by relatively short periods where availability decreases. Some of these decreases get partially reclaimed later on, some do not.

The above observations may be perfectly normal given what the system was doing at these times; I don’t know enough to be able to tell. I know we weren’t watching anything at the highlighed times, but, of course, the Pi is never really “idle”, either; e.g., it polls the server every few minutes and appears from the logs to be doing lots of other things as well.

I think my next step might be to take out the nightly reboot and see how long it lasts before it runs out of memory.

As always, I appreciate your thoughts, ideas, and support. Thank you.

I agree. That was the original issue and you now need to see if it still occurs on the new SD card.

Well, the answer is about 5.5 days from reboot to hang.

I guess it turns out the new SD card and fresh installation did not resolve my memory leakage problem. Memory leakage (and I do think it’s leakage) was a relatively constant 4MB per hour over the entire span. Here is a graph of “available” memory from free -m

image

I’m trying a couple other things before I give up. First, I did get my hands on a powered USB hub per the suggestion from @bmillham on another thread. I’ve plugged the OSMC dongle into it to see if that makes any difference. I’ll collect data for a couple days to see if the leakage rate is any different.

Second, I broke down and bought a RPi3B+ including a new power supply. I’ve installed the same version of OSMC on it as I have installed on the 3B with the memory issue. I’ve been running it for 3 days now and it has not leaked any memory at all. Before I switch the 3B out for the 3B+ for daily viewing, I’ll use the new 3B+ power supply on the 3B to see if that affects memory leakage.

If neither the powered hub nor the new power supply makes any difference, then I’m quite confident that the problem lies with the OSMC 5G adapter. That will end up being the only difference – to my nontechnical mind – between the two systems save basic architectural differences between the 3B and the 3B+. I guess that means we should give the new driver a whirl, but I’ll leave that to those who know more than I do.

Edited to add: The powered hub made no difference. Also, I decided against swapping power supplies. I already observed that, when the wifi failed to connect for several hours after a nightly reboot, free memory was flat.

As always, I look forward to any comment or suggestions from the group. Thank you in advance.

That looks like a pretty convincing memory leak. You are to be commended for your persistence in getting to the bottom of the problem.

I see that you relented and bought a Pi 3B+, so I’m not sure if you want to try the 5.10 kernel, which was going to be the next step.

Thanks for the kind words. Sometimes I worry that my persistence ends up looking like nuisance! :smile:

I would like to try the new kernel on the 3B. I’d like to use it in wireless mode from another location in the house.

Thanks again very much for your advice and support!

To get the latest 5.10 kernel:

wget http://ftp.fau.de/osmc/osmc/apt/pool/main/r/rbp2-image-5.10.3-2-osmc/rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb

To install:

sudo dpkg -i rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb

Then reboot. Running uname -r should show the new kernel version.

I did as you advised. After rebooting, wifi failed to connect, so I couldn’t get to the Pi via SSH. I did access OSMC on the connected TV and checked for wifi connectivity. The option to connect via wifi was not there; i.e., MyOSMC>Network displayed the wired, Bluetooth, and MySQL options but not the wireless option. Moreover, the dongle is not flashing. It’s as if the dongle isn’t there. I tried “pulling the plug” with the same results. Maybe I’m missing something?

Edited to add: I managed to login locally by pressing ESC after Power>Exit and I issued the uname -r command. The result was: 5.10.3-2-osmc

Here is a transcript of my session:

osmc@osmc:~$ wget http://ftp.fau.de/osmc/osmc/apt/pool/main/r/rbp2-image-5.10.3-2-osmc/rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb
--2021-03-21 16:18:38--  http://ftp.fau.de/osmc/osmc/apt/pool/main/r/rbp2-image-5.10.3-2-osmc/rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb
Resolving ftp.fau.de (ftp.fau.de)... 131.188.12.211, 2001:638:a000:1021:21::1
Connecting to ftp.fau.de (ftp.fau.de)|131.188.12.211|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 22700096 (22M) [application/x-debian-package]
Saving to: 'rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb'

rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_ 100%[===============================================================================>]  21.65M  1.11MB/s    in 16s

2021-03-21 16:18:54 (1.34 MB/s) - 'rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb' saved [22700096/22700096]

osmc@osmc:~$ sudo dpkg -i rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb
Selecting previously unselected package rbp2-image-5.10.3-2-osmc.
(Reading database ... 26922 files and directories currently installed.)
Preparing to unpack rbp2-image-5.10.3-2-osmc_5.10.3-2-osmc_armhf.deb ...
Unpacking rbp2-image-5.10.3-2-osmc (5.10.3-2-osmc) ...
Setting up rbp2-image-5.10.3-2-osmc (5.10.3-2-osmc) ...
osmc@osmc:~$shutdown -r now

Hmmm. Perhaps I/we’ve jumped the gun here I seem to recall that the driver was mt7610u but I can’t find it on kernel 5.10.3-1 that I’m running.

Perhaps @sam_nazarko can say whether it should be there.

I’ll stand by for word from @sam_nazarko. I’ve got a working system on the 3B+ right now so I’m not fussed about a snag with the “old” 3B. The thrill of the hunt is upon us! :smile:

Edited to add: I will note that the file /lib/firmware/mt7610u_sta.dat exists on this Pi because I needed to move it there to make the OSMC adapter work with the previous kernel. I don’t know if that’s needed now or, indeed, if it could be interfering with a new driver.

The new driver needs a different firmware file, which can be found here: [package] [base-files-osmc] Add MT7610u firmware for 5.x kernels · osmc/osmc@3e03228 · GitHub.

The new driver doesn’t seem to support the blue LED at this time, from a quick test.

Thank you, @sam_nazarko

I’m not comfortable interacting with github, so I’ll wait for further instructions from @dillthedog . I think you’re saying that I need to replace the firmware file have with the one you reference, but even then, the blue LED won’t flash. If that’s the correct understanding, it’s fine with me. I don’t care about the LED as long as the adapter works.

Thanks very much for your help.

Via SSH, you can run:

sudo mkdir -p /lib/firmware/mediatek
sudo wget https://github.com/osmc/osmc/raw/3e03228b3dce3028ad117d742714bcee2c637a7b/package/base-files-osmc/files/lib/firmware/mediatek/mt7610u.bin -O /lib/firmware/mediatek/mt7610u.bin

and reboot.

Thanks @sam_nazarko

I did as you described and wifi is up. I’m connected to my 5G SSID at about 70 mbits/second. That’s more than adequate for my needs but it is a bit slower than I was experiencing before. I also realize these speeds ebb and flow, so it might go up in time. I may have the Pi – and the dongle – in a “bad” spot, too. Regardless, I don’t see this as a problem, just an observation.

I will monitor memory usage and report back here in a day or two. I’m hopeful we’ll be able to mark this issue solved at that point.

The process of rebooting and reconnecting was a bit more exciting than I expected. Here are the highlights, in case they’re useful:

  • After rebooting and navigating to MyOSMC>Networks, both the wired and wireless adapters were enabled (I was using the wired adapter to access via SSH)
  • All local SSIDs were visiible, both 2.4 and 5G. This was not the case before; only 5G SSIDs were visible using the “old” driver
  • I attempted to connect to my 5G SSID. Configuration process completed with IP address assigned, but “no internet”
  • I backed out of MyOSMC and re-entered MyOSMC>Network. Still “no internet”
  • Navigated to Power>Reboot. Reboot took almost 5 minutes. Something very different than normal was going on
  • When OSMC restarted, got message that addon (NextPVR) could not be loaded. This usually means “no internet”
  • I checked MyOSMC>Network and noticed that status was “Connected” (meaning connected to Internet)
  • Attempted to navigate to My Addons>PVR Addons>NextPVR to disable and then re-enable. In the process, got a “sad face”
  • After sad face reboot, NextPVR internet connection was active and NextPVR loaded normally

Thanks again very much for the great support. @dillthedog , thanks for sticking with me!

1 Like

Apologies to jump in on this thread, but I feel that my question is related.

I’m about to install OSMC on my RPI 2B and use an OSMC Wifi dongle (previously purchased) for network access.

Would it be advisable to update to the 5.10 kernel and download the corresponding driver?

Thank you FrogFan for your effort and work in diagnosing what was happening :slightly_smiling_face:

I haven’t seen other reports of this issue – so you might want to wait until that kernel (which is still experimental) gets more testing and ships with Kodi v19.

1 Like

Perfect. Thanks for that Sam :+1:

Well, after just under 4 days of running since rebooting, a check of available memory suggests that my memory leakage problem is solved with the new (experimental, for now) kernel version. Thanks very much to everyone who assisted with this, especially @sam_nazarko and @dillthedog. It’s been a long slog.

I put together a graph showing how available memory changed over this period with the RPi 3B running 5.10.3-2-osmc (the “new” kernel). For reference, I’ve also included a graph of available memory for the same period with the RPi 3B+ running 4.19.122-2-osmc (the kernel version that shipped with the November release of OSMC).

You’ll note from the graph that, after a period of about two days, available memory settled down and became flat, at about the same amount, for both systems. This make sense to me, since both systems were running essentially the same software and I suspect it takes Linux a bit of time to figure out how much memory it needs (I’m guessing here).

Moreover, it seems quite evident that the onboard wifi adapter with the 3B+ is unaffected by the memory leakage issue I was having with the OSMC 5G adapter.

So, problem solved! Again, thanks very much.

2 Likes