Tenda U2 MT7601u 免驱动无线网卡,usb_modeswitch 切换模式后不能使用

Tenda U2 MT7601U Wireless Adapter
自带win驱动,在win上会自动(或不自动)弹出驱动安装界面,驱动成功安装后会从储存模式切换到网卡模式,此时能上网了。

存储模式 vid 148f pid 2878
网卡模式 vid 148f pid 7601

openSUSE 里的驱动是 mt7601u,423和150都有。

42.3 测试,偶尔能正确识别网卡,能看到周围的WIFI网络,输入密码无法连接,一直转圈。我安装了 opensuse_zh 的网卡驱动,能用NM正常连接WIFI了。

15.0 测试,偶尔能正确识别网卡,能用NM正常连接WIFI上网。

后来就无法识别网卡了,搜索得知要切换模式,从储存切换到网卡模式。

15.0 /lib/udev/rules.d/40-usb_modeswitch.rules 有对应的规则,也能自动切换成功,并加载驱动,但 NetworkMananger 里没有无线网卡。

40-usb_modeswitch.rules
#RaLink MT7601U
ATTR{idVendor}==“148f”, ATTR{idProduct}==“2878”, RUN+=“usb_modeswitch ‘/%k’”

/usr/share/usb_modeswitch/148f:2878
# RaLink MT7601U
TargetVendor=0x148f
TargetProduct=0x7601
StandardEject=1

USB_ModeSwitch log

Use global config file: /etc/usb_modeswitch.conf
Raw parameters: --switch-mode 1-5
Use top device dir /sys/bus/usb/devices/1-5
Check class of first interface …
Interface 0 class is 08.

USB values from sysfs:
manufacturer Љ
product Љ
serial

bNumConfigurations is 1 - don’t check for active configuration
ConfigList: /usr/share/usb_modeswitch/148f:2878
SCSI attributes not needed, move on
Check config: /usr/share/usb_modeswitch/148f:2878
! matched. Read config data
Command line:
usb_modeswitch -W -D -u -1 -b 1 -g 5 -v 148f -p 2878 -f $flags(config)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)

Read long config from command line

  • usb_modeswitch: handle USB devices with multiple modes
  • Version 2.5.1 (C) Josua Dietze 2017
  • Based on libusb1/libusbx

! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor= 0x148f
DefaultProduct= 0x2878
TargetVendor= 0x148f
TargetProduct= 0x7601

StandardEject=1
System integration mode enabled

Use given bus/device number: 001/005 …
Look for default devices …
bus/device number matched
found USB ID 148f:2878
vendor ID matched
product ID matched
Found devices in default mode (1)
Get the current device configuration …
Use interface number 0
with class 8
Use endpoints 0x08 (out) and 0x84 (in)

USB description data (for identification)

Manufacturer: ?
Product: ?
Serial No.: not provided

Sending standard EJECT sequence
Looking for active drivers …
OK, driver detached
Set up interface 0
Use endpoint 0x08 for message sending …
Trying to send message 1 to endpoint 0x08 …
OK, message successfully sent
Read the response to message 1 (CSW) …
Response successfully read (13 bytes), status 0
Trying to send message 2 to endpoint 0x08 …
OK, message successfully sent
Read the response to message 2 (CSW) …
Device seems to have vanished after reading. Good.
Device is gone, skip any further commands
ok:busdev

(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds …
Read attributes …
All attributes matched
Mode switching was successful, found 148f:7601 (MediaTek: 802.11 n WLAN)
Logger is /usr/bin/logger
Check for AVOID_RESET_QUIRK kernel attribute
AVOID_RESET_QUIRK activated

All done, exit

423 /lib/udev/rules.d/40-usb_modeswitch.rules 没有对应的规则,参考150 设置,
在 /etc/usb_modeswitch.d 添加新配置文件 148f:2878,内容同150

lsusb
Bus 001 Device 028: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter

lsmod | grep mt
mt7601Usta(这个只能423有)
mt7601u 118784 1
mac80211 888832 1 mt7601u
cfg80211 696320 2 mac80211,mt7601u
usbcore 286720 8 usbhid,usb_storage,mt7601u,ehci_hcd,ohci_pci,uas,ohci_hcd,ehci_pci

后来发现,我要是先进win,再重启进 lin 就能正常使用。搜索时也看到有人在mac进ubuntu虚拟机切换网卡模式的。这样太麻烦了。

我参考这个帖子的方法 【已解决】终端下如何配置网络联接 ,但根本让不出无线网卡,没有 wlan0。

还有这个,也不行。
Linux系统下安装USB无线网卡驱动方法
https://blog.csdn.net/qq_38473236/article/details/81159961

有什么办法吗?

参考6年前的帖子,当然修不好啊。我早就不用openSUSE了。

要是能软件控制改变模式,那估计要专用驱动。

找到一个补丁,编译失败。求助!
[Solved] MT7601U USB Wireless Adapter doesn’t work
https://bbs.archlinux.org/viewtopic.php?pid=1847725#p1847725

原文

It turns out to be a driver problem. I’ve found a solution to rebuild the driver at https://bugs.launchpad.net/ubuntu/+sour … ug/1716301.

Full steps:

  1. Download the driver codes from kernel.org.
  2. Rebuild the driver with mcu.patch provided by comment #53
cd drivers/net/wireless/mediatek/mt7601u
patch -p0 < mcu.patch
make -C /lib/modules/$(uname -r)/build/ M=$(pwd) modules
  1. Insert the device to load dependent modules.
  2. Remove the device along with the original driver:
sudo rmmod mt7601u
  1. Reload the new driver:
sudo insmod ./mt7601u.ko vnd_reset=0
  1. Insert the device.

Now the device works well.

补丁来源

添加了txt 后缀,否则无法上传。
mcu.patch.txt (1.0 KB)

423编译失败,150也是。@marguerite 女王大人,求助!
另,这个补丁是否可以加入 opensuse_zh和上游?

patch -p0 < mcu.patch
patching file mcu.c
Hunk #1 succeeded at 10 (offset -8 lines).
Hunk #2 succeeded at 23 (offset -8 lines).
Hunk #3 succeeded at 457 (offset -7 lines).

make -C /lib/modules/$(uname -r)/build/ M=$(pwd) modules
make: Entering directory ‘/usr/src/linux-4.4.165-81-obj/x86_64/default’
CC [M] /data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/usb.o
CC [M] /data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.o
/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.c: In function ‘mt7601u_register_device’:
/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.c:611:31: error: ‘NL80211_EXT_FEATURE_CQM_RSSI_LIST’ undeclared (first use in this function)
wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CQM_RSSI_LIST);
^
/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.c:611:31: note: each undeclared identifier is reported only once for each function it appears in
/usr/src/linux-4.4.165-81/scripts/Makefile.build:278: recipe for target ‘/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.o’ failed
make[3]: *** [/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u/init.o] Error 1
/usr/src/linux-4.4.165-81/Makefile:1459: recipe for target ‘module/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u’ failed
make[2]: *** [module/data/edata/data/tmp/build/driver/mt7601u/kernel/linux-5.2.9/drivers/net/wireless/mediatek/mt7601u] Error 2
Makefile:152: recipe for target ‘sub-make’ failed
make[1]: *** [sub-make] Error 2
Makefile:24: recipe for target ‘__sub-make’ failed
make: *** [__sub-make] Error 2
make: Leaving directory ‘/usr/src/linux-4.4.165-81-obj/x86_64/default’

这种问题啊,怕是你要找当时补丁的版本的源码慢慢修了。
先进主线内核,suse这边对这种无关紧要的功能性问题肯定不会先于上游吧…

3楼 bugs.launchpad.ne # Comment 53 for bug 1716301 那个补丁是 2019-04-18 发的,Arch 那边的 wenbushi 2019.05.28 发的使用说明。就是不知suse怎么搞。

@hillwood 大佬,看 opensuse_zh 里的 mt7601u 驱动说明里你搞过,请问,你有时间搞一下3楼这个补丁吗? 俺这普通用户搞不了。

这个驱动在后面 Tumbleweed 的新内核已经内建支持了,我就没继续弄了。当前的驱动在我的360网卡也是正常工作的。

好的,知道了。:pray: