分类: LINUX
2012-05-01 11:04:05
http://tw.myblog.yahoo.com/stevegigijoe/article?mid=212
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為優先.