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

Hah! you’re probably right… 4.14 from your 4.14-main branch has DRIVER_VERSION 2.0 and 4.16 has 1.0. Also for 4.14 the file is 621 lines vs 280 in 4.16… pff I was comparing with 4.14 mainline

Seems this is the missing part:

Forum-software stripped the #diff-a7c2e83ff71c648e58025d54ffb50e02

I will add this later…

[12:00] root@bpi-r2:~# uname -r                                                 
4.16.7-bpi-r2-wlan                                                              
[12:00] root@bpi-r2:~# uname -a                                                 
Linux bpi-r2 4.16.7-bpi-r2-wlan #211 SMP Mon May 21 11:54:59 CEST 2018 armv7l Gx
[12:00] root@bpi-r2:~# ifconfig ap0                                             
ap0       Link encap:Ethernet  HWaddr 02:08:22:52:61:fc                         
          inet addr:192.168.10.1  Bcast:0.0.0.0  Mask:255.255.255.0             
          inet6 addr: fe80::8:22ff:fe52:61fc/64 Scope:Link                      
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1                    
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0                    
          TX packets:7 errors:0 dropped:0 overruns:0 carrier:0                  
          collisions:0 txqueuelen:1000                                          
          RX bytes:0 (0.0 B)  TX bytes:746 (746.0 B)                            
                                                                                
[12:00] root@bpi-r2:~# dmesg |grep MTK                                          
[    1.510238] MTK-BTIF[E]hal_btif_clk_get_and_prepare(286):[CCF]clk_btif=3ac2d9
[    1.517534] MTK-BTIF[E]hal_btif_clk_get_and_prepare(292):[CCF]clk_btif_apdma0
[    1.711568] MTK_WDT_NONRST_REG(0)                                            
[   54.664170] [MTK-BT] BT_init: mtk_stp_BT_chrdev driver(major 192) installed  
[   54.664636] [GPS-MOD-INIT][I]do_gps_drv_init:CONFIG_MTK_COMBO_GPS is not defd
[   54.664917] [MTK-WIFI] WIFI_init: mtk_wmt_WIFI_chrdev driver(major 155) inst.
[   61.686268] [MTK-WIFI] WIFI_open: WIFI_open: major 155 minor 0 (pid 1000)    
[   61.686360] [MTK-WIFI] WIFI_write: WIFI_write A                              
[   62.916939] [MTK-WIFI] register_set_p2p_mode_handler: (pid 1026) register se7
[   62.917058] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!                 
[   62.918513] [MTK-WIFI] WIFI_write: Set wlan mode 0 --> 1                     
[   62.918578] [MTK-WIFI] WIFI_close: WIFI_close: major 155 minor 0 (pid 1000)

looks well :wink: thank you @BitMaster & @dfiloni very much

i can also connect to the AP :slight_smile:

Wow, great! Good job! You still did most of the work :slight_smile:

Do you know why this awful wmt whatever tool and stp blabla loader is required? Maybe we can combine some efforts to ban them as well, if it’s not too much work.

Wmt-tools are required because this driver is from android…i also want to kickoff these tools,but don’t know where these hook into the driver…i’m still no kernel-developer…i only copy files,compile them and try to fix the errors the compiler reports me :slight_smile:

Stp_art_launcher throw firmware-file to the driver, wmt_loader makes the init

I’m really happy to know it works! :sunny:

I’m not sure, maybe I’ll buy a board (I quit my old job so I don’t have any R2 anymore which I can use) to try to mainline only the WIFI driver (with all his dependencies such as watchdog 2.0, pwrap, etc.), is anyone working on this or interested in helping? Does anyone know if MTK guys already planned to do that? I think we could proceed as step, by porting all drivers one by one.

I still have to check if the WIFI firmware is proprietary but other core drivers (watchdog, pwrap…) can be already ported to mainline.

The wifi-driver is imho to large for mainline…and with the wmt-tools-depency we have imho no chance for mainline-integration. Afaik we can not hope for mtk-support…i have asked gary multiple times for porting this driver and some others for other drivers (hdmi,dual gmac,hnat)…there was not the best response

Also bt is not working…no help so far…

Thanks Frank! Sounds awesome! I’m also interested in getting the wifi driver in a better shape, have already a project with yocto on banana pi with 4.16, right now I’m just using external wifi card, soon will try to apply changes from your branch to a vanilla 4.16.x.

It will be good to get the smallest possible patch for latest upstream kernel to enable the wifi driver, last time I’ve checked that on 4.14 it was a huge ~7MB diff.

The patch was bigger when i got it…i have removed a folder that was not used and had redundancy files…but sure it’s to big for mainline

Maybe you can wait to the moment i merge the code to 4.16-main…so you can generate a single patch

Of course we should mainline the watchdog driver first, then the pwrap one, then the mt6625 core one, then… (this is an example, IDK all mini-drivers involved), you think it is too large because you’re seeing it as a single big driver :wink:

I think it can be integrated in mainline (at least some simple drivers such as the watchdog). Also maybe…maybe… MTK guys (and others) will help us to remove that wmt-tools-thing if everything else is already in mainline

About BT: I think we can merge the Wifi driver without BT (it’s another config so it is quite easy to remove it)

Can you post these parts for mainline…still try to figure out how to post a simple patch (leds)

The code requires a huge cleanup before you can submit it to patchwork :sweat_smile:

thats why i guess, we cannot do it…i have not much time for cleaning up this hugh folder…tried to do it a bit, but there is also much garbage in it (references to LTE,GPS-Driver in makefiles/code that is not existent)…there are many compiler-switches in the code currently not used.

maybe we can push code outside the driver/misc/mediatek-folder like watchdog and genetlink to avoid porting that every time…as a first step

@garywang / @Ryder.Lee: i made a pull-request for merging wlan-branch into 4.16-main…there i see some changes in cpu-section in dtsi:

 		cpu2: cpu@2 {
 			device_type = "cpu";
 			compatible = "arm,cortex-a7";
 			reg = <0x2>;
+			clocks = <&infracfg CLK_INFRA_CPUSEL>,
+				 <&apmixedsys CLK_APMIXED_MAINPLL>;
+			clock-names = "cpu", "intermediate";
 			operating-points-v2 = <&cpu_opp_table>;
 			clock-frequency = <1300000000>;
 		};

should i remove that before merging or are they meaningful?

Any idea to bypass linaro-bug?

I doubt it is a linaro bug, I also spent some time on it with gcc 7, although not this one specific as far as I can remember. Couldn’t find it at the time either… but I suspect some shady coding, perhaps even compiler flags.

strange tried building 4.14-main (also with this wifi-driver) and no error occour…and this error/warning is not the only one in kernel 4.16…

e.g. this is outside the wifi-driver and also not compilable with gcc7-cross

drivers/usb/core/hcd.c:460:34: warning: '%s' directive output may be truncated writing up to 64 bytes into a region of size between 35 and 99 [-Wformat-truncation=]
   snprintf (buf, sizeof buf, "%s %s %s", init_utsname()->sysname,
                                  ^~
    init_utsname()->release, hcd->driver->description);
    ~~~~~~~~~~~~                   
drivers/usb/core/hcd.c:460:3: note: 'snprintf' output 3 or more bytes (assuming 131) into a destination of size 100
   snprintf (buf, sizeof buf, "%s %s %s", init_utsname()->sysname,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    init_utsname()->release, hcd->driver->description);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [drivers] Error 2

for wifi-driver i can disable the following -Werror…but this is imho not the right way and does not solve compile-issues outside wifi-driver:

drivers/misc/mediatek/connectivity/common/Makefile:1:subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include
drivers/misc/mediatek/connectivity/common/Makefile:2:subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/include/mt-plat
drivers/misc/mediatek/Makefile:15:subdir-ccflags-y += -Werror

Tried to port driver to 4.18: Searching testing people for hdmi + wifi in Kernel 4.16

Sadly it crashes on loading firmware in hal_btif_hw_init

got wifi-driver working…i’m able to run hostapd on ap0 and can connect to it with 4.18-rc1 :slight_smile:

see here for details: Searching testing people for hdmi + wifi in Kernel 4.16

tried porting driver back to 4.17 because 4.16 is EOL

  • echo A
    /usr/local/sbin/wifi.sh: line 64: echo: write error: Input/output error

https://github.com/frank-w/BPI-R2-4.14/tree/4.17-wlan

dmesg_4.17-wlan_wmt.txt (31,6 KB) dmesg_4.17-wlan_full.txt (118,4 KB)

fixed…the btif-enable-node in dts was missing

Hi Frank,

is there an image which contains 4.18rc1 with working WLAN for test? Try to have some headles ubuntu router for AP, Router and iobroker.

Kind regards

Daniel