Skip to content

Commit 1eced20

Browse files
committed
Update configs for emmc emulation
1 parent 8e67b47 commit 1eced20

File tree

7 files changed

+100
-13
lines changed

7 files changed

+100
-13
lines changed

BoardConfig.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ RECOVERY_GRAPHICS_USE_LINELENGTH := true
4545
TW_HAS_NO_BOOT_PARTITION := true
4646
TWRP_CUSTOM_KEYBOARD := ../../../device/emulator/twrp/recovery/hardwarekeyboard.cpp
4747

48+
RECOVERY_SDCARD_ON_DATA := true
49+
TW_INTERNAL_STORAGE_PATH := "/data/media"
50+
TW_INTERNAL_STORAGE_MOUNT_POINT := "data"
51+
TW_EXTERNAL_STORAGE_PATH := "/external_sd"
52+
TW_EXTERNAL_STORAGE_MOUNT_POINT := "external_sd"
53+

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,46 @@
22

33
This is a set of device configs that you can use to build and test TWRP in the Android emulator. Note that adb will take about 10 to 15 seconds after TWRP is booted to become available. Just wait and it will come online eventually.
44

5+
This branch of the device configs is intended to give you a more modern emmc type of device instead of relying on the mtd nand setup that the default emulator configuration uses. In order to make this setup work, you will have to boot the emulator with a custom kernel. We added ext2/3/4 support as well as support for reading a partition map to the kernel configuration. The source for this kernel is located here:
6+
7+
[Kernel Source](https://github.com/Dees-Troy/android_kernel_goldfish "Kernel Source")
8+
59
To boot this in the emulator, build your recoveryimage. With the Android emulator make a new device based on a Galaxy Nexus. Allow it to have a hardware keyboard and a sdcard. Give it a name like TWRP. Then from your android-sdk/tools folder run the following command:
6-
./emulator -avd TWRP -ramdisk ~/cm_folder/out/target/product/twrp/ramdisk-recovery.img
710

8-
You can find a compiling guide [here](http://forum.xda-developers.com/showthread.php?t=1943625 "Guide").
11+
./emulator -avd TWRP -ramdisk ~/cm_folder/out/target/product/twrp/ramdisk-recovery.img -kernel ~/cm_folder/device/emulator/twrp/goldfish_2.6_kernel
12+
13+
After the first boot, wait for ADB to start up, then: adb shell /sbin/create_partitions.sh
14+
15+
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 suite your needs. The script will also copy the existing system files from the MTD system partition to the new emmc-based partition.
16+
17+
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:
18+
19+
mkdir ramdisk
20+
21+
cd ramdisk
22+
23+
gzip -dc ../ramdisk.img | cpio -i
24+
25+
Modify the init.rc to mount your mmc based partitions instead of the mtd ones by locating the line in init.rc that says "on fs" and modifying it to look like this:
26+
27+
on fs
28+
# mount emmc partitions
29+
# Mount /system rw first to give the filesystem a chance to save a checkpoint
30+
# mount yaffs2 mtd@system /system
31+
# mount yaffs2 mtd@system /system ro remount
32+
# mount yaffs2 mtd@userdata /data nosuid nodev
33+
# mount yaffs2 mtd@cache /cache nosuid nodev
34+
mount ext4 /dev/block/mmcblk0p3 /system wait ro
35+
mount ext4 /dev/block/mmcblk0p5 /data wait noatime nosuid nodev
36+
mount ext4 /dev/block/mmcblk0p4 /cache wait noatime nosuid nodev
37+
38+
Save the changes and repack the ramdisk image as follows:
39+
40+
find . | cpio -o -H newc > gzip > ../newramdisk.img
41+
42+
Boot the emulator using -ramdisk path/to/newramdisk.img -kernel path/to/goldfish_2.6_kernel
43+
44+
You can find a compiling guide for TWRP [here](http://forum.xda-developers.com/showthread.php?t=1943625 "Guide").
945

1046
[More information about the project.](http://www.teamw.in/project/twrp2 "More Information")
1147

goldfish_2.6_kernel

1.8 MB
Binary file not shown.

recovery.fstab

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# mount point fstype device
22

3-
/system yaffs2 system
4-
/cache yaffs2 cache
5-
/data yaffs2 userdata
6-
/sdcard vfat /dev/block/mmcblk0
3+
/external_sd vfat /dev/block/mmcblk0p6
4+
/boot emmc /dev/block/mmcblk0p1
5+
/recovery emmc /dev/block/mmcblk0p2
6+
/system ext4 /dev/block/mmcblk0p3
7+
/cache ext4 /dev/block/mmcblk0p4
8+
/data ext4 /dev/block/mmcblk0p5 length=-16384
79

recovery/init-twrp.rc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ on init
2020
mkdir /cache
2121
mount /tmp /tmp tmpfs
2222

23-
on boot
24-
23+
on init
2524
ifup lo
2625
ifup eth0
2726
hostname localhost
@@ -32,16 +31,17 @@ on boot
3231
service ueventd /sbin/ueventd
3332
critical
3433

35-
service recovery /sbin/recovery
36-
37-
service adbd /sbin/adbd recovery
38-
disabled
39-
4034
#this starts the network needed to get adb working in the emulator
4135
service network_start /sbin/network_start.sh
4236
user root
4337
oneshot
4438

39+
on boot
40+
service recovery /sbin/recovery
41+
42+
service adbd /sbin/adbd recovery
43+
disabled
44+
4545
# Always start adbd on userdebug and eng builds
4646
# In recovery, always run adbd as root.
4747
on property:ro.debuggable=1
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/sbin/sh
2+
# This will repartition the emulated sdcard so that
3+
# you can emulate a newer, non-MTD device.
4+
# This partitioning scheme is based on a 1500MiB
5+
# sdcard.
6+
7+
umount /sdcard
8+
9+
echo "Creating partition table..."
10+
# Wipe all partitions and give you a gpt partition table
11+
parted -s /dev/block/mmcblk0 mklabel gpt
12+
# 8MB boot partition
13+
parted /dev/block/mmcblk0 mkpart boot ext2 0 8MB
14+
# 8MB recovery partition
15+
parted /dev/block/mmcblk0 mkpart recovery ext2 8MB 16MB
16+
# 200MB system partition
17+
parted /dev/block/mmcblk0 mkpart system ext4 16MB 216MB
18+
# 64MB cache partition
19+
parted /dev/block/mmcblk0 mkpart cache ext4 216MB 280MB
20+
# 720MB data partition
21+
parted /dev/block/mmcblk0 mkpart data ext4 280MB 1000MB
22+
# 573MB external_sd partition
23+
parted /dev/block/mmcblk0 mkpart external_sd ext4 1000MB 1573MB
24+
25+
echo "Formatting system, data, and cache..."
26+
# Format system, cache, and data as ext4
27+
make_ext4fs /dev/block/mmcblk0p3
28+
make_ext4fs /dev/block/mmcblk0p4
29+
make_ext4fs -l -16384 /dev/block/mmcblk0p5
30+
31+
echo "Formatting external_sd..."
32+
# Format external_sd as vfat
33+
mkdosfs /dev/block/mmcblk0p6
34+
35+
echo "Mounting new system and sdcard and make a copy of system..."
36+
mount -t vfat /dev/block/mmcblk0p6 /sdcard
37+
mkdir /systemmtd
38+
mount -t ext4 /dev/block/mmcblk0p3 /system
39+
mount -t yaffs2 /dev/block/mtdblock0 /systemmtd
40+
cd /system2 && cp -R * /system
41+
echo "DONE!"
42+

recovery/root/sbin/network_start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@ case "$my_ip" in
7070
*) ifconfig eth1 "$my_ip" netmask 255.255.255.0 up
7171
;;
7272
esac
73+

0 commit comments

Comments
 (0)