Adding WiFi Driver to the Kernel

Hello,

I wanted to add WiFi ath9k driver (generally change the kernel config) using open embedded core.

First of all I have started with the tutorial to build image using open embedded (core). I did all the settings and finally used bitbake angstrom-lxde-image to build the image. The built image working well.
Now I want to add Wireless drivers to support PCIe atheros WiFi cards.

I used bitbake -c menueconfig virtual/kernel to change the config of the kernel. Then added the all device drivers I need. And then saved the config file and used bitbake virtual/kernel to build new kernel based on the new config. After that I used again bitbake angstrom-lxde-image to build new image.

But still new image doesn’t detect PCIe. Also, when I use ifconfig it doesn’t show any wlan0 interface (it just have eth0, lo and usb0).

Could you please help me with that?
Am I doing something wrong or missing some steps?

Thanks.

Can you try with the following order of operations?

bitbake -c menuconfig virtual/kernel
bitbake -f  -c compile virtual/kernel
bitbake angstrom-lxde-image

IHello,

I did these step again but it doesn’t work and the image doesn’t show even wlan0.
I used these three steps:

 bitbake -c menuconfig virtual/kernel
 bitbake -f  -c compile virtual/kernel
 bitbake angstrom-lxde-image

After flashing new image I used connmanctl enable wifi to activate wifi but it shows "net.conmanctl.Technology" doesn't exist.. Even in ifconfig output I can not see Wlan0.
Should I add something, more in kernel more than ath9k driver to activate WiFi?

After flashing the module should I install anything else to activate WiFi? Because in config file I can put <M> for config of ath9k driver and I can not put <*> fir that.

Thanks.

Hi Asad,

You’re taking the right steps by using the commands recommended by @sanchayan.maity.

Make sure you also include the firmware in your image. Add IMAGE_INSTALL_append = " linux-firmware-ath9k" to the conf/local.conf file.

When you boot the image, check for the relevant ath9k configs in the running kernel by typing:

zcat /proc/config.gz | grep CONFIG_ATH

Also check the currently loaded kernel configs by entering lsmod - see if the ath9k driver is listed. You may also try searching for the kernel modules in /lib/modules:

find /lib/modules -name "*ath*.ko"

If the module is in “/lib/modules”, but isn’t listed in “lsmod”, then try entering:

depmod -a
modprobe ath9k

Also, verify that the firmware was installed in the correct location. Check /lib/firmware; for example, try checking for any of the following:

find /lib/firmware -name "*ath*"
find /lib/firmware -name "*ar9*"
find /lib/firmware -name "*htc_*"

Hi Brandon,

It seems that the driver has been installed :
for the lsmod command I can see this line: ath9k

For the find /lib/modules -name "*ath*.ko" I get:

/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko
/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko
/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko
/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath.ko
/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath10k/ath10k_core.ko
/lib/modules/3.14.28-V2.5b3+g0632def/kernel/drivers/net/wireless/ath/ath10k/ath10k_pci.ko

For the find /lib/firmware -name "*ath*" I get:

/lib/firmware/LICENCE.atheros_firmware

And for the find /lib/firmware -name "*ar9*" I get:

/lib/firmware/ar9271.fw

But I don’t know why I just see AR9271.fw in case that ath9k should support more atheros modules. This is the module I have:
https://www.thinkpenguin.com/gnu-linux/penguin-wireless-n-half-height-mini-pcie-card that uses Atheros AR9285 (2.4Ghz) chipset. And I know the ath9k should support this chipset too.

In addition to that why there is no wlan0 in ifconfig output?

I also need to add, when I use lspci it shows the detail of the module:

00:00.0 PCI bridge: Synopsys, Inc. Device abcd (rev 01)
01:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) (rev 01)

I added driver for Atheros AR9382 mini-PCIe module to Apalis i.MX6 v2.3 Linux (Linux 3.10) via recompiling Linux kernel instead of bitbake. Below items were what I added to Linux configuration.

[user@host linux-toradex]:~#make menuconfig

    [*] Networking support  --->
    	-*-   Wireless  ---> 
    		 <*>   cfg80211 - wireless configuration API
    		 <*>   Generic IEEE 802.11 Networking Stack (mac80211) 
    
    Device Drivers  --->
    [*] Network device support  ---> 
    	[*]   Wireless LAN  ---> 
    		<*>   Atheros Wireless Cards  ---> 
    			 <*>   Atheros 802.11n wireless cards support  
    			 [*]     Atheros ath9k PCI/PCIe bus support

After compile and reflashing kernel image to Apalis i.MX6, AR9382 worked well.

root@apalis-imx6:~# lspci
00:00.0 PCI bridge: Device 16c3:abcd (rev 01)
01:00.0 PCI bridge: PLX Technology, Inc. PEX 8605 PCI Express 4-port Gen2 Switch (rev aa)
02:01.0 PCI bridge: PLX Technology, Inc. PEX 8605 PCI Express 4-port Gen2 Switch (rev aa)
02:02.0 PCI bridge: PLX Technology, Inc. PEX 8605 PCI Express 4-port Gen2 Switch (rev aa)
02:03.0 PCI bridge: PLX Technology, Inc. PEX 8605 PCI Express 4-port Gen2 Switch (rev aa)
04:00.0 Network controller: Qualcomm Atheros AR93xx Wireless Network Adapter (rev 01)

root@apalis-imx6:/var/lib/connman# ifconfig
wlp4s0    Link encap:Ethernet  HWaddr 20:7C:8F:56:BC:DE  
          inet addr:10.20.248.47  Bcast:10.20.248.255  Mask:255.255.255.0
          inet6 addr: fe80::227c:8fff:fe56:bcde/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:24 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:5436 (5.3 KiB)  TX bytes:7047 (6.8 KiB)

root@apalis-imx6:/var/lib/connman# ping 10.20.248.1
PING 10.20.248.1 (10.20.248.1): 56 data bytes
64 bytes from 10.20.248.1: seq=0 ttl=255 time=7.834 ms
64 bytes from 10.20.248.1: seq=1 ttl=255 time=2.614 ms

Hi,

Thanks for the information.
Could you please show me the output of this command in your system ?

find /lib/firmware -name "*ar9*"

I was wondering if your system has the firmware module for this specific Atheros AR9382 module? Something like : /lib/firmware/ar9382.fw. In my system after flashing new image I have all ath9k drivers and I checked the same setting in menuconfig but I don’t know why in find /lib/firmware I just see one atheros module: ar9271.fw

In addition to that what is difference between building kernel from the source or building using bitbake?

This is also the output of dmesg | grep ath:

[    7.415773] Modules linked in: ath9k(+) ath9k_common ath9k_hw ath mac80211 max9526_tvin v4l2_int_device cfg80211 libcomposite configfs
[    7.428349] [<8065b2f8>] (dump_stack) from [<8002e464>] (warn_slowpath_common+0x74/0x90)
[    7.428364] [<8002e3f0>] (warn_slowpath_common) from [<8002e524>] (warn_slowpath_null+0x24/0x2c)
[    7.428389] [<8002e500>] (warn_slowpath_null) from [<80070744>] (request_threaded_irq+0x104/0x12c)
[    7.428492] [<80070640>] (request_threaded_irq) from [<7f1470d4>] (ath_pci_probe+0x1a0/0x2dc [ath9k])
[    7.428573] [<7f146f34>] (ath_pci_probe [ath9k]) from [<802d46b8>] (pci_device_probe+0x7c/0xd0)
[    7.428783] [<802d415c>] (__pci_register_driver) from [<7f147348>] (ath_pci_init+0x28/0x2c [ath9k])
[    7.428843] [<7f147320>] (ath_pci_init [ath9k]) from [<7f156010>] (ath9k_init+0x10/0x4c [ath9k])
[    7.428875] [<7f156000>] (ath9k_init [ath9k]) from [<80008874>] (do_one_initcall+0x100/0x15c)
[    7.428968] ath9k 0000:01:00.0: request_irq failed
[    7.429084] ath9k: probe of 0000:01:00.0 failed with error -22

Thanks.

Hi Asad,

What is the output of zcat /proc/config.gz | grep 80211?

This is the output:

CONFIG_CFG80211=m
# CONFIG_NL80211_TESTMODE is not set
# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
# CONFIG_CFG80211_REG_DEBUG is not set
# CONFIG_CFG80211_CERTIFICATION_ONUS is not set
CONFIG_CFG80211_DEFAULT_PS=y
# CONFIG_CFG80211_DEBUGFS is not set
# CONFIG_CFG80211_INTERNAL_REGDB is not set
# CONFIG_CFG80211_WEXT is not set
CONFIG_LIB80211=m
CONFIG_LIB80211_CRYPT_WEP=m
CONFIG_LIB80211_CRYPT_CCMP=m
CONFIG_LIB80211_CRYPT_TKIP=m
# CONFIG_LIB80211_DEBUG is not set
CONFIG_MAC80211=m
CONFIG_MAC80211_HAS_RC=y
# CONFIG_MAC80211_RC_PID is not set
CONFIG_MAC80211_RC_MINSTREL=y
CONFIG_MAC80211_RC_MINSTREL_HT=y
CONFIG_MAC80211_RC_DEFAULT_MINSTREL=y
CONFIG_MAC80211_RC_DEFAULT="minstrel_ht"
# CONFIG_MAC80211_MESH is not set
CONFIG_MAC80211_LEDS=y
CONFIG_MAC80211_DEBUGFS=y
# CONFIG_MAC80211_MESSAGE_TRACING is not set
# CONFIG_MAC80211_DEBUG_MENU is not set
# CONFIG_MAC80211_HWSIM is not set

I did a little research, it seems this device doesn’t require firmware to be loaded.

I think this patch may help: https://dev.openwrt.org/browser/trunk/target/linux/imx6/patches-3.14/0055-ARM_dts_imx_fix-invallid-%23address-cells-value.patch?rev=41004&order=name

Try removing line 51 & 52 from this file and then rebuilding the device tree: imx6qdl.dtsi « dts « boot « arm « arch - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

You should be able to do this in Yocto by modifying the device tree of the kernel source in the work-shared directory and then force recompile using bitbake -f -c compile virtual/kernel.

Let me know if that helps

Hi Asad,

I just noticed that this and other PCI fixes are already made as part of our ‘-next’ branch: https://git.toradex.com/cgit/linux-toradex.git/log/?h=toradex_imx_3.14.28_1.0.0_ga-next.

Hello Benjamin,

I am trying to do a similar procedure for a Altera SoC where in I want to interface TP-Link TL-WN722N wifi dongle. The option (Atheros/Qualcomm)is enabled in make menuconfig .
When I plug in the device in the Altera SoC, I am able to see the device ID and name with the dmesg command. Howeer, I observe the following errors as well:

[   2.223039] usb 1-1: New USB device found, idVendor=0cf3, idProduct=9271
[    2.229735] usb 1-1: New USB device strings: Mfr=16, Product=32, SerialNumber=48
[    2.237129] usb 1-1: Product: USB2.0 WLAN
[    2.241124] usb 1-1: Manufacturer: ATHEROS
[    2.245215] usb 1-1: SerialNumber: 12345
[    5.351145] EXT4-fs (mmcblk0p2): recovery complete
[    5.359958] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    5.368058] VFS: Mounted root (ext3 filesystem) on device 179:2.
[    5.375560] devtmpfs: mounted
[    5.379310] Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
**[    5.670820] systemd[1]: Failed to insert module 'autofs4': No such file or directory**
[    5.722709] systemd[1]: systemd 226 running in system mode. (+PAM -AUDIT -SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP -LIBCRYPTSETUP -GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD +IDN)
[    5.741016] systemd[1]: Detected architecture arm.
[    5.773409] systemd[1]: Set hostname to <cyclone5>.

It states the error : Failed to insert module ‘autofs4’ .
Have you faced such a situation ? what could be the possible reasons?

Also when I see the path /lib/modules/.../kernel/drivers/net I observe only 2 modules ethernet and mdio.ko

can anyone please explain me the steps to add the driver. I am trying to interface the wifi dongle with cyclone v processor and unfortunately the drivers are not present in /lib/modules/../kernel/drivers/net/.
I have also enabled the appropriate ath9k_htc option in the make menuconfig option.
The firmware is present in the folder /lib/firmware . However when I plug in, I observe the following error:

[    2.309362] usb 1-1: ath9k_htc: Firmware htc_9271-1.4.0.fw requested
[    2.317158] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
[    2.325761] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
[    2.331607] usb 1-1: Direct firmware load for htc_9271.fw failed with error -2
[    2.338817] usb 1-1: no suitable firmware found!
[    2.343428] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
[    2.349896] usb 1-1: ath9k_htc: USB layer deinitialized

Can anyone guide me with this issue?

Update: So I could locate the drivers now in the filesystem. /sys/bus/usb/drivers/ath9k/

SO the issue currently is with the firmware. The USB dongle somehow does not seem to find the firmware. There was no folder named firmware in /lib/so I created manually a new folder named firmware and placed the firmware fileshtc_7010.fwandhtc_9271.fwin there. But the usb tried to search forath9k_htc/htc_9271-1.4.0.fwin the first try and thenhtc_9271.fw. My question is now that is the path/lib/firmware` correct for placing the firmware files there for the Angstrom, or should they b placed at some other path?

Update to the issue :

can anyone please explain me the steps to add the driver. I am trying to interface the wifi dongle with cyclone v processor and unfortunately the drivers are not present in /lib/modules/../kernel/net/.
I have also enabled the appropriate ath9k_htc option in the make menuconfig option. The firmware is present in the folder lib/firmware . However when I plug in, I observe the following error:

[    2.309362] usb 1-1: ath9k_htc: Firmware htc_9271-1.4.0.fw requested
 [    2.317158] usb 1-1: Direct firmware load for ath9k_htc/htc_9271-1.4.0.fw failed with error -2
 [    2.325761] usb 1-1: ath9k_htc: Firmware htc_9271.fw requested
 [    2.331607] usb 1-1: Direct firmware load for htc_9271.fw failed with error -2
 [    2.338817] usb 1-1: no suitable firmware found!
 [    2.343428] usb 1-1: ath9k_htc: Failed to get firmware htc_9271.fw
 [    2.349896] usb 1-1: ath9k_htc: USB layer deinitialized

You’ll need to move htc_9271-1.4.0.fw (exact name is important file htc_9271.fw is not a appropriate firmware for your card) to /lib/firmware/ath9k_htc/
You can find all current firmwares with correct directory structure here:
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/

Anyway, This forum is a support forum for users of our SoMs, and our custom BSPs, we’re not providing support for other products.