[BPI-R2] internal Wifi/BT (MT6625L) - Kernel

Yes…tftp has no modules…wifi/hdmi is builtin

Other things like external drivers,iptables are missing…just for testing wifi/hdmi. If you use this device for dialin to your isp just skip the dialin while testing

ap0 in your kernel looks pretty stable for me. I have no internet with it, but iperf works great. I’ve tested it in about 10 mins, it much more than mine.

i’ve found differences on hostapd start:

You kernel:

 bpi-r2-gentoo ~ # /etc/init.d/hostapd2 start                                                                                                                                                                                                       
 * Starting hostapd2 ...Configuration file: /etc/hostapd/hostapd.conf.ap                                                                                                                                                                           
ap0: interface state UNINITIALIZED->COUNTRY_UPDATE                                                                                                                                                                                                 
 [ ok ]   

My:

bpi-r2-gentoo ~ # /etc/init.d/hostapd2 start                                                                                                                                                                                                        
* Starting hostapd2 ...Configuration file: /etc/hostapd/hostapd.conf.ap                                                                                                                                                                            
ap0: interface state UNINITIALIZED->COUNTRY_UPDATE                                                                                                                                                                                                  
Using interface ap0 with hwaddr 02:08:22:e4:e0:fe and ssid "ap2"                                                                                                                                                                                    
random: Only 18/20 bytes of strong random data available                                                                                                                                                                                            
random: Not enough entropy pool available for secure operations                                                                                                                                                                                     
WPA: Not enough entropy in random pool for secure operations - update keys later when the first station connects                                                                                                                                    
ap0: interface state COUNTRY_UPDATE->ENABLED                                                                                                                                                                                                        
ap0: AP-ENABLED                                                                                                                                                                                                                                     
[ ok ]

The same distro, same wifi-init, same hostapd config.

The question, is it built like:

git clone <url>
git checkout 5.5-merged
./build.sh importconfig
./build

?

Yes…basicly same…

Maybe you disable modules on your kernel (nomodule in cmdline or renaming folder in /lib/modules) maybe anything (like nftables) is affecting wifi

Only new drivers, nothing was removed.

May be. I’ll try to build it with default config. Then, if everything is OK, to add wifi and 4g drivers. And so on unless I’ll find the reason/driver.

with my kernel you have no modules…also none from default. I guess it maybe a firewall issue. Maybe nftables have problems with later init of ap0 interface or similar.thats why recommend to test your kernel without modules

Nice thought, I have to try it, but only tommorow.

Done test with my kernel and all modules disabled - works without any problems, same as your kernel. Want to determine which module/subsystem breaks ap.

P. S. Both compiled with gcc-6.5 and 9.2 are OK without modules.

BTW modules doens’n affects on mt76xe2 and rtl88x2BU ( usb wifi dongle replacement)

Maybe nftables blocking traffic which causing timeout?

It doesn’t work even when nftables modules are fully unloaded.

Have you tried unloading all other modules? If i find some time i try booting 5.5-rc5 with all modules…afair i had not tested ap-mode with local installed kernel

All unused. All modules i have:

bpi-r2-gentoo ~ # lsmod                                                                                                                                                                                                                             
Module                  Size  Used by                                                                                                                                                                                                               
qcserial               16384  0                                                                                                                                                                                                                     
cdc_mbim               16384  0                                                                                                                                                                                                                     
aes_arm_bs             24576  6                                                                                                                                                                                                                     
crypto_simd            16384  1 aes_arm_bs                                                                                                                                                                                                          
cryptd                 24576  1 crypto_simd                                                                                                                                                                                                         
xt_MASQUERADE          16384  2                                                                                                                                                                                                                     
iptable_nat            16384  1                                                                                                                                                                                                                     
nf_nat                 45056  2 xt_MASQUERADE,iptable_nat                                                                                                                                                                                           
nf_conntrack          159744  2 xt_MASQUERADE,nf_nat                                                                                                                                                                                                
nf_defrag_ipv6         20480  1 nf_conntrack                                                                                                                                                                                                        
nf_defrag_ipv4         16384  1 nf_conntrack                                                                                                                                                                                                        
ip_tables              24576  1 iptable_nat                                                                                                                                                                                                         
x_tables               32768  2 ip_tables,xt_MASQUERADE                                                                                                                                                                                             
sch_fq                 20480  10                                                                                                                                                                                                                    
cdc_ncm                36864  1 cdc_mbim                                                                                                                                                                                                            
cdc_wdm                28672  2 cdc_mbim                                                                                                                                                                                                            
usbnet                 49152  2 cdc_mbim,cdc_ncm                                                                                                                                                                                                    
88x2bu               2752512  0                                                                                                                                                                                                                     
mt76x2e                24576  0                                                                                                                                                                                                                     
mii                    16384  1 usbnet                                                                                                                                                                                                              
usb_wwan               24576  1 qcserial                                                                                                                                                                                                            
mt76x2_common          28672  1 mt76x2e                                                                                                                                                                                                             
mt76x02_lib            73728  2 mt76x2_common,mt76x2e                                                                                                                                                                                               
mt76                   61440  3 mt76x02_lib,mt76x2_common,mt76x2e

Some of them i can’t unload (like aes_arm_bs, sch_fq etc ) so i want to blacklist them and load 1 by 1. I’m a little bit busy next couple of days, so i’m planning to do than on weekend.

started local installed 5.5-rc5-merged and wifi-ap on it

root@bpi-r2:~# wifi.sh                                                          
wifidev does not exist...create it...                                           
10: ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qle0
    link/ether 02:08:22:58:74:fc brd ff:ff:ff:ff:ff:ff                          
Done, all good, ready to lauch hostapd                                          
set IP                                                                          
restart dnsmasq...                                                              
root@bpi-r2:~# lsmod                                                            
Module                  Size  Used by                                           
spi_mt65xx             20480  0                                                 
mtk_thermal            16384  0                                                 
mtk_pmic_keys          16384  0                                                 
pwm_mediatek           16384  0                                                 
mt6577_auxadc          16384  0                                                 
nvmem_mtk_efuse        16384  0                                                 
ip_tables              24576  0                                                 
x_tables               32768  1 ip_tables                                       
root@bpi-r2:~# ps -o pid,args -C hostapd                                        
  PID COMMAND                                                                   
  666 hostapd -dd /etc/hostapd/hostapd_ap0.conf                                              
root@bpi-r2:~# dmesg | tail -10                                                 
[   62.342980] [STP] mtk_wcn_stp_psm_enable:[W] STP Not Ready, Dont do Sleep/Wap
[   66.732903] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 622)     
[   66.732974] [MTK-WIFI] WIFI_write: WIFI_write A                              
                                                                                
[   66.778085] kalFirmwareImageMapping firmware size 225840                     
[   67.963207] [MTK-WIFI] register_set_p2p_mode_handler: (pid 628) register set5
[   67.965142] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!                 
[   67.966462] [MTK-WIFI] WIFI_write: Set wlan mode 0 --> 1                     
[   67.966503] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 622)   
[   70.096751] IPv6: ADDRCONF(NETDEV_CHANGE): ap0: link becomes ready           
root@bpi-r2:~# uname -a                                                         
Linux bpi-r2 5.5.0-rc5-bpi-r2-merged #98 SMP Mon Jan 6 19:37:34 CET 2020 armv7lx
root@bpi-r2:~# 

can connect to it…leave it now running an hour and try again…

edit: 2h later ap0 still working, tried loading some modules from your list (don’t have the crypto ones and mt76 yet in 5.5)

root@bpi-r2:~# lsmod
Module                  Size  Used by
iptable_nat            16384  0
xt_MASQUERADE          16384  0
nf_nat                 45056  2 xt_MASQUERADE,iptable_nat
nf_conntrack          135168  2 xt_MASQUERADE,nf_nat
nf_defrag_ipv6         20480  1 nf_conntrack
nf_defrag_ipv4         16384  1 nf_conntrack
spi_mt65xx             20480  0
mtk_thermal            16384  0
mtk_pmic_keys          16384  0
pwm_mediatek           16384  0
mt6577_auxadc          16384  0
nvmem_mtk_efuse        16384  0
ip_tables              24576  1 iptable_nat
x_tables               32768  2 ip_tables,xt_MASQUERADE
root@bpi-r2:~#

but still working

Done! I’ve found the reason - sch_fq module - CONFIG_NET_SCH_FQ=m in my config. How and why it affects on internal wifi, and only to it (i’ve tested mt76x2e and 2 usb wifi dongles) is unclear for me. Also interesting if other schedulers may affect this driver.

For now i’m satisfied by working wifi, and interested in reasons :slight_smile:

Also i didn’t yet understoof why it was loaded and used - for now i don’t use qdisc at all. (some default config?)

Until you finished testing, could you please test how hostapd works after restart with internal wifi?

For me i can only start it one across reboot, even disabling/re-enabling through /dev/wmtWifi doesnt works for me.

bpi-r2-gentoo ~ # tc qdisc show dev ap0    
qdisc mq 0: root
qdisc pfifo_fast 0: parent :4 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent :3 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent :2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
qdisc pfifo_fast 0: parent :1 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
bpi-r2-gentoo ~ # tc qdisc show dev lan0
qdisc noqueue 0: root refcnt 2
bpi-r2-gentoo ~ # tc qdisc show dev eth0
qdisc pfifo_fast 0: root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

looks like there are some rules by defaul - the dump is after sch_fq module has removed.

Have not done much with tc,but imho there should be the qos classes and routing all to best-effort by default.

Regarding ap0,afair it was not suggested anywhere recreating the device or disable it…create it once and use…setting state multiple times by echo will lead to unstable/undefined behaviour. Why do you need it?

I don’t mean recreating device. In my case i can’t restart hostapd, it restarts but doesn’t work. In general i don’t need to restart it, but looks like it’s a driver issue, as other wifi devices lets to restart hostapd and continue to work. In case of new setup it can be very useful: change password or channel.

Afair this was happening also in earlier versions of driver. But none had an idea why this happen. We have no support for the code which is large and dirty. a few users like lexa2 helped me to get it working in newer kernelversions or in better shape.

BTW, did someone tried to compile ti as a module? in this case it may be possible to reload module as some type of workaround.

Imho lexa did with last version. He fixed module build (merged to 5.4)…before it can’t be compiled as module.