To test Android kernel, keeping minimum number of user space process is very useful.
Actually, 'adbd' and 'ueventd' is enough on Android.
Here is the way how to make device have only minimum user space processes - adbd and ueventd.
Followings are file structure of ramdisk image.
[ Create ramdisk ]
let's make following directory structure in ramdisk.
/bin -> sbin /sbin -+- busybox +- adbd +- ueventd -> ../init +- <...> -> busybox /init /init.rc /default.prop
All are same with default android except that busybox is in /sbin and /bin is symbolic link to /sbin.
Let's look into one by one.
/init : same binary with default Android.
/bin : symbolic link to /sbin.
/default.prop : same with default Android. - adb and debugging is enabled.
/sbin/busybox : statically linked busybox.
/sbin/... : tools (symbolic link to busybox). Ex, sh -> busybox, ls -> busybox.
/sbin/adbd :
Modified adbd. Original adbd uses /system/bin/sh as its terminal shell. But, this one uses /bin/sh.
To do this, value of SHELL_COMMAND at system/core/adb/service.c should be modified.
/init.rc :
Simplified one. Only adbd and ueventd is started.
One important note is, "DO NOT make empty section(ex. on fs)!". This will lead init process to error and system will restarted again and again.
Here is sample.
on early-init start ueventd on init sysclktz 0 export PATH /bin:/sbin: #on fs #on post-fs #on post-fs-data on boot start adbd ## Daemon processes to be run by init. ## service ueventd /sbin/ueventd service adbd /sbin/adbd
[ Make ramdisk image ]
Let's assume that current working directory is ramdisk directory.
find . | cpio -o -H newc | gzip > newramdisk.gz
This newly generated gzip file can be renamed directly to ramdisk.img.
[ Make boot image ]
mkbootimg tool is used. This can be easily found at out/host/<arch>/bin after building android from source.
mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel <zImage file> --ramdisk <ramdisk image> -o newboot
[ Verify ]
After flashing newly generated boot image, reboot device.
The only respond that device can do, is done at boot-loader stage. After that device doesn't anything.
After waiting some moments, try adb device. Then host PC can find the device and adb shell can be used.
Type adb shell ps. Then, you can check that only three user space process are running - init, adbd and ueventd.
[ Debugging ]
Except for kernel, adbd and init may be required to be modified (As mentioned above, modified adbd is used.). Printing log is very helpful for debugging and using framebuffer console is simple way to do this.
Here is the step (ex. adbd).
* comment out xxxx in init.c
=> this removes /dev/console (framebuffer console)
* modify start_logging() and start_device_log() in adb.c.
=> use /dev/console as stdout and stderr file.
Now, log message of adbd will be shown on the framebuffer (that is, displayed at the panel.)
[ Something more ]
You may build your own Linux environment on the device by building file system and installing libraries etc.
In my case, I set up tools for development - ex. glibc, gcc, binutils etc, and compiled LTP(Linux Test Project) to test kernel.
Enjoy your minimum Android environment :-).
'Domain > Android' 카테고리의 다른 글
Points to consider for recycling Bitmap of ImageView. (0) | 2012.09.21 |
---|---|
[Android] Developing Android-native-library on 64bit build machine (0) | 2011.09.15 |
[Android] Managing service... (0) | 2011.05.02 |
[Android] Handling kernel device uevent in userspace. (0) | 2011.04.20 |
[Android][GNU] establishing gnu system root on android devices (0) | 2011.03.18 |