Support overriding of the bml partition used for boot and recovery. This is not ideal, because that means that there are different flash_image binaries for different samsung phones. But as far as I know, there is no way to find out which bml device is boot or recovery.

Change-Id: I5e3b83dd9267a275def003182c1bd5d2cf585896
This commit is contained in:
Koushik Dutta 2011-07-07 12:55:02 -07:00
parent 50732e3c67
commit a75c067df4
4 changed files with 38 additions and 6 deletions

View File

@ -1,7 +1,15 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CFLAGS += -DBOARD_BOOT_DEVICE=\"$(BOARD_BOOT_DEVICE)\"
BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
$(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
$(if $($(board_define)), \
$(eval LOCAL_CFLAGS += -D$(board_define)=\"$($(board_define))\") \
) \
)
LOCAL_SRC_FILES := bmlutils.c
LOCAL_MODULE := libbmlutils
LOCAL_MODULE_TAGS := eng

View File

@ -23,6 +23,13 @@
extern int __system(const char *command);
#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW
#ifndef BOARD_BML_BOOT
#define BOARD_BML_BOOT "/dev/block/bml7"
#endif
#ifndef BOARD_BML_RECOVERY
#define BOARD_BML_RECOVERY "/dev/block/bml8"
#endif
static int restore_internal(const char* bml, const char* filename)
{
@ -66,13 +73,13 @@ int cmd_bml_restore_raw_partition(const char *partition, const char *filename)
// always restore boot, regardless of whether recovery or boot is flashed.
// this is because boot and recovery are the same on some samsung phones.
// unless of course, recoveryonly is explictly chosen (bml8)
ret = restore_internal("/dev/block/bml7", filename);
ret = restore_internal(BOARD_BML_BOOT, filename);
if (ret != 0)
return ret;
}
if (strcmp(partition, "recovery") == 0 || strcmp(partition, "recoveryonly") == 0)
ret = restore_internal("/dev/block/bml8", filename);
ret = restore_internal(BOARD_BML_RECOVERY, filename);
return ret;
}
@ -80,9 +87,9 @@ int cmd_bml_backup_raw_partition(const char *partition, const char *out_file)
{
char* bml;
if (strcmp("boot", partition) == 0)
bml = "/dev/block/bml7";
bml = BOARD_BML_BOOT;
else if (strcmp("recovery", partition) == 0)
bml = "/dev/block/bml8";
bml = BOARD_BML_RECOVERY;
else {
printf("Invalid partition.\n");
return -1;

View File

@ -9,6 +9,15 @@ LOCAL_MODULE := libflashutils
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES += bootable/recovery
LOCAL_STATIC_LIBRARIES := libmmcutils libmtdutils libbmlutils libcrecovery
BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
$(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
$(if $($(board_define)), \
$(eval LOCAL_CFLAGS += -D$(board_define)=\"$($(board_define))\") \
) \
)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)

View File

@ -6,12 +6,20 @@
#include "flashutils/flashutils.h"
#ifndef BOARD_BML_BOOT
#define BOARD_BML_BOOT "/dev/block/bml7"
#endif
#ifndef BOARD_BML_RECOVERY
#define BOARD_BML_RECOVERY "/dev/block/bml8"
#endif
int the_flash_type = UNKNOWN;
int device_flash_type()
{
if (the_flash_type == UNKNOWN) {
if (access("/dev/block/bml7", F_OK) == 0) {
if (access(BOARD_BML_BOOT, F_OK) == 0) {
the_flash_type = BML;
} else if (access("/proc/emmc", F_OK) == 0) {
the_flash_type = MMC;