포럼 회원으로 등록하신분만 다운로드가 가능합니다. 최대 업로드 가능한 용량은 20MB 입니다.

*** Warnings ***

linux as host os is required, windows might be possible but is untested
You can easily destroy your emulator. Backup your emulator
Root access required


Preface

${android_sdk} refers to your android sdk root folder

Your emulator consists of three images:
  • ${android_sdk}/tools/lib/images/ramdisk.img (cpio[cnew] archive, gzip compressed)
  • ${android_sdk}/tools/lib/images/system.img (yaffs2 formated)
  • ${android_sdk}/tools/lib/images/userdata.img (yaffs2 formated)

By now noone has managed to mounting the yaffs2 formated partitions. Loopback mounting does not work. So for now the best way to hack the emulator is ${android_sdk}/tools/lib/images/ramdisk.img

Step 0 - backup
Code:
cp ${android_sdk}/tools/lib/images/ramdisk.img ${android_sdk}/tools/lib/images/ramdisk.img.old


Step 1 - extracting the ramdisk
Code:
mkdir ramdisk
cd ramdisk
cat ${android_sdk}/tools/lib/images/ramdisk.img | gunzip | sudo cpio -i

This will populate "ramdisk" with the ramdisks content.

Step 2 - looking at a simple boot skript
Android requires some special code to boot in the emulator, the code can be found in etc/qemu-init.sh
Code:
sudo vim etc/qemu-init.sh

Here is the original content:
Code:
#!/system/bin/sh

# Some special case stuff for running under emulation
qemu=`getprop ro.kernel.qemu`
case "$qemu" in
    "1" )
    ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
    route add default gw 10.0.2.2 dev eth0
    radio_ril=`getprop ro.kernel.android.ril`
    case "$radio_ril" in
        ttyS*) # a modem is emulated as a serial device
            ;;
        *) # no need for the radio interface daemon
            # telephony is entirely emulated in Java
            setprop ro.radio.noril yes
            stop ril-daemon
            ;;
    esac
    setprop net.eth0.dns1 10.0.2.3
    setprop net.gprs.local-ip 10.0.2.15
    setprop ro.radio.use-ppp no
    setprop ro.config.nocheckin yes
    setprop status.battery.state Slow
    setprop status.battery.level 5
    setprop status.battery.level_raw  50
    setprop status.battery.level_scale 9
    stop dund
    stop usbd
    ;;
esac


Step 3 - the target networking environment
Android is hardcoded to use 10.0.2.3 and 10.0.2.2 for comunication - especially with adb. You can not use anything except this userspace emulation for eth0.
Android
  • device: eth0, ip: 10.0.2.15, net: 10.0.2.0/255.255.255.0 - this will keep adb happy
  • device: eth1, ip: 192.168.1.2, net: 192.168.1.0/255.255.255.0 - this will be used for real communication
  • default gateway: 192.168.1.1 - or whatever suits your network
  • DNS: 10.0.2.3 - we simply keep this, no disadvantages except harder debugging

Host
  • net_android, virtual android network device
  • br0, network bridge linking eth0 and net_android

Depending on what you want to test you might want to turn your host system into a nat gateway, a dhcp server, transparent proxy, routing gateway or whatever you need.

Step 4 - altering the android network
Code:
#!/system/bin/sh

# Some special case stuff for running under emulation
qemu=`getprop ro.kernel.qemu`
case "$qemu" in
    "1" )

    if ifconfig eth1 up; then
        ifconfig eth1 down
        # Should we really check for eth1 that way?

        # DHCP - broken?
        # netcfg eth1 dhcp

        ifconfig eth1 192.168.1.2 netmask 255.255.255.0 up
        route add default gw 192.168.1.1 dev eth1

        ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up

        setprop net.eth0.dns1 10.0.2.3
        setprop net.eth1.dns1 10.0.2.3
        setprop net.gprs.local-ip 192.168.1.2
    else
        ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
        route add default gw 10.0.2.2 dev eth0
        setprop net.eth0.dns1 10.0.2.3
        setprop net.gprs.local-ip 10.0.2.15
    fi

    # Proxy support - broken too?
    # setprop net.gprs.http-proxy http://proxy:8080/

    # No longer needed
    # ifconfig eth0 10.0.2.15 netmask 255.255.255.0 up
    # route add default gw 10.0.2.2 dev eth0
    radio_ril=`getprop ro.kernel.android.ril`
    case "$radio_ril" in
        ttyS*) # a modem is emulated as a serial device
            ;;
        *) # no need for the radio interface daemon
            # telephony is entirely emulated in Java
            setprop ro.radio.noril yes
            stop ril-daemon
            ;;
    esac
    # no longer needed
    # setprop net.eth0.dns1 10.0.2.3
    # setprop net.gprs.local-ip 10.0.2.15
    setprop ro.radio.use-ppp no
    setprop ro.config.nocheckin yes
    setprop status.battery.state Slow
# Interresting - is this the way to check battery status?
    setprop status.battery.level 5
    setprop status.battery.level_raw  50
    setprop status.battery.level_scale 9
    stop dund
    stop usbd
    ;;
esac

This will keep your classic config if eth1 doesn't exist and if it exists adb will still work.

Step 5 - packing your new ramdisk
Code:
 sudo find | sudo cpio -o -H newc | gzip -9 > ${android_sdk}/tools/lib/images/ramdisk.img


Step 6 - Host configuration
Code:
sudo brctl addbr br0
sudo tunctl -u $USER -t net_android
sudo ifconfig eth0 0.0.0.0 promisc up
sudo ifconfig net_android 0.0.0.0 promisc up
sudo brctl addif br0 eth0
sudo brctl addif br0 net_android
sudo dhclient3 br0

Depending on you sodu configuration you might need to substitute $USER with your username. Depending on your local network you might need to substitute sudo dhclient3 br0 with your normal network initialization.

Step 7 - boot and test
Code:
${android_sdk}/tools/emulator -debug-kernel -qemu -net nic -net user -net nic -net tap,ifname=net_android

Now on your host system do
Code:
ping 192.168.2.2
adb shell

If everything went well both commands will work.

Enjoy!

TODO1: Tutorial how to use the new network link from within dalvik.
TODO2: Find a windows user who will try the ramdisk with windows and openvpn/tun/tap driver


http://www.anddev.org/advanced_networking_with_android-linux-t155.html
profile

인생은 연극이고 세상은 무대이다!

이솝 임베디드 포럼 운영 및 비즈니스와 관련된 것 이외에 E-Mail이나 메신저 및 휴대폰 등을 통한 개인적인 질문 및 답변은 받지 않습니다. 문의 사항은 이솝 임베디드 포럼 게시판을 이용해 주시면 감사하겠습니다.

엮인글 :
http://www.aesop.or.kr/index.php?mid=Board_Documents_Android_Frameworks&document_srl=34648&act=trackback&key=948

고현철

2009.04.21 23:04:59
*.32.117.22

안드로이드 부티되고 나서는 netcfg 명령이 ifconfig랑 비슷하더군요....
List of Articles
번호 제목 글쓴이 날짜 조회 수
24 Google Android 커널 버전별 Testing Report [2] 김재훈 2009-05-17 11493
23 Android 동작시 Battery 관련 /sys 파일 에러 & Power off ... [2] 2009-05-09 11010
22 Android 커널 2.6.27~28버젼에서 CONFIG_SUSPEND옵션시 죽는 문... [3] 2009-05-08 10026
21 S3C6410 target으로의 Android porting에 대하여(1) [3] 고현철 2009-04-23 20133
20 Android 초보도 가능한 Touch 잡기. [1] 2009-04-23 12229
19 touch calibrate 방법 file [1] 전병환 2009-04-23 10442
» Android에서의 Linux Network 환경 설정 방법 [1] 김재훈 2009-04-21 20515
17 PV와 Android [5] 이제현 2009-04-19 18163
16 OpenGL ES와 Android [3] 이제현 2009-04-18 22839
15 Android에서 yaffs2 image 만들때 oobfree 따르도록 수정 file [1] 2009-04-16 11896
14 안드로이드 6410 보드 관련 s3c-ts touch 잡기 [5] 김한철 2009-04-16 13738
13 Android yaffs image 흠..oob가 이상합니다. 2009-04-16 10888
12 File System 관련 문제 및 power off 문제 해결 [3] 김한철 2009-04-14 10202
11 Google Android Kernel-2.6.29 file 관리자 2009-04-14 12085
10 aesop-6410용 android 2.6.24 source file [12] 고현철 2009-04-12 12131
9 android를 6410에 포팅하면서... [7] 전병환 2009-04-10 18227
8 Android Debug Bridge(ADB) 사용 가이드 김재훈 2009-04-09 18864
7 Android Initialization Process 최종환 2009-04-09 24638
6 Android 부팅 및 초기화 절차 김재훈 2009-04-09 17000
5 Android용 root filesystem으로 cramfs 구성 할 때의 주의사항 [7] 김영문 2009-04-09 21375

사용자 로그인