blob: bb9582d98ade5fa0b4c859bc919090ab925eceab [file] [log] [blame]
James Christopher Adduonoa6108c92016-06-26 20:26:08 -04001---
2layout: device
3title: "Android Emulator"
4codename: twrp
5downloadfolder: twrp
6oldurl: http://teamw.in/project/twrp2/169
7supportstatus: Current
8maintainer: Dees_Troy
9oem: TWRP
10devicetree: https://github.com/TeamWin/android_device_emulator_twrp
11xdathread: "http://forum.xda-developers.com/showthread.php?p=32965365"
12---
13
14{% include supportstatus.html %}
15
16{% include download.html %}
17
18<p class="text">TWRP can be booted in the Android emulator. To use this you will need to download both the goldfish_2.6_kernel and the appropriate .img file from one of our mirrors above.</p>
19<p>With the Android emulator make a new device based on a Galaxy Nexus. Allow it to have a hardware keyboard and a 1500MB sdcard. Give it a name like TWRP. Then from your android-sdk/tools folder run the following command:</p>
20<p><tt>./emulator -avd TWRP -ramdisk ~/cm_folder/out/target/product/twrp/ramdisk-recovery.img -kernel ~/cm_folder/device/emulator/twrp/goldfish_2.6_kernel</tt></p>
21<p>(Note that you will have to change the paths to match the locations of the files that you have downloaded.)</p>
22<p>After the first boot, wait for ADB to start up (usually ADB comes online about 15 seconds after TWRP boots), then:</p>
23<p><tt>adb shell /sbin/create_partitions.sh</tt></p>
24<p>
25<p>This script will partition the sdcard with a boot, recovery, system, cache, data, and removable sdcard partition. It's designed to work with a 1500MiB sdcard. If you want a different sdcard size then you will need to modify the script in the cm_folder/device/emulator/twrp/recovery/root/sbin/create_partitions.sh location to suit your needs. The script will also mount the old MTD system device to /system so that you can make a backup of the system image to restore to your new mmc-based system.</p>
26<p>If you want to make the emulator boot up using the emmc partitions, you will need to modify the ramdisk.img. Locate the ramdisk.img in your android-sdk/system-images/android##/armeabi-v7a/ folder. To unpack it:</p>
27<div><tt>mkdir ramdisk</tt></div>
28<div><tt>cd ramdisk</tt></div>
29<div><tt>gzip -dc ../ramdisk.img | cpio -i</tt></div>
30<p>Modify the init.rc to mount your mmc based partitions instead of the mtd ones by locating the line in init.rc that says &quot;on fs&quot; and modifying it to look like this:</p>
31<div><tt>on fs</tt></div>
32<div><tt># mount emmc partitions</tt></div>
33<div><tt>&nbsp; &nbsp; # Mount /system rw first to give the filesystem a chance to save a checkpoint</tt></div>
34<div><tt>&nbsp; &nbsp; # mount yaffs2 mtd@system /system</tt></div>
35<div><tt>&nbsp; &nbsp; # mount yaffs2 mtd@system /system ro remount</tt></div>
36<div><tt>&nbsp; &nbsp; # mount yaffs2 mtd@userdata /data nosuid nodev</tt></div>
37<div><tt>&nbsp; &nbsp; # mount yaffs2 mtd@cache /cache nosuid nodev</tt></div>
38<div><tt>&nbsp; &nbsp; mount ext4 /dev/block/mmcblk0p3 /system wait ro</tt></div>
39<div><tt>&nbsp; &nbsp; mount ext4 /dev/block/mmcblk0p5 /data wait noatime nosuid nodev</tt></div>
40<div><tt>&nbsp; &nbsp; mount ext4 /dev/block/mmcblk0p4 /cache wait noatime nosuid nodev</tt></div>
41<p>Save the changes and repack the ramdisk image as follows:</p>
42<p><tt>find . | cpio -o -H newc &gt; gzip &gt; ../newramdisk.img</tt></p>
43<p>Boot the emulator using -ramdisk path/to/newramdisk.img -kernel path/to/goldfish_2.6_kernel</p>