From d352233ab60a37ccc4f8c4247a6eabbe0c94fb4b Mon Sep 17 00:00:00 2001 From: "Brint E. Kriebel" Date: Sat, 11 Dec 2010 20:52:06 -0700 Subject: [PATCH] Added options for an internal SD card to be handled by recovery. Exable uses in BoardConfig.mk: BOARD_HAS_SDCARD_INTERNAL := true BOARD_SDCARD_DEVICE_INTERNAL := /dev/block/mmcblk3p1 Setting BOARD_SDCARD_DEVICE_SECONDARY to the same value as BOARD_SDCARD_DEVICE_INTERNAL will allow the device to "fall back" to the internal SD card for other actions. Change-Id: I2cf8ab4b1d385ac714f5b7416b915d059033d94b --- Android.mk | 2 +- etc/init.rc | 1 + extendedcommands.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ roots.c | 3 +++ roots.h | 4 ++++ 5 files changed, 61 insertions(+), 1 deletion(-) diff --git a/Android.mk b/Android.mk index 6779312..1098121 100644 --- a/Android.mk +++ b/Android.mk @@ -44,7 +44,7 @@ LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) -BOARD_RECOVERY_DEFINES := BOARD_HAS_NO_SELECT_BUTTON BOARD_SDCARD_DEVICE_PRIMARY BOARD_SDCARD_DEVICE_SECONDARY BOARD_SDEXT_DEVICE BOARD_SDEXT_FILESYSTEM BOARD_DATA_DEVICE BOARD_DATA_FILESYSTEM BOARD_DATADATA_DEVICE BOARD_DATADATA_FILESYSTEM BOARD_CACHE_DEVICE BOARD_CACHE_FILESYSTEM BOARD_SYSTEM_DEVICE BOARD_SYSTEM_FILESYSTEM BOARD_HAS_DATADATA BOARD_DATA_FILESYSTEM_OPTIONS BOARD_DATADATA_FILESYSTEM_OPTIONS BOARD_CACHE_FILESYSTEM_OPTIONS BOARD_SYSTEM_FILESYSTEM_OPTIONS BOARD_HAS_MTD_CACHE BOARD_USES_BMLUTILS BOARD_USES_MMCUTILS BOARD_HAS_SMALL_RECOVERY BOARD_LDPI_RECOVERY BOARD_RECOVERY_IGNORE_BOOTABLES BOARD_HAS_NO_MISC_PARTITION +BOARD_RECOVERY_DEFINES := BOARD_HAS_NO_SELECT_BUTTON BOARD_SDCARD_DEVICE_PRIMARY BOARD_SDCARD_DEVICE_SECONDARY BOARD_SDEXT_DEVICE BOARD_SDEXT_FILESYSTEM BOARD_DATA_DEVICE BOARD_DATA_FILESYSTEM BOARD_DATADATA_DEVICE BOARD_DATADATA_FILESYSTEM BOARD_CACHE_DEVICE BOARD_CACHE_FILESYSTEM BOARD_SYSTEM_DEVICE BOARD_SYSTEM_FILESYSTEM BOARD_HAS_DATADATA BOARD_DATA_FILESYSTEM_OPTIONS BOARD_DATADATA_FILESYSTEM_OPTIONS BOARD_CACHE_FILESYSTEM_OPTIONS BOARD_SYSTEM_FILESYSTEM_OPTIONS BOARD_HAS_MTD_CACHE BOARD_USES_BMLUTILS BOARD_USES_MMCUTILS BOARD_HAS_SMALL_RECOVERY BOARD_LDPI_RECOVERY BOARD_RECOVERY_IGNORE_BOOTABLES BOARD_HAS_NO_MISC_PARTITION BOARD_HAS_SDCARD_INTERNAL BOARD_SDCARD_DEVICE_INTERNAL $(foreach board_define,$(BOARD_RECOVERY_DEFINES), \ $(if $($(board_define)), \ diff --git a/etc/init.rc b/etc/init.rc index d9e86d7..56c6542 100644 --- a/etc/init.rc +++ b/etc/init.rc @@ -8,6 +8,7 @@ on init symlink /system/etc /etc mkdir /sdcard + mkdir /emmc mkdir /system mkdir /data mkdir /cache diff --git a/extendedcommands.c b/extendedcommands.c index 2c8e227..3d47341 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -446,6 +446,9 @@ void show_partition_menu() { "mount /data", "unmount /data", "DATA:" }, { "mount /cache", "unmount /cache", "CACHE:" }, { "mount /sdcard", "unmount /sdcard", "SDCARD:" }, +#ifdef BOARD_HAS_SDCARD_INTERNAL + { "mount /emmc", "unmount /emmc", "SDINTERNAL:" }, +#endif { "mount /sd-ext", "unmount /sd-ext", "SDEXT:" } }; @@ -458,6 +461,9 @@ void show_partition_menu() string mmcs[MMC_COUNT][3] = { { "format sdcard", "SDCARD:" }, +#ifdef BOARD_HAS_SDCARD_INTERNAL + { "format internal sdcard", "SDINTERNAL:" }, +#endif { "format sd-ext", "SDEXT:" } }; @@ -760,6 +766,9 @@ void show_advanced_menu() #ifndef BOARD_HAS_SMALL_RECOVERY "Partition SD Card", "Fix Permissions", +#ifdef BOARD_HAS_SDCARD_INTERNAL + "Partition Internal SD Card", +#endif #endif NULL }; @@ -865,6 +874,49 @@ void show_advanced_menu() ui_print("Done!\n"); break; } + case 7: + { + static char* ext_sizes[] = { "128M", + "256M", + "512M", + "1024M", + "2048M", + "4096M", + NULL }; + + static char* swap_sizes[] = { "0M", + "32M", + "64M", + "128M", + "256M", + NULL }; + + static char* ext_headers[] = { "Data Size", "", NULL }; + static char* swap_headers[] = { "Swap Size", "", NULL }; + + int ext_size = get_menu_selection(ext_headers, ext_sizes, 0); + if (ext_size == GO_BACK) + continue; + + int swap_size = 0; + if (swap_size == GO_BACK) + continue; + + char sddevice[256]; + const RootInfo *ri = get_root_info_for_path("SDINTERNAL:"); + strcpy(sddevice, ri->device); + // we only want the mmcblk, not the partition + sddevice[strlen("/dev/block/mmcblkX")] = NULL; + char cmd[PATH_MAX]; + setenv("SDPATH", sddevice, 1); + sprintf(cmd, "sdparted -es %s -ss %s -efs ext3 -s", ext_sizes[ext_size], swap_sizes[swap_size]); + ui_print("Partitioning Internal SD Card... please wait...\n"); + if (0 == __system(cmd)) + ui_print("Done!\n"); + else + ui_print("An error occured while partitioning your Internal SD Card. Please see /tmp/recovery.log for more details.\n"); + break; + } } } } diff --git a/roots.c b/roots.c index 19855b2..a97970e 100644 --- a/roots.c +++ b/roots.c @@ -50,6 +50,9 @@ static RootInfo g_roots[] = { { "PACKAGE:", NULL, NULL, NULL, NULL, g_package_file, NULL }, { "RECOVERY:", g_default_device, NULL, "recovery", "/", g_raw, NULL }, { "SDCARD:", BOARD_SDCARD_DEVICE_PRIMARY, BOARD_SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat", NULL }, +#ifdef BOARD_HAS_SDCARD_INTERNAL + { "SDINTERNAL:", BOARD_SDCARD_DEVICE_INTERNAL, NULL, NULL, "/emmc", "vfat", NULL }, +#endif { "SDEXT:", BOARD_SDEXT_DEVICE, NULL, NULL, "/sd-ext", BOARD_SDEXT_FILESYSTEM, NULL }, { "SYSTEM:", BOARD_SYSTEM_DEVICE, NULL, "system", "/system", BOARD_SYSTEM_FILESYSTEM, BOARD_SYSTEM_FILESYSTEM_OPTIONS }, { "MBM:", g_default_device, NULL, "mbm", NULL, g_raw, NULL }, diff --git a/roots.h b/roots.h index 02ec2fb..833c1b5 100644 --- a/roots.h +++ b/roots.h @@ -37,6 +37,10 @@ #define BOARD_SDCARD_DEVICE_SECONDARY "/dev/block/mmcblk0" #endif +#ifndef BOARD_SDCARD_DEVICE_INTERNAL +#define BOARD_SDCARD_DEVICE_INTERNAL g_default_device +#endif + #ifndef BOARD_SDEXT_DEVICE #define BOARD_SDEXT_DEVICE "/dev/block/mmcblk0p2" #endif