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

Hold up, I thought 5.8-main compiled correctly. Instead, I found this error:

  CC      drivers/crypto/mediatek/mtk-aes.o
drivers/mmc/host/mtk-sd.c:439:24: error: duplicate member 'reset'
  struct reset_control *reset;
                        ^~~~~
scripts/Makefile.build:280: recipe for target 'drivers/mmc/host/mtk-sd.o' failed
scripts/Makefile.build:497: recipe for target 'drivers/mmc/host' failed
scripts/Makefile.build:497: recipe for target 'drivers/mmc' failed
make[3]: *** [drivers/mmc/host/mtk-sd.o] Error 1
make[2]: *** [drivers/mmc/host] Error 2
make[1]: *** [drivers/mmc] Error 2
make[1]: *** Waiting for unfinished jobs....

seems i had added patches to this file to fix mmc issue (afair for r64 emmc)

https://elixir.bootlin.com/linux/v5.8.18/source/drivers/mmc/host/mtk-sd.c#L418

just drop the resetcontrol from end of the struct…i do this too and make compile-test, but i will take some time

I just dropped that line as recommended, then branch 5.8-main compiles correctly.

thx, but i guess the reset is done twice now…will fix this too, so do not yet boot it up, only compile-test

edit: it seems only the struct-member was twice, so you can try booting it

Cool, it looks like 5.8 boots up fine on my R2 (don’t have a R64). hci0 can also be brought up.

in 5.17 i get the error

drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.c: In function 'wmt_detect_unlocked_ioctl':
drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.c:120:12: error: implicit declaration of function 'wmt_plat_get_soc_chipid' [-Werror=implicit-function-declaration]
  120 |   retval = wmt_plat_get_soc_chipid();
      |            ^~~~~~~~~~~~~~~~~~~~~~~

as far as i debugged, this filter in drivers/misc/mediatek/connectivity/common/Makefile does not match and do not include the conn_soc directory:

ifneq ($(filter "CONSYS_%",$(CONFIG_MTK_COMBO_CHIP)),)

MTK_COMBO_CHIP is set to this [=CONSYS_7623] so imho it should be included

but the filter seems not working, it returns empty string

$(warning $$MTK_PLATFORM is [${MTK_PLATFORM}])
$(warning $$CONFIG_MTK_COMBO_CHIP is [$(CONFIG_MTK_COMBO_CHIP)] (should not be empty))
$(warning filter-result: $(filter "CONSYS_%",$(CONFIG_MTK_COMBO_CHIP)))

shows this:

drivers/misc/mediatek/connectivity/common/Makefile:4: $MTK_PLATFORM is [mt7623]
drivers/misc/mediatek/connectivity/common/Makefile:5: $CONFIG_MTK_COMBO_CHIP is [CONSYS_7623] (should not be empty)
drivers/misc/mediatek/connectivity/common/Makefile:7: filter-result:

does anyone have an idea?

if i skip the check and always include the conn_soc, i get the same error about implicit declaration, but i have it in sourcefile defined, and it seems this is compiled

drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/wmt_plat_alps.c:1019:UINT32 wmt_plat_get_soc_chipid(void)
drivers/misc/mediatek/connectivity/common/conn_soc/mt7623/wmt_plat_alps.c:1026:EXPORT_SYMBOL(wmt_plat_get_soc_chipid);

uploaded my current state to 5.17-rc tree

seems problem is again the filter command in a makefile…

drivers/misc/mediatek/connectivity/common/common_detect/Makefile

-ifneq ($(filter "CONSYS_%",$(CONFIG_MTK_COMBO_CHIP)),)
+#ifneq ($(filter "CONSYS_%",$(CONFIG_MTK_COMBO_CHIP)),)
        subdir-ccflags-y += -D MTK_WCN_SOC_CHIP_SUPPORT
        ccflags-y += -I$(srctree)/$(src)/../conn_soc/linux/include
-endif
+#endif

MTK_WCN_SOC_CHIP_SUPPORT is guarding the extern function declaration in drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.h

The problem are the quotes around filter string…without them compiling works

but in system i get a

root@bpi-r2:~# echo A > /dev/wmtWifi                                            
-bash: echo: write error: Input/output error

:frowning: this had same rootcause…there were many other filter statements.got it solved so far.wifi is working.only see a trace on poweroff.

noticed some errors (maybe false positives) with wifi driver in gcc11 (gcc10 does not show this error)

drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c: In function '_stp_btm_put_dump_to_nl':
drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c:139:34: error: array subscript 'STP_PACKET_T {aka struct stp_dbg_pkt}[0]' is partly outside array bounds of 'UINT8[2048]' {aka 'unsigned char[2048]'} [-Werror=array-bounds]
  139 |                         len = pkt->hdr.len;
      |                                  ^~
drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c:116:22: note: while referencing 'buf'
  116 |         static UINT8 buf[2048];
      |                      ^~~
drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c: In function '_stp_btm_handler':
drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c:257:33: error: array subscript 'STP_PACKET_T {aka struct stp_dbg_pkt}[0]' is partly outside array bounds of 'UINT8[2048]' {aka 'unsigned char[2048]'} [-Werror=array-bounds]
  257 |                                 memcpy(&tmp[0], pkt->raw, pkt->hdr.len);
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/misc/mediatek/connectivity/common/conn_soc/core/btm_core.c:239:22: note: while referencing 'buf'
  239 |         static UINT8 buf[2048];
      |                      ^~~

imho buffer is large enough

#define STP_DMP_SZ 16

typedef struct stp_dbg_pkt_hdr {
	/* packet information */
	unsigned int sec;
	unsigned int usec;
	unsigned int dbg_type;
	unsigned int dmy;
	unsigned int no;
	unsigned int dir;

	/* packet content */
	unsigned int type;
	unsigned int len;
	unsigned int ack;
	unsigned int seq;
	unsigned int chs;
	unsigned int crc;
} STP_DBG_HDR_T;

typedef struct stp_dbg_pkt {
	struct stp_dbg_pkt_hdr hdr;
	unsigned char raw[STP_DMP_SZ];
} STP_PACKET_T;

so we have 12 x uint32 + 16 = 62 bytes, buffer is 2028, i guess the error comes because array is defined as bytes and types are uint32 so using 4 array-elements each

maybe anybody has an idea how to fix it (@BitMaster @deadmeat )…

the only solution i’ve found till now is adding “-Wno-array-bounds” to cflags…but maybe there is a better solution

hi,

currently i try to update driver for linux 6.0…@deadmeat and i already fixed some problems, but now we are hanging on these:

drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_cfg80211.c: In function 'mtk_p2p_cfg80211_start_ap':
drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_cfg80211.c:582:50: error: 'struct wireless_dev' has no member named 'preset_chandef'
  582 |         struct cfg80211_chan_def *chandef = &wdev->preset_chandef;
      |                                                  ^~

the preset_chandef has been removed in 6.0

some modern drivers use cfg80211_chandef_create even in kernels before 6.0 e.g.:

https://elixir.bootlin.com/linux/v6.0-rc1/source/drivers/net/wireless/ath/ath6kl/cfg80211.c#L1115

looks like in this commit the member was deleted: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7b0a0e3c3a88260b6fcb017e49f198463aa62ed1

any help @BitMaster @abbradar @LeXa2 @asac @dfiloni or maybe @graphine ?

@dougiefresh i dropped the quirk for bluetooth,if we get driver compilable can you please check the bluetooth function?