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
This commit is contained in:
Brint E. Kriebel 2010-12-11 20:52:06 -07:00 committed by Koushik Dutta
parent 16c0ace22b
commit d352233ab6
5 changed files with 61 additions and 1 deletions

View File

@ -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)), \

View File

@ -8,6 +8,7 @@ on init
symlink /system/etc /etc
mkdir /sdcard
mkdir /emmc
mkdir /system
mkdir /data
mkdir /cache

View File

@ -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;
}
}
}
}

View File

@ -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 },

View File

@ -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