2013年1月31日 星期四

GM812x cramfs測試步驟


PS: 已經有一個cramfs image file大小約3M

1. 以目前的ramdiskfs模式下,使用chroot 測試cramfs:
  1.1 變更kernal MTD table(mtdblock5),切割一塊3M的partition。
  1.2 enable kernal config to support cramfs.
  1.3 更新FW,讓kernal能support cramfs
  1.4 上傳測試用cramfs,將其寫入mtdblock5:
      dd if=/upload/roo.img of=/dev/mtdblock5
  1.5 切換rootfs:
     mount -t cramfs /dev/mrdblock5 /mnt/mtd
    chroot /mnt/mtd
2. 在kernal boot command 直接開啟cramfs
  2.1 disable kernal config to dissupport ramdiskfs
  2.2 修改kernal boot command,加入cramfs 開機指令:
    ... rootfs=/dev/mtdbloack5 rootfstype=cramfs

2013年1月30日 星期三

iwlist [interface] scanning 回傳訊息的順序修改

常常發現在不同的wifi dongle在使用iwlist [interface] scanning後所得到訊息往往裡面的順序都會有所不同,可是上層APP parse function已經寫好了(例如:目前的parse是以"Quality"的訊息來判對AP資訊的結束),又不想改寫的話,就只好修改wifi dongle driver 在iwlist [interface] scanning 回傳訊的順序,所以就去瞭解一下iwlist [interface] scanning的動作流程。

由iwlist.c中可以發現,scanning的動作是呼叫"print_scanning_info"函式,在此function中可以看到
      /* Initiate Scanning */
      if(iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0)
這裡就是對interface發出scanning的ioctl,而後就等待底層的回應
      /* Wait until something happens */
      ret = select(last_fd + 1, &rfds, NULL, NULL, &tv);
當底層有回應後,在呼叫
 if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
來讀取底層回傳的訊息。

所以修改底層可以先以"SIOCGIWSCAN"來搜尋,以RTL8192CU的驅動來看,
rtw_wx_set_scan, /* SIOCSIWSCAN */
rtw_wx_get_scan, /* SIOCGIWSCAN */
rtw_wx_set_essid, /* SIOCSIWESSID */
可以看到"SIOCGIWSCAN" 對應函式為"rtw_wx_get_scan",在其中可以看到"translate_scan"的函式,這個函式就是要修改的地方。在此函式中可以看到最後的訊息是Quality相關,也可以看到關鍵的cmd。
/* Add quality statistics */
iwe.cmd = IWEVQUAL;
接著再以"IWEVQUAL" 來搜尋RT5370 dirver,就可以看到"rt_ioctl_siwscan" int sta_ioctl.c,而其中Quality相關的動作是在中間
/*Channel and Frequency */
......
/*Add quality statistics */
....
/*Encyption key */
接下來就只要把Quality相關的程式碼移到函式的尾端,如此就可讓兩個WIFI dongle在iwlist [interface] scanning的回傳訊息中,每個AP都會以Quality作為結尾。

WIFI signal percentage與dbm互轉

因RTL8192CU與RT5370在iwlist [interface] scanning 回傳的訊息中,signal level的回傳值RTL8192CU使用percentage,而RT5370卻是以DB表示,所以為了統一UI上顯示的訊息,所以將signal level轉為percentage表示。

percentage to dbm:
在RTL8192CU的driver中有段程式碼將percentage to dbm(rtw_recv.h),程式碼如下:

__inline static s32 translate_percentage_to_dbm(u32 SignalStrengthIndex)
{
s32 SignalPower; // in dBm.

// Translate to dBm (x=0.5y-95).
SignalPower = (s32)((SignalStrengthIndex + 1) >> 1);
SignalPower -= 95;

return SignalPower;
}

dbm to percentage:
在RT5370的driver中有段程式碼將dbm to percentage(cmm_info.c),程式碼如下:
/* Rssi*/
Rssi = (INT)pBss->Rssi;
if (Rssi >= -50)
Rssi_Quality = 100;
else if (Rssi >= -80)    /* between -50 ~ -80dbm*/
Rssi_Quality = (UINT)(24 + ((Rssi + 80) * 26)/10);
else if (Rssi >= -90)   /* between -80 ~ -90dbm*/
Rssi_Quality = (UINT)(((Rssi + 90) * 26)/10);
else    /* < -84 dbm*/
Rssi_Quality = 0;
sprintf(msg+strlen(msg),"%-9d", Rssi_Quality);

也許有人會問怎麼不把percent to dbm的函式反轉就可以做dbm to percentage,為什麼要這麼麻煩?原本也是打算這麼做,可是實做後發現,也許是廠商不同,RT5370回傳的dbm值若是直接使用反轉的函式所得到的percentage值有時會出現超過100%的數值,所以後來還是乖乖的使用判斷的方式來將dbm to percentage。

2013年1月24日 星期四

Apache Software License Version 1.1

目前遇到國外客戶需要我們列出平台使用的software license,可是因為公司沒有這方面的經驗,所以就大家分別研究各種license的限制。然而,被分配到研究"Apache Software Licence version 1.1",首先先放中英文對照翻譯:(這時候Google翻譯真好用...)

※目前已經被Apache Software License Version 2.0取代※

Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
版權所有(c)2000 Apache軟件基金會。 保留所有權利。
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
准許以無論有無修改的原始碼或二進位碼形式,為再散布或使用行為,只要符合義務要求即可。
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
1. 原始碼的重製物必須包含授權條款的著作權聲明和授權條款的所有內容。
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
以二進位碼呈現的重製物必須在程式本體或其他說明資料中重現授權條款的著作權聲明和授權條款的所有內容。
3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment:
"This product includes software developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear.
3. 若含有終端用戶使用說明時,必須同時包含「此產品所含軟體為 ASF 所開發」的確認訊息,並可與第三者的確認訊息間隔並列。
4. The names "Apache" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org.
4. 在沒有事前書面的允許下,"Apache" 和 "Apache Software Foundation" 的名稱不被用於支持或宣傳從本軟體衍生的產品。書面許可請洽"apache@apache.org"
5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation.
5.  未經Apache Software Foundation書面允許前,從本軟體衍生的產品不得以 "Apache" 稱呼或在名稱中包含 "Apache" 的字眼。

======以下省略=====
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see .
Portions of this software are based upon public domain software originally written at the National Center for Supercomputing Applications, University of Illinois, Urbana-Champaign.
======以上省略=====

看起來這種License很簡單,沒有強迫軟體商必須放出自己的原始碼,只要發行時保留授權條款的著作權聲明和授權條款的所有內容、在使用說明書中說明「此產品所含軟體為 ASF 所開發」、並且在沒有書面允許前不要使用"Apache"相關字樣來宣傳或命名產品

資料來源:
http://www.openfoundry.org/tw/licenses/28-apache-license-11-apache-11 (中文翻譯部分)
http://opensource.org/licenses/apachepl-1.1.php (英文部分)
http://www.apache.org/licenses/LICENSE-1.1 (原始文件)

LDD命令

来自:http://blog.csdn.net/tenfyguo/article/details/5605120

Linux中,可以顯示指令/程式所聯結的so,但不會執行指令/程式。
一般是使用環境變數來開啟或關閉:
開啟:export LD_TRACE_LOADED_OBJECTS=1
關閉:unset LD_TRACE_LOADED_OBJECTS
當開啟LDD功能後,指令/程式就只會顯示所聯結的so檔,例:(GM812x平台)

# ls /usr
        libm.so.6 => /lib/libm.so.6 (0x40028000)
        libc.so.6 => /lib/libc.so.6 (0x400c4000)
        /lib/ld-linux.so.3 (0x40000000)