[BPI-R2] MT7615 Wifi no IR flag

Ok tested without loading anything related to mt7615 and “echo 0 /dev/wmtWifi” works without a hitch.

Here is the output:

Apr  6 15:06:56 kernel: [   77.455378] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1488)
Apr  6 15:06:56 kernel: [   77.455470] [MTK-WIFI] WIFI_write: WIFI_write 0
Apr  6 15:06:56 kernel: [   77.455480] DEBUG: Passed WIFI_write 355
Apr  6 15:06:56 kernel: [   77.455487] DEBUG: Passed WIFI_write 362
Apr  6 15:06:56 kernel: [   77.455506] DEBUG: Passed WIFI_write 365 wlan0
Apr  6 15:06:56 kernel: [   77.455514] DEBUG: Passed WIFI_write 372
Apr  6 15:06:56 kernel: [   77.455520] DEBUG: Passed WIFI_write 374
Apr  6 15:06:56 kernel: [   77.544785] DEBUG: Passed WIFI_write 379
Apr  6 15:06:56 kernel: [   77.544818] [MTK-WIFI] WIFI_write: Turn off p2p/ap mode
Apr  6 15:06:56 kernel: [   77.544824] DEBUG: Passed WIFI_write 384
Apr  6 15:06:56 kernel: [   77.544832] DEBUG: Passed WIFI_write 386
Apr  6 15:06:56 kernel: [   77.544838] DEBUG: Passed WIFI_write 390
Apr  6 15:06:56 kernel: [   77.584674] [MTK-WIFI] register_set_p2p_mode_handler: (pid 1087) register set p2p mode handler 00000000
Apr  6 15:06:56 kernel: [   77.685331] DEBUG: Passed mtk_cfg80211_update_mgmt_frame_register 1423 frame-filter:0x0
Apr  6 15:06:56 kernel: [   77.834835] DEBUG: Passed WIFI_write 396
Apr  6 15:06:56 kernel: [   77.834859] [MTK-WIFI] WIFI_write: WMT turn off WIFI OK!
Apr  6 15:06:56 kernel: [   77.834866] DEBUG: Passed WIFI_write 405
Apr  6 15:06:56 kernel: [   77.834877] [MTK-WIFI] WIFI_write: WIFI_write
Apr  6 15:06:56 kernel: [   77.834877]
Apr  6 15:06:56 kernel: [   77.834896] [MTK-WIFI] WIFI_write: WIFI_write invalid param
Apr  6 15:06:56 kernel: [   77.836216] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 1488)

I feel like there is a naming issue happening, maybe.

Like when “wlan0” and “wlan1” are present and while removing the first one and the renaming happens whatever does the removing(I guess the driver?) now also tries to remove the now “new” “wlan0” (which is the mt7615 and that doesn’t work obvioulsy)

yes thats the behaviour i tried to fix…by default wlan0 was hardcoded in the driver, now i use the get_netdev function… get_netdev returns last wlanX, which may be wrong if mt7615 is initialized after ap0

we need a way to store the netdev on creation (which happens in wlanNetRegister 2273 in drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c) and read this in wifi_write, but this part i have no idea because i have no idea how :frowning:

1 Like

I sadly can’t help you there I’m no programer :slightly_frowning_face:

It’s already very good however that you got it working like it is now. Which helps me and hopefully others very much :slightly_smiling_face:.

If you think of something and need someone to test then just write to me and I would be happy to help :sunglasses:.

I guess the solution in the meantime is to “rmod mt7615e mt76” and then do “echo 0 > /dev/wmtWifi”.

Again thank you very much for all the help :smile:

You don’t have to remove the module, you can simply rename mt7615 wlanX directly after creating it

ip link set wlan0 name wlan_2g

Or do this by udev based on mac

Basicly it should work (with the get_netdev function) too if you create ap0 after mt7615 is loaded (so last wlanX is from mt6625)

Maybe i go back to static device and name the wlanX on creation same way (e.g. mt6625_ctl)

1 Like

Oh that is certainly helpfull, I just renamed “wlan1” to “wlan_5g” and did “echo 0 > /dev/wmtWifi” and it works!

So I just have to insert a “ip link set wlan1 name wlan_5g” into my script and have it working.

good to know…it was my first workaround before get_netdev function

you could also look if this patch fixes the problem too (uses “mt6625_%d” instead of “wlan%d” as interface name)

wifi_dev.patch (1,3 KB)

1 Like

Applied the patch and startup was fine, took a little longer for some reason, but devices were properly named. Then tried to disable the device, worked fine.

“echo 0 >/dev/wmtWifi” output:

Apr  6 16:21:49 kernel: [  148.212189] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1518)
Apr  6 16:21:49 kernel: [  148.212283] [MTK-WIFI] WIFI_write: WIFI_write 0
Apr  6 16:21:49 kernel: [  148.212294] DEBUG: Passed WIFI_write 355
Apr  6 16:21:49 kernel: [  148.212302] DEBUG: Passed WIFI_write 362
Apr  6 16:21:49 kernel: [  148.212319] DEBUG: Passed WIFI_write 365 (null)
Apr  6 16:21:49 kernel: [  148.212327] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device
Apr  6 16:21:49 kernel: [  148.212334] DEBUG: Passed WIFI_write 390
Apr  6 16:21:49 kernel: [  148.242941] [MTK-WIFI] register_set_p2p_mode_handler: (pid 680) register set p2p mode handler 00000000
Apr  6 16:21:49 kernel: [  148.354708] DEBUG: Passed mtk_cfg80211_update_mgmt_frame_register 1423 frame-filter:0x0
Apr  6 16:21:50 kernel: [  148.513100] DEBUG: Passed WIFI_write 396
Apr  6 16:21:50 kernel: [  148.513124] [MTK-WIFI] WIFI_write: WMT turn off WIFI OK!
Apr  6 16:21:50 kernel: [  148.513131] DEBUG: Passed WIFI_write 405
Apr  6 16:21:50 kernel: [  148.513141] [MTK-WIFI] WIFI_write: WIFI_write
Apr  6 16:21:50 kernel: [  148.513141]
Apr  6 16:21:50 kernel: [  148.513160] [MTK-WIFI] WIFI_write: WIFI_write invalid param
Apr  6 16:21:50 kernel: [  148.513266] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 1518)

Trying to re-enable the device gabe me this:

“echo A >/dev/wmtWifi” output:

Apr  6 16:23:08 kernel: [  226.789837] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1518)
Apr  6 16:23:08 kernel: [  226.789929] [MTK-WIFI] WIFI_write: WIFI_write A
Apr  6 16:23:08 kernel: [  226.825780] kalFirmwareImageMapping firmware size 225840
Apr  6 16:23:09 kernel: [  227.874660] DEBUG: Passed wlanNetRegister 2264 devname:mt6625_%d
Apr  6 16:23:09 kernel: [  227.875702] DEBUG: Passed wlanNetRegister 2273 devname:mt6625_0 (need to be used everywhere "wlan0" is used)
Apr  6 16:23:09 kernel: [  227.875745] [MTK-WIFI] register_set_p2p_mode_handler: (pid 680) register set p2p mode handler dcd64e0d
Apr  6 16:23:09 kernel: [  227.875851] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!
Apr  6 16:23:09 kernel: [  227.875879] DEBUG: Passed WIFI_write 496 (null)
Apr  6 16:23:09 kernel: [  227.875889] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:09 kernel: [  228.192893] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:10 kernel: [  228.512913] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:10 kernel: [  228.832917] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:10 kernel: [  229.152896] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:11 kernel: [  229.472922] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:11 kernel: [  229.792887] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:11 kernel: [  230.112939] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:12 kernel: [  230.432900] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:12 kernel: [  230.752887] [MTK-WIFI] WIFI_write: Fail to get wlan0 net device, sleep 300ms
Apr  6 16:23:12 kernel: [  231.072893] [MTK-WIFI] WIFI_write: Get wlan0 net device timeout
Apr  6 16:23:12 kernel: [  231.073137] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 1518)

Weird I’m just seing that in the bootlog the same error happened but the device was there after boot. I guess since wlan0 is now mt7615 it still errors out.

Oh wait nvm, the device is also there after re-enabling it, I just didn’t to the right “ifconfig” command :stuck_out_tongue:

Seems like wlan0 is still hardcoded somewhere…

Fail to get wlan0 net device, sleep 300ms

Seems the first one can be ignored as ifname is still wlan0 but uses get_netdev

Is your get_netdev function patched too? Error should not occour…all positions with this message are after get_netdev call

1 Like

I don’t know what you mean by that.

This should be mt6625l_%d instead of wlan%d…is a mt6625_0 created in your system?

Yes it is:

“ifconfig -a”

mt6625_0  Link encap:Ethernet  HWaddr 00:08:22:40:E9:FE
          inet addr:172.20.15.1  Bcast:0.0.0.0  Mask:255.255.255.0
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

It seems there is one missing though, ap0 is never created and hostapd won’t work with the “mt6625_0” interface as that has not the AP mode according to “iw list”

Oh,i see problem…

char tmpifname[6]="";

Should be of length 9,just replace 6 with 9

1 Like

I’d say solved, as everything works now :slight_smile:.

thanks for testing, have added changes to 5.12-hnat

Can you post order of commands (wmt_loader,stp_uart_launcher,modprobe,echos)? I guess this order…

Yes of course:

Before anything:

modprobe mac80211
modprobe cfg80211

For cfg80211 you probably want to to that with “ieee80211_regdom=”

Like this:

modprobe cfg80211 ieee80211_regdom=US

For mt6625:

wmt_loader
stp_uart_launcher -p /etc/firmware &
modprobe stp_chrdev_bt
modprobe wmt_chrdev_wifi
modprobe wlan_gen2
echo A > /dev/wmtWifi

For mt7615:

modprobe mt76
modprobe mt7615e

For mac80211 and cfg80211 you could just add those to /etc/modules.

And define the “ieee80211_regdom” option in /etc/modprobe.d/cfg80211.conf and insert the following:

options cfg80211 ieee80211_regdom=

1 Like

I guess this needs to be loaded before chardev,or not?

For mt7615 its module should be enough…mt76.ko should be loaded automaticly by mt7615e

No as “wlan_gen2” depends on “wmt_chrdev_wifi” to be loaded.

lsmod:

Module                  Size  Used by    Not tainted
aes_arm_bs             24576  1
crypto_simd            16384  1 aes_arm_bs
cryptd                 24576  1 crypto_simd
nft_reject_ipv4        16384  1
nf_reject_ipv4         16384  1 nft_reject_ipv4
nft_reject             16384  1 nft_reject_ipv4
nf_log_ipv4            16384  4
nf_log_common          16384  1 nf_log_ipv4
nft_log                16384  4
nft_limit              16384  1
nft_masq               16384  1
nft_nat                16384  3
nft_ct                 20480 11
nft_chain_nat          16384  4
nf_nat                 45056  3 nft_masq,nft_nat,nft_chain_nat
nft_counter            16384  6
mt7615e                24576  0
mt7615_common          94208  1 mt7615e
mt76_connac_lib        36864  2 mt7615e,mt7615_common
mt76                   73728  3 mt7615e,mt7615_common,mt76_connac_lib
wlan_gen2            1548288  0
wmt_chrdev_wifi        20480  1 wlan_gen2
stp_chrdev_bt          24576  0
nft_flow_offload       16384  0
nf_flow_table          36864  1 nft_flow_offload
nf_tables             196608 482 nft_reject_ipv4,nft_reject,nft_log,nft_limit,nft_masq,nft_nat,nft_ct,nft_chain_nat,nft_counter,nft_flow_offload
nfnetlink              20480  1 nf_tables
nf_conntrack          135168  6 nft_masq,nft_nat,nft_ct,nf_nat,nft_flow_offload,nf_flow_table
nf_defrag_ipv6         20480  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
mac80211              745472  4 mt7615e,mt7615_common,mt76_connac_lib,mt76
cfg80211              745472  5 mt7615_common,mt76_connac_lib,mt76,wlan_gen2,mac80211
libarc4                16384  1 mac80211

Yes it’s enough to just load mt7615e as it will load mt76 with it, I was just doing that for completeness sake :slightly_smiling_face:

1 Like

Ok,then wmt_chrdev_wifi should be loaded if wlan_gen2 (like mt76 by mt7615) or doesn’t it?

Yes you can just load “wlan_gen2” dependency should load “wmt_chrdev_wifi” on its own.

Alex reported loading wlan_gen2 is enough. Cfg80211 can be configured using file

cat /etc/modprobe.d/cfg80211.conf  
options cfg80211 ieee80211_regdom=US