Android把 System V -IPC 拿掉,改用 Binder。
Binder 是 linux kernel 的一個 driver。user program 利用 /proc/binder 與他溝通。
Android 設計 ServiceManager 這個 program,作為 user program 和 binder 間的介面。
Binder 提供的 IPC 和被拿掉的 System V IPC 不一樣。
Android 好像只有用 Binder 實作出一個 IPC 的功能,就是類似 message的 send-reply。
但是不是任意兩個 process 都可以用 Binder 來作 IPC。
一個要是 Service,一個要是 Client。
Service 向 ServiceManager 註冊一個 Service/Interface, ServiceManager 會幫他把 service name, interface pointer 加到 Binder 的資料裡。
Client 向 ServiceManager 要求取得 XXX service (以 service name 為參數)。
ServiceManager 就會由 Binder 找出對應的 Service interface 給 Client。
然後 Client 就可以利用這個 interface 對 Service send msg.
這個 Interface prototype 是固定的,所以就像 IOControl 一樣, interface 的第一個 argument 是 function code,後面是 sendmsg (client to server), 再來是 reply (server reply to client)。
所以 service 在作這個 interface 的時候,就像 IoControl 一樣,依照 function code 對 sendmsg, replymsg 作不同的處置。
有點麻煩..
ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上
2011年1月6日 星期四
2011年1月5日 星期三
bionic libc liked busybox
現在要 build 使用 bionic libc 的 busybox 變得比較簡單了。
這都要感謝 android-x86 專案。
因為 android-x86 已經把 busybox 內建在 source package,
所以只要把 external/busybox copy 到自己的專案就可以。
-- 他的 git link 到 .rep/project/external/busybox.git,有需要也可以一併 copy
然後就可以用 mm build 了。
如果你的 bionic 版本太舊,可以參考 android-x86 的 bionic 修改。
一般來說,會缺 這一篇 (http://lazyhack.net/compile-busybox-linked-bionic/ ) 講得幾個 system call.
還有修改 mk 和 header ,
這樣就可以重新 build bionic, busybox。
busybox build 完會 install 在 out 的 system/xbin 下面。
這樣就見識到 open source 的專案, user 會讓 function 漸漸的完整。
這都要感謝 android-x86 專案。
因為 android-x86 已經把 busybox 內建在 source package,
所以只要把 external/busybox copy 到自己的專案就可以。
-- 他的 git link 到 .rep/project/external/busybox.git,有需要也可以一併 copy
然後就可以用 mm build 了。
如果你的 bionic 版本太舊,可以參考 android-x86 的 bionic 修改。
一般來說,會缺 這一篇 (http://lazyhack.net/compile-busybox-linked-bionic/ ) 講得幾個 system call.
bionic/libc/arch-arm/syscalls/adjtimex.S
bionic/libc/arch-arm/syscalls/stime.S
bionic/libc/arch-arm/syscalls/swapoff.S
bionic/libc/arch-arm/syscalls/swapon.S
bionic/libc/arch-arm/syscalls/sysinfo.S
bionic/libc/arch-arm/syscalls/getsid.S
就 follow 把 android-x86 的 source code copy 過來。還有修改 mk 和 header ,
這樣就可以重新 build bionic, busybox。
busybox build 完會 install 在 out 的 system/xbin 下面。
這樣就見識到 open source 的專案, user 會讓 function 漸漸的完整。
2011年1月4日 星期二
install disk
利用原來的 kerne, rootfs, 和 system image (主要是要用到裡面的 command)。來作 auto install disk
當然,target 要能選擇從另一個 sd 開機。
大概就是 pc 做的一樣:
然後寫成 shell script,放到 init.rc 裡。
init.rc 可以參考 recovery 和 diskinstaller 裡的 init.rc 來作。
大概就是 甚麽都不用了,只要記得 mount partition 跟 class_start default
-----> 因為要 class_start default,接下來的一堆 service command h才會啟動。
上述動作都寫在同一個 shell script,然後由 service 叫起來:
因為 partition, format,dd 有相依,一個做完才能換另一個,所以要寫在同一個 script,如果用分別的 service 寫,在 sleep的時候,下一個service就會啟動了。
shell script 要注意, sh 在 /system/bin/sh
貼一下 diskinstall 的 init.rc:
當然,target 要能選擇從另一個 sd 開機。
大概就是 pc 做的一樣:
- partition
- format
- dd
- fdisk -- busybox
- mke2fs -- e2fsprog
- dd -- busybox (android 付的 dd 不認識 K, M, G 等 size argument)
然後寫成 shell script,放到 init.rc 裡。
init.rc 可以參考 recovery 和 diskinstaller 裡的 init.rc 來作。
大概就是 甚麽都不用了,只要記得 mount partition 跟 class_start default
-----> 因為要 class_start default,接下來的一堆 service command h才會啟動。
上述動作都寫在同一個 shell script,然後由 service 叫起來:
service installall /sdcard/installall.sh
console
oneshot
因為 partition, format,dd 有相依,一個做完才能換另一個,所以要寫在同一個 script,如果用分別的 service 寫,在 sleep的時候,下一個service就會啟動了。
shell script 要注意, sh 在 /system/bin/sh
貼一下 diskinstall 的 init.rc:
on init
export PATH /sbin:/system/sbin:/system/bin
export ANDROID_ROOT /system
export ANDROID_DATA /data
symlink /system/etc /etc
mkdir /data
mkdir /cache
mount /tmp /tmp tmpfs
# mount the installer needed partitions
# mount ext2 /dev/block/sdb2 /data ro
on boot
ifup lo
hostname localhost
domainname localdomain
class_start default
service installer /system/bin/installer -p /dev/block/sdb2
console
oneshot
service logcat /system/bin/logcat
console
service console /system/bin/sh
console
fdisk in shell script
nelson 說的 在 shell script 裡要用 fdisk ,可以這樣用:
#!/bin/sh
sudo fdisk /dev/sdc <lt; EOF
n
p
1
w
EOF
exit
其中有兩行只按 enter,對應 fdisk 的操作
2011年1月3日 星期一
partition table
partition table 就位在 以 0x55AA 結束的 第 0 sector 。
只有 4 個 entry 的空間,每個 partition 佔掉 16 bytes。
每個 partition entry 的內容:
用一個 byte 代表 partition 的 id - 是什摩 partition,0x05 就是 extend partition。
如果是 extend partition,那個 partition table entry (16 bytes) 的 start sector,就代表 extend partition table 的所在位置。
extend partition table 的內容跟 mbr partition table 一模一樣,但是只有用到其中 4 個 partition entry 的兩個。
一個代表這個 parition 的內容
第二個代筆下一個 partition table 的位置
就這樣,像 linking list 一樣,連下去。 ...
所以 使用 mbr partition table ,最多只有 4 個 primary partition,但是 extend partition 的 數量則沒有限制。
ref
只有 4 個 entry 的空間,每個 partition 佔掉 16 bytes。
每個 partition entry 的內容:
------------------------------ | 00 | 1 | boot indicator | ------------------------------- | 01 | 3 | Start CHS | ------------------------------ | 04 | 1 | Partition Type | ------------------------------ | 05 | 3 | End CHD | ------------------------------ | 08 | 4 | Start - LBA | ------------------------------ | 0C | 4 | End - LBA | ------------------------------
用一個 byte 代表 partition 的 id - 是什摩 partition,0x05 就是 extend partition。
如果是 extend partition,那個 partition table entry (16 bytes) 的 start sector,就代表 extend partition table 的所在位置。
extend partition table 的內容跟 mbr partition table 一模一樣,但是只有用到其中 4 個 partition entry 的兩個。
一個代表這個 parition 的內容
第二個代筆下一個 partition table 的位置
就這樣,像 linking list 一樣,連下去。 ...
所以 使用 mbr partition table ,最多只有 4 個 primary partition,但是 extend partition 的 數量則沒有限制。
ref
Android Init Language - init
Android source 的 system/core/init 有 readme,說明 init 的使用方法 (Android Init Language)
每個指令有四項選項:
Action 當 XX 事情發生時,依序執行下列的 command.. 這個 XX 事情稱為 " Trigger",有:
init 還會 upate 以下的 system property:
所以要執行自己的 command 大概要用 exec ..
- Action
- Command
- Service
- Options
Action 當 XX 事情發生時,依序執行下列的 command.. 這個 XX 事情稱為 " Trigger",有:
- boot : init 開始執行
- <name>=<value> : name == value 時
- device-add-<path> / device-remove-<path> : 當 device add 或 remove 時。
- service-exited-<name> : service 結束得時候。
- exec <path> [<argument>]* : fork and execute 'path'. init 會停止,等這個程式執行完畢
- export <nam> <value> : set global environment variable
- ifup <inteface>
- import <filename> : 類似 include XXX
- hostname <name> : 設定 hostname
- chdir <directory> : change working directory
- chmod <octal-mode> <path> : 變更 'path' 的權限
- chown <owner> <group> <path>
- chroot <directory> : change root directory
- class_start <service classname > : 把同屬於 'class name' 的所有 service 啟動
- class_stop <service classname >
- domain <name>
- insmod <path>
- mkdir <path> [mode] [owner] [groupe] : create a new directory
- mount <type> <device> <dir> [ <mount options>]*
- setrop <name> <valu> : set system property
- setrlimit <resource> <cir> <max> : 設定 resource 的使用值, max limit
- start / stop <service> : 停止,啟動 service
- symink <target> <path> : 就是 ln -s
- sysclktz : set timezone
- trigger <event> : Trigger Event
- write <path> <string> [<string>]* : 開啟 file (path),寫入 string...
- critical : 如果這個 service 在一分鐘內resart 4 次,把系統重新啟動,進入 recovery mode.
- disabled : 不啟動
- setenv <name> <value> : 啟動時,環境變數設好
- socket <name> <type> <perm> [ <user> [<group>]] : create socket並且 pass 給啟動的程式
- user >username> : 以 username 來執行
- groupe <groupename> [<groupename>]* : 以 groupename 來執行
- oneshoot : 執行一次就好,不用 restart
- class <name> : 給定一個 classs name, 同屬一個 class 的所有 service 都要一起啟動,一起停止。
- onrestart : 這個 service reatart 時,同時執行下列 command..
init 還會 upate 以下的 system property:
- init.action : 目前的 action
- init.command : 目前的 command
- init.svc.<name> : 目前 'service' 的狀態。
所以要執行自己的 command 大概要用 exec ..
標籤
- 3g (19)
- 工作的備worklog (93)
- 自言自語 (36)
- 草稿 (1)
- 亂亂寫 (8)
- 翻譯 (3)
- administration (76)
- alsa (7)
- android (299)
- apple (5)
- application (42)
- archlinux (1)
- audio (3)
- avr (6)
- backup_restore (2)
- bluetooth (5)
- bookmark (38)
- bootloader (21)
- browser (5)
- cellphone (28)
- command (8)
- Configuration (27)
- debug (7)
- django (1)
- driver (15)
- earphone (1)
- editor (1)
- EFL (1)
- ffmpeg (18)
- Filesystem (4)
- GCC (8)
- Gentoo (1)
- google (1)
- Graphic (3)
- hardware (40)
- hero (7)
- hibernation (9)
- iMX51 (38)
- Info (3)
- Install (30)
- java (4)
- Kernel (102)
- language (2)
- life (2)
- make (11)
- MantainLog (38)
- MCU_P (9)
- memo (8)
- microcontroller (3)
- MINGW (7)
- network (19)
- OpenCL (1)
- OS (11)
- package (3)
- pad (1)
- ProblemAndSolve (15)
- programming (8)
- Python (7)
- raspberry_pi (23)
- SDL (2)
- sensation (13)
- setup (3)
- software_package (36)
- SQL (1)
- suspend (2)
- ToDo (5)
- tool (3)
- ubuntu (1)
- VersionControl (45)
- Virtualization (15)
- VLC (5)
- wheezy (1)
- wifi (3)
- Windows (16)
- xiaomi (1)
- xperia (1)