2010年12月20日 星期一

RIL for android

RIL: Radio Interface Layer, RIL控制數據機和提供通訊協定(Protocol)
並且和rild(ril daemon)溝通.
RIL主要是基於AT command來操作,如發命令和response解析等等

*Android ril layer on /hardware/ril
*Android ril 主要分為三塊:
./system/lib/libreference-ril.so
./system/lib/libril.so
./system/bin/rild

reference:http://miox.cc/2009/07/android-gsmrild.html
1. rild:
僅實現一main函數作為整個ril層的入口點,負責完成初始化。

2. libril.so:
與 rild結合相當緊密,是其共享庫,編譯時就已經建立了這一關係。組成部分為ril.cpp,ril_event.cpp。libril.so駐留在 rild這一守護進程中,主要完成同上層通信的工作,接受ril請求並傳遞給librefrence_ril.so, 同時把來自librefrence_ril.so的反饋回傳給調用進程。

3. librefrence_ril.so:
rild通過手 動的dlopen方式加載,結合稍微鬆散,這也是因為librefrence.so主要負責跟Modem硬件通信的緣故。這樣做更方便替換或修改以適配更 多的Modem種類。它轉換來自libril.so的請求為AT命令,同時監控Modem的反饋信息,並傳遞迴libril.so。在初始化時, rild通過符號RIL_Init獲取一組函數指針並以此與之建立聯繫。

4. radiooptions:
radiooptiongs通過獲取啟動參數, 利用socket與rild通信,可供調試時配置Modem參數。



./ril/
|-- CleanSpec.mk
|-- include
| `-- telephony
| |-- ril.h
| `-- ril_cdma_sms.h
|-- libril
| |-- Android.mk
| |-- MODULE_LICENSE_APACHE2
| |-- NOTICE
| |-- ril.cpp
| |-- ril_commands.h
| |-- ril_event.cpp
| |-- ril_event.h
| `-- ril_unsol_commands.h
|-- reference-cdma-sms
| |-- Android.mk
| |-- reference-cdma-sms.c
| `-- reference-cdma-sms.h
|-- reference-ril
| |-- Android.mk
| |-- MODULE_LICENSE_APACHE2
| |-- NOTICE
| |-- at_tok.c
| |-- at_tok.h
| |-- atchannel.c
| |-- atchannel.h
| |-- misc.c
| |-- misc.h
| `-- reference-ril.c
`-- rild
|-- Android.mk
|-- MODULE_LICENSE_APACHE2
|-- NOTICE
|-- radiooptions.c
`-- rild.c


./ril/
|-- CleanSpec.mk
|-- include
| `-- telephony
| |-- ril.h
| `-- ril_cdma_sms.h
|-- libril
| |-- Android.mk
| |-- MODULE_LICENSE_APACHE2
| |-- NOTICE
| |-- ril.cpp
| |-- ril_commands.h
| |-- ril_event.cpp
| |-- ril_event.h
| `-- ril_unsol_commands.h
|-- reference-cdma-sms
| |-- Android.mk
| |-- reference-cdma-sms.c
| `-- reference-cdma-sms.h
|-- reference-ril
| |-- Android.mk
| |-- MODULE_LICENSE_APACHE2
| |-- NOTICE
| |-- at_tok.c
| |-- at_tok.h
| |-- atchannel.c
| |-- atchannel.h
| |-- misc.c
| |-- misc.h
| `-- reference-ril.c
`-- rild
|-- Android.mk
|-- MODULE_LICENSE_APACHE2
|-- NOTICE
|-- radiooptions.c
`-- rild.c

2010年12月14日 星期二

Vim plugin tabbar/easygrep

使用起來也很方便,把下載的tabbar.vim放在Linux環境下的$HOME/.vim/plugin或Windows環境下的C:\Program Files\Vim\vimfiles\plugin就可以啦。

在同時開啓編輯多個檔案時,就會在編輯的上方多出一個TabBar的區域,顯示目前開啓的全部檔案和檔案編號,要切換不同的檔案就用+<檔案編號>就可以了

you may try to delete buffers with:
:bdelete
or
:bd

reference:
http://allen501pc.wordpress.com/2009/12/17/%E6%88%91%E7%9A%84-vim-%E8%A8%AD%E5%AE%9A%E9%85%8D%E7%BD%AE/
http://rickey-nctu.blogspot.com/2009/02/vim-nerd-tree.html


Easygrep:
依照滑鼠的位置來搜尋字串"\"+"vv" in my PC

cscope:
[ Ctrl + \ + s ] : 搜尋游標上的 function 哪邊參考到
[ Ctrl + \ + c ] : 搜尋游標上的 function 哪邊呼叫到
[ Ctrl + \ + g ] : 搜尋游標上的 function 是在哪邊定義的

[ Ctrl + \ + t ] : 跳回下一個位置
[ Ctrl + \ + o ] : 跳回上一個位置

http://blog.chhsu.org/2009/03/multi-projects-of-vim-using-cscope.html

----------------------------------------
*ctags and cscope script file
#!/bin/sh
#Using Ctrl+] and Ctr+T
ctags -R -h ".h.c.s"
#
#find . -name '*.[hc]' | cscope -i - -b -R &
cscope.sh `pwd`

----------------------------------------
cscope.sh

#!/bin/sh
CSCOPE_FILE=cscope.out
if [ -n "$1" ]; then
echo "Source code directory: " $1
echo "Create file map : " $CSCOPE_FILE
find $1 -name "*.h" -o -name "*.c" -o -name "*.cpp" > $CSCOPE_FILE
cscope -bkq -i $CSCOPE_FILE
# cscope -Rbkq
ctags -R
else
echo "Please key-in path of project"
fi

2010年12月13日 星期一

Using diff on VIM

http://www.farmer.idv.tw/index.php?viewDoc=364

*vimdiff FILE_LEFT FILE_RIGHT
*然後在vim的ex模式(也就是"冒號"模式)下輸入:

:vertical diffsplit FILE_RIGHT

更新diff的狀況
:diffupdate

用 do 可以把對面比對的部份的抓過來 , o for "obtain" 。
用 dp 則是把目前視窗比對到的部份的放到對面去。 p for "put"。

:wa 存全部
:diffupdate

2010年12月2日 星期四

Study BT concept

http://dicky-chiang.blogspot.com/2009_07_01_archive.html

先總結一下目前我所認知BT :

藍牙協議堆疊依照其功能可分四層:

* 核心協議層(HCI、LMP、L2CAP、SDP)
* 線纜替換協定層(RFCOMM)
* 電話控制協定層(TCS-BIN)
* 選用協議層(PPP、TCP、IP、UDP、OBEX、IrMC、WAP、WAE)

藍牙規範(Profile)是指藍牙通訊在那一種用途下應該使用的通訊協定和相關的規範。藍牙1.1定義的profile有13個。SIG 認為藍牙裝置有4個最基本的 Profile:

* General Access Profile(GAP)
* Service Discovery Application Profile(SDAP)
* Serial Port Profile(SPP)
* General Object Exchange Profile(GOEP)

我所關心的是核心協議層,其中

LMP(Link Management Protocol):它主要是負責base band與之間控制訊息的交換

HCI(Host Controller Interface):這個介面是用來處理Host與BT device之間的通訊,透過HCI,無論這個BT device是以USB介面還是serial port介面連接到Host,Host都可以存取BT device,聽起來很像是驅動程式,但它卻不會像驅動程式一樣去存取記憶體等資源,它的作法是HCI透過發送命令或是資料封包到BT device,這時BT device也會回覆資訊,所以簡單講,HCI提供了一個uniform的介面來存取BT device

L2CAP(Logic Link Control and Apapation Protocol):L2CAP是負責多工,從上層送來的封包過大時,它是切成適當的大小往下層送,好讓下層可以處理,反之亦然.

SDP(service discovery protocol):簡單的話,這協議定議了如何發現哪個可用的BT deivce,並且在找不到BT device時,同時也有探測的功能.

Bluez它是標準的Linux Bluetooth module,幾乎支援各個BT device

整個BT architecture中,除了硬體的RF module , base band , Link Manager之外

還需要軟體部份的L2CAP,RFcomm module,SDP,TCS 而Bluez就是負責這部份


--------------------------------------------------------------
http://dicky-chiang.blogspot.com/2009_07_01_archive.html

Bluez是官方 Linux Bluetooth stack,由主機控制介面(Host Control Interface ,HCI)層、Bluetooth 協定核心、邏輯鏈路控制和適配協定(Logical Link Control and Adaptation Protocol,L2CAP)、SCO 音訊層、其他 Bluetooth 服務、使用者空間後臺預設程式以及設定工具組成.

而bluez裡面,有一個源始碼叫 hci_core.c ,它是HCI的核心所在,而H4 procotol跟BCSP procotol全都依賴這個HCI core,而H4跟BCSP的源始碼也放在bluez裡叫hci_h4.c和hci_bcsp.c,想更深入了解的人可以先去翻閱.

那H4跟BCSP又是什麼呢?BCSP全名叫BlueCore serial Protocol,而H4是UART的規範,如果是RS232呢?那就是H3 procotol,所以這次的HCI protcol將會用到H4跟BCSP,所以在設置核心時,記得要打勾!!

己經知道BT會用到的protocol之後,再來就是要來了解是誰負責傳/收資料,誰又是負責處理資料.

負責傳/收當然就由UART負責跟硬體層溝通,接著會到serial core,這個serial core會把UART接收到的信號轉成數位,而且handle所有的資料跟接口(ports),並且對該device向tty I/O註冊,而tty I/O會再把它轉換成device並通知核心註冊一個character device,讓你能夠經由terminal對serial port下command.

而處理資料是經過一個叫HCIline discipline,Line disicpline是在同一種serial driver上使用不同科技的一種方法,它是位於serial core的上層,如果說serial是負責控制硬體傳/收資料,那line disicpline就是負責處理這些資料的方法,而且是在user space及kernel space做傳輸.

它會執行封包切割 配置並且產生相對對應的網路資料結構,然後把對應的資料傳送到對應的協定層...沒錯,它將會傳送到H4及BCSP的協定層.

而這顆chip是屬於內置CSR bluetooth並使用UART連接.因為CSR是設計為HCI資料分組,所以必為要用hciattach來通知bluez來鏈結驅動程式.

reference:
http://i-miss-erin.blogspot.com/search/label/bluetooth

2010年11月24日 星期三

2010年11月23日 星期二

wifi hal layer on android

- wifi ap layer on Android
frameworks/base/core/jni/android_net_wifi_Wifi.cpp
framwworks/base/wifi/java/android/net/wifi/WifiStateTracker.java

- Wifi HAL layer
Android/hardware/libhardware_legacy/wifi/wifi.c

- Tool: wpa_suplicant and wpa_cli.c
external/wpa_supplicant/wpa_cli.c

2010年11月19日 星期五

using wpa_cli setting wifi

#!/system/bb/ash
start wpa_supplicant
sleep 1
wpa_cli -i tiwlan0 scan
wpa_cli -i tiwlan0 scan_result
wpa_cli -i tiwlan0 add_network
wpa_cli -i tiwlan0 set_network 0 key_mgmt NONE
wpa_cli -i tiwlan0 set_network 0 ssid '"QQ"'
wpa_cli -i tiwlan0 enable_network 0
;--------------------------------------------------

#!/system/bb/ash
start wpa_supplicant
sleep 1
wpa_cli -i tiwlan0 scan
wpa_cli -i tiwlan0 scan_result
wpa_cli -i tiwlan0 add_network
wpa_cli -i tiwlan0 set_network 0 key_mgmt NONE
wpa_cli -i tiwlan0 set_network 0 ssid '"'$1'"'
wpa_cli -i tiwlan0 enable_network 0
echo $1


;--------------------------------------------------
使用wpa_cli控制和管理wpa_supplicant
# wpa_cli -i wlan0 status (看看目前的狀態)
# wpa_cli -i wlan0 help (查看參數與指令)
# wpa_cli -i wlan0 terminate (關閉wpa_supplicant)
# wpa_cli -i wlan0 interface (查看有那些無線網卡介面)
# wpa_cli -i wlan0 list_networks (查看wpa_supplicant.conf檔裡的設定)
# wpa_cli -i wlan0 select_network (選擇不同的AP,id為AP代號0,1,2,3...)
# wpa_cli -i wlan0 enable_network
# wpa_cli -i wlan0 disable_network
# wpa_cli -i wlan0 remove_network (刪除AP資訊)
# wpa_cli -i wlan0 reconfigure (重新讀取wpa_supplicant.conf設定內容)
# wpa_cli -i wlan0 save_config (儲存寫入到wpa_supplicant.conf中,否責變更無效)
# wpa_cli -i wlan0 disconnect (斷線)
# wpa_cli -i wlan0 reconnect (重新連線)
# wpa_cli -i wlan0 scan (掃描附近的AP)
# wpa_cli -i wlan0 scan_results (印出附近AP的相關資訊)

;---------------------------------------
http://linux.die.net/man/8/wpa_cli

wpa_cli [ -p path to ctrl sockets ] [ -i ifname ] [ -hvB ] [ -a action file ] [ -P pid file ] [ command ... ]

2010年11月3日 星期三

indent

find . -name '*.[hc]' -exec indent -kr -l 80 -ts 8 {} \;

indent -kr -i8 -ts 8 -l 80 ilitek_ts.c

2010年11月2日 星期二

study input device

http://www.mask.org.tw/blog/category/linux/
http://blog.csdn.net/colorant/archive/2007/04/12/1561837.aspx

Driver -> InputCore -> Eventhandler -> userspace

# EV_RST 0x00 Reset
# EV_KEY 0x01 按键
# EV_REL 0x02 相对坐标
# EV_ABS 0x03 绝对坐标
# EV_MSC 0x04 其它
# EV_LED 0x11 LED
# EV_SND 0x12 声音
# EV_REP 0x14 Repeat

2010年10月25日 星期一

Driver: passing Command Line Argument to a Module

#include
#include
#include
#include
#include



#define DRIVER_AUTHOR "winnie@quanta"
#define DRIVER_DESC "hello"
static int myinit = 3;

module_param(myinit, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
MODULE_PARM_DESC(myinit, "An integer");

static int __init hello_init(void)
{
printk(KERN_INFO "hello init myinit= %d \n", myinit);
if(myinit==0)
printk(KERN_INFO "@@myinit is zero = %d \n", myinit);
else
printk(KERN_INFO "@@myinit other = %d \n", myinit);
return 0;
}

static void __exit hello_exit(void)
{
printk(KERN_INFO "hellp exit \n");
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);

insmod proc.ko myinit=10

S_IRUSR/S_IWUSR/S_IRGRP/S_IWGRP

S_IRUSR
Permits the file's owner to read it.

S_IWUSR
Permits the file's owner to write to it.

S_IRGRP
Permits the file's group to read it.

S_IWGRP
Permits the file's group to write to it.

Can't rmmod driver on Android

mkdir -p /lib/modules
cd /lib/modules
ln -s /system/lib/modules `uname -r`

2010年10月20日 星期三

linux driver

http://www.tldp.org/LDP/lkmpg/2.6/html/

http://www.captain.at/howto-linux-kernel-parallel-port-interrupt.php

http://tw.myblog.yahoo.com/chimei-015/archive?l=f&id=20

2010年10月18日 星期一

cscope & ctags

find . -name '*.h' -o -name '*.c' | cscope -i - -b &

-----------------------------------------------------
@@cscope setting on ubuntu
1./usr/share/vim/vim72/plugin/cscope_map.vim

@@Step 1 : Create cscope.out file on project.
#find . -name '*.h' -o -name '*.c' | cscope -i - -b &
or
#find . -name '*.[hc]' | cscope -i - -b -R &

Step 2 : At cscope.out directory and trace code by cscope

Search "Ctrl+[" in my PC.

General using "Ctrl+\" in general PC.

Step 3 :


@@ctags: "ctags -R ."

Start trace code "Ctrl+]"


----------------------------------------------------
ctaglist:
vi /etc/vim/vimrc


"Taglist edit"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
nnoremap :TlistToggle


----------------------------------------------------
reference:
http://www.cmlab.csie.ntu.edu.tw/~daniel/linux/vim_source_navigation.html

2010年10月17日 星期日

Using screen to paste

Enter CTRL+A+[
Then, Using " " to select region
Finally, Using " " to return select region.

Go to another screen, Using CTRL+A+]

2010年10月14日 星期四

objdump

objdump -t u-boot
objdump -d u-boot

-i objdump –i 顯示支援的檔案格式與機器架構
-f objdump -f a.o 顯示檔頭資訊 (-file-headers)
-h objdump -h a.o 顯示區段表頭 (-[section-]header)
-x objdump -x a.o 顯示所有表頭 (-all-headers)
-d objdump -d a.o 反組譯程式段 (-disassemble)
-D objdump -D a.o 反組譯全部區段 (-disassemble-all)
-t objdump -t a.o 顯示符號表 (-syms)
-r objdump -r a.o 顯示重定位記錄 (-reloc)

2010年10月11日 星期一

minicom

minicom -c on

Study vi edit

1. Using Vi to see Hex file
:!xxd

2.http://edt1023.sayya.org/vim/node1.html

3. [count] CMD [addr]
count : 次數
CMD : command
addr : ex: %,},{.......

4 normal mode :
"G" --> 最後一頁
"gg" --> 首頁
"%" --> 搜尋括號
">" --> 縮排

5. Turn off vim 自動縮排
":set paste"

6.對目前編輯檔案分割視窗:
分割垂直視窗: v
分割水平視窗: s
關閉視窗: q
留下目前視窗並且關閉其他視窗: o

於分割視窗開新檔案: n

切換:
切換到下方視窗: j
切換到上方視窗: k
切換到左方視窗: h
切換到右方視窗: l
切換到下一個視窗:

調整大小


調整視窗垂直大小: [+|-]
調整視窗水平大小: [<|>]

將目前視窗垂直打開到最到: _
將目前視窗水平打開到最大: |

其他資訊可參見 Vim Documentation: windows


7. 取代xxx為ooo用法
:%s/xxx/ooo/g

取代^M為空格 ,^M Ctrl+V+M
:%s/^M//g


8 http://homepage.ttu.edu.tw/u9106240/page_main/vim_menu.html
:set all
顯示所有參數
可透過此指令查詢 VIM 支援的所有參數。
若在執行 VIM 程式期間,透過「:set 參數」的方式來設定參數,在每次開啟 VIM 程式時都必須再重新設定一次,若想要讓 VIM 在每次啟動時,都能夠自動載入使用者的設定,則可以在使用者的家目錄下,建立一個名為 「.vimrc」的檔案來存放個人 VIM 的設定。
如:建立一個檔案「vi /home/kevin/.vimrc」,檔案內容為:
set background=dark set autoindent set number
此設定中,第一行代表設定字體顏色為適用黑色背景之顏色,第二行表示開啟自動縮排功能,第三行表示開啟顯示行號功能

:set nu
顯示行數
若想知道文件的行數,可下達這項指令。

:set nonu
隱藏行數
若想隱藏文件的行數,可下達這項指令。

:set autoindent
自動縮排功能
開啟此功能之後,按下 enter 鍵所產生的新行,會複製前一行最前方的 tab 和 space 數量,以達到對齊的目的。此功能可透過「:set noautoindent」關閉

:set tabstop=數字
設定 tab 對齊的字元數
一般 VIM 設定中,tabstop 的預設值為 8,但在 windows 下,許多文字編輯軟體的預設 tabstop 數為 4,若想要把 VIM 的 tab 對齊字元數變更為 4,可以在 VIM 的命令模式下,下達 「:set tabstop=4」指令

:set background=模式
設定 keyword 字體顏色模式
使用「:set background=dark」指令可以讓 VIM 中的 keyword 以較亮眼的顏色表現出來,適用於暗色系的背景。使用「:set background=light」指令可以讓 VIM 中的 keyword 以較暗沉的顏色表現出來,適用於亮色系的背景。

:split [檔案名稱]
水平分割文字編輯視窗
若有指定「檔案名稱」,則新視窗會開啟該檔案; 若沒有指定,則新視窗仍會開啟原檔案。
另外,在編輯視窗中可以利用 +w 配合方向鍵跳躍選取所要編輯的視窗,
若想要關閉視窗,則在欲關閉視窗裡的命令模式下,
打入離開指令,如: :wq 即可關閉該視窗。


分割視窗
:split
分割視窗(可加檔名順便開啟另一檔案)
:diffsplit xxx
以分割視窗和檔案xxx做比較(diff)
Ctrl-W p
跳到前一個分割視窗(在兩個分割窗來回切換)
Ctrl-W j
跳到下面的分割窗
Ctrl-W h
跳到左邊的分割窗
Ctrl-W k
跳到上面的分割窗
Ctrl-W l
跳到右邊的分割窗

;-----------------------
" 按 F7 可以切換是否顯示行號
" (有行號較易閱讀,要複制時需要將行號拿掉,用快速鍵可以節省時間)
map :set nu!set nu?
" 按 F8 可以切換是否高亮度顯示搜尋字串
" (有時搜尋某個 patten 後,在下一個文件還是會高亮顯示,很煩 = =)
map :set hls!set hls?

3G information

GSM(2G)→GPRS(2.5G)→EDGE(2.75G)->WCDMA(3G)→HSDPA(3.5G)


1. HSPDA(High Speed Downlink Packet Access, HSDPA):高速下行封包接收
在5MHz載波下面傳輸速度可達8-10Mbit/s

2. HSUPA:高速上行接收

Study 3G using AT command

1.Port: Diagnostic, appliction, control and modem

2.Android log :
#logcat -b radio

3.Get 3G information
#cat /sys/class/tty/ttyHSx/hsotype

4.#echo -e "at\r\n" > /dev/ttyHS2 -->#cat /dev/ttyHS2
#echo -e "at+creg?\r\n" > /dev/ttyHS2 --> #cat /dev/ttyHS2
#echo -e "at+creg?\r\n" > /dev/ttyHS2
#echo -e "at+cfun?\r\n" > /dev/ttyHS2
#echo -e "at+csq\r\n" > /dev/ttyHS2

5. Get IP
#echo -e "at_owancall=1,1\r\n" > /dev/ttyHS2
#echo -e "at_owandata?\r\n" > /dev/ttyHS2
#ifconfig hso0 netmask 255.255.255.255 up
#route add default dev hso0


6.
echo -e "ati\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cpin?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cfun?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cops?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cops=?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+creg?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cgreg?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+csq\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at_opsys?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at_osec?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at_opbm?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at_oiface?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2
echo -e "at+cgsn?\r\n" > /dev/ttyHS2
cat /dev/ttyHS2

2010年9月21日 星期二

Using hso on Linux x86

Step1: Installing hso dirver
dpkg -i hso-dkms_1.3.0_all.deb
Step2: modprobe hso
Step3: Attached 3G modules
Step4: Find out device note
dev/ttyHS0, dev/ttyHS1, dev/ttyHS2, dev/ttyHS3
Step5: Using "cutecom" on Linux
Step6: Send "at" command by cutecome

2010年9月14日 星期二

Turn off wifi power off script

while [ 1 ]
do
iwconfig > /data/powersave.log
cat /data/powersave.log | grep mlan0
if [ $? -ne 0 ] ; then
echo "mlan0 not exist"
else
echo "turn off power saving mode"
iwconfig mlan0 power off
fi
sleep 10
done

2010年8月18日 星期三

bluetooth with UART interface

#rfkill unblock wifi
#insmod mlan.ko
#insmod sdxxx.ko
#rfkill unblock bluetooth
#insmod hci_uart.ko
#hciattach /dev/ttyS0 any 115200
#hciconfig hci0 up

2010年8月17日 星期二

Create image

dd if=/dev/zero of=userdata_ext3.img.large bs=1M seek=149 count=1
mke2fs -j -F -m0 userdata_ext3.img.large

2010年8月11日 星期三

bluetooth

http://bluecove.org/images/stack-diagram.png
http://blog.csdn.net/dinuliang/archive/2010/07/07/5717382.aspx

2010年8月8日 星期日

Tar file

;壓檔案 : tar -cf - otg.sh wifi-bt.sh | gzip --best > ../labtool.tgz
; Only view tar files : tar -tvf labtool.tgz

壓檔案
tar -cf /tmp/a.tar bin/11 bin/22 etc/33.bin
就可以呀你想要壓的檔案到同一個tar檔

檢測
tar -tvf a.tar

Using rx tool to transfer file

;Step 1:
; Target board
; # mount -o remount,rw /dev/block/mtdblock2 /system
; # rx a.tgz
;Step 2:
; PC->tera term ->File-> Transfer->XMODEM->Send
;Step 3:
; Target board
; #tar -xvf a.tgz



mount -o remount,rw /dev/block/mtdblock2 /system;dmesg -n1 ; rx a.tgz ;tar -C /system/tmp/ -xvf a.tgz ; rm a.tgz ;mount -o remount,ro /dev/block/mtdblock2 /system

2010年6月29日 星期二

Using the Low Level debug on kernel

Using the Low Level debug
a) Enable the Low Level debug in the menuconfig
Kernel hacking --->
[*] Kernel low-level debugging functions

b) Add the code (the red lines) in the file kernel/printk.c
extern void printch(char c);
static void emit_log_char(char c)
{
LOG_BUF(log_end) = c;
log_end++;
if (log_end - log_start > log_buf_len)
log_start = log_end - log_buf_len;
if (log_end - con_start > log_buf_len)
con_start = log_end - log_buf_len;
if (logged_chars < log_buf_len)
logged_chars++;
printch(c);
}
c) Use the new kernel, then you can get the uart info.
Note: if it cannot work, please make sure in the file -- include/asm-arm/arch-pxa/debug-macro.S, there is the right map for UART registers.

2010年6月25日 星期五

Android adb config

vi ~/.android/adb_usb.ini
Add vendor ID to this file (I forget which one is for marvell):
0x403
0x18d1

Restart adb:
sudo ./adb kill-server
sudo ./adb devices

mount nfs

#mount -t nfs 192.168.100.120:/export /tftpboot/nfs

2010年5月30日 星期日

Manual Installing busybox into android system

Copy busybox into filesystem
#./cp /sdcard/busybox /data/tmp
#./busybox ash

change system read/write
#mount -oremount,rw /dev/block/mmcblk0p2 /system

Enter /system/busybox and copy busybox into /system/busybox
#cd /system/busybox
#cp /data/tmp/busybox .

List all command of busybox
#./busybox > list
# vi list
# for I in `cat list `
> do
> ln bus> ln busybox $I
> done
/system/busybox # ls

Remove list file and change the mount from rw to ro
#rm list
#mount -oremount ,ro /dev/block/mmcblk0p2 /system

Then, you can list busybox command
#cd /system/busybox
#./ash
#export PATH='pwd':$PATH

Modify ramdisk.img on android

open device board and find ramdisk.img location
1. #ls /dev/block
2. #cd /data/tmp
3. #mount -t ext3 /dev/block/mmcblk0p1 mnt/
4. on /data/tmp/mnt
# mdkir cpio
5. cat ../ramdisk.img | gunzip | cpio -idv
Then, we can modify the init.rc
such as
1. mount mtd partition from ext2 to ext3
>>mount ext3 /dev/block/mmcblk0p2 /system
>>mount ext3 /dev/block/mmcblk0p2 /system ro remount
>>mount ext3 /dev/block/mmcblk0p3 /data nosuid nodev
2. global environment
>>export PATH /system/busybox:/sbin:/system/sbin:/system/bin:/system/xbin
>>export HOME /
3. Added other service
>>service otg /data/tmp/otg.sh
>>oneshot

If you change successfully, you can comparess and umount it
1. on /data/tmp/mnt/cpio
#find . | cpio -o -H newc | gzip > ../ramdisk.img
#umount mnt

2010年5月6日 星期四

debug kernel for dump message

We cannot get any information about the issue, since the console cannot be enabled. Now we introduce two ways to get the log info.

1. Using XDB

a) Find the line ” c0574960 b __log_buf” in the file System.map in the build root folder

b) XDB load the log buf from the address c0574960

Note: the address may change after rebuilding the kernel.

2. Using the Low Level debug

a) Enable the Low Level debug in the menuconfig

Kernel hacking --->

[*] Kernel low-level debugging functions

b) Add the code (the red lines) in the file kernel/printk.c

extern void printch(char c);

static void emit_log_char(char c)

{

LOG_BUF(log_end) = c;

log_end++;

if (log_end - log_start > log_buf_len)

log_start = log_end - log_buf_len;

if (log_end - con_start > log_buf_len)

con_start = log_end - log_buf_len;

if (logged_chars <>

logged_chars++;

printch(c);

}

c) Use the new kernel, then you can get the uart info.

Note: if it cannot work, please make sure in the file -- include/asm-arm/arch-pxa/debug-macro.S, there is the right map for UART registers.

2010年3月8日 星期一

Linux driver Makefile for CROSS-COMPILE

ifneq ($(KERNELRELEASE),)
obj-m := test.o

else
KDIR := /work/mydroid/kernel/kernel
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -r .tmp_versions *.mod.c .*.cmd *.o *.ko Module.symvers

endif

~
~

Linux driver Makefile for CROSS-COMPILE

ifneq ($(KERNELRELEASE),)
obj-m := test.o

else
KDIR := /work/mydroid/kernel/kernel
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -r .tmp_versions *.mod.c .*.cmd *.o *.ko Module.symvers

endif

~

KERNEL_TOOLCHAIN_PREFIX := path/arm-eabi-
export ARCH:=arm
export CROSS_COMPILE:=$(KERNEL_TOOLCHAIN_PREFIX)

obj-m := proc.o

KDIR := /apps/study/mydroid/kernel/kernel
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
clean:
rm -r .tmp_versions *.mod.c .*.cmd *.o *.ko Module.symvers

~
~

2010年2月25日 星期四

Setup my busybox into Android platform

進入Android
#cd system
#cd /system/busybox
#./busybox ash
#export PATH=/system/busybox/:$PATH

Mount SD/MMC card in Android
#mkdir /data/tmp
#mount -t ext3 /dev/block/mmcblk1 /data/tmp

Mount Android img
#sudo mount -t ext3 -o loop system_ext2.img /tmp/android

Extract ramdisk.img
Method 1:
#sudo mount -t ext3 -o loop ramdisk.img /tmp/ramdisk
#cd /tmp/ramdisk
#cp ramdisk.img /tmp
#mkdir qq
#cd qq
#cpio -idv < ../ramdisk.img

Method 2:
#sudo mount -t ext3 -o loop ramdisk.img /tmp/ramdisk
# cd /tmp/rd
#cat /tmp/ramdisk/ramdisk.img | gunzip | cpio -idv

2010年1月31日 星期日

setup ubuntu environment

* setup ubuntu environment
1. ssh :
#sudo apt-get install openssh-server
check ssh server
#ps aux | grep ssh
stop and start ssh daemon
#sudo /etc/init.d/ssh stop #sudo /etc/init.d/ssh start

2. Install vim
#sudo apt-get install vim
Then, edit ~/.bashrc
added
alias ll='ls -l'
alias vi='vim'

3. tftp server:
#sudo apt-get install xinetd tftp-hpa tftpd-hp

安裝TFTP server
修改設定檔/etc/default/tftpd-hpa
RUN_DAEMON="yes"
OPTIONS="-l -c -s /tftpboot"
也修改/etc/inetd.conf
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -c -s /tftpboot
參數:
-c 讓client可以修改server內的檔案
-s 指定server的資料夾

重新啟動ttftp server
#sudo /etc/init.d/tftpd-hpa restart

安裝client
#sudo apt-get install tftp

4. Install nfs server
$sudo apt-get install nfs-common nfs-kernel-server
$ sudo vi /etc/exports
/work/MVP 192.168.*.*(rw,no_root_squash,nohide,insecure,no_subtree_check,async)

啟動nfs
$/etc/init.d/nfs-kernel-server restart

檢查
$showmount -e

掛載
$mount -t nfs 192.168.xxx.xxx:/work /mnt/nfs


5.Edit screen setting at ~/.screenrc

6.Install samba
#sudo apt-get install samba

Edit vi /etc/samba/smb.conf
Add:
[SHARE] path = /work browseable = yes read only = no create mask = 0644 directory mask = 0755
-------------------------------------------------
Added User
#sudo smbpasswd -a username
Restart samba server
#sudo /etc/init.d/samba restart







2010年1月14日 星期四

How to create vlc server

Case 1: vod (video on demand)
#vlc -I http --http-src /folder --http-host IP:PORT

Case 2: Broadcast
VLC play
工具 -> VLM configuration -->

@Test VLC streaming server
#mplayer rtp://192.168.1.255:1234/ -fps 23.976 -nosound

2010年1月13日 星期三

Install VLC on ubuntu 9.10

You need to check that a "multiverse" mirror is listed in your /etc/apt/sources.list.

% sudo apt-get update
% sudo apt-get install vlc vlc-plugin-pulse mozilla-plugin-vlc






2010年1月7日 星期四

how to create remote git repository

//for remote repository
step1: create public directory for remote access repository
#mkdir /git/pub

step2: #cd /git/pub
#git clone --bare proj
Then, you will get proj.git. It is no working tree

step3: Edit /et/cgitrc

# List of repositories
repo.group=gittest
repo.url=test
repo.path=/apps/git/pub/proj.git
repo.desc= projgit
repo.owner= winnie

step4: cd /git/pub/proj.git
#touch git-daemon-export-ok

step5: Enable git-daemon and can freely git clone
#/usr/lib/git-core/git-daemon --enable=receive-pack&
==========================
//for local repository
step6: create local project
#mkdir /git/local/proj
#cd /git/local/proj
#git init

==========================
//updated (pull) local repostory from remote repository
# git fetch ../pub/proj.git
# git merge FETCH_HEAD

// Push local file to remote repository
#git push ../pub/proj.git/ master:master

//Create new branch and push it to remote repository
#git checkout -b new-branch
Then, push it to remote repository

#git push ../pub/proj.git/ new-branch:new-branch

2010年1月4日 星期一

Git : How to config git environment

First time installing git, you need to configure git environment into ~/.gitconfig

# git config --global user.name "NAME"
# git config --global user.email NAME@example.com
# git config --global core.editor vi

http://progit.org/book/ch7-1.html


example: .gitconfig

vi .gitconfig

[color]

        ui = auto
branch = auto

[alias]

        co = checkout
ci = commit -a
st = status
br = branch
w = whatchanged

[user]

        name = foo
email = foo@gmail.com

[apply]

        whitespace = strip

[diff]

        color = auto
rename = copy