Wifi dongle MT7601U

Description


While struggling with at BT dongles, I am also trying to try experimental Wifi dongle alternative.
I’ve bought the following dongle:
ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter

It does not work and generates mt7601u 1-1:1.0: warning: unsupported eeprom version 0d in dmesg.
Even if mt7601u.bin firmware is in place.

While it works (with the same firmware) on my ubuntu server (Linux mcs 5.13.0-27-generic #29~20.04.1-Ubuntu), it looks like it is not a strictly ModDuoX issue - it does not work on a lot of linux systems as well.

As far as I can see from the driver sources, driver throws this issue when checking eeprom version here:

if (eeprom[MT_EE_VERSION_EE] > MT7601U_EE_MAX_VER)
		dev_warn(dev->dev,
			 "Warning: unsupported EEPROM version %02hhx\n",
			 eeprom[MT_EE_VERSION_EE]);
	dev_info(dev->dev, "EEPROM ver:%02hhx fae:%02hhx\n",
		 eeprom[MT_EE_VERSION_EE], eeprom[MT_EE_VERSION_FAE]);

Three years ago, maxumum allowed eeprom version for mt7601u was bumped in the following commit: https://github.com/torvalds/linux/commit/3bd1505fed71d834f45e87b32ff07157fdda47e0

#define MT7601U_EE_MAX_VER			0x0c  ->  #define MT7601U_EE_MAX_VER			0x0d

Therefore, it looks like driver IS actually able to work with this dongle, but it does not, being scared of the 0d eeprom version and accepts only 0c. And this happens only because of the kernel module being built from the sources older than 3 years.

Expected/suggested solution

This particular case might be solved by using newer kernel module sources.
However, I suspect that one non-working wifi dongle is not a reason to force a huge overall upgrade, and at least you guys have your own schedule for things like that.

Therefore I have a question - is it possible for me to rebuild some particular module for the specific dongle and apply this fix?

I have no problems with building kernel modules for a regular desktop machines, but for MOD DuoX I might need some guidance from the MOD team, to understand if it is even possible.

1 Like

TL;DR - I’ve got my wifi dongle to work, but the approach was dirty.

As far as I do not know specifics of building kernel modules for MOD Duo X yet, while waiting answer from the MOD team or somebody else - I’ve tried to use an alternative approach to the driver patching.

I’ve used IDA disassembler to drill down the binary compiled driver internals ( /usr/lib/modules/4.4.167-rt176-duox/kernel/drivers/net/wireless/mediatek/mt7601u/mt7601u.ko) that I’ve found on the device to find the solution.

As you can see below, there is a CMP assembler instruction, that is responsible for deciding to allow EEPROM version:

Responsible instruction is CMP W2, #0xC At this place driver makes a comparison and decides not to work with my dongle, as soon as my dongle has version 0xD and the maximum allowed is 0xC.
Swapping this to CMP W2, #0xD will force the driver to allow my EEPROM version.
I’ve made this by replacing the following corresponding sequence of bytes: 5F 30 00 71 to 5F 34 00 71 with a hex editor at address 0x0000400C, and replaced the original mt7601u.ko on the MOD device after remount rw.

After such change and device reboot I’ve got MOD Duo X sucesfully connecting to my WiFi network:


Jan 01 00:11:51 modduox systemd[1]: Started WPA supplicant for wlan0.
Jan 01 00:11:51 modduox systemd[1]: Starting WPA supplicant for wlan0...
Jan 01 00:11:51 modduox wpa_supplicant[1830]: Successfully initialized wpa_supplicant
Jan 01 00:11:51 modduox wpa_supplicant[1830]: rfkill: Cannot open RFKILL control device
Jan 01 00:11:53 modduox wpa_supplicant[1830]: wlan0: SME: Trying to authenticate with 48:8f:5a:8b:67:84 (SSID='TheInternets-2' freq=2452 MHz)
Jan 01 00:11:53 modduox wpa_supplicant[1830]: wlan0: Trying to associate with 48:8f:5a:8b:67:84 (SSID='TheInternets-2' freq=2452 MHz)
Jan 01 00:11:53 modduox wpa_supplicant[1830]: wlan0: Associated with 48:8f:5a:8b:67:84
Jan 01 00:11:53 modduox wpa_supplicant[1830]: wlan0: WPA: Key negotiation completed with 48:8f:5a:8b:67:84 [PTK=CCMP GTK=CCMP]
Jan 01 00:11:53 modduox wpa_supplicant[1830]: wlan0: CTRL-EVENT-CONNECTED - Connection to 48:8f:5a:8b:67:84 completed [id=0 id_str=]

At this moment my wifi problem seems to be temporary solved, but in quite a hacky way. After next update it will be washed away and I will have to repeat this procedure again after each update, cracking and patching ko module from the scratch. Therefore it would be great to have newer kernel modules out of the box, or this particular kernel module updated, or at least an instruction to build new kernel module from sources so I would be able to use more conventional approarch.

Cheers.

5 Likes

Just wanted a simple human-readable conclusion for this wall of text.

Please apply this fix below to the next release if possible, and my case will be solved permanently.

1 Like

really nice and interesting work! congrats

2 Likes

“…and then I used IDA to get my guitar pedal working” :rofl:

4 Likes