记录一下自己移植AR9374wifi驱动的一些问题。
1.解压拿到的驱动程序;
tar -xzvf ATH6KL-LSDK-WLAN-AIO-5.0.0.28.tgz
2.进入其中的build/scripts目录,将其中的x86文件夹拷贝一份,重命名为arm。修改其中的config.x86、Makefile.x86名称为arm后缀。修改config.arm其中的KERNELPATH为内核的路径,KERNELARCH=arm,TOOLPREFIX为自己的交叉编译器,注释掉export BUILD_DRIVERFW_TOLOCAL=y。Makefile.arm中的一些不需要的工具从targetList中注释掉。
3.进入自己的内核目录,make menuconfig找到 Networking support ---> Wireless ---> cfg80211 - wireless configuration API ,
将此选项cfg80211设置为Module,否则编译ar9374驱动时会依赖内核的配置,即不选择模块的话,驱动中的cfg80211将不会被编译,而是使用内核自己的cfg80211。
4.回到build目录,make BOARD_TYPE=arm drivers_patch,将patch打上(有的驱动如果是新的可以不用patch)。然后直接make BOARD_TYPE=arm,一般可以直接编译通过,生成的驱动文件在上级目录的rootfs-arm.build目录中,有固件和3个ko文件。如果编译出现implicit declaration of function 'vmalloc',vmalloc未定义的话,在头文件中加上#include <linux/vmalloc.h>即可。
5.将rootfs-arm.build中的firmware和ko移到自己的文件系统中,firmware要在lib目录下。就可以insmod这3个ko了。可以看到iwconfig已经能找到wifi的node了。
# insmod /tmp/mmcblk0p1/cfg80211.ko
[ 39.490000] Calling CRDA to update world regulatory domain
[ 39.500000] World regulatory domain updated:
[ 39.500000] (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp)
# [ 39.530000] (2302000 KHz - 2382000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
[ 39.580000] (2402000 KHz - 2482000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
[ 39.580000] (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
[ 39.640000] (5110000 KHz - 5250000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
[ 39.710000] (5250000 KHz - 5710000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
[ 39.720000] (5735000 KHz - 5835000 KHz @ 20000 KHz), (300 mBi, 500 mBm)
# insmod /tmp/mmcblk0p1/compat.ko
# insmod /tmp/mmcblk0p1/ath6kl_usb.ko
[ 54.160000] <6>ath6kl: 3VAP/1, P2P enable, concurrent on , with dedicate p2p-device, multi-channel-concurrent enable, p2p-compat disable, sta-p2p-ie removed, p2p_wise_scan enable
[ 54.180000] <6>ath6kl: target bootstrap: 0x00000810
[ 54.810000] <6>ath6kl: target's subtype is 0x7, HT20/40 2SS Dual-band
[ 54.890000] <6>ath6kl: Create HTC cookie, type 1 num 440
[ 54.930000] <6>ath6kl: Create HTC cookie, type 2 num 66
[ 54.930000] <6>ath6kl: P2P flowctrl enabled
[ 54.970000] <6>ath6kl: RX aggregation drop disabled
[ 54.970000] <6>ath6kl: Using driver's regdb.
[ 55.450000] <6>ath6kl: ar6004 hw 3.0 usb fw 3.5.0.28
[ 55.450000] <6>ath6kl: Wait defer tasks done...
[ 55.970000] <6>ath6kl: Create dedicated p2p interface
[ 55.980000] Calling CRDA for country: 6A
[ 58.000000] usbcore: registered new interface driver ath6kl_usb
#
# iwconfig
lo no wireless extensions.
wlan0 IEEE 802.11abgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=0 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
p2p0 IEEE 802.11abgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=0 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on
#
2017年6月14日10:39:39 在其他平台上编译遇到新问题:
drivers/ath6kl/cfg80211.c:4348: error: 'struct ath6kl' has no member named 'wake_lock'
查看此处代码,发现是因为定义了 CONFIG_HAS_WAKELOCK 的原因,将内核中autoconf.h头文件里的的CONFIG_HAS_WAKELOCK、CONFIG_WAKELOCK配置去掉。从新编译就ok。