wl12xx移植

关于wpa_supplicant:
用到wpa_cli命令
wpa_cli -iwlan0
add_network             // wlan0 是无线网络设备的名字,增加一个网络,会返回一个数字,假设为1
set_network 1 ssid '"……"'    //这里ssid是要连接的网络名,注意 后面是单引号+双引号
set_network 1 psk '"……"'     //这里psk是密码
enable_network 1
select_network 1
save_config


dhclient -r wlan0
dhclient wlan0
//注意可能wlan0是down的状态,有时需要  ifconfig wlan0 up
或者/etc/init.d/networking restart
wpa_cli -iwlan0 scan
wpa_cli -iwlan0 scan_result
wpa_cli -iwlan0 status
sudo ifconfig wlan0 up
sudo ifconfig wlan0 192.168.1.126 
应该能ping通局域网 






wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
wpa_supplicant.conf 可以在wpa_supplicant源码目录中找到:如下
cd wpa_supplicant
find -name *.conf ,不同的conf对用不同的加密方式


ps -aux |grep "wpa_supplicant"后会看到(系统默认运行的wpa_supplicant命令)
/sbin/wpa_supplicant -B -P /run/sendsigs.omit.d/wpasupplicant.pid -u -s -O /var/run/wpa_supplicant






//wpa_wpa2.conf文件
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="网络名"
psk = "密码"
}
重启网络:/etc/init.d/networking restart
添加路由:route add default gw 192.168.1.1
添加DNS :/etc/resolv.confnameserver 192.168.1.1




sudo killall wpa_supplicant
会提示
Delete '/var/run/wpa_supplicant/wlan0' manually if it is not used anymore
执行sudo rm /ver/run/wpa_supplicant
就可以成功执行sudo wpa_supplicant -Dwext  -iwlan0 -c/wpa_wpa2.conf -B


不加 -B 会打印如下内容
<3>Trying to associate with bc:d1:77:f6:9f:26 (SSID='xiaofengche' freq=2437 MHz)
<3>Associated with 00:00:00:00:00:00
<3>CTRL-EVENT-DISCONNECTED bssid=bc:d1:77:f6:9f:26 reason=0
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>Trying to associate with bc:d1:77:f6:9f:26 (SSID='xiaofengche' freq=2437 MHz)
<3>Associated with 00:00:00:00:00:00
<3>CTRL-EVENT-DISCONNECTED bssid=bc:d1:77:f6:9f:26 reason=0
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE      //
写错用户名 的反应 (fengche)
ioctl[SIOCSIWSCAN]: Device or resource busy
wlan0: Failed to initiate AP scan
ioctl[SIOCSIWSCAN]: Device or resource busy
wlan0: Failed to initiate AP scan












编译并安装无线驱动     //参考http://omappedia.com/wiki/Android_Mac80211
①WLAN Driver build instruction
cd $MYDROID/hardware/ti/wlan/mac80211/compat_wl18xx
export KLIB=/path/to/kernel
export KLIB_BUILD=/path/to/kernel
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
make






编译wifi模块命令:(前提是内核先编译成功)
make KLIB=/home/shang/kernel_vkboard KLIB_BUILD=/home/shang/kernel_vkboard CROSS_COMPILE=arm-none-linux-gnueabi-  ARCH=arm 
make KLIB=/home/shang/svn/kernel_vkboard KLIB_BUILD=/home/shang/svn/kernel_vkboard CROSS_COMPILE=arm-none-linux-gnueabi-  ARCH=arm
cp ../compat_wl12xx/drivers/net/wireless/wl12xx/version.h  drivers/net/wireless/ti/wl18xx/
vi drivers/net/wireless/ti/wl18xx/version.h


static const char *wl16xx_timestamp = __TIMESTAMP__;==>static const char *wl18xx_timestamp = __TIMESTAMP__;
static const char *wl16xx_git_head = "";            ==>static const char *wl18xx_git_head = "r8.a2.09";
vi drivers/net/wireless/ti/wl18xx/Makefile
$(obj)/version.h: #.git/HEAD .git/index .git/refs/tags
        @$(call filechk,version.h)
与wl18xx_git_head相关的都是打印语句,注释掉即可成功编译
//wl1271_info("wl18xx driver version: %s", wl18xx_git_head);
wl1271_info("wl18xx driver version: %s", wl18xx_git_head);
//DRIVER_STATE_PRINT_GENERIC(version, "%s", wlcore_git_head);
//DRIVER_STATE_PRINT_GENERIC(timestamp, "%s", wlcore_timestamp);






 2015  sudo cp ~/svn/mac80211/compat_wl12xx/wifi_mod/cfg80211.ko ./kernel/net/wireless/cfg80211.ko
 2016  sudo cp ~/svn/mac80211/compat_wl12xx/wifi_mod/mac80211.ko ./kernel/net/mac80211/mac80211.ko
 2017  sudo cp ~/svn/mac80211/compat_wl12xx/wifi_mod/wl12xx.ko ./kernel/drivers/net/wireless/ti/wl12xx/wl12xx.ko
 2018  sudo cp ~/svn/mac80211/compat_wl12xx/wifi_mod/wl12xx_sdio.ko ./kernel/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko








②Target file system setup
cd $MYDROID/hardware/ti/wlan/mac80211/compat_wl12xx
cp ./compat/compat.ko $OUT/system/lib/modules/
cp ./net/wireless/cfg80211.ko $OUT/system/lib/modules/
cp ./net/mac80211/mac80211.ko $OUT/system/lib/modules/
cp ./drivers/net/wireless/wl12xx/wl12xx.ko $OUT/system/lib/modules/
cp ./drivers/net/wireless/wl12xx/wl12xx_sdio.ko $OUT/system/lib/modules/


③WLAN firmware
Firmware files go to following location on target file system.
/system/etc/firmware/ti-connectivity/




# su
# cd   /mac80211/config/
# Switch_To_WiLink7.sh中有这么一句
ln -s $WL7_MODULES_PATH/cfg80211.ko $MODULES_PATH/cfg80211.ko
chmod 644 $MODULES_PATH/cfg80211.ko
ln -s $WL7_MODULES_PATH/mac80211.ko $MODULES_PATH/mac80211.ko
chmod 644 $MODULES_PATH/mac80211.ko
ln -s $WL7_MODULES_PATH/wl12xx.ko $MODULES_PATH/wl12xx.ko
chmod 644 $MODULES_PATH/wl12xx.ko
ln -s $WL7_MODULES_PATH/wl12xx_sdio.ko $MODULES_PATH/wlcore_sdio.ko
chmod 644 $MODULES_PATH/wlcore_sdio.ko
sleep 2
sync












linux/documentment/dynamic-debug-howto.txt
首先定义CONFIG_DYNAMIC_DEBUG
zcat /proc/config.gz | grep DEBUG | grep DYN   ///查看内核编译时的 .config 文件选项




/sys/kernel/debug/ieee80211/phy0/wl12xx# cat driver_state     ///可以查看驱动的工作状态
strings /lib/firmware/ti-connectivity/wl128x-fw-4-sr.bin | grep Rev -m1    // 以二进制格式打开文件,查看版本信息(Rev)
          //安卓启动wifi会打印固件版本信息           wl12xx: firmware booted (Rev 7.3.10.0.125)
echo 256 > /sys/module/wl12xx/parameters/debug_level
iw wlan0 scan






echo 256 > /sys/module/wl12xx/parameters/debug_level     配置模块调试模式的打印级别
cat /proc/kmsg    //Reading log messages is done by opening /proc/kmsg




mount -t debugfs none /sys/kernel/debug
echo 8 > /proc/sys/kernel/printk
echo -n 'module wl12xx +p' > /sys/kernel/debug/dynamic_debug/control


+p 表示打开 pr_debug ,-p 表示关闭 pr_debug   
   - source filename
   
   - function name


   - line number (including ranges of line numbers)


   - module name


   - format string






在android上操作:mv wl128x-fw-4-sr.bin  bakwl128x-fw-4-sr.bin后,重新启动android
[   28.602020] wl12xx: ERROR could not get firmware ti-connectivity/wl128x-fw-4-sr.bin: -2
[   29.009002] wl12xx: ERROR could not get firmware ti-connectivity/wl128x-fw-4-sr.bin: -2
[   29.421752] wl12xx: ERROR could not get firmware ti-connectivity/wl128x-fw-4-sr.bin: -2
现象:可以打开wifi开关,半分钟后自动关闭
操作:sudo mv wl128x-fw-4-mr.bin  bakwl128x-fw-4-mr.bin   能正常启动wifi
说明这个文件就是固件文件




sudo iw reg set US
//android上有这么一种情况,当insmod模块以后不能正常使用wl12xx,当重启之后会发现wl12xx能正常使用了,所以是在开机的时候执行了某些程序。所以下边我想把ko文件拷贝到相应的文件夹下。
lib/modules/`uname -r`/kernel/net/wireless/cfg80211.ko
lib/modules/`uname -r`/kernel/net/mac80211/mac80211.ko
lib/modules/`uname -r`/kernel/drivers/net/wireless/ti/wlcore/wlcore.ko
lib/modules/`uname -r`/kernel/drivers/net/wireless/ti/wlcore/wlcore_sdio.ko
lib/modules/`uname -r`/kernel/drivers/net/wireless/ti/wl12xx/wl12xx.ko
但是没有管用




WL12XX管脚指南
http://processors.wiki.ti.com/index.php/OMAP_Wireless_Connectivity_Hardware_Porting_for_new_Platform#Ref
看一下wifi下接在mmc接口上,有使能引脚、中断引脚、四根数据线等等






/*******************http://wireless.kernel.org/en/users/Drivers/wl12xx/calibrator#wl12xx_Calibration
Make sure your kernel is configured to support nl80211 testmode commands (NL80211_TESTMODE=y). The calibrator tool requires the use of libnl v2.x package.
安装libnl2.x,因为wireless.kernel中有这么一句:Make sure your kernel is configured to support nl80211 testmode commands (NL80211_TESTMODE=y). The calibrator tool requires the use of libnl v2.x package.
apt-get install libnl2-dev可以成功安装libnl v2.x




git clone git://github.com/TI-OpenLink/ti-utils.git
cd ti-utils
make
会生成calibrator
将calibrator拷贝到/bin中即可
/********************************************************************
④WLAN Calibration Instruction
***********************************************************************/
copy wl1271-nvs.bin from file system for back-up  底下会删除它
Follow the procedure below on target device to calibrate Wi-Fi
mount -o remount rw /system
2) Remove old NVS file
rm /system/etc/firmware/ti-connectivity/wl1271-nvs.bin
3) Set the following parameters:
export TARGET_FW_DIR=/system/etc/firmware/ti-connectivity
export TARGET_NVS_FILE=$TARGET_FW_DIR/wl1271-nvs.bin
export WL12xx_MODULE=/system/lib/modules/wl12xx_sdio.ko
export TARGET_INI_FILE=/system/etc/wifi/TQS_S_2.6.ini






4) Execute Calibrator command
# calibrator plt autocalibrate <dev> <module path> <ini file> <nvs file> [<mac addr>]
# dev: Device name. i.e. wlan0
# module path: Full path to wl12xx_sdio.ko kernel module
# ini file: Full path to Radio param ini file i.e. TQS_S_2.6.ini in this case
# nvs file: Full path of nvs file. i.e. wl1271-nvs.bin. Must be the real path as wl12xx will load it
# mac addr: MAC address to program into the NVS file [optional]

calibrator plt autocalibrate wlan0 $WL12xx_MODULE $TARGET_INI_FILE $TARGET_NVS_FILE
or 
calibrator plt autocalibrate wlan0 $WL12xx_MODULE $TARGET_INI_FILE $TARGET_NVS_FILE 08:00:12:34:56:78


Calibration Process
从https://github.com/TI-OpenLink/ti-utils/tree/master/hw/ini_files/128x下载TQS_D_1.7.ini
cd /lib/firmware/ti-connectivity/
rm wl1271-nvs.bin
创建NVS文件,并拷贝为wl1271-nvs.bin


calibrator set ref_nvs /usr/share/ti/wifi-utils/ini_files/127x/TQS_S_2.6.ini 
cp new-nvs.bin /lib/firmware/ti-connectivity/wl1271-nvs.bin
ifconfig wlan0 down
rmmod wl12xx_sdio
modprobe wl12xx_sdio
ifconfig wlan0 down
calibrator plt calibrate
cp new-nvs.bin /lib/firmware/ti-connectivity/wl1271-nvs.bin














/*********firmware文件下载地址*********/
https://github.com/TI-OpenLink/firmwares/tree/master/ti-connectivity
/********** calibrator 指导 **********/里边有ini文件下载地址  mac80211/config 文件下也有ini文件
https://github.com/TI-OpenLink/firmwares/tree/master/ti-connectivity






问题:直接运行calculator  set_nvs /home/TQS_D_1.7.ini    出现错误nl80211 not found
先加载模块 insmod wl12xx_sido.ko 问题解决
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值