我會直接拿prebuild image放進去,省時又省力,除了每次要下busybox之外...
但最近在porting softAP,突然意識到一件事,在Linux底下我可以直接 build udhcpd...那Android怎辦 ?
等我從Linux換到要porting Android時,感覺很不對勁 = =
udhcpd似乎沒被整進去Android裡,那SoftAP要怎麼自動分配DHCP !?
從TI的source code來看,原來它是直接使用busybox udhcpd....但沒講怎麼從Android service啟動呀> "<
找了網路上的文章又很複雜的樣子,所以就硬著頭皮自己試...還真沒想到被我試出來了 XD
下面是我自己try出來的結果...
1. Download Busybox-1.19.2
2. 搭配 arm-2009q1 (我只記得是2009...q多少忘了0.0)
3. make & make install busybox
$ make menuconfig
Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs)
Busybox Settings ---> Build Options ---> Installation Options ("make install" behavior) ---> "請選擇你 Android file system路徑"
example : /home/dicky/android/out/target/product/xxxxx/root/bin
$ make ; make install
這時在你out的目錄下應該就能看到剛安裝的路徑,接著就要靠這些來替換Android shell。
直接貼我自己底下的init.rc :
diff --git a/device/ti/beagleboard/init.rc b/device/ti/beagleboard/init.rc
index 357ce26..96617bb 100755
--- a/device/ti/beagleboard/init.rc
+++ b/device/ti/beagleboard/init.rc
@@ -9,7 +9,7 @@ sysclktz 0
loglevel 3
# setup the global environment
- export PATH /sbin:/system/sbin:/system/bin:/system/xbin
+ export PATH /bin/bin:/bin/sbin:/sbin:/system/sbin:/system/bin:/system/xbin
export LD_LIBRARY_PATH /system/lib
export ANDROID_BOOTLOGO 1
export ANDROID_ROOT /system
@@ -375,7 +375,8 @@ on boot
service ueventd /sbin/ueventd
critical
-service console /system/bin/sh
+#service console /system/bin/sh
+service console /bin/bin/sh
console
這樣就OK囉 ! 然後再加上udhpcd的service ... 這樣就能透過setprop來啟動,也可以直接在code裡面加上,像我的udhcpd是這麼做 :
init.rc :
service dhcpd_softap /bin/sbin/udhcpd -f /etc/dhcpcd/dhcpcd-hooks/dhcpcd.conf
disabled
oneshot
console可以這樣呼叫 :
setprop ctl.start dhcpd_softap
code可以這樣寫 :
+#define HOSTAPD_DHCPD_SERVICE_NAME "dhcpd_softap"
property_set("ctl.start", HOSTAPD_DHCPD_SERVICE_NAME
現在試起來好像沒權限問題....其它就沒試過了...
有關/system/bin帶起來service也沒問題....後面就不知道了qq
No comments:
Post a Comment