Chinaunix首页 | 论坛 | 博客
  • 博客访问: 958808
  • 博文数量: 116
  • 博客积分: 3923
  • 博客等级: 中校
  • 技术积分: 1337
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-23 01:22
文章分类

全部博文(116)

文章存档

2013年(1)

2012年(17)

2011年(69)

2009年(29)

分类: LINUX

2011-05-15 00:01:59

WiFi 88W8686移植过程记录:

(1)移植gspi_io.c和gspi_io.h文件,主要是WiFi中断响应函数,直接发送数据函数,直接接收数据函数的移植过程。

(2)配置linux系统为打开所有的Wireless参数.

(3)Linux WiFi source code makefile修改为如下:
============================================================================
# File: Makefile
#############################################################################
# Configuration Options
#############################################################################
# Debug Option
# DEBUG LEVEL n/1/2:
# n: NO DEBUG
# 1: Only PRINTM(MSG,...), PRINTM(FATAL,...), ...
# 2: All PRINTM()
CONFIG_DEBUG=0

# Proc in /proc/net/wlan
CONFIG_PROC_DEBUG=y

# Linux Power Management
CONFIG_ENABLE_PM=n

# Re-association in driver
CONFIG_REASSOCIATION=y

# Manufacturing firmware support
CONFIG_MFG_CMD_SUPPORT=y

CONFIG_PROC_FS=y
CONFIG_PROC_DEBUG=y

CONFIG_WIRELESS_EXT=y

CONFIG_REASSOCIATION=y

#############################################################################
# Select Platform Tools
#############################################################################

KERNEL_WE=22

KERNELDIR=/home/no773/xxxx/kernel
BINDIR = ../bin_gspi8686

#############################################################################
# Compiler Flags
#############################################################################

CFLAGS += -I$(KERNELDIR)/include

CFLAGS += -DFPNUM='"4"'


ifeq ($(CONFIG_DEBUG),1)
    CFLAGS += -DDEBUG_LEVEL1
endif

ifeq ($(CONFIG_DEBUG),2)
    CFLAGS += -DEBUG_LEVEL2
    CFLAGS += -DDEBUG_LEVEL1
    CFLAGS += -DDEBUG_LEVEL2
    DBG = -dbg
endif

ifeq ($(CONFIG_WIRELESS_EXT),y)
    CFLAGS += -DWIRELESS_EXT=22
endif



ifeq ($(CONFIG_PROC_DEBUG),y)
    CFLAGS += -DPROC_DEBUG
    export CONFIG_PROC_DEBUG
endif

ifeq ($(CONFIG_ENABLE_PM),y)
    CFLAGS += -DENABLE_PM
endif

ifeq ($(CONFIG_REASSOCIATION),y)
    CFLAGS += -DREASSOCIATION
endif

ifeq ($(CONFIG_MFG_CMD_SUPPORT),y)
    CFLAGS += -DMFG_CMD_SUPPORT
endif

#############################################################################
# Make Targets
#############################################################################
WLANOBJS =    wlan_main.o wlan_fw.o wlan_wext.o \
        wlan_rx.o wlan_tx.o \
        wlan_cmd.o wlan_cmdresp.o \
        wlan_scan.o wlan_join.o

WLANOBJS += wlan_wmm.o
WLANOBJS += wlan_11d.o
WLANOBJS += wlan_fops.o

ifeq ($(CONFIG_PROC_FS),y)
    CFLAGS += -DCONFIG_PROC_FS
    WLANOBJS += wlan_proc.o
    ifeq ($(CONFIG_PROC_DEBUG), y)
        CFLAGS += -DCONFIG_PROC_DEBUG
        WLANOBJS += wlan_debug.o
    endif
endif

CFLAGS += -DSSPCTRLER=1
IFOBJS := if_gspi.o
IOOBJS := gspi_io.o gspi_debug.o
obj-m := gspi8xxx.o gspi.o
gspi8xxx-objs := $(WLANOBJS) $(IFOBJS)
gspi-objs := $(IOOBJS)

default:
    $(MAKE) -C $(KDIR) M=`pwd` modules

clean:
    $(MAKE) -C $(KDIR) M=`pwd` clean
    rm -rf *.o *.ko *.mod.c *.symvers *.cmd *.mod  wlanconfig

============================================================================

(4)编译内核后,再编译wifi驱动,成功后,再把无线配置工具也移植过去。

(5)移植iwconfig工具,直接使用交叉编译器编译(修改Makefile后)然后,"./configure&make",
    编译链接后把iw开头的工具全部移动到嵌入式NFS根目录下,就可以使用啦。
============================================================================
##
## Please check the configurion parameters below
##

ARCH ?=arm
CROSS_COMPILE ?= arm-softfloat-linux-gnu-
#INCLUDE ?= /usr/local/arm/3.4.5/arm-softfloat-linux-gnu/include
INCLUDE ?= /home/no773/xxxx/compiler/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/

CC := $(CROSS_COMPILE)gcc
AS := $(CROSS_COMPILE)as
GCC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar

## Installation directory. By default, go in /usr/local.
## Distributions should probably use /, but they probably know better...
ifndef PREFIX
  PREFIX = .
endif

## Compiler to use (modify this for cross compile).
//CC = gcc
## Other tools you need to modify for cross compile (static lib only).
//AR = ar
RANLIB = ranlib
##
.......
============================================================================

(6)同时也把测试工具netperf移植过来,交叉工具编译时把"./configure"时的错误信息直接屏蔽,跳过错误后,就可以编译链接处结果。

(6.5)编译wpa_supplicant-0.7.3包时,可以先不使用OpenSSL库,“cp defconfig .config”然后
修改.config内容如下(在默认基础上,修改如下,其他不变):
============================================================================
# Driver interface for Atmel driver
##CONFIG_DRIVER_ATMEL=y  (注释掉这个)

# Select TLS implementation
# openssl = OpenSSL (default)
# gnutls = GnuTLS (needed for TLS/IA, see also CONFIG_GNUTLS_EXTRA)
# internal = Internal TLSv1 implementation (experimental)
# none = Empty template
#CONFIG_TLS=openssl
CONFIG_TLS=none (配置为空,不使用OpenSSL)
============================================================================


(7)写个bash的脚本,在编译驱动完成时也把这些iw*配置工具和netperf测试工具拷贝到NFS根目录下,如下:
============================================================================
#! /bin/sh -v

###############################################################
#  @file: post_process.sh
#  @brief: post-process for install the output file
#  @author: NO.773 (xxxx@xxxx.com)
#  history:
#  @20110513: initial
#
###############################################################


NFS_HOME='/root/rootfs/home'

WIFI_TST='/home/no773/xxx/driver/wifi/s80/test'
WIFI_SRC='/home/no773/xxx/driver/wifi/s80/src'
WIFI_CFG='/home/no773/xxx/driver/wifi/s80/iwconfig'
WIFI_LIB='/home/no773/xxx/driver/wifi/s80/lib'
WIFI_TOOLS='/home/no773/xxx/driver/wifi/s80/tools'
NFS_HOME='/root/rootfs/home'

## remove all file under nfs root
rm -f ${NFS_HOME}/*

## copy all needed files to nfs root
cp  "${WIFI_SRC}/gspi.ko" \
    "${WIFI_SRC}/gspi8xxx.ko" \
    "${WIFI_SRC}/gspi8686.bin" \
    "${WIFI_SRC}/helper_gspi.bin" \
    "${WIFI_TOOLS}"/* \
    "${NFS_HOME}/"

## make test example and copy to nfs root
make -C "${WIFI_TST}"/examples/
cp "${WIFI_TST}"/examples/*-tcp "${WIFI_TST}"/examples/*-udp "${NFS_HOME}/"



============================================================================

(8)写好上述步骤后,就可以下载linux内核,然后启动linux,通过串口输出shell来操作嵌入式linux系统,进入到nfs根系统的home目录下后,直接启动"./init.sh"脚本来配置wifi网络参数,init.sh如下所示:
============================================================================
#! /bin/sh -v

###############################################################
#  @file: init.sh
#  @brief: initial wifi enviroment after linux boot up
#  @author: NO.773 (xxx@xxx.com)
#  history:
#  @20110513: initial
#  @20110516: add WEP, WPA-PSK(TKIP/AES), WPA2-PSK(TKIP/AES)
#             testing code.
#  @20110517: add DHCP client
#
###############################################################

RESOLV_CONF="/etc/resolv.conf"  # DNS server file
DNS_S1='192.168.0.126'          # DNS server IP
DNS_S2='192.168.0.111'          # DNS server IP

DHCP=yes                        # DHCP client

AUTH_SEL=wpa            # 'wep' slect WEP method to encrypt data,
                        # 'wpa' use WPA-PSK method
                        # otherwise plain text ( free ... )

LIB_DIR='/lib'            # lib directory
BIN_DIR='/bin'            # bin directory
AP_NAME='xxx_NO773'       # accept point (ssid)
AP_PW=''     # AP psk (pre-shared key)
AP_PRO='WPA2'             # WPA or WPA2

WEP_K0='aaaaa'            # WEP KEY 0
WEP_K1='bbbbb'            # WEP KEY 1
WEP_K2='ccccc'            # WEP KEY 2
WEP_K3='ddddd'            # WEP KEY 3

ETH_NUM='eth1'            # device (eth0, eth1 ...)
IP_CARD='192.168.56.200'  # ip address
NM_CARD='255.255.254.0'   # net mask
RT_NET='192.168.56.0'     # route net
RT_GW='192.168.56.1'      # route gate way

FW_HP='./helper_gspi.bin' # firmware helper bin
FW_NM='./gspi8686.bin'    # firmware name bin

NETPERF_PORT='8880'            # netperf server port
NETPERF_SERV='192.168.56.137'  # netperf server host IP

## install wifi fireware firstly
insmod gspi.ko
insmod gspi8xxx.ko helper_name=${FW_HP} fw_name=${FW_NM}

## tool for setting wifi options
cp iw*  ${BIN_DIR}/
cp *.so* ${LIB_DIR}/

## tool for testing wifi performance
cp netperf netserver ${BIN_DIR}/

## setting which AP(SSID) to connect
## iwconfig ${ETH_NUM} essid ${AP_NAME}

##########################################################################
## WPA(2)-PSK: create the configure file of setting SSID and Password Info
##########################################################################
AP_CF_FILE='WPA-PSK-TEMP.conf'
touch ${AP_CF_FILE}
echo "# WPA-PSK
network={
    ssid=\"${AP_NAME}\"
    key_mgmt=WPA-PSK
    proto=${AP_PRO}
    pairwise=CCMP TKIP
    group=CCMP TKIP
    psk=\"${AP_PW}\"
}" > ${AP_CF_FILE}

##########################################################################
## WEP KEY: create the configure file of setting SSID and Password Info
##########################################################################
AP_WEP_FILE='WEP-TEMP.conf'
touch ${AP_WEP_FILE}
echo "# Static WEP keys
network={
    ssid=\"${AP_NAME}\"
    key_mgmt=NONE
    wep_key0=\"${WEP_K0}\"
    wep_key1=\"${WEP_K1}\"
    wep_tx_keyidx=0
}" > ${AP_WEP_FILE}

##########################################################################
## NO KEY: create the configure file of setting SSID and Password Info
##########################################################################
AP_PLAIN_FILE='PLAIN-TEMP.conf'
touch ${AP_PLAIN_FILE}
echo "# Plaintext (no encryption) network
network={
    ssid=\"${AP_NAME}\"
    key_mgmt=NONE
}" > ${AP_PLAIN_FILE}


## login the Accept Point
if [ "${AUTH_SEL}" = wep ]; then
    ./wpa_supplicant -B -i${ETH_NUM} -c./${AP_WEP_FILE}
elif [ "${AUTH_SEL}" = wpa ]; then
    ./wpa_supplicant -B -i${ETH_NUM} -c./${AP_CF_FILE}
else
    ./wpa_supplicant -B -i${ETH_NUM} -c./${AP_PLAIN_FILE}
fi


if [ "${DHCP}" = yes ]; then
## DHCP allocate IP address from DHCP server
udhcpc -b -i ${ETH_NUM} -C "pos_wifi"
else
## setting DNS servers
echo "nameserver ${DNS_S1}
nameserver ${DNS_S2}" > ${RESOLV_CONF}
## setting wifi IP manually
ifconfig ${ETH_NUM} ${IP_CARD} netmask ${NM_CARD}
fi

## delay for a minite
ping -c 2 -I ${ETH_NUM} ${NETPERF_SERV}

## view current ethXX infomation
ifconfig -a

## make the wifi route at the toppest item in route table
route del -net ${RT_NET} netmask ${NM_CARD} dev ${ETH_NUM}
route add -net ${RT_NET} netmask ${NM_CARD} dev ${ETH_NUM}

## setting the default gateway in route table
route add default gw ${RT_GW} ${ETH_NUM}

## testing to WLAN
ping -c 4 -I eth1

## testing the bandwidth of WiFi Card
## netperf server need startup firstly
## command "netserver.exe -L 192.168.56.137 -p 8880 -4"
./netperf -p ${NETPERF_PORT} -H ${NETPERF_SERV}

## view route table
netstat -nr

============================================================================

DONE! GOOD LUCK!

阅读(2835) | 评论(0) | 转发(1) |
0

上一篇:WiFi加密体系

下一篇:WiFi认证测试

给主人留下些什么吧!~~