Wi-Fi : Driver Build & Load
Topics in this section,
In this section, you are going to learn
How to load intel wifi driver
# |
Version |
---|---|
Freebsd |
14.1.0 |
wpa_supplicant |
2.10 |
By default, the wi-fi driver module is included in the kernel, so it needs to be separated from the kernel build.
To compile the kernel source code user should change the user acess to root previlege
Execute below command to redirect to root access
test:~$ su
Run the below command to change the directory to kernel source code location
test:~$ cd /usr/src/
Note: By default “/usr/src directory contain the exist version kernel source code. if you want to compile from externally, follow steps 3.1 and 3.2
test:~$ rm -rf /usr/src/* & rm -rf /usr/src/.*
test:~$ cd /usr
NOTE: git branch name “release/14.1.0” is for user validate. Based on user requirement clone the respective branch and compile it.
test:~$ git clone -b release/14.1.0 https://github.com/freebsd/freebsd-src.git
Copy all the directories and files from freebsd-src to src directory
test:~$ cp -rf freebsd-src/* src/ & cp -rf freebsd-src/.* src/
Run the below command to move to the sys directory
test:~$ cd /sys
Run the below command to move to the platform directory
Many platform source code available in the “/usr/src/sys” directory, based on requirement select platform directory and compile it.
test:~$ cd amd64
Run the below command to move to the conf directory
test:~$ cd conf
TESTCONF is custom configuration file name, you can mention any name
test:~$ cp GENERIC TESTCONF
Modify the configuration file which is required for the systems
Open TESTCONF file and copy below lines to TESTCONF file
test:~$ vi TESTCONF
ident GENERIC
ident TESTCONF
To disable the specific module on kernel. Open the kernel configuration file.
Comment the device which is used for the specific module
test:~$ vi /usr/src/sys/amd64/conf/TESTCONF
#device wlan
#device iwn
#device iwi
#device wpi
#device wlan_wep
#device wlan_ccmp
#device wlan_tkip
Change to src directory
test:~$ cd /usr/src/
Execute the below command to build the kernel source code
test:~$ make -j8 -DKERNFAST buildkernel KERNCONF=TESTCONF
Execute the below command to install the kernel module on system
test:~$ make -j8 installkernel KERNCONF=TESTCONF
Some of the Deamon running in background and allow to load the wlan modules automatically without user request.
Add the given line “ devmatch_enable=”NO” in /etc/rc.conf file and reboot the system.
In next reboot, system deamon wont allow a module to load automatically.
test:~$ vi /etc/rc.conf
devmatch_enable="NO"
Compile the wifi module: if_iwlwifi.ko
test:~$ cd /usr/src/freebsd-src/sys/modules/iwlwifi/
test:~$ make clean & make
Check compiled module “if_iwlwifi.ko” in this path
test:~$ cd /usr/obj/usr/src/freebsd-src/amd64.amd64/sys/modules/iwlwifi/
test:~$ ls -l
if_iwlwifi.ko
Compile another wifi module: wlan.ko
test:~$ cd /usr/src/freebsd-src/sys/modules/wlan/
test:~$ make clean & make
Check compiled module “wlan.ko” in this path
test:~$ cd /usr/obj/usr/src/freebsd-src/amd64.amd64/sys/modules/wlan/
test:~$ ls -l
wlan.ko
test:~$ cd /usr/obj/usr/src/freebsd-src/amd64.amd64/sys/modules/iwlwifi/
test:~$ kldload ./if_iwlwifi.ko
test:~$ cd /usr/obj/usr/src/freebsd-src/amd64.amd64/sys/modules/wlan/
test:~$ kldload ./wlan.ko
test:~$ iwconfig
Check if your FreeBSD laptop has an Intel Wi-Fi chipset
test:~$ pciconf -lv | grep -A1 -B4 network
iwlwifi0@pci0:0:20:3: class=0x028000 rev=0x20 hdr=0x00 vendor=0x8086 device=0xa0f0 subvendor=0x8086
subdevice=0x0074
vendor = 'Intel Corporation'
device = 'Wi-Fi 6 AX201'
class = network
From above pciconf output we know ‘Intel Wireless- ‘Wi-Fi 6 AX201’ chip is being used.
Wi-Fi Driver Compilation as Standalone:
By default, the Wi-Fi driver module is included in the kernel, so it needs to be separated from the kernel build.
The wifi module(if_iwlwifi) as a separate module by modifying the TESTCONF kernel configuration file:
test:~$ vim /usr/src/sys/amd64/conf/ TESTCONF --> TESTCONF is custom configuration file name
Comment the device which is used for the specific module.
Example:
#device wlan
#device iwn
#device iwi
#device wpi
#device wlan_wep
#device wlan_ccmp
#device wlan_tkip
Run the below command to change the directory.
test:~$ cd /usr/src/
Execute the below command to build the kernel source code.
test:~$ make -j8 -DNO_CLEAR buildkernel KERNCONF=TESTCONF
Execute the below command to install the kernel module on system
test:~$ make -j8 installkernel KERNCONF=TESTCONF
Note: Some of the Deamon running in background and allow to load the wlan modules automatically without user request. Add the given line “ devmatch_enable=”NO” “ in /etc/rc.conf file and reboot the system , when next reboot system daemon won’t allow a module to load automatically.
Reboot the system
test:~$ reboot
Compile the Wi-Fi module: if_iwlwifi.ko
test:~$ cd /usr/src/sys/modules/iwlwifi/
test:~$ make clean & make
Check compiled module “ if_iwlwifi.ko “ in this path
test:~$ cd /usr/obj/usr/src/amd64.amd64/sys/modules/iwlwifi/
test:~$ ls -l
if_iwlwifi.ko
Compile another Wi-Fi module: wlan.ko
test:~$ cd /usr/src /sys/modules/wlan/
test:~$ make clean & make
Check compiled module “ wlan.ko “ in this path
test:~$ cd /usr/obj/usr/src/amd64.amd64/sys/modules/wlan/
test:~$ ls -l
wlan.ko
Load the kernel module
test:~$ cd /usr/obj/usr/src/amd64.amd64/sys/modules/iwlwifi/
test:~$ kldload ./if_iwlwifi.ko
test:~$ cd /usr/obj/usr/src/amd64.amd64/sys/modules/wlan/
test:~$ kldload ./wlan.ko
Check your prints(if added print in source file) in dmesg logs
test:~$ dmesg | tail
If the modules need to be unloaded.
test:~$ kldunload wlan_wep.ko
test:~$ kldunload wlan_tkip.ko
test:~$ kldunload wlan_ccmp.ko
test:~$ kldunload wlan.ko
test:~$ kldunload if_iwlwifi.ko