wl12xx: build two wireless tools calibrate and wlan_prov
authorArron Wang <arron.wang@intel.com>
Wed, 23 Jan 2013 06:46:22 +0000 (14:46 +0800)
committerArron Wang <arron.wang@intel.com>
Thu, 24 Jan 2013 02:14:58 +0000 (10:14 +0800)
Change-Id: Ieb6082039cd31798d78962ab292175cd89e56ef0

packaging/kernel-mfld-blackbay.spec
packaging/tizen-wl12xx-compat-build.patch
ti-wlan/wlan_prov/Makefile [new file with mode: 0644]
ti-wlan/wlan_prov/wlan_provisioning.c

index 7fa6214..a29f13f 100644 (file)
@@ -20,6 +20,7 @@ BuildRequires: findutils
 BuildRequires: elfutils-libelf-devel
 BuildRequires: binutils-devel
 BuildRequires: which
+BuildRequires: libnl2-devel
 ExclusiveArch: %{ix86}
 
 Provides: kernel = %{version}-%{release}
@@ -214,6 +215,8 @@ fi
 /lib/modules/%{kernel_full_version}/updates
 /lib/modules/%{kernel_full_version}/modules.*
 %ghost /boot/initrd-%{kernel_full_version}.img
+/usr/sbin/calibrator
+/usr/sbin/wlan_prov
 
 
 %files devel
index d5cca29..7cbff5a 100644 (file)
@@ -1,8 +1,7 @@
-diff --git a/packaging/wl12xx-compat-build.sh b/packaging/wl12xx-compat-build.sh
-index dd33741..22ee7dd 100755
---- a/packaging/wl12xx-compat-build.sh
-+++ b/packaging/wl12xx-compat-build.sh
-@@ -39,19 +39,20 @@ _preserve_kernel_config=""
+diff -uNr a/wl12xx-compat-build.sh b/wl12xx-compat-build.sh
+--- a/packaging/wl12xx-compat-build.sh 2013-01-23 18:03:14.602741237 +0800
++++ b/packaging/wl12xx-compat-build.sh 2013-01-23 18:02:46.118740560 +0800
+@@ -39,19 +39,20 @@
  _menuconfig="false"
  _config_file_type=android
  _regdom="00"
@@ -28,7 +27,7 @@ index dd33741..22ee7dd 100755
      if [ -z "$CROSS_COMPILE" ];then
          export CROSS_COMPILE="`basename ${TARGET_TOOLS_PREFIX}`"
      fi
-@@ -60,7 +61,7 @@ init_variables() {
+@@ -60,7 +61,7 @@
          export CROSS_COMPILE="ccache $CROSS_COMPILE"
      fi
      export ARCH=i386
@@ -37,7 +36,7 @@ index dd33741..22ee7dd 100755
      echo >&3 "ARCH: $ARCH"
      echo >&3 "CROSS_COMPILE: $CROSS_COMPILE"
      echo >&3 "PATH: $PATH"
-@@ -86,32 +87,33 @@ init_variables() {
+@@ -86,32 +87,39 @@
      esac
  
      PRODUCT_OUT=${TOP}/out/target/product/${BOARD}
@@ -79,10 +78,16 @@ index dd33741..22ee7dd 100755
 +    local MODULE_DEST_TMP=${INSTALL_MOD_PATH}
 +    cd ${COMPAT_SRC_DIR}
 +    make ARCH=${ARCH} KLIB=${MODULE_DEST_TMP} KLIB_BUILD=${KERNEL_BUILD_DIR} install-modules
++    cd $TOP/ti-wlan/calibrator/
++    make
++    mkdir -p ${MODULE_DEST_TMP}/usr/sbin/ && cp -f ./calibrator ${MODULE_DEST_TMP}/usr/sbin/
++    cd $TOP/ti-wlan/wlan_prov/
++    make
++    cp -f ./wlan_prov ${MODULE_DEST_TMP}/usr/sbin/
      exit_on_error $? quiet
  
      cd ${TOP}
-@@ -134,7 +136,7 @@ usage() {
+@@ -134,7 +142,7 @@
  main() {
      local custom_board_list="vbox mfld_cdk mfld_pr2 mfld_gi mfld_dv10 mfld_tablet_evx ctp_pr0 ctp_pr1 mrfl_vp mrfl_hvp mrfl_sle"
  
@@ -91,7 +96,7 @@ index dd33741..22ee7dd 100755
      do
          case "${opt}" in
          K)
-@@ -180,6 +182,9 @@ main() {
+@@ -180,6 +188,9 @@
          r)
              _regdom=$OPTARG
              ;;
@@ -101,7 +106,7 @@ index dd33741..22ee7dd 100755
          ?)
              echo "Unknown option"
              usage
-@@ -190,11 +195,18 @@ main() {
+@@ -190,11 +201,18 @@
  
      for custom_board in $custom_board_list
      do
diff --git a/ti-wlan/wlan_prov/Makefile b/ti-wlan/wlan_prov/Makefile
new file mode 100644 (file)
index 0000000..265048f
--- /dev/null
@@ -0,0 +1,15 @@
+CC = $(CROSS_COMPILE)gcc
+CFLAGS = -O2 -Wall
+CFLAGS += -I/usr/include -I/include
+
+wlan_prov: wlan_provisioning.c
+       $(CC) -o wlan_prov wlan_provisioning.c
+
+install:
+       @mkdir -p /usr/sbin/
+       @echo Copy files to /usr/sbin/
+       @cp -f ./wlan_prov /usr/sbin/
+       @chmod 755 /usr/sbin/wlan_prov
+
+clean:
+       @rm -f wlan_prov
index 1e11073..4186471 100644 (file)
  *  limitations under the License.
 */
 
-#define LOG_TAG "wlan_prov"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <cutils/log.h>
-#include <cutils/misc.h>
-#include <cutils/android_reboot.h>
 #include <string.h>
 #include <sys/types.h>
 #include <dirent.h>
@@ -37,7 +32,7 @@
 const unsigned char NullMacAddr[MAC_ADDRESS_LEN] = { 0, 0, 0, 0, 0, 0 };
 
 #define WIFI_PATH "/data/misc/wifi"
-const char NVS_file_name[] = "/factory/wifi/wl1271-nvs.bin";
+const char NVS_file_name[] = "/lib/firmware/ti-connectivity/wl1271-nvs.bin";
 const char Default_NVS_file_name[] = "/system/etc/wifi/wl1271-nvs.bin";
 const char WLAN_SDIO_BUS_PATH[] = "/sys/bus/sdio/drivers/wl1271_sdio/";
 #define WLAN_DRV_SDIO_NAME "wl1271_sdio"
@@ -103,7 +98,7 @@ static char *parse_uevent_file(char *path, char *pattern)
 
        file = fopen(path, "r");
        if (!file) {
-               LOGE("%s: %s file not found\n", __func__, path);
+               /* LOGE("%s: %s file not found\n", __func__, path); */
                goto out;
        }
 
@@ -132,7 +127,7 @@ static int sdio_get_pci_id(char *sdio_device_path, char *pci_id)
        char *uevent_entry = NULL;
        char sub_entry[256];
        if (!sdio_path) {
-               LOGE("Cannot open directory, ret with %d\n", errno);
+               /* LOGE("Cannot open directory, ret with %d\n", errno); */
                ret = -EINVAL;
                goto exit;
        }
@@ -193,7 +188,7 @@ static int bind_unbind_driver(const char *driver_path, const char *driver_id,
 
        file_path = (char *) malloc(n+1);
        if (!file_path) {
-               LOGE("Not enough space\n");
+               /* LOGE("Not enough space\n"); */
                ret = -ENOMEM;
                goto fail;
        }
@@ -202,7 +197,7 @@ static int bind_unbind_driver(const char *driver_path, const char *driver_id,
 
        file = fopen(file_path, "w");
        if (!file) {
-               LOGE("Unable to open file %s in write mode", file_path);
+               /* LOGE("Unable to open file %s in write mode", file_path); */
                ret = -EIO;
                goto open_fail;
        }
@@ -210,7 +205,7 @@ static int bind_unbind_driver(const char *driver_path, const char *driver_id,
        fprintf(file,"%s", driver_id);
 
        if (fclose(file)) {
-               LOGE("Unable to close file");
+               /* LOGE("Unable to close file"); */
                ret = -EIO;
        }
 
@@ -253,7 +248,7 @@ int main(int argc, char **argv)
                ChaabiMacAddr = (unsigned char *) malloc(MAC_ADDRESS_LEN);
                memcpy(ChaabiMacAddr, NullMacAddr, MAC_ADDRESS_LEN);
 
-               LOGW("MAC not found");
+               /* LOGW("MAC not found"); */
 #ifdef BUILD_WITH_CHAABI_SUPPORT
        }
 #endif
@@ -261,7 +256,7 @@ int main(int argc, char **argv)
        nvsBinFile = fopen(NVS_file_name, "rb");
 
        if (!nvsBinFile) {
-               LOGI("run calibration");
+               /* LOGI("run calibration"); */
                if (wifi_calibration()) {
                        res =  -2;
                        goto end;
@@ -272,8 +267,11 @@ int main(int argc, char **argv)
                        /* NVS file already exist but chaabi read error */
                        /* exit here to avoid randomize new MAC address */
                        /* at each boot */
-                       res =  0;
-                       goto end;
+                       /* res =  0;
+                        * goto end;
+                        * we need to randomize new MAC address because we can't read
+                        * chaabi and we have the same nvs file for all devices
+                        */
                }
        }
 
@@ -298,7 +296,7 @@ int main(int argc, char **argv)
                ChaabiMacAddr[3] = (unsigned char) (rand() & 0xff);
                ChaabiMacAddr[4] = (unsigned char) (rand() & 0xff);
                ChaabiMacAddr[5] = (unsigned char) (rand() & 0xff);
-               LOGI("MAC randomized");
+               /* LOGI("MAC randomized"); */
        }
 
        /* Chaabi MAC @ shall be write in NVS file ? */
@@ -338,7 +336,7 @@ end:
        return res;
 fatal:
        sync();
-       android_reboot(ANDROID_RB_RESTART, 0, 0);
+       /* android_reboot(ANDROID_RB_RESTART, 0, 0); */
        return res;
 }
 
@@ -390,18 +388,20 @@ static int nvs_replace_mac(unsigned char *MacAddr)
        int err = 0;
        char system_cmd[500];
 
-       snprintf(system_cmd, sizeof(system_cmd), "/system/bin/calibrator set nvs_mac"
+       snprintf(system_cmd, sizeof(system_cmd), "/usr/sbin/calibrator set nvs_mac"
                                                " %s %02x:%02x:%02x:%02x:%02x:%02x",
                                                NVS_file_name,
                                                MacAddr[0], MacAddr[1], MacAddr[2],
                                                MacAddr[3], MacAddr[4], MacAddr[5]);
-       if (debug)
+       /* if (debug)
                LOGI("cmd: %s",system_cmd);
+        */
 
        err = system(system_cmd);
 
-       if (err)
+       /* if (err)
                LOGE("NVS update with new MAC error= %d",err);
+        */
 
        return err;
 }
@@ -414,18 +414,20 @@ static int wifi_calibration(void)
        int module_is_loaded = 0;
 
        /* start calibration & nvs update */
-       snprintf(system_cmd, sizeof(system_cmd), "/system/bin/calibrator plt autocalibrate wlan0"
+       snprintf(system_cmd, sizeof(system_cmd), "/usr/sbin/calibrator plt autocalibrate wlan0"
                                                        " /lib/modules/wl12xx_sdio.ko %s %s %s",
                                                        TQS_FILE,
                                                        NVS_file_name,
                                                        (unsigned char *)"08:00:28:DE:AD:00");
-       if (debug)
+       /* if (debug)
                LOGI("cmd: %s",system_cmd);
+        */
 
        err = system(system_cmd);
 
-       if (err)
+       /* if (err)
                LOGE("Calibration error= %d",err);
+        */
 
        return err;
 }