硬件平台: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
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了。