How to enable SDIO WiFi in imx7

Hi,
I want to enable SDIO (WiFi) interface from menuconfig but don’t see the option as given in Toradex help page as:

[user@host linux-toradex]$ make menuconfig
Device Drivers  --->
[*] Network device support  --->
[*]   Wireless LAN  --->
<*>   Marvell WiFi-Ex Driver
<*>   Marvell WiFi-Ex Driver for SD8786/SD8787/SD8797/SD8887/SD8897
 (4 times)
Do you wish to save your new configuration? 

What i get is below:
[*] Network device support  --->
[*]   Wireless 
and there is no Marvell options.

I use Linux2.8B

The Angstrom Distribution colibri-imx7-emmc ttymxc0
Angstrom v2017.12 - Kernel
Colibri-iMX7-eMMC_Console-Image 2.8b6 20190801

root@colibri-imx7-emmc:~# uname -a
Linux colibri-imx7-emmc 4.9.166-2.8.6+gd899927728be #1 SMP Mon Jul 22 18:51:47 UTC 2019 armv7l GNU/Linux

Thank you
Neeraj

Hi @neeraj.verma

Which Kernel branch are you compiling?

Best regards,
Jaski

Hi @jaski.tx ,
I use below branch:
repo init -u Index of /toradex-bsp-platform.git -b LinuxImageV2.8

I pulled 3.0 even though I don’t see option as described in support link.

— Wireless │ │
│ │ cfg80211 - wireless configuration API │ │
│ │ nl80211 testmode command │ │
│ │ enable developer warnings │ │
│ │ cfg80211 certification onus │ │
│ │ [] enable powersave by default │ │
│ │ [ ] cfg80211 DebugFS entries │ │
│ │ [ ] use statically compiled regulatory rules database │ │
│ │ [ ] cfg80211 wireless extensions compatibility │ │
│ │ Generic IEEE 802.11 Networking Stack (mac80211) │ │
│ │ [
] Minstrel │ │
│ │ [*] Minstrel 802.11n support │ │
│ │ Minstrel 802.11ac support │ │
│ │ Default rate control algorithm (Minstrel) —> │ │
│ │ Enable mac80211 mesh networking (pre-802.11s) support │ │
│ │ Enable LED triggers │ │
│ │ Export mac80211 internals in DebugFS │ │
│ │ Trace all mac80211 debug messages │ │
│ │ Select mac80211 debugging features ----

Could you please help me if I am missing something?

You need to get the kernel sources and enable the wifi driver there and not in the Open embedded Environment.

Hi @jaski.tx
I pulled git clone -b toradex_4.14-2.0.x-imx git://git.toradex.com/linux-toradex.git branch and check ‘make menuconfig’ but I don’t see option to enable SDIO.
if I remember correctly I see exactly same options as I was getting in case of bitbake when pulling code using repo init -u Index of /toradex-bsp-platform.git -b LinuxImage3.0 -m default.xml

Could you please help?

Thank You
Neeraj

First of all, you are comparing two different things. The Wifi drivers are backports drivers in our kernel which were dropped in Bsp 3.0. So you won’t see them in the regular 4.1 or 4.9 branch.

So for Bsp 2.8, you would need to follow the instructions of backports integration.

Best regards,
Jaski

I am sorry for the confusion. I followed the steps as Kernel Driver Backports Integration
I have pulled code “git clone git://git.toradex.com/backports-toradex.git” and can see the options in make menuconfig for enable/disable WiFi what I need.

Which path is this? export KLIB_BUILD=~/linux-toradex
but I am seeing build failure and not sure what is the reason. I set env as below:

export ARCH=arm
export PATH=~/gcc-linaro/bin/:$PATH
export CROSS_COMPILE=arm-linux-gnueabihf-
export KLIB=/build/build_wifi
export KLIB_BUILD=/build/linux-toradex

Build Error:  
neeraj.verma@IRVAPPARM1:/build/backports-toradex$ make -j4 modules
make[4]: 'conf' is up to date.
warning: (USB_ALI_M5632 && USB_AN2720 && USB_BELKIN && USB_ARMLINUX && USB_EPSON2888 && USB_KC2190) selects USB_NET_CDC_SUBSET_ENABLE which has unmet direct dependencies (USB_NET_DRIVERS && n && m && BP_MODULES && USB_NET_CDC_SUBSET)
warning: (USB_ALI_M5632 && USB_AN2720 && USB_BELKIN && USB_ARMLINUX && USB_EPSON2888 && USB_KC2190) selects USB_NET_CDC_SUBSET_ENABLE which has unmet direct dependencies (USB_NET_DRIVERS && n && m && BP_MODULES && USB_NET_CDC_SUBSET)
#
# configuration written to .config
#
Building backport-include/backport/autoconf.h ... done.

  ERROR: Kernel configuration is invalid.
         include/generated/autoconf.h or include/config/auto.conf are missing.
         Run 'make oldconfig && make prepare' on kernel src to fix it.
WARNING: Symbol version dump ./Module.symvers
       is missing; modules will have no dependencies and modversions.

/--------------
| You shouldn't run make in the backports tree, but only in
| the generated output. This here is only the skeleton code
| copied into the output directory. To use the backport system
| from scratch, go into the top-level directory and run
|	./gentree.py /path/to/linux-next/ /tmp/output
| and then make menuconfig/... in the output directory. See
|	./gentree.py --help
| for more options.
\--
  Building modules, stage 2.
scripts/Makefile.modpost:43: include/config/auto.conf: No such file or directory
/--------------
| You shouldn't run make in the backports tree, but only in
| the generated output. This here is only the skeleton code
| copied into the output directory. To use the backport system
| from scratch, go into the top-level directory and run
|	./gentree.py /path/to/linux-next/ /tmp/output
| and then make menuconfig/... in the output directory. See
|	./gentree.py --help
| for more options.
\--
/build/backports-toradex/Makefile:40: recipe for target 'include/config/auto.conf' failed
make[4]: *** [include/config/auto.conf] Error 1
Makefile:1537: recipe for target 'modules' failed
make[3]: *** [modules] Error 2
Makefile.build:6: recipe for target 'modules' failed
make[2]: *** [modules] Error 2
Makefile.real:88: recipe for target 'modules' failed
make[1]: *** [modules] Error 2
Makefile:40: recipe for target 'modules' failed
make: *** [modules] Error 2
neeraj.verma@IRVAPPARM1:/build/backports-toradex$ make oldconfig && make prepare
make[2]: 'conf' is up to date.
warning: (USB_ALI_M5632 && USB_AN2720 && USB_BELKIN && USB_ARMLINUX && USB_EPSON2888 && USB_KC2190) selects USB_NET_CDC_SUBSET_ENABLE which has unmet direct dependencies (USB_NET_DRIVERS && n && m && BP_MODULES && USB_NET_CDC_SUBSET)
warning: (USB_ALI_M5632 && USB_AN2720 && USB_BELKIN && USB_ARMLINUX && USB_EPSON2888 && USB_KC2190) selects USB_NET_CDC_SUBSET_ENABLE which has unmet direct dependencies (USB_NET_DRIVERS && n && m && BP_MODULES && USB_NET_CDC_SUBSET)
#
# configuration written to .config
#
make[1]: *** No rule to make target 'prepare'.  Stop.
Makefile:40: recipe for target 'prepare' failed
make: *** [prepare] Error 2

Thank You
Neeraj

Hi Neeraj

Which path is this? export KLIB_BUILD=~/linux-toradex

This is where you downloaded the sources of the downstream kernel ( 4. x).

export KLIB_BUILD=/build/linux-toradex
Are you sure that this kernel path is correct?
You should correct the path above and then the compilation should work.

Best regards,
Jaski

Hi @jaski.tx
Thank you for your help.
I am able to proceed but now getting another errors.

Following below:

  1. Set evn variables

    export ARCH=arm
    export PATH=~/gcc-linaro/bin/:$PATH
    export CROSS_COMPILE=arm-linux-gnueabihf-
    export KLIB=/build/build_wifi
    export KLIB_BUILD=/build/linux-toradex
    :

  2. Download kernel & build

    git clone -b toradex_4.14-2.0.x-imx git://git.toradex.com/linux-toradex.git
    make colibri_imx7_defconfig
    disable the drivers/dependencies, open .config and commented out CONFIG_CFG80211 & CONFIG_WLAN
    make -j16 zImage 2>&1 | tee build.log
    make imx7d-colibri-emmc-eval-v3.dtb
    :

  3. Download backport drivers

    git clone git://git.toradex.com/backports-toradex.git
    cd backports-toradex
    git checkout -b toradex-4.14 origin/toradex-4.14
    make defconfig-wifi
    make -j16 modules

    Error while (make -j16 modules):
    CC [M] /build/backports-toradex/net/wireless/sysfs.o
    /build/backports-toradex/compat/lib-iov_iter.c:1099:21: error: redefinition of ‘kvmalloc’
    static inline void *kvmalloc(size_t size, gfp_t flags)
    ^
    In file included from /build/backports-toradex/backport-include/linux/mm.h:3:0,
    from ./include/linux/pagemap.h:8,
    from /build/backports-toradex/compat/lib-iov_iter.c:4:
    ./include/linux/mm.h:529:21: note: previous definition of ‘kvmalloc’ was here
    static inline void *kvmalloc(size_t size, gfp_t flags)
    ^
    /build/backports-toradex/compat/lib-iov_iter.c:1104:21: error: redefinition of ‘kvmalloc_array’
    static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags)
    ^
    In file included from /build/backports-toradex/backport-include/linux/mm.h:3:0,
    from ./include/linux/pagemap.h:8,
    from /build/backports-toradex/compat/lib-iov_iter.c:4:
    ./include/linux/mm.h:542:21: note: previous definition of ‘kvmalloc_array’ was here
    static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags)^
    Thank You,
    Neeraj

HI @neeraj.verma

First of all, you don’t need backports for Bsp 3.0 (kernel 4.14).

export KLIB=/build/build_wifi
export KLIB_BUILD=/build/linux-toradex

As already said before, this path might not work as a regular user, you are not allowed to write to this path. You should rather use /home/username/...

Regarding the error, did you setup the Toolchain and exported the variables correctly. You should check this by echo $ARCH.

I tested this on my side and the compilation worked perfectly.

Best regards,
Jaski

Hi @jaski.tx ,
when I built 2.8 kernel, build was okay and I am able to find .ko files below:

scp -r ~/build_wifi/lib/modules/3.1.10-g54d69d3 root@172.16.114.56:/lib/modules/

I loaded module using “insmod mwifiex.ko” and can see :

root@colibri-imx7-emmc:/# lsmod
Module                  Size  Used by
**mwifiex               270988  0**
bluetooth             339518  2
usb_f_rndis            15714  2
u_ether                12580  1 usb_f_rndis
rtl8xxxu              108816  0
mac80211              390819  1 rtl8xxxu
cfg80211              254686  2 mwifiex,mac80211
compat                 91786  5 mwifiex,bluetooth,mac80211,rtl8xxxu,cfg80211
libcomposite           44419  10 usb_f_rndis
configfs               31094  3 usb_f_rndis,libcomposite

how can I use this? I do not see phy in ifconfig
Could you please help me?

Thank You
Neeraj

Hi Neeraj
Could you share the dmesg.log and output of ( uname -a ) in a text file?

Thanks and best regards,
Jaski

Hi @jaski.tx ,

root@colibri-imx7-emmc:/# uname -a
Linux colibri-imx7-emmc 4.9.166-2.8.6+gd899927728be #1 SMP Fri Nov 22 17:54:00 UTC 2019 armv7l GNU/Linux
root@colibri-imx7-emmc:/#

Attaching log files (before dmesg and after).
link text

Hi Neeraj

According to the dmesg.log the Ethernet and Wireless is present and connected. I don’t get it what is your issue?

Best regards,
Jaski

Hi @jaski.tx ,
Issues is, I am not able to see interface mlan0 which is Marvell SDIO. Ethernet and wlan0 is known working interfaces in board.
actually I get below error which I noticed when used serial/debug port to see console message. (I was using ssh earlier).

root@colibri-imx7-emmc:/lib/modules/4.9.166-2.8.6+gd899927728be/updates/drivers/net/wireless/marvell/mwifiex# insmod mwifiex.ko
[  219.889053] mwifiex: Unknown symbol cfg80211_sched_scan_results (err 0)
[  219.896049] mwifiex: Unknown symbol cfg80211_chandef_dfs_required (err 0)
[  219.902972] mwifiex: Unknown symbol cfg80211_scan_done (err 0)
[  219.909055] mwifiex: Unknown symbol cfg80211_sched_scan_stopped (err 0)
[  219.915924] mwifiex: Unknown symbol cfg80211_remain_on_channel_expired (err 0)
[  219.923286] mwifiex: Unknown symbol cfg80211_cac_event (err 0)
[  219.929473] mwifiex: Unknown symbol ieee80211_amsdu_to_8023s (err 0)
[  219.936112] mwifiex: Unknown symbol regulatory_hint (err 0)
[  219.941853] mwifiex: Unknown symbol cfg80211_find_ie_match (err 0)
[  219.948238] mwifiex: Unknown symbol cfg80211_chandef_valid (err 0)
[  219.954733] mwifiex: Unknown symbol cfg80211_new_sta (err 0)
[  219.960502] mwifiex: Unknown symbol cfg80211_disconnected (err 0)
[  219.976652] mwifiex: Unknown symbol wiphy_new_nm (err 0)
[  219.992114] mwifiex: Unknown symbol cfg80211_ready_on_channel (err 0)
[  220.008983] mwifiex: Unknown symbol cfg80211_classify8021d (err 0)
[  220.025453] mwifiex: Unknown symbol wiphy_register (err 0)
[  220.041136] mwifiex: Unknown symbol cfg80211_put_bss (err 0)
[  220.057109] mwifiex: Unknown symbol cfg80211_ch_switch_notify (err 0)
[  220.073750] mwifiex: Unknown symbol cfg80211_tdls_oper_request (err 0)
[  220.090284] mwifiex: Unknown symbol ieee80211_bss_get_ie (err 0)
[  220.106609] mwifiex: Unknown symbol cfg80211_ibss_joined (err 0)
[  220.123114] mwifiex: Unknown symbol cfg80211_michael_mic_failure (err 0)
[  220.140138] mwifiex: Unknown symbol wiphy_apply_custom_regulatory (err 0)
[  220.157229] mwifiex: Unknown symbol ieee80211_get_channel (err 0)
[  220.173722] mwifiex: Unknown symbol cfg80211_del_sta_sinfo (err 0)
[  220.190419] mwifiex: Unknown symbol wiphy_unregister (err 0)
[  220.206487] mwifiex: Unknown symbol cfg80211_sched_scan_stopped_rtnl (err 0)
[  220.223961] mwifiex: Unknown symbol cfg80211_get_bss (err 0)
[  220.239702] mwifiex: Unknown symbol rfc1042_header (err 0)
[  220.254841] mwifiex: Unknown symbol cfg80211_mgmt_tx_status (err 0)
[  220.270416] mwifiex: Unknown symbol ieee80211_channel_to_frequency (err 0)
[  220.286657] mwifiex: Unknown symbol cfg80211_rx_mgmt (err 0)
[  220.301804] mwifiex: Unknown symbol cfg80211_chandef_create (err 0)
[  220.317482] mwifiex: Unknown symbol cfg80211_report_wowlan_wakeup (err 0)
[  220.333324] mwifiex: Unknown symbol cfg80211_inform_bss_data (err 0)
[  220.348420] mwifiex: Unknown symbol ieee80211_frequency_to_channel (err 0)
[  220.364114] mwifiex: Unknown symbol cfg80211_radar_event (err 0)
[  220.378966] mwifiex: Unknown symbol bridge_tunnel_header (err 0)
[  220.393740] mwifiex: Unknown symbol cfg80211_find_vendor_ie (err 0)
[  220.408929] mwifiex: Unknown symbol cfg80211_connect_done (err 0)
[  220.423926] mwifiex: Unknown symbol wiphy_free (err 0)
[  220.438044] mwifiex: Unknown symbol cfg80211_cqm_rssi_notify (err 0)
insmod: ERROR: could not insert module mwifiex.ko: Unknown symbol in module
root@colibri-imx7-emmc:/lib/modules/4.9.166-2.8.6+gd899927728be/updates/drivers/net/wireless/marvell/mwifiex# [  297.004583] random: crng init done

Could you check the output of lsmod? If cfg80211 is not present, then you should load ( insmod) it before.

Best regards,
Jaski

Hi @jaski.tx ,
You were right, these errors are gone… but I do not see SDIO interface up.

root@colibri-imx7-emmc:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:14:2D:61:D8:7D
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:82 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:6220 (6.0 KiB)  TX bytes:6220 (6.0 KiB)

usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@colibri-imx7-emmc:~#
root@colibri-imx7-emmc:~# modprobe cfg80211
[   24.443109] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   24.461400] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
root@colibri-imx7-emmc:~# modprobe mwifiex
root@colibri-imx7-emmc:~# dmesg | grep -i mwifiex_sdio
root@colibri-imx7-emmc:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:14:2D:61:D8:7D
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:242 errors:0 dropped:0 overruns:0 frame:0
          TX packets:242 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:17740 (17.3 KiB)  TX bytes:17740 (17.3 KiB)

usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@colibri-imx7-emmc:~# lsmod
Module                  Size  Used by
mwifiex               270988  0
cfg80211              254686  1 mwifiex
bluetooth             339518  2
compat                 91786  3 mwifiex,bluetooth,cfg80211
usb_f_rndis            15714  2
u_ether                12580  1 usb_f_rndis
libcomposite           44419  10 usb_f_rndis
configfs               31094  3 usb_f_rndis,libcomposite
root@colibri-imx7-emmc:~#

Do I have to modify device tree?

&usdhc1 {
#ifdef SD_1_8
    pinctrl-names = "default", "state_100mhz", "state_200mhz";
    pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_cd_usdhc1>;
    pinctrl-1 = <&pinctrl_usdhc1_100mhz &pinctrl_cd_usdhc1>;
    pinctrl-2 = <&pinctrl_usdhc1_200mhz &pinctrl_cd_usdhc1>;
    vqmmc-supply = <&reg_LDO2>;
#else
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_cd_usdhc1>;
    no-1-8-v;
#endif
    /*cd-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; */
    disable-wp;
    enable-sdio-wakeup;
    keep-power-in-suspend;
    wakeup-source;
    status = "okay";
    vmmc-supply = <&reg_3v3>;
};
&usdhc1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_usdhc1 &pinctrl_cd_usdhc1>;
    /*cd-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;*/
    disable-wp;
};

Thank you
Neeraj

Hi @neeraj.verma

You have to bring up the Wifi as described here. The device-tree changes are just needed if you have fast SDIO Wifi card. We treated the question about Sdio Wifi Speed here.

Best regards,
Jaski

Hi @jaski.tx ,
I am getting below error now (using CYW43455 chipset):

root@colibri-imx7-emmc:~# modprobe cfg80211
[  130.078540] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[  130.093959] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
root@colibri-imx7-emmc:~# modprobe mwifiex
root@colibri-imx7-emmc:~# connmanctl
Error getting VPN connections: The name net.connman.vpn was not provided by any .service filescconnmanctl> enable wifi
Error wifi: Method "SetProperty" with signature "sv" on interface "net.connman.Technology" doesn't exist

connmanctl> quit
root@colibri-imx7-emmc:~# lsmod
Module                  Size  Used by
mwifiex               270988  0
cfg80211              254686  1 mwifiex
usb_f_rndis            15714  2
u_ether                12580  1 usb_f_rndis
bluetooth             339518  2
compat                 91786  3 mwifiex,bluetooth,cfg80211
libcomposite           44419  10 usb_f_rndis
configfs               31094  3 usb_f_rndis,libcomposite
root@colibri-imx7-emmc:~#
root@colibri-imx7-emmc:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:14:2D:61:D8:7D
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1682 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1682 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:121420 (118.5 KiB)  TX bytes:121420 (118.5 KiB)

usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@colibri-imx7-emmc:~#

Thank you
Neeraj