http://blog.csdn.net/armeasy/article/details/6566462
硬件平臺:mx53_qsb開發板
軟件平臺:android2.2.1
第一步:網上下載wireless_tools源碼包,放在/external目錄,並解壓,這裏使用wireless_tools.29.tar.gz
可從下面的網址下載:
http://bbs.9tripod.com/viewthread.PHP?tid=126&extra=page%3D1
第二步:解壓該文件,在external目錄中將會新生成wireless_tools.29目錄
第三步:在wireless_tools.29目錄下創建Android.mk文件,內容如下:
LOCAL_PATH:= $(call my-dir)
################## build iwlib ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwlib.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= libiw
LOCAL_STATIC_LIBRARIES := libcutils libc libm
include $(BUILD_STATIC_LIBRARY)
################## build iwconfig ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwconfig.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwconfig
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
################## build iwlist ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwlist.c iwlib.h
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwlist
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
第四步:源代碼修改
1.將wireless.22.h 更名爲wireless.h
2.修改ifrename.c 增加getline的函數,代碼可以從external/genext2fs/genext2fs.c中獲得
3.修改iwlib.h,將#include <net/ethernet.h>改爲#include <net/if_ether.h>
4.在iwlib.h中,將下面的代碼移出#ifndef IW_EV_LCP_PK_LEN ...... #endif宏,確保下面的代碼生效,否則將提示編譯找不到這些宏定義的錯誤:
struct iw_pk_event
{
__u16 len; /* Real lenght of this stuff */
__u16 cmd; /* Wireless IOCTL */
union iwreq_data u; /* IOCTL fixed payload */
} __attribute__ ((packed));
struct iw_pk_point
{
void __user *pointer; /* Pointer to the data (in user space) */
__u16 length; /* number of fields or size in bytes */
__u16 flags; /* Optional params */
} __attribute__ ((packed));
#define IW_EV_LCP_PK2_LEN (sizeof(struct iw_pk_event) - sizeof(union iwreq_data))
#define IW_EV_POINT_PK2_LEN (IW_EV_LCP_PK2_LEN + sizeof(struct iw_pk_point) - IW_EV_POINT_OFF)
事實上,我們只用將#endif挪在這段代碼的上面即可。
第五步:在android源碼包根目錄下,分別執行如下代碼編譯文件:
source build/envsetup.sh
mm bionic/libm PRODUCT-imx53_loco-eng
mm external/wireless_tools.29/ PRODUCT-imx53_loco-eng
編譯完成,將會在out/target/product/imx53_loco/system/xbin下生成iwlist,iwconfig等無線工具。
第六步:使用adb push或者重新下載system.img映像文件,就可以正常使用wireless_tools了。