Android 的shell真是鳥到不行.功能超陽春.
現在教各位安裝busybox到Android的環境中來解決這個問題
1.Download BusyBox -> 這個不用偶教吧 :)
2.
cd busybox-1.15.1
make menuconfig
設定BusyBox為Static link
BusyBox Settings -> Build Options -> Build BusyBox as a static binary (no shared libs)
設定安裝路徑到Android root file system
BusyBox Settings -> Installation Options -> BusyBox Installation Prefix
${HOME}/S3C6410/android_cupcake_smdk6410/opensource_cupcake_0424_opencore203/out/target/product/smdk6410/system/busybox
Config functions you need...
make
make install
3.Go to Android root file system
cd ${HOME}/S3C6410/android_cupcake_smdk6410/opensource_cupcake_0424_opencore203/out/target/product/smdk6410/root
修改 init.rc 使busybox正常運作
# export PATH /sbin:/system/sbin:/system/bin:/system/xbin
export PATH /bin:/system/busybox/sbin:/system/busybox/usr/bin:/system/busybox/usr/sbin:/sbin:/system/sbin:/system/bin:/system/xbin
使用busybox提供的shell
## Daemon processes to be run by init.
##
#service console /system/bin/sh
service console /system/busybox/bin/sh
console
4.編輯 /etc/inittab
cd ${HOME}/S3C6410/android_cupcake_smdk6410/opensource_cupcake_0424_opencore203/out/target/product/smdk6410/
產生 system/etc/inittab 內容如下
::sysinit:/etc/init.d/rcS
ttySAC0::askfirst:/system/busybox/bin/sh
5.編輯 /etc/init.d/rcS
mkdir system/etc/init.d
產生 system/etc/init.d/rcS 內容如下
#!/bin/sh
echo "Processing etc/init.d/rc.S"
echo "Starting mdevd"
echo /system/busybox/sbin/mdev > /proc/sys/kernel/hotplug
/system/busybox/sbin/mdev -s
/system/busybox/sbin/ifconfig eth0 192.168.168.209 netmask 255.255.255.0
/system/busybox/usr/sbin/inetd
/system/busybox/usr/sbin/telnetd -l /bin/login
echo "Start Android ..."
/init
設定權限為可執行
chmod 755 system/etc/init.d/rcS
5.1 Create device node
sudo mknod root/dev/tty1 c 4 1
sudo mknod root/dev/tty2 c 4 2
sudo mknod root/dev/tty3 c 4 3
sudo mknod root/dev/tty4 c 4 4
sudo mknod root/dev/tty5 c 4 5
sudo mknod root/dev/null c 1 3
sudo mknod root/dev/ttySAC0 c 204 64
cd root/dev
ln -s ttySAC0 console
cd ../..
5.2 Symbolic link
為了讓busybox啟動時找的到 /etc 目錄
cd root
ln -s system/etc etc
cd ..
為了讓busybox啟動時找的到 /bin 目錄
cd root
ln -s system/busybox/bin bin
cd ..
建立linuxrc
cd root
ln -s system/busybox/linuxrc linuxrc
cd ..
6.busybox ftpd
編輯 system/etc/inetd.conf
21 stream tcp nowait root ftpd ftpd -w -v /
產生 system/etc/passwd
system/etc/group
system/etc/services
system/etc/resolv.conf
7.複製system目錄到root file system
8.重新打包Android root file system放到target就可以了
9.kernel param fix
修改 init=/init 為 init=/linuxrc
使得busybox會先被系統執行
10.附記
Android support busybox有點小複雜因為Android本身就有shell.
目前這樣的作法不會覆蓋到Android binary code.是比較好的作法.
system boot會先run busybox,大致流程是
/linuxrc -> /etc/inittab -> /etc/init.d/rcS -> Run ash -> Run /init to start Android -> /init.rc
透過init.rc設定PATH環境變數讓busybox command為優先.
你好:
回覆刪除請問一下有關於:
>產生 system/etc/passwd
> system/etc/group
> system/etc/services
> system/etc/resolv.conf
要如何產生,有相關檔案可以參考嗎,謝謝。
[版主回覆11/30/2010 01:20:46]1.使用htpasswd產生passwd檔案
2.group 可有可無
3.services可直接複製 PC上 /etc/services來使用
4.請google resolv.conf 了解如何設定再自行產生
你好:
回覆刪除請問我照著上面的作法做 之後再把file sytem COPY 到SD card
也設定了init=/linuxrc
但是再執行linuxrc的時候,卻出現以下訊息
EXT3-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
EXT3-fs (mmcblk0p2): using internal journal
EXT3-fs (mmcblk0p2): recovery complete
EXT3-fs (mmcblk0p2): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) on device 179:2.
Freeing init memory: 184K
Warning: unable to open an initial console.
Failed to execute /linuxrc. Attempting defaults...
Kernel panic - not syncing: No init found. Try passing init= option to kernel.
不知是哪裡沒設定好?
會因為我resolv.conf還沒設定的關係嗎?
因為還不會用 所以我還沒丟進去 想說看可不可以開機看看
[版主回覆02/14/2011 15:17:47]跟resolv.conf沒關係
請確定你的root file system裡是否有 /linuxrc 及其是否正確
有沒有試過放入 INETD功能,且能順利動作?
回覆刪除