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

+1 was trying to keep up,but most time take me just setting up repo and applying patches.

Great! Looking good! Now you can create a branch from tag 4.14 online with github, call it as you like. Then git clone the repository to your development machine and change the branch with git checkout. Overwrite and git add the files with updated code (try to be conservative with changes as possible, to keep things readable, you can check with git diff --cached). When you finished git commit the code to your local ‘clone’ and then git push the code back to github. You should be able to view the result online.

You could use tools like SourceTree or TortoiseGit to support you in getting familiar with git. Another way is do the interactive tutorial at https://try.github.io/. It probably takes a few times back to google, but it will pay off eventually.

renamed repository:

  • main-branch is to get working kernel
  • wifi_mt6625l-branch is for testing the internal wifi-driver (currently does not compile complete)

edit: updated wifi-branch (fixed dts, config and add logging to build.sh…)

anyone tried to build? you have not make it compile complete…step by step

IMHO first we must separate wifi from BT in the common-dir (common/conn_soc/linux/pri) to get first wifi running without BT

I just successfully built the main branch (as a test), but didn’t try to run it yet. To be honest the build.sh isn’t really convenient for me because I have different paths, compiler settings, make flags and git usage. But it can be useful as a reference.

Later I will switch to the wifi branch and check out how I can contribute.

build.sh is only a start to get a working kernel :wink:

of course you can use your own script/environment…i want to make a small script to do the common tasks in building

tried to set function-calls to btif-functions in

#ifdef CONFIG_MTK_BTIF
...
#endif

to get rid of the depencies, till i come to drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_ctrl.c

/*do not need contol uart because B/G/F send/receive data by BTIF*/

B/G/F are the wifi-bands, right? seems that BTIF does not stand for BlueToothInterFace…whats the meaning?

https://lwn.net/Articles/729641/

MediaTek BTIF controller is the serial interface similar to UART but it works only as the digital device which is mainly used to communicate with the connectivity module also called CONNSYS inside the SoC which could be mostly found on those MediaTek SoCs with Bluetooth feature.

BTIF is needed for wifi and bt see Gary’s answer: 2.4Ghz and 5.6Ghz Wifi Working fine

as of the other errors, i’ve found out that in 4.4.70 there is

include/linux/device.h:303:#define DRIVER_ATTR(_name, _mode, _show, _store)

in 4.14 this is missing…

seems to be related: https://patchwork.kernel.org/patch/9851919/

then we must use one of these:

#define DRIVER_ATTR_RW(_name) \
    struct driver_attribute driver_attr_##_name = __ATTR_RW(_name)
#define DRIVER_ATTR_RO(_name) \
    struct driver_attribute driver_attr_##_name = __ATTR_RO(_name)
#define DRIVER_ATTR_WO(_name) \
    struct driver_attribute driver_attr_##_name = __ATTR_WO(_name)

but here the functions seems not to be given as params…how to set _show and _store? the macro builds the function-name together…see actual commit :wink: compiles fine

but throws a kernel-panic when wmt_launcher is running:

root@bpi-r2:~# wmt_loader                                                                                                      
init combo device                                                                                                              
Opened combo device                                                                                                            
get de[  282.101063] Internal error: Oops: 17 [#1] SMP ARM                                                                     
[  282.106861] Modules linked in:                                                                                              
                                                                                                                               
set device id [  282.111265] CPU: 3 PID: 12863 Comm: wmt_loader Not tainted 4.14.6-00012-g3bf8d6a #21                          
: 30243                                                                                                                        
[  282.120309] Hardware name: Mediatek Cortex-A7 (Device Tree)                                                                 
[  282.126687] task: db54e000 task.stack: dc228000                                                                             
[  282.131193] PC is at __list_del_entry_valid+0x28/0xdc                                                                       
[  282.136212] LR is at wakeup_source_remove+0x34/0x88                                                                         
[  282.141055] pc : [<c03c8534>]    lr : [<c04829a0>]    psr: 800e0093                                                         
[  282.147275] sp : dc229df8  ip : 00000000  fp : dc229e0c                                                                     
[  282.152461] r10: c0b01b40  r9 : ffffffff  r8 : c0f3eb9c                                                                     
[  282.157647] r7 : 0be00000  r6 : 00000001  r5 : a00e0013  r4 : c0f3f1b0                                                      
[  282.164128] r3 : c0f3f1b4  r2 : c0efc308  r1 : 00000000  r0 : c0f3f1b4                                                      
[  282.170609] Flags: Nzcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none                                              
[  282.177781] Control: 10c5387d  Table: 9c53006a  DAC: 00000051                                                               
[  282.183484] Process wmt_loader (pid: 12863, stack limit = 0xdc228218)                                                       
[  282.189878] Stack: (0xdc229df8 to 0xdc22a000)                                                                               
[  282.194203] 9de0:                                                       c04c4b60 c0482994                                   
[  282.202328] 9e00: dc229e24 dc229e10 c04829a0 c03c8518 c0e538cc 00000000 dc229e3c dc229e28                                   
[  282.210453] 9e20: c04c3820 c0482978 c0f3eb9c c0e53868 dc229e64 dc229e40 c04a544c c04c3800                                   
[  282.218578] 9e40: ffffffff c047149c dc229ea4 c0f3eb9c c0e53868 c0e5384c dc229ea4 dc229e68                                   
[  282.226703] 9e60: c04c0548 c04a542c c0b01b40 c017672c dc229e94 00000000 c0177360 c0e53970                                   
[  282.234826] 9e80: 00007623 00007623 00007623 00007623 debeecb0 00000000 dc229ec4 dc229ea8                                   
[  282.242951] 9ea0: c04c7940 c04c02fc 00007623 80047704 00007623 00007623 dc229edc dc229ec8                                   
[  282.251076] 9ec0: c04c7794 c04c78d8 c0e5396c 80047704 dc229efc dc229ee0 c04c6c4c c04c7784                                   
[  282.259200] 9ee0: c04c6af8 dd9cf600 dd9cf600 80047704 dc229f7c dc229f00 c02776f8 c04c6b04                                   
[  282.267325] 9f00: 00000020 00000000 00000000 00000000 ddacd000 c0264c70 ddacd000 dd9c99c0                                   
[  282.275450] 9f20: 00000017 dedd57a0 00000000 00000002 dd9c99c8 00000000 dc229f74 dc229f48                                   
[  282.283575] 9f40: c0264d44 c02a9a40 00000000 00000000 00000000 dd9cf600 dd9cf600 80047704                                   
[  282.291700] 9f60: 00007623 00000003 dc228000 00000000 dc229fa4 dc229f80 c0277f88 c0277658                                   
[  282.299825] 9f80: 00000000 bea12c58 00000000 00000000 00000036 c0108d64 00000000 dc229fa8                                   
[  282.307950] 9fa0: c0108b80 c0277f50 bea12c58 00000000 00000003 80047704 00007623 00000000                                   
[  282.316075] 9fc0: bea12c58 00000000 00000000 00000036 00000000 00000000 b6ffa000 00000000                                   
[  282.324200] 9fe0: 00021010 bea12c1c 000105b7 b6f73766 20080030 00000003 00000000 00000000                                   
[  282.332338] [<c03c8534>] (__list_del_entry_valid) from [<c04829a0>] (wakeup_source_remove+0x34/0x88)                        
[  282.341418] [<c04829a0>] (wakeup_source_remove) from [<c04c3820>] (wmt_plat_deinit+0x2c/0xc0)                               
[  282.349892] [<c04c3820>] (wmt_plat_deinit) from [<c04a544c>] (wmt_lib_deinit+0x2c/0x178)                                    
[  282.357934] [<c04a544c>] (wmt_lib_deinit) from [<c04c0548>] (mtk_wcn_soc_common_drv_init+0x258/0x324)                       
[  282.367096] [<c04c0548>] (mtk_wcn_soc_common_drv_init) from [<c04c7940>] (do_common_drv_init+0x74/0x1c0)                    
[  282.376519] [<c04c7940>] (do_common_drv_init) from [<c04c7794>] (do_connectivity_driver_init+0x1c/0x154)                    
[  282.385940] [<c04c7794>] (do_connectivity_driver_init) from [<c04c6c4c>] (wmt_detect_unlocked_ioctl+0x154/0x1b0)            
[  282.396053] [<c04c6c4c>] (wmt_detect_unlocked_ioctl) from [<c02776f8>] (do_vfs_ioctl+0xac/0x8f8)                            
[  282.404785] [<c02776f8>] (do_vfs_ioctl) from [<c0277f88>] (SyS_ioctl+0x44/0x6c)                                             
[  282.412052] [<c0277f88>] (SyS_ioctl) from [<c0108b80>] (ret_fast_syscall+0x0/0x54)                                          
[  282.419575] Code: e3510c01 0a00000a e35c0c02 0a000023 (e59cc000)                                                            
[  282.425628] ---[ end trace a2052d2229096773 ]---                                                                            
[  282.430494] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 12863)                                             
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.101063] Internal error: Oops: 17 [#1] SMP ARM                                                                   
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.183484] Process wmt_loader (pid: 12863, stack limit = 0xdc228218)                                               
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.189878] Stack: (0xdc229df8 to 0xdc22a000)                                                                       
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.194203] 9de0:                                                       c04c4b60 c0482994                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.202328] 9e00: dc229e24 dc229e10 c04829a0 c03c8518 c0e538cc 00000000 dc229e3c dc229e28                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.210453] 9e20: c04c3820 c0482978 c0f3eb9c c0e53868 dc229e64 dc229e40 c04a544c c04c3800                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.218578] 9e40: ffffffff c047149c dc229ea4 c0f3eb9c c0e53868 c0e5384c dc229ea4 dc229e68                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.226703] 9e60: c04c0548 c04a542c c0b01b40 c017672c dc229e94 00000000 c0177360 c0e53970                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.234826] 9e80: 00007623 00007623 00007623 00007623 debeecb0 00000000 dc229ec4 dc229ea8                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.242951] 9ea0: c04c7940 c04c02fc 00007623 80047704 00007623 00007623 dc229edc dc229ec8                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.251076] 9ec0: c04c7794 c04c78d8 c0e5396c 80047704 dc229efc dc229ee0 c04c6c4c c04c7784                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.259200] 9ee0: c04c6af8 dd9cf600 dd9cf600 80047704 dc229f7c dc229f00 c02776f8 c04c6b04                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.267325] 9f00: 00000020 00000000 00000000 00000000 ddacd000 c0264c70 ddacd000 dd9c99c0                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.275450] 9f20: 00000017 dedd57a0 00000000 00000002 dd9c99c8 00000000 dc229f74 dc229f48                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.283575] 9f40: c0264d44 c02a9a40 00000000 00000000 00000000 dd9cf600 dd9cf600 80047704                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.291700] 9f60: 00007623 00000003 dc228000 00000000 dc229fa4 dc229f80 c0277f88 c0277658                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.299825] 9f80: 00000000 bea12c58 00000000 00000000 00000036 c0108d64 00000000 dc229fa8                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.307950] 9fa0: c0108b80 c0277f50 bea12c58 00000000 00000003 80047704 00007623 00000000                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.316075] 9fc0: bea12c58 00000000 00000000 00000036 00000000 00000000 b6ffa000 00000000                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.324200] 9fe0: 00021010 bea12c1c 000105b7 b6f73766 20080030 00000003 00000000 00000000                           
                                                                                                                               
Message from syslogd@bpi-r2 at Dec 14 15:22:50 ...                                                                             
 kernel:[  282.419575] Code: e3510c01 0a00000a e35c0c02 0a000023 (e59cc000)                                                    
Segmentation fault                                                       

any idea? @garywang have the wifi-helper-tools/firmware changed?

wmt_plat_deinit is the first function from top i’ve found in source…

drivers/misc/mediatek/connectivity/common/combo/platform/alps/wmt_plat_alps.c

INT32 wmt_plat_deinit(VOID)
{
	INT32 iret;

	/* 1. de-init cmb_hw */
	iret = mtk_wcn_cmb_hw_deinit();
	/* 2. unreg to cmb_stub */
	iret += mtk_wcn_cmb_stub_unreg();
	/*3. wmt wakelock deinit */
#ifdef CFG_WMT_WAKELOCK_SUPPORT
	wake_lock_destroy(&wmtWakeLock);
	osal_sleepable_lock_deinit(&gOsSLock);
	WMT_DBG_FUNC("destroy wmtWakeLock\n");
#endif
	WMT_DBG_FUNC("WMT-PLAT: ALPS platform init (%d)\n", iret);

	return 0;
}

Last init-function (drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/wmt_dev.c):

int mtk_wcn_soc_common_drv_init(void)
{
	return WMT_init(); //this call is not in stacktrace
}

static int WMT_init(void)
{
	dev_t devID = MKDEV(gWmtMajor, 0);
	INT32 cdevErr = -1;
	INT32 ret = -1;

	WMT_INFO_FUNC("WMT Version= %s DATE=%s\n", MTK_WMT_VERSION, MTK_WMT_DATE);
	/* Prepare a UINT8 device */
	/*static allocate chrdev */
	gWmtInitDone = 0;
	init_waitqueue_head((wait_queue_head_t *) &gWmtInitWq);

	stp_drv_init();

	ret = register_chrdev_region(devID, WMT_DEV_NUM, WMT_DRIVER_NAME);
	if (ret) {
		WMT_ERR_FUNC("fail to register chrdev\n");
		return ret;
	}

	cdev_init(&gWmtCdev, &gWmtFops);
	gWmtCdev.owner = THIS_MODULE;

	cdevErr = cdev_add(&gWmtCdev, devID, WMT_DEV_NUM);
	if (cdevErr) {
		WMT_ERR_FUNC("cdev_add() fails (%d)\n", cdevErr);
		goto error;
	}
	WMT_INFO_FUNC("driver(major %d) installed\n", gWmtMajor);

#if WMT_CREATE_NODE_DYNAMIC
	wmt_class = class_create(THIS_MODULE, "stpwmt");
	if (IS_ERR(wmt_class))
		goto error;
	wmt_dev = device_create(wmt_class, NULL, devID, NULL, "stpwmt");
	if (IS_ERR(wmt_dev))
		goto error;
#endif

#if 0
	pWmtDevCtx = wmt_drv_create();
	if (!pWmtDevCtx) {
		WMT_ERR_FUNC("wmt_drv_create() fails\n");
		goto error;
	}

	ret = wmt_drv_init(pWmtDevCtx);
	if (ret) {
		WMT_ERR_FUNC("wmt_drv_init() fails (%d)\n", ret);
		goto error;
	}

	WMT_INFO_FUNC("stp_btmcb_reg\n");
	wmt_cdev_btmcb_reg();

	ret = wmt_drv_start(pWmtDevCtx);
	if (ret) {
		WMT_ERR_FUNC("wmt_drv_start() fails (%d)\n", ret);
		goto error;
	}
#endif
	ret = wmt_lib_init();
	if (ret) {
		WMT_ERR_FUNC("wmt_lib_init() fails (%d)\n", ret);
		goto error;
	}
#if CFG_WMT_DBG_SUPPORT
	wmt_dev_dbg_setup();
#endif

#if CFG_WMT_PROC_FOR_AEE
	wmt_dev_proc_for_aee_setup();
#endif

	WMT_INFO_FUNC("wmt_dev register thermal cb\n");
	wmt_lib_register_thermal_ctrl_cb(wmt_dev_tm_temp_query);

	wmt_dev_bgw_desense_init();

	gWmtInitDone = 1;
	wake_up(&gWmtInitWq);

	osal_sleepable_lock_init(&g_es_lr_lock);
	INIT_WORK(&gPwrOnOffWork, wmt_pwr_on_off_handler);
#ifdef CONFIG_EARLYSUSPEND
	register_early_suspend(&wmt_early_suspend_handler);
	WMT_INFO_FUNC("register_early_suspend finished\n");
#else
	wmt_fb_notifier.notifier_call = wmt_fb_notifier_callback;
	ret = fb_register_client(&wmt_fb_notifier);
	if (ret)
		WMT_ERR_FUNC("wmt register fb_notifier failed! ret(%d)\n", ret);
	else
		WMT_INFO_FUNC("wmt register fb_notifier OK!\n");
#endif
	WMT_INFO_FUNC("success\n");
	return 0;

error:
	wmt_lib_deinit();
#if CFG_WMT_DBG_SUPPORT
	wmt_dev_dbg_remove();
#endif
#if WMT_CREATE_NODE_DYNAMIC
	if (!(IS_ERR(wmt_dev)))
		device_destroy(wmt_class, devID);
	if (!(IS_ERR(wmt_class))) {
		class_destroy(wmt_class);
		wmt_class = NULL;
	}
#endif

	if (cdevErr == 0)
		cdev_del(&gWmtCdev);

	if (ret == 0) {
		unregister_chrdev_region(devID, WMT_DEV_NUM);
		gWmtMajor = -1;
	}

	WMT_ERR_FUNC("fail\n");

	return -1;
}

Is there any debug-mode to see on which step it failes? There are messages with WMT_INFO_FUNC and WMT_ERR_FUNC…how to display them?

try to add some printk’s like it’s recommended here: https://elinux.org/Debugging_by_printing (Author’s practical advice) oh, is see the messages only in dmesg :wink:

[   37.004665] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 1339) 
[   37.004699] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191037),arg(0)
[   37.004763] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (1074034433),arg(302
43)                                                                             
[   37.004768] set current consys chipid (0x7623)                               
[   37.004783] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191036),arg(30
243)                                                                            
[   37.004789] [WMT-MOD-INIT][I]do_common_drv_init:start to do common driver ini
t, chipid:0x00007623                                                            
[   37.004796] DEBUG: Passed WMT_init 2396                                      
[   37.005267] DEBUG: Passed WMT_init 2404                                      
[   37.005274] DEBUG: Passed WMT_init 2407                                      
[   37.005282] DEBUG: Passed WMT_init 2414                                      
[   37.005358] DEBUG: Passed WMT_init 2419                                      
[   37.006734] DEBUG: Passed WMT_init 2423                                      
[   37.008914] [WMT-DEV][E]wmt_dev_read_file(1458):error code:-2                
[   37.008930] [WMT-DEV][E]wmt_dev_patch_get(1575):load file (/system/etc/firmwa
re/WMT_SOC.cfg) fail, iRet(-2)                                   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<               
[   37.008937] [WMT-CONF][E]wmt_conf_read_file(516):read /system/etc/firmware/WM
T_SOC.cfg file fails                                                            
[   37.008943] drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_conf.
c, 517, (0)                                                                     
[   37.008949] [WMT-LIB][E]wmt_lib_init(179):read wmt config file fail(-1)      
[   37.008953] DEBUG: Passed WMT_init 2452                                      
[   37.008958] [WMT-DEV][E]WMT_init(2454):wmt_lib_init() fails (-1)             
[   37.008966] [WMT-LIB][E]wmt_lib_deinit(306):osal_thread_stop(0xc0efca60) fail
(-1)                                                                            
[   37.008970] [cmb_stub] unregistered                                          
[   37.008989] Unable to handle kernel NULL pointer dereference at virtual addre
ss 00000000

then comes the oops listed above…and also the WMT-mesages are here…

wmt_dev.c (68,8 KB) wmt_plat_alps.c (44,9 KB)

seems that the problem is that my cfg could not be loaded…have lowercase filename instead of uppercase (for whatever reason) after renaming, kernel hangs…seems that kernel has crashed more than i thought…the renaming was not present after a reset…so i renamed again and started wmt_loader:

root@bpi-r2:~# wmt_loader
init combo device
Opened combo device
get device id : 30243
set device id : 30243
do module init: 30243
failed to init module <<<< can be ignored, same as 4.4.70

second step:

root@bpi-r2:~# stp_uart_launcher -p /etc/firmware &                             
[1] 1482                                                                        
open device node[  263.950509] Internal error: Oops: 17 [#1] SMP ARM            
 succeed.(Node:/[  263.956093] Modules linked in:                               
dev/stpwmt, fd:3[  263.960498] CPU: 3 PID: 1118 Comm: mtk_wmtd Not tainted 4.14.
6-00012-g3bf8d6a-dirty #25                                                      
)                                                                               
chip id is 0[  263.969808] Hardware name: Mediatek Cortex-A7 (Device Tree)      
x7623                                                                           
chiId:0x7[  263.976704] task: debdd400 task.stack: dc87e000                     
623, setting to [  263.982574] PC is at mutex_lock+0x28/0x54                    
property((null))[  263.987917] LR is at regulator_set_mode+0x2c/0xb4            
                                                                                
chiId:0x7623                                                                    
[  263.993950] pc : [<c08d100c>]    lr : [<c0428ba0>]    psr: 60080013          
run SOC chip flo[  264.001538] sp : dc87fd80  ip : dc87fd90  fp : dc87fd8c      
w                                                                               
create pwr on[  264.008088] r10: 00000000  r9 : 00000000  r8 : 00000000         
 thread ok                                                                      
root[  264.014641] r7 : 00000001  r6 : c0efd204  r5 : 00000040  r4 : 00000000   
@bpi-r2:~# [  264.022488] r3 : debdd400  r2 : dc87fd80  r1 : 00000008  r0 : 0000
0040                                                                            
[  264.029901] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[  264.036985] Control: 10c5387d  Table: 9df2806a  DAC: 00000051                
[  264.042688] Process mtk_wmtd (pid: 1118, stack limit = 0xdc87e218)           
[  264.048823] Stack: (0xdc87fd80 to 0xdc880000)                                
... (removed memory-dump)
[  264.215660] [<c08d100c>] (mutex_lock) from [<c0428ba0>] (regulator_set_mode+0
x2c/0xb4)                                                                       
[  264.223534] [<c0428ba0>] (regulator_set_mode) from [<c04c21e4>] (mtk_wcn_cons
ys_hw_reg_ctrl+0x84/0x69c)                                                      
[  264.232870] [<c04c21e4>] (mtk_wcn_consys_hw_reg_ctrl) from [<c04c29b0>] (mtk_
wcn_consys_hw_pwr_on+0x50/0xc4)                                                 
[  264.242636] [<c04c29b0>] (mtk_wcn_consys_hw_pwr_on) from [<c04c478c>] (wmt_pl
at_pwr_ctrl+0xa4/0x124)                                                         
[  264.251713] [<c04c478c>] (wmt_plat_pwr_ctrl) from [<c04a1c88>] (wmt_ctrl_hw_p
wr_on+0x68/0x88)                                                                
[  264.260186] [<c04a1c88>] (wmt_ctrl_hw_pwr_on) from [<c04a1d78>] (wmt_ctrl+0x4
4/0xc0)                                                                         
[  264.267882] [<c04a1d78>] (wmt_ctrl) from [<c049e2cc>] (wmt_core_ctrl+0x4c/0xc
c)                                                                              
[  264.275146] [<c049e2cc>] (wmt_core_ctrl) from [<c04a028c>] (opfunc_pwr_on+0x5
c/0x204)                                                                        
[  264.282928] [<c04a028c>] (opfunc_pwr_on) from [<c04a0490>] (opfunc_func_on+0x
5c/0x358)                                                                       
[  264.290795] [<c04a0490>] (opfunc_func_on) from [<c049e1f4>] (wmt_core_opid_ha
ndler+0x34/0x54)                                                                
[  264.299266] [<c049e1f4>] (wmt_core_opid_handler) from [<c049e240>] (wmt_core_
opid+0x2c/0x6c)                                                                 
[  264.307651] [<c049e240>] (wmt_core_opid) from [<c04a7508>] (wmtd_thread+0x18c
/0x244)                                                                         
[  264.315348] [<c04a7508>] (wmtd_thread) from [<c0146118>] (kthread+0x13c/0x16c
)                                                                               
[  264.322530] [<c0146118>] (kthread) from [<c0108c68>] (ret_from_fork+0x14/0x2c
)                                                                               

dmesg

[   26.210065] [WMT-MOD-INIT][I]do_common_drv_init:finish common driver init    
[   26.210070] [BT-MOD-INIT][I]do_bluetooth_drv_init:CONFIG_MTK_COMBO_BT is not 
defined                                                                         
[   26.210075] [WCN-MOD-INIT][E]do_connectivity_driver_init(57):do common driver
 init failed, ret:-1                                                            
[   26.210079] [GPS-MOD-INIT][I]do_gps_drv_init:CONFIG_MTK_COMBO_GPS is not defi
ned                                                                             
[   26.210083] [WCN-MOD-INIT][E]do_connectivity_driver_init(62):do common driver
 init failed, ret:-1                                                            
[   26.210086] [FM-MOD-INIT][I]do_fm_drv_init:start to do fm module init        
[   26.210089] [FM-MOD-INIT][I]do_fm_drv_init:finish fm module init             
[   26.210093] [WLAN-MOD-INIT][I]do_wlan_drv_init:start to do wlan module init 0
x7623                                                                           
[   26.213412] [MTK-WIFI] WIFI_init: mtk_wmt_WIFI_chrdev driver(major 153) insta
lled.                                                                           
[   26.213423] [WLAN-MOD-INIT][I]do_wlan_drv_init:WMT-WIFI char dev init, ret:0 
[   26.214325] [WLAN-MOD-INIT][I]do_wlan_drv_init:WLAN-GEN2 driver init, ret:0  
[   26.214333] [WLAN-MOD-INIT][I]do_wlan_drv_init:finish wlan module init       
[   26.214731] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 1114
)                                                                               
[  263.950064] [WMT-DEV][W]WMT_unlocked_ioctl:chipid = 0x7623                   
[  263.950151] [WMT-LIB][W]wmt_lib_set_hif:new hifType: 2, fm:2                 
[  263.950203] [WMT-CORE][E]opfunc_hif_conf(874):WMT-CORE: WMT HIF info added   
[  263.950236] [WMT-DEV][W]WMT_unlocked_ioctl:unknown cmd (-2147180516)         
[  263.950486] Unable to handle kernel NULL pointer dereference at virtual addre
ss 00000040                                                                     
[  263.950491] pgd = c0004000                                                   
[  263.950496] [00000040] *pgd=00000000                                         
[  263.950509] Internal error: Oops: 17 [#1] SMP ARM                            
[  263.956093] Modules linked in:                                               
[  263.960498] CPU: 3 PID: 1118 Comm: mtk_wmtd Not tainted 4.14.6-00012-g3bf8d6a
-dirty #25                                                                      
[  263.969808] Hardware name: Mediatek Cortex-A7 (Device Tree)                  
[  263.976704] task: debdd400 task.stack: dc87e000                              
[  263.982574] PC is at mutex_lock+0x28/0x54                                    
[  263.987917] LR is at regulator_set_mode+0x2c/0xb4


root@bpi-r2:~# stp_uart_launcher -p /etc/firmware &                             
[1] 1308
root@bpi-r2:~# open device node succeed.(Node:/
[   33.157686] Internal error: Oops: 17 [#1] SMP ARM  << here the kernel oops, after that my r2 is not responsible
dev/stpwmt, fd:3
chip id is 0

have opened a ssh-session in second terminal looking live at dmesg:

root@bpi-r2:~# dmesg -wH
[Dec15 14:07] [WMT-DETECT][I]wmt_detect_open:open major 154 minor 0 (pid 1415)
[  +0.000034] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191037),arg(0)
[  +0.000062] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (1074034433),arg(30243)
[  +0.000005] set current consys chipid (0x7623)
[  +0.000014] [WMT-DETECT][I]wmt_detect_unlocked_ioctl:cmd (-2147191036),arg(30243)
[  +0.000006] [WMT-MOD-INIT][I]do_common_drv_init:start to do common driver init, chipid:0x00007623
[  +0.000007] DEBUG: Passed WMT_init 2396 
[  +0.000483] DEBUG: Passed WMT_init 2404 
[  +0.000007] DEBUG: Passed WMT_init 2407 
[  +0.000007] DEBUG: Passed WMT_init 2414 
[  +0.000076] DEBUG: Passed WMT_init 2419 
[  +0.001493] DEBUG: Passed WMT_init 2423 
[  +0.001085] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6620.defAnt'.
[  +0.000012] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6620.defAnt, mt6620_ant_m3.cfg, -1)
[  +0.000007] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6628.defAnt'.
[  +0.000007] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6628.defAnt, mt6628_ant_m1.cfg, -1)
[  +0.000007] [WMT-CONF][E]wmt_conf_parse_pair(323):unknown field 'mt6630.defAnt'.
[  +0.000007] [WMT-CONF][W]wmt_conf_parse:parse fail (mt6630.defAnt, mt6630_ant_m1.cfg, -1)
[  +0.002628] [WMT-CONSYS-HW][E]mtk_wmt_probe(122):Wmt Cannot find pinctrl default!
[  +0.000304] OF: /consys@18070000: could not get #reset-cells for /watchdog@10007000
[  +0.000008] [WMT-CONSYS-HW][E]mtk_wmt_probe(170):CanNot get consys reset. ret=-22
[  +0.000410] mt7623consys: probe of 18070000.consys failed with error -22
[  +0.000659] DEBUG: Passed WMT_init 2452 
[  +0.000006] DEBUG: Passed WMT_init 2457 
[  +0.000016] DEBUG: Passed WMT_init 2460 
[  +0.000011] DEBUG: Passed WMT_init 2465 
[  +0.000005] DEBUG: Passed WMT_init 2470 
[  +0.000025] DEBUG: Passed WMT_init 2472 
[  +0.000004] DEBUG: Passed WMT_init 2475 
[  +0.000004] DEBUG: Passed WMT_init 2477 
[  +0.000003] DEBUG: Passed WMT_init 2486 
[  +0.000007] [WMT-MOD-INIT][I]do_common_drv_init:finish common driver init
[  +0.000004] [BT-MOD-INIT][I]do_bluetooth_drv_init:CONFIG_MTK_COMBO_BT is not defined
[  +0.000006] [WCN-MOD-INIT][E]do_connectivity_driver_init(57):do common driver init failed, ret:-1
[  +0.000003] [GPS-MOD-INIT][I]do_gps_drv_init:CONFIG_MTK_COMBO_GPS is not defined
[  +0.000005] [WCN-MOD-INIT][E]do_connectivity_driver_init(62):do common driver init failed, ret:-1
[  +0.000003] [FM-MOD-INIT][I]do_fm_drv_init:start to do fm module init
[  +0.000003] [FM-MOD-INIT][I]do_fm_drv_init:finish fm module init
[  +0.000008] [WLAN-MOD-INIT][I]do_wlan_drv_init:start to do wlan module init 0x7623
[  +0.003067] [MTK-WIFI] WIFI_init: mtk_wmt_WIFI_chrdev driver(major 153) installed.
[  +0.000010] [WLAN-MOD-INIT][I]do_wlan_drv_init:WMT-WIFI char dev init, ret:0
[  +0.000870] [WLAN-MOD-INIT][I]do_wlan_drv_init:WLAN-GEN2 driver init, ret:0
[  +0.000010] [WLAN-MOD-INIT][I]do_wlan_drv_init:finish wlan module init
[  +0.000460] [WMT-DETECT][I]wmt_detect_close:close major 154 minor 0 (pid 1415)

Message from syslogd@bpi-r2 at Dec 15 14:08:14 ...
 kernel:[  131.083366] Internal error: Oops: 17 [#1] SMP ARM  <<<<oops happens here
[Dec15 14:08] [WMT-DEV][W]WMT_unlocked_ioctl:chipid = 0x7623
[  +0.000123] [WMT-LIB][W]wmt_lib_set_hif:new hifType: 2, fm:2
[  +0.000039] [WMT-DEV][W]WMT_unlocked_ioctl:unknown cmd (-2147180516)
[  +0.000036] [WMT-CORE][E]opfunc_hif_conf(874):WMT-CORE: WMT HIF info added
[  +0.000187] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 232       <<< beginning of mtk_wcn_consys_hw_reg_ctrl
[  +0.000016] vcn18: mode operation not allowed
[  +0.000004] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 236 
[  +0.000003] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 239 
[  +0.000007] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 241 
[  +0.000509] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 248 
[  +0.000316] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 275 
[  +0.000004] ------------[ cut here ]------------
[  +0.000017] WARNING: CPU: 0 PID: 1420 at drivers/reset/core.c:230 reset_control_reset+0x130/0x150
[  +0.000004] Modules linked in:
[  +0.000012] CPU: 0 PID: 1420 Comm: mtk_wmtd Not tainted 4.14.6-00012-g3bf8d6a-dirty #27
[  +0.000004] Hardware name: Mediatek Cortex-A7 (Device Tree)
[  +0.000023] [<c0113208>] (unwind_backtrace) from [<c010d6b0>] (show_stack+0x20/0x24)
[  +0.000014] [<c010d6b0>] (show_stack) from [<c08b91e0>] (dump_stack+0x9c/0xb0)
[  +0.000015] [<c08b91e0>] (dump_stack) from [<c0125478>] (__warn+0xf8/0x110)
[  +0.000012] [<c0125478>] (__warn) from [<c0125560>] (warn_slowpath_null+0x30/0x38)
[  +0.000011] [<c0125560>] (warn_slowpath_null) from [<c042e6a4>] (reset_control_reset+0x130/0x150)
[  +0.000013] [<c042e6a4>] (reset_control_reset) from [<c04c2374>] (mtk_wcn_consys_hw_reg_ctrl+0x214/0x6a0)
[  +0.000011] [<c04c2374>] (mtk_wcn_consys_hw_reg_ctrl) from [<c04c29b4>] (mtk_wcn_consys_hw_pwr_on+0x50/0xc4)
[  +0.000010] [<c04c29b4>] (mtk_wcn_consys_hw_pwr_on) from [<c04c4790>] (wmt_plat_pwr_ctrl+0xa4/0x124)  
[  +0.000012] [<c04c4790>] (wmt_plat_pwr_ctrl) from [<c04a1c88>] (wmt_ctrl_hw_pwr_on+0x68/0x88)
[  +0.000010] [<c04a1c88>] (wmt_ctrl_hw_pwr_on) from [<c04a1d78>] (wmt_ctrl+0x44/0xc0)
[  +0.000009] [<c04a1d78>] (wmt_ctrl) from [<c049e2cc>] (wmt_core_ctrl+0x4c/0xcc)
[  +0.000009] [<c049e2cc>] (wmt_core_ctrl) from [<c04a028c>] (opfunc_pwr_on+0x5c/0x204)
[  +0.000009] [<c04a028c>] (opfunc_pwr_on) from [<c04a0490>] (opfunc_func_on+0x5c/0x358)
[  +0.000009] [<c04a0490>] (opfunc_func_on) from [<c049e1f4>] (wmt_core_opid_handler+0x34/0x54)
[  +0.000009] [<c049e1f4>] (wmt_core_opid_handler) from [<c049e240>] (wmt_core_opid+0x2c/0x6c)
[  +0.000010] [<c049e240>] (wmt_core_opid) from [<c04a7508>] (wmtd_thread+0x18c/0x244)
[  +0.000012] [<c04a7508>] (wmtd_thread) from [<c0146118>] (kthread+0x13c/0x16c)
[  +0.000012] [<c0146118>] (kthread) from [<c0108c68>] (ret_from_fork+0x14/0x2c)
[  +0.000020] ---[ end trace ddb7121164b33204 ]---
[  +0.000004] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 277 
[  +0.000071] DEBUG: Passed mtk_wcn_consys_hw_reg_ctrl 279 
[  +0.000025] Unable to handle kernel NULL pointer dereference at virtual address 00000010
[  +0.000004] pgd = c0004000
[  +0.000004] [00000010] *pgd=00000000
[  +0.000012] Internal error: Oops: 17 [#1] SMP ARM
[  +0.005920] Modules linked in:
[  +0.003039] CPU: 0 PID: 1420 Comm: mtk_wmtd Tainted: G        W       4.14.6-00012-g3bf8d6a-dirty #27
[  +0.009165] Hardware name: Mediatek Cortex-A7 (Device Tree)
[  +0.005536] task: db0f3c00 task.stack: dc688000
[  +0.004503] PC is at clk_core_enable+0x6c/0x234
[  +0.004498] LR is at clk_core_enable+0x4c/0x234
... removed memory dump
[  +0.008137] [<c0419228>] (clk_core_enable) from [<c0419564>] (clk_core_enable_lock+0x28/0x3c)
[  +0.008473] [<c0419564>] (clk_core_enable_lock) from [<c041959c>] (clk_enable+0x24/0x28)
[  +0.008041] [<c041959c>] (clk_enable) from [<c04c256c>] (mtk_wcn_consys_hw_reg_ctrl+0x40c/0x6a0)
[  +0.008731] [<c04c256c>] (mtk_wcn_consys_hw_reg_ctrl) from [<c04c29b4>] (mtk_wcn_consys_hw_pwr_on+0x50/0xc4)
[  +0.009765] [<c04c29b4>] (mtk_wcn_consys_hw_pwr_on) from [<c04c4790>] (wmt_plat_pwr_ctrl+0xa4/0x124)
[  +0.009075] [<c04c4790>] (wmt_plat_pwr_ctrl) from [<c04a1c88>] (wmt_ctrl_hw_pwr_on+0x68/0x88)
[  +0.008472] [<c04a1c88>] (wmt_ctrl_hw_pwr_on) from [<c04a1d78>] (wmt_ctrl+0x44/0xc0)
[  +0.007695] [<c04a1d78>] (wmt_ctrl) from [<c049e2cc>] (wmt_core_ctrl+0x4c/0xcc)
[  +0.007263] [<c049e2cc>] (wmt_core_ctrl) from [<c04a028c>] (opfunc_pwr_on+0x5c/0x204)
[  +0.007781] [<c04a028c>] (opfunc_pwr_on) from [<c04a0490>] (opfunc_func_on+0x5c/0x358)
[  +0.007866] [<c04a0490>] (opfunc_func_on) from [<c049e1f4>] (wmt_core_opid_handler+0x34/0x54)
[  +0.008469] [<c049e1f4>] (wmt_core_opid_handler) from [<c049e240>] (wmt_core_opid+0x2c/0x6c)
[  +0.008385] [<c049e240>] (wmt_core_opid) from [<c04a7508>] (wmtd_thread+0x18c/0x244)
[  +0.007697] [<c04a7508>] (wmtd_thread) from [<c0146118>] (kthread+0x13c/0x16c)
[  +0.007180] [<c0146118>] (kthread) from [<c0108c68>] (ret_from_fork+0x14/0x2c)
[  +0.007177] Code: e595307c e3530000 ca00003b e5943004 (e5933010) 
[  +0.006053] ---[ end trace ddb7121164b33205 ]---

seems that i must rework my dts(i)

after dts(i) rework (had to patch manually, patch have some hunks failed):

Debian GNU/Linux 9 bpi-r2 ttyS0

bpi-r2 login: root 
Password: 
Last login: Fri Dec 15 14:06:28 CET 2017 from 192.168.0.21 on pts/0
Linux bpi-r2 4.14.6-00012-g3bf8d6a-dirty #28 SMP Fri Dec 15 14:32:03 CET 2017 armv7l
root@bpi-r2:~# dmesg -C
root@bpi-r2:~# wmt_loader 
init combo device
Opened combo device
get device id : 30243
set device id : 30243
do module init: 30243
failed to init module 
root@bpi-r2:~# stp_uart_launcher -p /etc/firmware &
[1] 1434
open device node succeed.(Node:/dev/stpwmt, fd:3) 
chip id is 0x7623
chiId:0x7623, setting to property((null))
chiId:0x7623
run SOC chip flow
create pwr on thread ok
root@bpi-r2:~# enter power on connsys flowpatch name pre-fix:ROMv2_lm_patch
fwVersion:0x8a00
/etc/firmware/ROMv2_lm_patch_1_0_hdr.bin
fw Ver in patch: 0x8a00
read patch info:0x22,0x00,0x06,0x00
gpatchnum = [2]
gdwonseq = [2]
/etc/firmware/ROMv2_lm_patch_1_1_hdr.bin
fw Ver in patch: 0x8a00
read patch info:0x21,0x00,0x0e,0xf0
gdwonseq = [1]
cmd(srh_patch) resp(ok)

root@bpi-r2:~# ls /dev/wmt*
wmtdetect  wmtWifi
root@bpi-r2:~# 
root@bpi-r2:~# 
root@bpi-r2:~# echo A >/dev/wmtWifi
root@bpi-r2:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e6:fd:cf:08:11:dc brd ff:ff:ff:ff:ff:ff
    inet6 fe80::e4fd:cfff:fe08:11dc/64 scope link 
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
4: wan@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether e6:fd:cf:08:11:dc brd ff:ff:ff:ff:ff:ff
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 08:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.10/24 brd 192.168.0.255 scope global lan0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:ff:fe00:0/64 scope link 
       valid_lft forever preferred_lft forever
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN group default qlen 1000
    link/ether 08:00:00:00:00:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.10/24 brd 192.168.1.255 scope global lan1
       valid_lft forever preferred_lft forever
7: lan2@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether e6:fd:cf:08:11:dc brd ff:ff:ff:ff:ff:ff
8: lan3@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether e6:fd:cf:08:11:dc brd ff:ff:ff:ff:ff:ff
9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 00:08:22:c2:81:02 brd ff:ff:ff:ff:ff:ff
10: ap0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000   <<<<<<<<<<<<< ap0 exists :)
    link/ether 02:08:22:c2:81:02 brd ff:ff:ff:ff:ff:ff
root@bpi-r2:~# 

pushed current state to my github-wifi-branch

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

and uploaded compiled Kernel to my gdrive

https://drive.google.com/drive/folders/1EGN1TvqCpDHdOAS-mjRg9ipi0kahnOUV

happy testing :wink:

some messages in log that should be fixed, if all is working and debug-kprints are removed: wifi_dmesg.log (6,5 KB)

configured hostapd, seems to run, see the AP “test”, but cannot connect to it (hostapd does not recognize connect-attempt)

http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/wlan

anybody tried it?

i try to find the kernel-oops (currently for the missing conf-file)

it happens while calling “wmt_plat_deinit();” in drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/wmt_plat_alps.c

[  +0.000006] DEBUG: Passed wmt_plat_deinit 362 now calling wake lock destroy -1057754704
[  +0.000004] DEBUG: Passed wmt_plat_deinit 364 now wmtWakeLock:-1057754704
[  +0.000004] DEBUG: Passed wmt_plat_deinit 365 now wmtWakeLock->ws: -1057754704
[  +0.000013] Unable to handle kernel NULL pointer dereference at virtual address 00000000

as you see both adresses are the same:

created the messages like this way:

INT32 wmt_plat_deinit(VOID)
{
    INT32 iret = 0;
    /* 2. unreg to cmb_stub */
    iret = mtk_wcn_cmb_stub_unreg();
    printk(KERN_ALERT "DEBUG: Passed %s %d now calling wmt wakelock deinit\n",__FUNCTION__,__LINE__);
    /*3. wmt wakelock deinit */
#ifdef CFG_WMT_WAKELOCK_SUPPORT
#ifdef CONFIG_PM_WAKELOCKS
    printk(KERN_ALERT "DEBUG: Passed %s %d now calling wakeup_source_trash\n",__FUNCTION__,__LINE__);
    wakeup_source_trash(&wmtWakeLock);
#else
    printk(KERN_ALERT "DEBUG: Passed %s %d now calling wake lock destroy %d\n",__FUNCTION__,__LINE__,(int)&wmtWakeLock);
    //destroy in wakelock.h calls wakeup_source_trash (include/linux/pm_wakeup.h) with &lock->ws
    printk(KERN_ALERT "DEBUG: Passed %s %d now wmtWakeLock:%d\n",__FUNCTION__,__LINE__,(int)&wmtWakeLock);
    printk(KERN_ALERT "DEBUG: Passed %s %d now wmtWakeLock->ws: %d\n",__FUNCTION__,__LINE__,(int)&(wmtWakeLock.ws));
    wake_lock_destroy(&wmtWakeLock);
...

any idea how to fix this? wmtWakeLock and its member ws is a struct and not dynamic allocated as i’ve found out, so i assume that there have no memory freed manually.

(drivers/misc/mediatek/connectivity/common/combo seems not be used, deleted from git after try to build without it)

back to AP-function itself…i can create the AP, see it in handy, but hostapd does nothing if i try to connect…any idea here?

hostapd-output:

root@bpi-r2:~# hostapd -dd /etc/hostapd/hostapd.conf                                                                                                      
random: Trying to read entropy from /dev/random                                                                                                           
Configuration file: /etc/hostapd/hostapd.conf                                                                                                             
rfkill: Cannot open RFKILL control device                                                                                                                 
nl80211: RFKILL status not available                                                                                                                      
nl80211: Supported cipher 00-0f-ac:1                                                                                                                      
nl80211: Supported cipher 00-0f-ac:5                                                                                                                      
nl80211: Supported cipher 00-0f-ac:2                                                                                                                      
nl80211: Supported cipher 00-0f-ac:4                                                                                                                      
nl80211: Supported cipher 00-0f-ac:6                                                                                                                      
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=1                                                                                              
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=6                                                                                              
nl80211: Disable use_monitor with device_ap_sme since no monitor mode support detected                                                                    
nl80211: interface ap0 in phy phy1                                                                                                                        
nl80211: Set mode ifindex 10 iftype 3 (AP)                                                                                                                
nl80211: Setup AP(ap0) - device_ap_sme=1 use_monitor=0                                                                                                    
nl80211: Subscribe to mgmt frames with AP handle 0x91898 (device SME)                                                                                     
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x91898 match=                                                                         
nl80211: Enable Probe Request reporting nl_preq=0x91528                                                                                                   
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x91528 match=                                                                      
nl80211: Add own interface ifindex 10                                                                                                                     
nl80211: if_indices[16]: 10                                                                                                                               
phy: phy1                                                                                                                                                 
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)                                                                                                        
nl80211: Regulatory information - country=00                                                                                                              
nl80211: 2402-2472 @ 40 MHz 20 mBm                                                                                                                        
nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR)                                                                                                                
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)                                                                                                      
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)                                                                                                                
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)                                                                                                          
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)                                                                                                         
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)                                                                                                                
nl80211: 57240-63720 @ 2160 MHz 0 mBm                                                                                                                     
nl80211: Added 802.11b mode based on 802.11g information                                                                                                  
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=1 chan=12 freq=2467 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=1 chan=13 freq=2472 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=52 freq=5260 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=56 freq=5280 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=60 freq=5300 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=64 freq=5320 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=2 chan=100 freq=5500 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=104 freq=5520 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=108 freq=5540 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=112 freq=5560 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=116 freq=5580 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=120 freq=5600 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=124 freq=5620 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=128 freq=5640 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=132 freq=5660 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=136 freq=5680 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=140 freq=5700 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=20 dBm                                                                                        
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm                                                                                          
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=0 chan=12 freq=2467 MHz max_tx_power=20 dBm                                                                                         
Allowed channel: mode=0 chan=13 freq=2472 MHz max_tx_power=20 dBm                                                                                         
Completing interface initialization                                                                                                                       
Mode: IEEE 802.11g  Channel: 6  Frequency: 2437 MHz                                                                                                       
DFS 0 channels required radar detection                                                                                                                   
nl80211: Set freq 2437 (ht_enabled=0, vht_enabled=0, bandwidth=20 MHz, cf1=2437 MHz, cf2=0 MHz)                                                           
  * freq=2437                                                                                                                                             
  * vht_enabled=0                                                                                                                                         
  * ht_enabled=0                                                                                                                                          
RATE[0] rate=10 flags=0x1                                                                                                                                 
RATE[1] rate=20 flags=0x1                                                                                                                                 
RATE[2] rate=55 flags=0x1                                                                                                                                 
RATE[3] rate=110 flags=0x1                                                                                                                                
RATE[4] rate=60 flags=0x0                                                                                                                                 
RATE[5] rate=90 flags=0x0                                                                                                                                 
RATE[6] rate=120 flags=0x0                                                                                                                                
RATE[7] rate=180 flags=0x0                                                                                                                                
RATE[8] rate=240 flags=0x0                                                                                                                                
RATE[9] rate=360 flags=0x0                                                                                                                                
RATE[10] rate=480 flags=0x0                                                                                                                               
RATE[11] rate=540 flags=0x0                                                                                                                               
hostapd_setup_bss(hapd=0x90e60 (ap0), first=1)                                                                                                            
ap0: Flushing old station entries                                                                                                                         
nl80211: flush -> DEL_STATION ap0 (all)                                                                                                                   
ap0: Deauthenticate all stations                                                                                                                          
nl80211: sta_remove -> DEL_STATION ap0 ff:ff:ff:ff:ff:ff --> 0 (Success)                                                                                  
wpa_driver_nl80211_set_key: ifindex=10 (ap0) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0                                                      
wpa_driver_nl80211_set_key: ifindex=10 (ap0) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0                                                      
wpa_driver_nl80211_set_key: ifindex=10 (ap0) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0                                                      
wpa_driver_nl80211_set_key: ifindex=10 (ap0) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0                                                      
Using interface ap0 with hwaddr 02:08:22:e2:02:fd and ssid "test"                                                                                         
nl80211: Set beacon (beacon_set=0)                                                                                                                        
nl80211: Beacon head - hexdump(len=55): 80 00 00 00 ff ff ff ff ff ff 02 08 22 e2 02 fd 02 08 22 e2 02 fd 00 00 00 00 00 00 00 00 00 00 64 00 01 04 00 04 
74 65 73 74 01 08 82 84 8b 96 0c 12 18 24 03 01 06                                                                                                        
nl80211: Beacon tail - hexdump(len=9): 2a 01 04 32 04 30 48 60 6c                                                                                         
nl80211: ifindex=10                                                                                                                                       
nl80211: beacon_int=100                                                                                                                                   
nl80211: dtim_period=2                                                                                                                                    
nl80211: ssid - hexdump_ascii(len=4):                                                                                                                     
     74 65 73 74                                       test                                                                                               
  * beacon_int=100                                                                                                                                        
nl80211: hidden SSID not in use                                                                                                                           
nl80211: privacy=0                                                                                                                                        
nl80211: auth_algs=0x1                                                                                                                                    
nl80211: wpa_version=0x0                                                                                                                                  
nl80211: key_mgmt_suites=0x4                                                                                                                              
nl80211: pairwise_ciphers=0x0                                                                                                                             
nl80211: group_cipher=0x1                                                                                                                                 
nl80211: SMPS mode - off                                                                                                                                  
nl80211: Set ap0 operstate 0->1 (UP)                                                                                                                      
netlink: Operstate: ifindex=10 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)                                                                          
Failed to set TX queue parameters for queue 0.                                                                                                            
Failed to set TX queue parameters for queue 1.                                                                                                            
Failed to set TX queue parameters for queue 2.                                                                                                            
Failed to set TX queue parameters for queue 3.                                                                                                            
ap0: interface state UNINITIALIZED->ENABLED                                                                                                               
ap0: AP-ENABLED                                                                                                                                           
ap0: Setup of interface done.                                                                                                                             
ctrl_iface not configured!                                                                                                                                
random: Got 20/20 bytes from /dev/random                                                                                                                  
RTM_NEWLINK: ifi_index=10 ifname=ap0 operstate=2 linkmode=0 ifi_family=0 ifi_flags=0x11003 ([UP][LOWER_UP])                                               
nl80211: Set IF_OPER_UP again based on ifi_flags and expected operstate                                                                                   
netlink: Operstate: ifindex=10 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)                                                                          
RTM_NEWLINK: ifi_index=10 ifname=ap0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])    

dmesg (from stp-launcher and following):

[  +0.001906] [WMT-IC][W]mtk_wcn_soc_ver_check:0x7623: read hw_ver (hw version) (0x8a00)
[  +0.000895] [WMT-IC][W]mtk_wcn_soc_ver_check:0x7623: read fw_ver (rom version) (0x8a00)
[  +0.000011] [WMT-IC][W]mtk_wcn_soc_ver_check:0x7623: ic info: SOC_CONSYS.E1 (0x8a00/0x8a00, WMTHWVER:0, patch_ext:_e1)
[  +0.098973] [WMT-IC][W]mtk_wcn_soc_patch_dwn:wmt_core: patch dwn:0 frag(51, 268) ok
[  +0.128768] [WMT-IC][W]mtk_wcn_soc_patch_dwn:wmt_core: patch dwn:0 frag(114, 52) ok
[  +0.328089] [WMT-IC][W]mtk_wcn_soc_sw_init:co-clock disabled.
[  +0.000315] [STP] mtk_wcn_stp_psm_enable:[W] STP Not Ready, Dont do Sleep/Wakeup
[  +0.000015] [WMT-CORE][W]wmt_core_dump_func_state:[AF FUNC ON]status(b:0 f:0 g:0 w:0 lpbk:2 coredump:0 wmt:2 stp:0)
[  +0.000069] [WMT-EXP][W]mtk_wcn_wmt_func_ctrl:OPID(3) type(9) ok
[Dec17 16:55] [MTK-WIFI] WIFI_open: WIFI_open: major 153 minor 0 (pid 1336)
[  +0.000059] [MTK-WIFI] WIFI_write: WIFI_write A

[  +0.039709] [WMT-FUNC][W]wmt_func_wifi_on:WMT-FUNC: wmt wlan func on before wlan probe
[  +0.003212] kalFirmwareImageMapping firmware size 225840
[  +1.157852] [MTK-WIFI] register_set_p2p_mode_handler: (pid 1348) register set p2p mode handler c05067e0
[  +0.000025] [WMT-FUNC][W]wmt_func_wifi_on:WMT-FUNC: wmt call wlan probe ok
[  +0.000011] [WMT-CORE][W]wmt_core_dump_func_state:[AF FUNC ON]status(b:0 f:0 g:0 w:2 lpbk:2 coredump:0 wmt:2 stp:0)
[  +0.000083] [WMT-EXP][W]mtk_wcn_wmt_func_ctrl:OPID(3) type(3) ok
[  +0.000009] [MTK-WIFI] WIFI_write: WMT turn on WIFI success!
[  +0.001100] [MTK-WIFI] WIFI_write: Set wlan mode 0 --> 1
[  +0.000046] [MTK-WIFI] WIFI_close: WIFI_close: major 153 minor 0 (pid 1336)

have the same issue with 4.4 Kernel…maybe its any config-option in my debian stretch…

after closing hostapd the first time and starting it again, the AP is no more visible

used same kernel (4.4.107) on debian jessie works, can connect to the AP with same steps…now trying the same with 4.14

with 4.14 AP also works in jessie too :slight_smile: no idea, why it does not work in stretch…

but also on close hostapd and restart, ap is no more visible

ap0: AP-STA-CONNECTED b4:9d:0b:5f:22:e9
ap0: STA b4:9d:0b:5f:22:e9 RADIUS: starting accounting session 425F6BE3-00000000

included wifi-driver in main-branch…please do some tests

issues (same in 4.4.x):

  • kernel-oops if /system/etc/firmware/WMT_SOC.cfg not existing
  • hostapd is working the first-time, after killing it and restart, AP is not visible on clients (no error-Message on hostapd). tested on debian jessie (after upgrade to stretch it have same behavior after killing hostapd) => see https://github.com/frank-w/BPI-R2-4.14/issues/4

bluetooth is not working yet

currently i try to port the wifi-driver to 4.16

having problems to change

init_timer(timer);

to

timer_setup(timer,(void *)pTimer->timeoutHandler,0);

in drivers/misc/mediatek/connectivity/common/conn_soc/linux/pub/osal.c because with 4.15 init_timer is no more available and i have no idea where to put the timer->data, because “timer_list” does not have the data member anymore

any idea how to port that?

edit: here data is used before and from_timer function is used to get the pointer…but where is it set? https://patchwork.kernel.org/patch/9986119/

I’ve found an article on lwn https://lwn.net/Articles/735887/ the data seems to be no more needed because the parameter of callback also changed

dear frank-w a few days trying to activate the internal wifi on the forum manuals, but nothing happened.

Therefore, if possible, please, instead of kilometers of logs and patches, put a normally understood instruction or ready firmware with a working wifi.

as a basis I took your firmware bpi-r2_debian_stretch_4.14.13.img from 21.01.18 in it I tried different versions of the kernel

Steps are the same as with Kernel 4.4…

http://www.fw-web.de/dokuwiki/doku.php?id=en:bpi-r2:wlan#internal

  1. wmt_loader
  2. stp_uart_launcher -p /etc/firmware &
  3. echo A >/dev/wmtWifi (activate AP-Mode)

if you have done this you should see an ap0-device in “ip a”. My image has no wpa-supplicant installed so you can skip this point in my wiki

Also a script is linked on that page to do the steps and if you modify last lines it can set ip-address and launch dnsmasq and hostapd

Hi. Just the quick success story report.

So I am using Frank’s image deb_stretch_4.14.13.img.gz from https://drive.google.com/drive/folders/1oP7jy1KrrIOifvImo2nQ59wx3_9hHkgk with manually updated kernel 4.14.27-bpi-r2-main (both compile on arm and cross-compile on pc seems to work) from Frank’s github.

For the moment the list of features I could get to work with it.

  • working Ethernet - both lan and wan
  • working intrenal wifi ap (g-mode, single ssid for now), hostapd restarting fine
  • working routing and nat (yet have not bothered to check if it is hardware or cpu-based)
  • working site to site ipsec (other sbc devices on opposite side e.g. opi prime/win, bpi r1 and even Cisco routers)
  • working dhcp server
  • working dns server
  • could move the image to emmc

My goals left for this hardware:

  • see if it is possible to actually make multi-ssid ap working
  • wifi faster than g mode
  • see if nat is performed with cpu and find if it might be performed with hardware
  • investigate gpio f-ty of this hardware, for one of my side-project

Strange questions left:

  • what is the purpose of the switch above sd card slot (at least on my hardware revision v1.2). It says emmc-sd but seems to influence nothing.
  • what is the difference between wlan0 and ap0 interfaces. If one is virtual bounded to another why do it for single ssid?
  • have anyone managed to use mini PCI-E interface? I’ve tried to insert 1u-n01 usb3.0 card into it but it seems not to see it (no output in dmesg, no leds on card or power on port).

Huge thanks to Frank W for his work and answers and to sinovoip for hardware.

You have wlan0 and ap0? wlan0 is for client-mode, ap0 for ap-mode

Pcie works with my kernel (i have mt7612-card running) but you need to include drivers for your card…

dear renard.

Can you post this image? I can not activate the wifi and enable the access point.

The image is linked to his post. You need to do same steps as with Kernel 4.4. Maybe i have the wifi.sh included to make the steps. Else you can use it from here: https://github.com/frank-w/BPI-R2-4.14/tree/main/utils/scripts

dear renard. Can you post this image? I can not activate the wifi and enable the access point.

Yes. Just be sure that you copy this script (wifi.sh) or write your own (which I did before have noticed this one), enable it (with systemctl or init.d) and make it the prerequisite for hostapd service. You may use the image straight from the link in my post (I updated the kernel because I needed some iptables and ipsec related modules, wifi worked with the included 4.14.13 kernel).

You have wlan0 and ap0? wlan0 is for client-mode, ap0 for ap-mode

Understood. Looks logical. Thanks.

Pcie works with my kernel (i have mt7612-card running) but you need to include drivers for your card…

Maybe my mPCIe to USB3.0 card is not working - I have nowhere else to test it. Yet it should be at least seen in dmesg if it is working and provide 5v on usb. Anyway - no big deal about it.