summaryrefslogtreecommitdiff
path: root/multitech/recipes/wl12xx-scripts/wl12xx-scripts-1.0/calibrate-wifi.sh
blob: 65de71f425862841b956b2a25b626dd96d6f92ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

OEM_DIR="/var/oem"
NVS_DIR="mts"
NVS_OEM_FILE="$OEM_DIR/$NVS_DIR/wl1271-nvs.bin"
NVS_FILE="/lib/firmware/ti-connectivity/wl1271-nvs.bin"
NVS_DEFAULT_FILE="$NVS_FILE.factory"

if [[ $# -eq 1 ]]; then
	WIFIMAC=$1
else
	WIFIMAC=$(mts-io-sysfs show mac-wifi)
fi

# detect mci driver
if find /lib/modules -name "atmel-mci.ko" | grep -q "atmel-mci"; then
	MCI_MODULE="atmel_mci"
else
	MCI_MODULE="at91_mci"
fi

echo "starting wifi calibration..."

killall hostapd
killall wpa_supplicant

modprobe -r wl12xx_sdio
modprobe -r $MCI_MODULE

mts-io-sysfs store wlan-enabled 0
sleep 1
mts-io-sysfs store wlan-enabled 1
sleep 1

mount -o remount,rw /var/oem
echo "removing $NVS_OEM_FILE"
rm -f $NVS_OEM_FILE
mkdir -p $OEM_DIR/$NVS_DIR

modprobe $MCI_MODULE
sleep 3
rmmod wl12xx_sdio

echo "calibrating..."
calibrator plt autocalibrate wlan0 \
    /lib/modules/2.6.39.4/updates/drivers/net/wireless/wl12xx/wl12xx_sdio.ko \
    /usr/share/ti/wifi-utils/ini_files/127x/TQS_S_2.6.ini \
    $NVS_FILE $WIFIMAC

mount -o remount,ro /var/oem

echo "...calibration finished"