内核需要选中Bus support -> PCI support,否则编译会报错:

compat-wireless-2012-02-22/drivers/net/wireless/ath/ath9k/pci.c:371: error: redefinition of 'ath_pci_exit'
 

另外

Networking support  ->Wireless -> cfg80211 - wireless configuration API
Networking support ->Wireless ->Generic IEEE 802.11 Networking Stack (mac80211)

需要设置为 ,config.mk会检测kernel的.config中的CONFIG_CFG80211和CONFIG_MAC80211

但是执行./scripts/gen-compat-autoconf.sh时报错:

 error: static declaration of 'usb_buffer_alloc' follows non-static declaration

看起来似乎是代码的定义和kernel的头文件冲突,注释掉compat-wireless-2.6.34.1\include\linux\compat-2.6.35.h:

#define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma)
#define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma)

整个代码都没有调用这两个。

error: invalid application of 'sizeof' to incomplete type 'struct led_trigger'

选中Networking support  ---> Wireless  ---> Enable LED triggers

但是这样编译的话,最后还是有很多ko会报找不到kernel的函数:

WARNING: "ssb_sdio_scan_read32" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "ssb_sdio_scan_switch_coreidx" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "ssb_sdio_get_invariants" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "ssb_sdio_exit" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "ssb_sdio_ops" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "ssb_sdio_init" [compat-wireless-2.6.34.1/drivers/ssb/ssb.ko] undefined!
WARNING: "crc7" [compat-wireless-2.6.34.1/drivers/net/wireless/wl12xx/wl1271.ko] undefined!
WARNING: "crc7" [compat-wireless-2.6.34.1/drivers/net/wireless/wl12xx/wl1251_spi.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/rtl818x/rtl8187.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/rtl818x/rtl8187.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2x00lib.ko] undefined!
WARNING: "led_classdev_resume" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2x00lib.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2x00lib.ko] undefined!
WARNING: "led_classdev_suspend" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2x00lib.ko] undefined!
WARNING: "crc_ccitt" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2800usb.ko] undefined!
WARNING: "crc_ccitt" [compat-wireless-2.6.34.1/drivers/net/wireless/rt2x00/rt2800pci.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/p54/p54common.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/p54/p54common.ko] undefined!
WARNING: "iw_handler_set_thrspy" [compat-wireless-2.6.34.1/drivers/net/wireless/libertas/libertas.ko] undefined!
WARNING: "iw_handler_get_spy" [compat-wireless-2.6.34.1/drivers/net/wireless/libertas/libertas.ko] undefined!
WARNING: "iw_handler_get_thrspy" [compat-wireless-2.6.34.1/drivers/net/wireless/libertas/libertas.ko] undefined!
WARNING: "iw_handler_set_spy" [compat-wireless-2.6.34.1/drivers/net/wireless/libertas/libertas.ko] undefined!
WARNING: "wireless_spy_update" [compat-wireless-2.6.34.1/drivers/net/wireless/ipw2x00/libipw.ko] undefined!
WARNING: "iw_handler_get_thrspy" [compat-wireless-2.6.34.1/drivers/net/wireless/ipw2x00/ipw2200.ko] undefined!
WARNING: "iw_handler_set_thrspy" [compat-wireless-2.6.34.1/drivers/net/wireless/ipw2x00/ipw2200.ko] undefined!
WARNING: "iw_handler_get_spy" [compat-wireless-2.6.34.1/drivers/net/wireless/ipw2x00/ipw2200.ko] undefined!
WARNING: "iw_handler_set_spy" [compat-wireless-2.6.34.1/drivers/net/wireless/ipw2x00/ipw2200.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/b43legacy/b43legacy.ko] undefined!
WARNING: "hwrng_register" [compat-wireless-2.6.34.1/drivers/net/wireless/b43legacy/b43legacy.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/b43legacy/b43legacy.ko] undefined!
WARNING: "hwrng_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/b43legacy/b43legacy.ko] undefined!
WARNING: "b43_sdio_free_irq" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "b43_sdio_init" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "b43_sdio_exit" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "hwrng_register" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "hwrng_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "b43_sdio_request_irq" [compat-wireless-2.6.34.1/drivers/net/wireless/b43/b43.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ath9k/ath9k.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ath9k/ath9k.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ath5k/ath5k.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ath5k/ath5k.ko] undefined!
WARNING: "led_classdev_register" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ar9170/ar9170usb.ko] undefined!
WARNING: "led_classdev_unregister" [compat-wireless-2.6.34.1/drivers/net/wireless/ath/ar9170/ar9170usb.ko] undefined!

多次尝试配置kernel虽然可以减少出错个数,但是任然不能完全解决,看来只有使用driver-select脚本选择需要的wifi驱动,然后编译。

makefile参照网上的patch,以下一段有改动:

obj-$(CONFIG_COMPAT_NET_USB_MODULES) += drivers/net/usb/

obj-$(CONFIG_COMPAT_NETWORK_MODULES) += drivers/net/ethernet/atheros/
obj-$(CONFIG_COMPAT_NETWORK_MODULES) += drivers/net/ethernet/broadcom/

obj-$(CONFIG_COMPAT_VAR_MODULES) += drivers/ssb/
obj-$(CONFIG_COMPAT_VAR_MODULES) += drivers/bcma/
obj-$(CONFIG_COMPAT_VAR_MODULES) += drivers/misc/eeprom/

ifeq ($(CONFIG_STAGING_EXCLUDE_BUILD),)
obj-$(CONFIG_COMPAT_STAGING) += drivers/staging/brcm80211/
obj-$(CONFIG_COMPAT_STAGING) += drivers/staging/ath6kl/
endif
......
modules: $(CREL_CHECK)
 @./scripts/check_config.sh
 #$(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules
 $(MAKE) -C $(KLIB_BUILD) O=${KERNEL_OBJ_DIR}  M=$(PWD) modules
 @touch $@

select-driver网上也有很多patch编译时可以参考。至少./scripts/driver-select   ath9k_htc是可以编译通过的