[BPI-R2] Kernel Development

Start wifi.sh…this calles wmt-tools to create ap0 device and sets ip and hostapd on top,then restart dnsmasq to enable dhcp on wifi-clients

To get it after reboot you have to add wifi.sh to autostart (e.g. rc.local,which has to be enabled in systemd systems)

How can I test it in client mode ? or is the work only done for ap mode?

Disable dnsmasq,ip and hostapd and change “echo A” to “echo 1”

I had not tried client mode…don’t know how to connect to ssid

This fails with error wmt_loader not found.

I just used the last file wmt_tools+scripts+config.zip only.

Nothing else.

Here is a img of the error.

wmt_loader is in the zip-file…just unpack it to root (/) then all files are on right position (wmt-tools in /usr/bin) and also config and firmware

Yes I copied it accordingly. But still the same error. Well need to try it again later.

Uploaded the IMG. If you can give it a try.

Maybe you need to add execute-rights… have not much time this weekend

Ofcourse I make it chmod -x. Anyways will try it again at night.

Sure have a good weekend. And try when ever possible.

it needs to be +x :slight_smile: (chmod a+x …)

May I ask you to do multiple reboots (like 20+) in a row testing that network works after each and every reboot you do?

Sure but I can do this tomorrow, as I only have lan connection in my office.

Sorry, was far from my home PC yesterday reading forum from mobile so hadn’t any chance to check what was happening. So, am I getting it correctly that you’re having failures building wifi driver when try to do out-of-tree build (i.e. KBUILD_OUTPUT is set)? If that’s the case - I think I’ve got the idea what might be causing this (*cough* hackish Makefiles in wifi driver *cough*) but to be sure I need to reproduce/test it.

you have understood me right :slight_smile:

to reproduce (i had used these steps):

using the merged branch of 5.4 (5.4-wifi should work too, but i don’t know if i have added the out-of-tree option to build.sh)

and then the usual steps (./build.sh importconfig; ./build.sh)

i already tried a bit in the makefile where the header-/c-files are lying, but i’ve found no cause for the strange behaviour

Maybe it is the mixing between $src and $srctree here: https://github.com/frank-w/BPI-R2-4.14/blob/9465a82fad2a2a086dfa72aa6fc77fd57f4d8a09/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile#L3 ? mhm, added a ${warning …} to this makefile, but it seems it is not called…after adding a additional warning on top of this makefile, both warning are shown :thinking:

/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:3: $(src) is [drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri] $(srctree) is [/media/data_fast/bpi/kernel/BPI-R2-4.14]

just as summarization which files are not found and where they are:

../drivers/misc/mediatek/btif/common/mtk_btif_exp.c:20:10: fatal error: mtk_btif.h: No such file or directory
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/btif/common/mtk_btif.c:37:10: fatal error: btif_pub.h: No such file or directory
../drivers/misc/mediatek/connectivity/wlan/gen2/common/dump.c:47:10: fatal error: precomp.h: No such file or directory
../drivers/misc/mediatek/connectivity/common/common_detect/drv_init/conn_drv_init.c:20:10: fatal error: wmt_detect.h: No such file or directory
../drivers/misc/mediatek/connectivity/common/common_detect/wmt_stp_exp.c:14:10: fatal error: osal_typedef.h: No such file or directory
../drivers/misc/mediatek/connectivity/common/conn_soc/core/wmt_core.c:39:10: fatal error: osal_typedef.h: No such file or directory
../drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/stp_btif.c:35:10: fatal error: osal_typedef.h: No such file or directory
  • ./drivers/misc/mediatek/btif/common/inc/mtk_btif.h
  • ./drivers/misc/mediatek/btif/common/plat_inc/btif_pub.h
  • ./drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h
  • ./drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.h
  • ./drivers/misc/mediatek/connectivity/common/conn_soc/linux/include/osal_typedef.h

after adding the last 2 dirs via -I in the drivers/misc/mediatek/connectivity/common/Makefile i got more missing files…

diff --git a/drivers/misc/mediatek/connectivity/common/Makefile b/drivers/misc/mediatek/connectivity/common/Makefile
index 622b74430e13..0528e08afd24 100644
--- a/drivers/misc/mediatek/connectivity/common/Makefile
+++ b/drivers/misc/mediatek/connectivity/common/Makefile
@@ -1,6 +1,7 @@
 subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/include/mt-plat/$(MTK_PLATFORM)/include
 subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/include/mt-plat
 
+${warning subdir-flags: [${subdir-ccflags-y}]}
 #ifneq ($(filter "MT6620E3",$(CONFIG_MTK_COMBO_CHIP)),)
 #      obj-y   +=  combo/
 #endif
@@ -18,6 +19,8 @@ subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/include/mt-plat
 #endif
 ifneq ($(filter "CONSYS_%",$(CONFIG_MTK_COMBO_CHIP)),)
        obj-y   +=  conn_soc/
+       subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/connectivity/common/conn_soc/linux/include/
 endif
 
 obj-y   +=  common_detect/
+subdir-ccflags-y += -Werror -I$(srctree)/drivers/misc/mediatek/connectivity/common/common_detect/

According to the Makefile in the root, $(srctree) is pointing to the absolute addess if set, while $(src) is the relative location. So they both server a different purpose, the former is probably more meant to include elemens like <linux/version.h>.

The makefile in e.g. BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/ has an include specified as

-I$(srctree)/drivers/misc/mediatek/btif/common/inc

which looks to correctly point to BPI-R2-4.14/drivers/misc/mediatek/btif/common/ inc / even though I am actually not sure if it should end with a ‘/’ instead?

However the definition in the Makefile of BPI-R2-4.14/drivers/misc/mediatek/btif/ common /:

-I$(src)/inc

… should probably be enough. After all the build system is in this folder to build mtk_btif_exp.c so it should only need to care about local includes.

Maybe it get confused because the build system find supposly multiple include files with the same name?

Maybe you can try in the makefile something like

ifneq ("$(wildcard $(src)/inc/mtk_btif.h)","")
    echo >&2 "Found mtk_btif.h in $(src)/inc/";
else
    echo >&2 "Not found mtk_btif.h in $(src)/inc/";
endif

to see if the makefile actually can at least ‘see’ the file (maybe permissions hide the folder?)

it looks like subdir-ccflags getting overridden, example:

i have now in drivers/misc/mediatek/connectivity/common/conn_soc/Makefile

 1 subdir-ccflags-y += \
 2         -I$(src)/linux/include \
 3         -I$(src)/linux/pri/include \
 4         -I$(src)/core/include \
 5         -I$(src)/include \
 6         -I$(src)/../common_detect \
 7         -I$(src)/../../../btif/common/inc
 8 #       -I$(srctree)/drivers/misc/mediatek/btif/common/inc

and ./drivers/misc/mediatek/connectivity/common/conn_soc/include/wmt_exp.h

but get error

/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/wmt_exp.c:41:10: fatal error: wmt_exp.h: No such file or directory

in drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile the include is also there (but in ccflags directly)

 5 ccflags-y += \
 6         -I$(src)/../../linux/include \
 7         -I$(src)/../../linux/pri/include \
 8         -I$(src)/../../core/include \
 9         -I$(src)/../../include \ <<<<<<<
10         -I$(src)/../include \
11         -I$(src)/../../../common_detect \
12         -I$(srctree)/drivers/misc/mediatek/btif/common/inc \
13         -I$(srctree)/drivers/misc/mediatek/mach/$(MTK_PLATFORM)/include/mach

Are you sure that subdir-ccflags-y getting overriden? As far as I get it, this is usually used to set a common setting for current and all sub directories, so should carry over down the folders.

By the way that folder structure looks a bit like a mess. For the file wmt_exp.c, I would have expected the related include file either in . (same folder), .\inc\ (sub folder) or if generic in ..\include\ but it is in neither but even one upper in ..\..\include\?

Anyway I think the majority of the ccflags-y in the makefile seems to be a bit redundant what was setup in the top Makefile and not sure they are all needed as they are supposed to be taken from the subdir-ccflags-y and should be added infront of the local ccflags-y definition, no?

Probably can try to add an other echo for those variabels like

    @echo  ""
    @echo  "------- Building wmt_exp -------"
    @echo  "ccflags-y = $(ccflags-y)"
    @echo  "obj-m = $(obj-m)"
    @echo  "--------------------------------"
    @echo  ""

I guessed ot is overridden because it is set in makefile but file not found…

The complete driver is a mess and due to the depencies to other folders it is very confusing.

after adding the @echo lines i get

*** missing separator.  Stop.

if i make a tab before @echo

*** recipe commences before first target.

if i transform it into $(warning …) i see this:

/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:1: $(CONFIG_MTK_COMBO) is [y]
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:2: $(src) is [drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri] $(srctree) is [/media/data_fast/bpi/kernel/BPI-R2-4.14]
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:27: "------- Building wmt_exp -------"
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:28: "ccflags-y =  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../linux/include -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../linux/pri/include -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../core/include -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../include -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../include -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../../common_detect -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/btif/common/inc -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/mach//include/mach -DWMT_CREATE_NODE_DYNAMIC=1"
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:29: "obj-y =  stp_btif.o stp_dbg.o stp_exp.o wmt_dev.o wmt_exp.o"
/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/Makefile:30: "--------------------------------"

before the wmt_exp.h is missing files from other directories get build…so it still looks that this include-dir is dropped somewhere, but this can also be caused by multithreading

drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../include

is set as include-dir, maybe a string-limit causing this (very long ccflags-subdir, if concatenated to ccflags it can reach 256chars easily)?

ls drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../include
stp_exp.h  wmt_exp.h  wmt.h  wmt_plat.h

the test from above from @sisyphos shows this (after translate to warning, only one line…):

 "Not found mtk_btif.h in drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/inc/"

tried also with wmt_exp.h and without the inc-folder

Sorry, indeed echo is from shell and inside of Makefile usually replaced by $(info ...), $(warning ...) or $(error ...).

Regarding the command line limit, in DOS it is about 32k, but in Linux this limit is several thousand characters long (on my Ubuntu build machine about 2M characters) and the ccflags-y line printed above is not even 1000 characters long. So I don’t think it is cut off. Nor should multithreating be an issue, the compile may use multiple threats, that the makefile is multithreating would be new to me.

So you end up with a ccflags-y like

ccflags-y =
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../linux/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../linux/pri/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../core/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/../../../common_detect
  -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/btif/common/inc
  -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/mach//include/mach
  -DWMT_CREATE_NODE_DYNAMIC=1

which should be equivalent to:

ccflags-y =
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/core/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/include
  -Idrivers/misc/mediatek/connectivity/common/conn_soc/linux/include
  -Idrivers/misc/mediatek/connectivity/common/common_detect
  -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/btif/common/inc
  -I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/mach//include/mach
  -DWMT_CREATE_NODE_DYNAMIC=1

with

-I/media/data_fast/bpi/kernel/BPI-R2-4.14/drivers/misc/mediatek/btif/common/inc

pointing to the mtk_btif.h file… strange

Can you rewrite that include to use the $(src) instead of $(srctree) syntax?

like -I$(src)/../../../../../btif/common/inc?

Anyway for me this include this high up in the hierarchy should be probably declared in the top level makfile of the subdir-ccflags-y declaration in BPI-R2-4.14/drivers/misc/ mediatek /

Edit: scrap the last part, as it is actually defined in the makefile of btif/common/ Makefile using a local path. Also you alreayd wrote that you tried commenting out -I$(srctree)/drivers/misc/mediatek/btif/common/inc.

Question though, is the ifneq ($(KERNELRELEASE),) actually evaluated, in other words, does it go inside of this branch?

Imho i had already tried dropping the condition and else-part