说明之前:文档建立在实际的项目中:
硬件环境是三星x210,软件是android4.0 ubuntu13.04
1.1 AR6000 3.1的资源包最新可以找到的地方: 2014-5
http://git.omnilab.sjtu.edu.cn/chen_xm/linux-sunxi/tree/917c1c8cba6f33d53b68a1020d49d4da532e3329/modules/wifi/ar6003
https://github.com/psyke83/AR6kSDK.3.0
1.2 利用git可以拿到网上的资料:
Hacking on ath6kl
ath6kl is now part of wireless kernel trees. All the development happens in githubgithub's ath6kl project. To clone the tree:
git clone git://github.com/kvalo/ath.git
The driver is located in drivers/net/wireless/ath/ath6kl. To compile the driver enable CONFIG_ATH6KL which is found under Device Drivers/Network device support/Wireless LAN/Atheros Wireless Cards/Atheros ath6kl support. Also enable CONFIG_ATH6KL_DEBUG to include all debugging code.
Send any patches to Kalle Valo < [email protected] >, but remember also to CC both < [email protected] > and < [email protected]. To learn more about git you can refer to our Git guide. It even documents how to send patches with git format-patch.ref:
http://wireless.kernel.org/en/users/Drivers/ath6kl
1.3 最新的SDK应该还是在GIT上拿到的,利用GIT注册后,安装git的工具就可以下载。
https://github.com/CyanogenMod/AR6kSDK.3.1
讲到AR6K的编译我们大致有两种思路:在内核内找 或者 单独编译源码包
【提问】这个驱动是不是在内核里面,还是就是在其他地方?
1.0 android 内核驱动的路径:编译之前你得想想源码该放哪里呢?
【提问】当我们从网上拿到一个驱动的源码包的时候,驱动源码应该默认放在android的那个文件夹下面那?
【回答】其实放在那里都一样,关键是,输出的ko的路径,和你的kernel的配置.当然,作为一个严谨的驱动开发者,必须考虑路径的严谨性。
这样在将来做自动配置的时候会有一个很好的逻辑。
ref:
http://blog.csdn.net/wh_19910525/article/details/7393615
【实践】
我把驱动源文件放到如下目录:【驱动文件】
WIFI Driver = hanson@hanson-desktop:~/x210_ics_rtm_v13/hardware/qcom$
然后参照厂家的手册:check the guide of the software :
Modify <WIFI Driver>/host/localmake.linux.inc
ATH_ANDROID_ENV := yes
Build for Android system
ATH_SOFTMAC_FILE_USED :=yes
Use MAC address which is stored in /system/wifi/softmac
ATH_HTC_RAW_INT_ENV := yes
TCMD support
ATH_AR6K_OTA_TEST_MODE := no
Don’t enable power saving for OTA mode
ATH_CROSS_COMPILE_TYPE := $(ANDROID_SDK)/…/toolchain/…/a
【实践】
ATH_CROSS_COMPILE_TYPE := /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
ATH_BUS_TYPE:=SDIO
ATH_BUS_SUBTYPE:= linux_sdio
ATH_LINUXPATH := <Your kernel source path>
Android/out/target/product/xxxx/obj/KERNEL_OBJ
【实践】
ATH_LINUXPATH := ~/x210_ics_rtm_v13/kernel
Type ‘make’ to make the driver
host/.output/$(ATH_BUILD)‐$(ATH_BUS_TYPE)/image/ar6000.ko
【实践】在Host 目录进行编译,结果正确生成ko文件。
我选用了git上的AR6kSDK.build_3.1_RC.734包进行编译
hanson@hanson-desktop:~/x210_ics_rtm_v13/hsy_others/ar6k/AR6kSDK.3.1-master/AR6kSDK.build_3.1_RC.734/host$ make
make[1]: Leaving directory `/home/hanson/x210_ics_rtm_v13/hsy_others/ar6k/AR6kSDK.3.1-master/AR6kSDK.build_3.1_RC.734/host/hif/sdio'
cp -f /home/hanson/x210_ics_rtm_v13/hsy_others/ar6k/AR6kSDK.3.1-master/AR6kSDK.build_3.1_RC.734/host/os/linux/ar6000.ko /home/hanson/x210_ics_rtm_v13/hsy_others/ar6k/AR6kSDK.3.1-master/AR6kSDK.build_3.1_RC.734/host/.output/X210_ARM_NATIVEMMC-SDIO/image
/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-strip -g -S -d /home/hanson/x210_ics_rtm_v13/hsy_others/ar6k/AR6kSDK.3.1-master/AR6kSDK.build_3.1_RC.734/host/.output/X210_ARM_NATIVEMMC-SDIO/image/ar6000.ko
参考:
8192CU WIFI驱动移植
http://blog.chinaunix.net/uid-22910619-id-2606845.html
将wifi固件编译进内核,成功加载sdio wifi模块
http://wenku.baidu.com/link?url=ugCp3bKE1I_SArudXby2wpbx-927FHTi5lcxdPVMZMWDWb78AGDN8H564mcBmeJ9-TopLc9t5zin06XqfXmIKgBpvUavKOdcmXHD0NMh9Rq
calmake.linux.inc, 参考如下: #ATH_BUILD_TYPE := <Platform (Eg: LOCAL_i686)> #ATH_BUS_TYPE := <Interconnect type (Eg: SDIO, SPI)> #ATH_LINUXPATH := <Pointer to kernel source (Eg: /<path>/fc3-i686-2.6.9)> #ATH_ARCH_CPU_TYPE := <Type of architecture (Eg: arm)> #ATH_CROSS_COMPILE_TYPE := <Path to the compiler toolchain - Eg: (/<path>/arm_v4t_le-) #ATH_OS_SUB_TYPE := <Kernel version - (Eg: linux_2_4, linux_2_6)> #ATH_CFG80211_ENV := <yes or no> ATH_BUILD_TYPE := LOCAL_i686 ATH_BUS_TYPE := SDIO ATH_LINUXPATH := /usr/src/linux-headers-2.6.32-21-generic ATH_ARCH_CPU_TYPE := arm ATH_OS_SUB_TYPE := linux_2_6 ATH_HC_DRIVERS := 'pci_ellen/ pci_std/' ATH_BUS_SUBTYPE := linux_sdio #export ATH_EEPROM_FILE_USED:=yes export ATH_ANDROID_ENV := yes #export ATH_UPDATA_MAC_EEPROM := yes ATH_DEBUG_DRIVER := yes ATH_AR6K_BUILTIN_HCI_TRANSPORT := yes 【hsy75案】firmware的装载地址是可以在下面的头文件配置的 2.驱动包编译成功后,将附件固件放在默认路径ath6k/AR6003/hw2.0/下, (该目录也可根据自己的需要在驱动代码AR6kSDK.3.0_RC.205\host\os\linux\include\ar6000_drv.h 中进行修改。)然后insmod ar6000.ko即可。
Build the driver externally (Debug purpose)
1. Modify AR6kSDK.3.0_RC.375/host/localmake.linux.inc
2. Define your Android product name as ATH_BSP_TYPE
3. Define your android bsp path as ATH_ANDROID_ROOT
4. Define your kernel full path as ATH_LINUXPATH
5. cd to host/
6. type "make" to make the driver
7. the driver will be output into
AR6kSDK.3.0_RC.375/host/.output/$(ATH_BSP_TYPE)_ARM_NATIVEMMC-SDIO/
image/ar6000.ko
8. adb push ar6000.ko /system/wifi/
9. adb shell mkdir -p /system/wifi/ath6k/AR6003/hw2.0
10. Push the following firmware binaries to the directory in above step
adb push athwlan.bin.z77 /system/wifi/ath6k/AR6003/hw2.0
adb push otp.bin.z77 /system/wifi/ath6k/AR6003/hw2.0
adb push data.patch.hw2_0.bin /system/wifi/ath6k/AR6003/hw2.0/
data.patch.bin
adb push fakeBoardData_AR6003_v2_0.bin /system/wifi/ath6k/AR6003/hw2.0/
bdata.SD31.bin
在第二节的内容我们谈到了编译文件的路径问题,芯片公司对android的参考设置如下:
【案】这就是我们第一届可以从网上下载的源码
android/system/wlan/atheros/AR6kSDK.3.0_RC.375
GPL driver and utilities source code
android/system/wlan/atheros/AR6kSDK.3.0_RC.375-proprietary
Atheros proprietary firmware and utilities
【案】android wifi 的扩展工具集,也可以通过网上查找获得
android/external/wireless_tools.29
Wireless extension utilities. GPL license
android/external/ath_supplicant-0.6.10
wpa_supplicant 0.6.10 from Atheros.
android/external/iperf-2.0.4
Network performance testing tools
android/external/dnsmasq-2.55
DHCP server of AP mode for Android less than 2.2 It will not be built if Android
version =2.2
make menuconfig
然后 enable wifi extention
【andorid]\device\samsung\x210\BoardConfig.mk
#Add for wifi当然,如果按照手动的方式编译好了也是可以,不过既然在andorid,那么在文件夹下面修改android.mk是个标准的方法。
【andorid】\system\wlan\atheros\AR6kSDK.build_3.1_RC.734\host\Android.mk
ifeq ($(TARGET_PRODUCT),$(filter $(TARGET_PRODUCT),qsd8250_surf qsd8250_ffa msm7627_surf msm7627_ffa msm7627a msm7625_ffa msm7625_surf msm7630_surf full_x210))
#export ATH_LINUXPATH=$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
#ATH_CROSS_COMPILE_TYPE:=$(ATH_ANDROID_ROOT)/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin/arm-eabi-
ATH_CROSS_COMPILE_TYPE:=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi-
ATH_LINUXPATH:=/home/hanson/x210_ics_rtm_v13/kernel
endif
$(mod_file) : $(mod_cleanup) $(ACP)
$(MAKE) ARCH=arm CROSS_COMPILE=$(ATH_CROSS_COMPILE_TYPE) -C $(ATH_LINUXPATH) ATH_HIF_TYPE=$(ATH_HIF_TYPE) PLAT_WOW_GPIO_PIN=$(board_wow_gpio) SUBDIRS=$(ATH_SRC_BASE)/os/linux modules
$(ATH_ANDROID_ROOT)/$(ACP) $(ATH_TARGET_OUTPUT)/$(ATH_ANDROID_SRC_BASE)/host/os/linux/ar6000.ko $(ATH_ANDROID_ROOT)/$(TARGET_OUT)/wifi/
$(warning STEP3...................)
我在另外一个博文里面有比较详细的阐述:请参阅如下:
http://blog.csdn.net/yellow_hill/article/details/27327203
android.mk 的一些变量通过:
设置在andorid.mk设置命令打印出来:
$(warning $(mod_file) mod_file)
$(warning $(mod_cleanup) mod_cleanup)
$(warning $(TARGET_PREBUILT_KERNEL) TARGET_PREBUILT_KERNEL)
$(warning $(ACP) ACP)
$(warning $(ATH_CROSS_COMPILE_TYPE) ATH_CROSS_COMPILE_TYPE)
$(warning $(ATH_LINUXPATH) ATH_LINUXPATH)
$(warning $(ATH_HIF_TYPE) ATH_HIF_TYPE)
$(warning $(board_wow_gpio) board_wow_gpio)
$(warning $(ATH_SRC_BASE) ATH_SRC_BASE)
$(warning $(ATH_TARGET_OUTPUT) ATH_TARGET_OUTPUT)
$(warning $(ATH_ANDROID_SRC_BASE) ATH_ANDROID_SRC_BASE)
$(warning $(TARGET_OUT) TARGET_OUT)
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.0.4
TARGET_PRODUCT=full_x210
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=IMM76L
============================================
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:39: full_x210
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:40: system/wlan/atheros/AR6kSDK.build_3.1_RC.734
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:41: /home/hanson/x210_ics_rtm_v13
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:137: /home/hanson/x210_ics_rtm_v13/system/wlan/atheros/AR6kSDK.build_3.1_RC.734
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:146: out/target/product/x210/system/wifi/ar6000.ko mod_file
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:147: /home/hanson/x210_ics_rtm_v13/system/wlan/atheros/AR6kSDK.build_3.1_RC.734 mod_cleanup
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:148: TARGET_PREBUILT_KERNEL
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:149: out/host/linux-x86/bin/acp ACP
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:151: /usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi- ATH_CROSS_COMPILE_TYPE
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:152: /home/hanson/x210_ics_rtm_v13/kernel ATH_LINUXPATH
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:153: sdio ATH_HIF_TYPE
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:154: board_wow_gpio
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:155: /home/hanson/x210_ics_rtm_v13/system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host ATH_SRC_BASE
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:157: /home/hanson/x210_ics_rtm_v13 ATH_TARGET_OUTPUT
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:158: system/wlan/atheros/AR6kSDK.build_3.1_RC.734 ATH_ANDROID_SRC_BASE
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:159: out/target/product/x210/system TARGET_OUT
system/wlan/atheros/AR6kSDK.build_3.1_RC.734/host/Android.mk:174: STEP2..............
输出的编译结果放在如下的文件夹:android/out/target/product/<your-vendor-product>/system/wifi/
Android中通过wpa_supplicant控制wifi。
wpa_supplicant通过socket与hardware/libhardware_legacy/wifi/wifi.c通信,
当在UI开启wifi的时候首先要加载wifi模块驱动,然后开启wpa_supplicant配置文件,因此在wifi.c中修改驱动和配置文件的对应位置。
#ifndef WIFI_DRIVER_MODULE_PATH
#define WIFI_DRIVER_MODULE_PATH "/system/wifi/ar6000.ko"
#endif
#ifndef WIFI_DRIVER_MODULE_NAME
#define WIFI_DRIVER_MODULE_NAME "ar6000"
#endif
#ifndef WIFI_DRIVER_MODULE_ARG
#define WIFI_DRIVER_MODULE_ARG ""
#endif
#ifndef WIFI_FIRMWARE_LOADER
#define WIFI_FIRMWARE_LOADER ""
#endif
#define WIFI_TEST_INTERFACE "wlan0"
修改wpa_supplicant.conf 把external/ath_supplicant-0.8.x/wpa_supplicant/wpa_supplicant.conf拷贝到out/target/product/smdkv210/system/etc/wifi/目录下,
ctrl_interface=DIR=/data/misc/wifi/wpa_supplicant GROUP=wifi //wlan0在这个目录下 eapol_version=1 ap_scan=0 // fast_reauth=1
修改dhcp配置
在/system/etc/dhcpcd/dhcpcd.conf中修改
interface wlan0
option subnet_mask, routers, domain_name_server
配置路径和权限
wpa_supplicant运行在wifi用户和组下的。代码可见wpa_supplicant/os_unix.c 中的os_program_init()函数。
如果系统的/system目录为只读,那应该使用路径/data/misc/wifi/wpa_supplicant.conf.
确认init.rc中有如下配置:
cd ../<myandroid>/device/samsung/smdkv210
vi init.rc
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi
chmod 0770 /data/misc/wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
chmod 0660 /data/misc/wifi/hostapd.conf
mkdir /data/misc/wifi/sockets 0770 wifi wifi
chmod 0770 /data/misc/wifi/sockets
mkdir /data/misc/dhcp 0770 dhcp dhcp
chmod 0770 /data/misc/dhcp
chmod 0775 /system/etc/dhcp/dhcp-run-hooks setprop wifi.interface wlan0
配置运行wpa_supplicnat、dhcp和hostapd 在init.rc中添加如下语句:
service wpa_supplicant /system/bin/logwrapper /system/bin/wpa_supplicant -dd -Dwext -iwlan0 -c /data/misc/wifi/wpa_supplicant.conf
user root
group wifi inet
socket wpa_wlan0 dgram 660 wifi wifi
oneshot
service dhcpcd /system/bin/logwrapper /system/bin/dhcpcd -d -B wlan0
disabled
oneshot
service hostapd /system/bin/hostapd /system/etc/wifi/hostapd.conf
group wifi inet
oneshot
disabled
1 AR6003 SDK for Android
2 RAK310 WIFI 通信模块
3 AR6003 for Android Platform
*************************
PLATFORM:
BSP: GT-I5500
*************************
mkdir --parents /home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/.output/GT-I5500_ARM_NATIVEMMC-SDIO/image
mkdir --parents /home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/.output/bin
make ARCH=arm CROSS_COMPILE=/usr/local/arm/arm-2009q3/bin/arm-none-linux-gnueabi- -C ~/x210_ics_rtm_v13/kernel ATH_HIF_TYPE=`echo SDIO | tr [:upper:] [:lower:]` SUBDIRS=/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux modules
make[1]: Entering directory `/home/hanson/x210_ics_rtm_v13/kernel'
CC [M] /home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif.o
CC [M] /home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.o
/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.c: In function 'SetupHIFScatterSupport':
/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.c:284: error: 'struct mmc_host' has no member named 'max_hw_segs'
/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.c:285: error: 'struct mmc_host' has no member named 'max_hw_segs'
/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.c:285: error: 'struct mmc_host' has no member named 'max_hw_segs'
make[2]: *** [/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux/../../hif/sdio/linux_sdio/src/hif_scatter.o] Error 1
make[1]: *** [_module_/home/hanson/x210_ics_rtm_v13/hardware/qcom/AR6K/host/os/linux] Error 2
make[1]: Leaving directory `/home/hanson/x210_ics_rtm_v13/kernel'
make: *** [modules] Error 2
【原因】网上找了一下是kernel版本的问题
The problem is because the mmc stack is out of sync in Greg's staging tree and Stephen's linux-next tree. Greg asked me to generate a patch which I did and emailed to Greg.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
http://hi.baidu.com/hst_jiangbo/item/a622cdca611e3d0ec610b23e
http://blog.chinaunix.net/uid-21143149-id-1830087.html
(linux )
http://www.pudn.com/downloads515/sourcecode/unix_linux/network/detail2139419.html
(wince)
http://cewifidriverar6000.codeplex.com/SourceControl/latest#AR6K
2 AR6K 如果是SDIO 接口的话,下面的参考很有用,这是一个系列的博
linux下MMC/SD/SDIO驱动系列之一 ---- 概述
http://blog.csdn.net/xieweihua2012/article/details/12785491
linux下MMC/SD/SDIO驱动系列之二 ---- host注册过程(一)
http://blog.csdn.net/xieweihua2012/article/details/12844733
linux下MMC/SD/SDIO驱动系列之三 ---- host注册过程(二)
http://blog.csdn.net/xieweihua2012/article/details/12918763
linux下MMC/SD/SDIO驱动系列之四 ---- SDIO的识别与操作
http://blog.csdn.net/xieweihua2012/article/details/13984405
3 android 下的wifi的移植说明,
来自于google 网站
http://www.kandroid.org/online-pdk/guide/wifi.html
来自其他的博客:
Android下WIFI功能移植
http://www.2cto.com/kf/201209/156221.html
android wifi驱动移植详细过程
http://bbs.imp3.net/thread-10558924-1-1.html
Android平台开发-WIFI 驱动移植 -- 详细
http://blog.csdn.net/wh_19910525/article/details/7392199
wifi详解(5)
http://www.myexception.cn/mobile/548582.html
Porting WiFi drivers to Android
http://hi.baidu.com/aokikyon/item/db9ef9c07dcb77c6984aa00d
Android WIFI 驱动移植
http://blog.163.com/gl_jiang@126/blog/static/76100972201312832333879
Freescare wifi 移植说明:
https://community.freescale.com/docs/DOC-93603
SPI/SDIO 接口比较
http://wenku.baidu.com/link?url=Bx3P21vwKxQt0leLbQRrGjJ5uipzZdKf68O3ycboWZyJ78VLNpMmUINGoefTg5h91onPZmYMVwU9HU7MTt0Wv8bHmz7TsNq1OXxBpNUEItG
4 一些编译的问题
http://blog.chinaunix.net/uid-21696322-id-430774.html
5 系统集成实例
基于FS2410的SDIO WIFI移植
http://blog.csdn.net/bailyzheng/article/details/7492650
SDIO WIFI模块安卓系统RAK310_AND模块用户手册
http://wenku.baidu.com/link?url=fUzMmS9sl_ZuLHrdvKAT57P56VhzOHuKbcKGdE9uNqfY25thTKUlSSKXo_I-lH931dkRF68nO8OVoIA6IukQaINA-p6eGdJYsdesN99dl0K
6 一些讨论:
http://rootzwiki.com/topic/3552-the-kryptonite-project-touchpad-hardware-subsystems-and-a-kernel-to-match/page-10
####################################################################################################################################
正在制作中,马上还会更新。。。
Made by [email protected]