Galaxy S initial support. Fix firmware flash on inc. May need to fix other phones.

This commit is contained in:
Koushik Dutta 2010-07-22 20:14:44 -07:00
parent e074d8d543
commit d4060c3eb6
6 changed files with 64 additions and 43 deletions

View File

@ -26,12 +26,8 @@ else
LOCAL_CFLAGS += -DBOARD_HAS_NO_MISC_PARTITION
endif
ifdef BOARD_USES_FFORMAT
LOCAL_CFLAGS += -DBOARD_USES_FFORMAT
endif
ifdef BOARD_RECOVERY_IGNORE_BOOTABLES
LOCAL_CLFAGS += -DBOARD_RECOVERY_IGNORE_BOOTABLES
LOCAL_CFLAGS += -DBOARD_RECOVERY_IGNORE_BOOTABLES
endif
LOCAL_SRC_FILES += test_roots.c
@ -101,6 +97,26 @@ ifdef BOARD_HAS_DATADATA
LOCAL_CFLAGS += -DHAS_DATADATA
endif
ifdef BOARD_DATA_FILESYSTEM_OPTIONS
LOCAL_CFLAGS += -DDATA_FILESYSTEM_OPTIONS=\"$(BOARD_DATA_FILESYSTEM_OPTIONS)\"
endif
ifdef BOARD_DATADATA_FILESYSTEM_OPTIONS
LOCAL_CFLAGS += -DDATADATA_FILESYSTEM_OPTIONS=\"$(BOARD_DATADATA_FILESYSTEM_OPTIONS)\"
endif
ifdef BOARD_CACHE_FILESYSTEM_OPTIONS
LOCAL_CFLAGS += -DCACHE_FILESYSTEM_OPTIONS=\"$(BOARD_CACHE_FILESYSTEM_OPTIONS)\"
endif
ifdef BOARD_SYSTEM_FILESYSTEM_OPTIONS
LOCAL_CFLAGS += -DSYSTEM_FILESYSTEM_OPTIONS=\"$(BOARD_SYSTEM_FILESYSTEM_OPTIONS)\"
endif
ifdef BOARD_HAS_MTD_CACHE
LOCAL_CFLAGS += -DBOARD_HAS_MTD_CACHE
endif
# This binary is in the recovery ramdisk, which is otherwise a copy of root.
# It gets copied there in config/Makefile. LOCAL_MODULE_TAGS suppresses
# a (redundant) copy of the binary in /system/bin for user builds.
@ -163,16 +179,6 @@ LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_SRC_FILES := killrecovery.sh
include $(BUILD_PREBUILT)
ifdef BOARD_USES_FFORMAT
include $(CLEAR_VARS)
LOCAL_MODULE := fformat
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
LOCAL_SRC_FILES := prebuilt/fformat
include $(BUILD_PREBUILT)
endif
include $(commands_recovery_local_path)/amend/Android.mk
include $(commands_recovery_local_path)/minui/Android.mk
include $(commands_recovery_local_path)/minzip/Android.mk

View File

@ -870,7 +870,7 @@ void write_fstab_root(char *root_path, FILE *file)
}
fprintf(file, "%s ", info->mount_point);
fprintf(file, "%s rw\n", info->filesystem);
fprintf(file, "%s %s\n", info->filesystem, info->filesystem_options == NULL ? "rw" : info->filesystem_options);
}
void create_fstab()

View File

@ -6,5 +6,4 @@ touch /tmp/.ignorebootmessage
kill $(ps | grep /sbin/adbd)
kill $(ps | grep /sbin/recovery)
/sbin/recovery &
exit 1

View File

@ -216,7 +216,7 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* roo
sprintf(tmp, "%s/%s.img", backup_path, name);
struct stat file_info;
if (0 != (ret = statfs(tmp, &file_info))) {
ui_print("%s.img not found. Skipping restore of /sd-ext.", name);
ui_print("%s.img not found. Skipping restore of %s.\n", name, mount_point);
return 0;
}

48
roots.c
View File

@ -39,20 +39,20 @@ static const char g_raw[] = "@\0g_raw";
static const char g_package_file[] = "@\0g_package_file";
static RootInfo g_roots[] = {
{ "BOOT:", g_mtd_device, NULL, "boot", NULL, g_raw },
{ "CACHE:", CACHE_DEVICE, NULL, "cache", "/cache", CACHE_FILESYSTEM },
{ "DATA:", DATA_DEVICE, NULL, "userdata", "/data", DATA_FILESYSTEM },
{ "BOOT:", g_mtd_device, NULL, "boot", NULL, g_raw, NULL },
{ "CACHE:", CACHE_DEVICE, NULL, "cache", "/cache", CACHE_FILESYSTEM, CACHE_FILESYSTEM_OPTIONS },
{ "DATA:", DATA_DEVICE, NULL, "userdata", "/data", DATA_FILESYSTEM, DATA_FILESYSTEM_OPTIONS },
#ifdef HAS_DATADATA
{ "DATADATA:", DATADATA_DEVICE, NULL, "datadata", "/datadata", DATADATA_FILESYSTEM },
{ "DATADATA:", DATADATA_DEVICE, NULL, "datadata", "/datadata", DATADATA_FILESYSTEM, DATADATA_FILESYSTEM_OPTIONS },
#endif
{ "MISC:", g_mtd_device, NULL, "misc", NULL, g_raw },
{ "PACKAGE:", NULL, NULL, NULL, NULL, g_package_file },
{ "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw },
{ "SDCARD:", SDCARD_DEVICE_PRIMARY, SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat" },
{ "SDEXT:", SDEXT_DEVICE, NULL, NULL, "/sd-ext", SDEXT_FILESYSTEM },
{ "SYSTEM:", SYSTEM_DEVICE, NULL, "system", "/system", SYSTEM_FILESYSTEM },
{ "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw },
{ "TMP:", NULL, NULL, NULL, "/tmp", NULL },
{ "MISC:", g_mtd_device, NULL, "misc", NULL, g_raw, NULL },
{ "PACKAGE:", NULL, NULL, NULL, NULL, g_package_file, NULL },
{ "RECOVERY:", g_mtd_device, NULL, "recovery", "/", g_raw, NULL },
{ "SDCARD:", SDCARD_DEVICE_PRIMARY, SDCARD_DEVICE_SECONDARY, NULL, "/sdcard", "vfat", NULL },
{ "SDEXT:", SDEXT_DEVICE, NULL, NULL, "/sd-ext", SDEXT_FILESYSTEM, NULL },
{ "SYSTEM:", SYSTEM_DEVICE, NULL, "system", "/system", SYSTEM_FILESYSTEM, SYSTEM_FILESYSTEM_OPTIONS },
{ "MBM:", g_mtd_device, NULL, "mbm", NULL, g_raw, NULL },
{ "TMP:", NULL, NULL, NULL, "/tmp", NULL, NULL },
};
#define NUM_ROOTS (sizeof(g_roots) / sizeof(g_roots[0]))
@ -207,14 +207,15 @@ is_root_path_mounted(const char *root_path)
return internal_root_mounted(info) >= 0;
}
static int mount_internal(const char* device, const char* mount_point, const char* filesystem)
static int mount_internal(const char* device, const char* mount_point, const char* filesystem, const char* filesystem_options)
{
if (strcmp(filesystem, "auto") != 0) {
if (strcmp(filesystem, "auto") != 0 && filesystem_options == NULL) {
return mount(device, mount_point, filesystem, MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
}
else {
char mount_cmd[PATH_MAX];
sprintf(mount_cmd, "mount -onoatime,nodiratime,nodev %s %s", device, mount_point);
const char* options = filesystem_options == NULL ? "noatime,nodiratime,nodev" : filesystem_options;
sprintf(mount_cmd, "mount -t %s -o%s %s %s", filesystem, options, device, mount_point);
return __system(mount_cmd);
}
}
@ -259,7 +260,7 @@ ensure_root_path_mounted(const char *root_path)
}
mkdir(info->mount_point, 0755); // in case it doesn't already exist
if (mount_internal(info->device, info->mount_point, info->filesystem)) {
if (mount_internal(info->device, info->mount_point, info->filesystem, info->filesystem_options)) {
if (info->device2 == NULL) {
LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno));
return -1;
@ -311,7 +312,12 @@ get_root_mtd_partition(const char *root_path)
if (info == NULL || info->device != g_mtd_device ||
info->partition_name == NULL)
{
#ifdef BOARD_HAS_MTD_CACHE
if (strcmp(root_path, "CACHE:") != 0)
return NULL;
#else
return NULL;
#endif
}
mtd_scan_partitions();
return mtd_find_partition_by_name(info->partition_name);
@ -377,14 +383,6 @@ format_root_device(const char *root)
}
}
}
#ifdef BOARD_USES_FFORMAT
if (info->filesystem != NULL && strcmp("rfs", info->filesystem) == 0) {
char cmd[PATH_MAX];
sprintf("/sbin/fformat %s", info->device);
return __system(cmd);
}
#endif
return format_non_mtd_device(root);
}

18
roots.h
View File

@ -68,6 +68,23 @@
#define SYSTEM_FILESYSTEM "yaffs2"
#endif
#ifndef DATA_FILESYSTEM_OPTIONS
#define DATA_FILESYSTEM_OPTIONS NULL
#endif
#ifndef CACHE_FILESYSTEM_OPTIONS
#define CACHE_FILESYSTEM_OPTIONS NULL
#endif
#ifndef DATADATA_FILESYSTEM_OPTIONS
#define DATADATA_FILESYSTEM_OPTIONS NULL
#endif
#ifndef SYSTEM_FILESYSTEM_OPTIONS
#define SYSTEM_FILESYSTEM_OPTIONS NULL
#endif
/* Any of the "root_path" arguments can be paths with relative
* components, like "SYSTEM:a/b/c".
*/
@ -115,6 +132,7 @@ typedef struct {
const char *partition_name;
const char *mount_point;
const char *filesystem;
const char *filesystem_options;
} RootInfo;
#endif // RECOVERY_ROOTS_H_