From a75c067df4a08df6e734aba607c941eef7f261e0 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 7 Jul 2011 12:55:02 -0700 Subject: [PATCH] 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 --- bmlutils/Android.mk | 10 +++++++++- bmlutils/bmlutils.c | 15 +++++++++++---- flashutils/Android.mk | 9 +++++++++ flashutils/flashutils.c | 10 +++++++++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/bmlutils/Android.mk b/bmlutils/Android.mk index e95cb5f..6d9ab83 100644 --- a/bmlutils/Android.mk +++ b/bmlutils/Android.mk @@ -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 diff --git a/bmlutils/bmlutils.c b/bmlutils/bmlutils.c index 9ef04b4..db80501 100644 --- a/bmlutils/bmlutils.c +++ b/bmlutils/bmlutils.c @@ -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; diff --git a/flashutils/Android.mk b/flashutils/Android.mk index d513275..aa4c7d3 100644 --- a/flashutils/Android.mk +++ b/flashutils/Android.mk @@ -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) diff --git a/flashutils/flashutils.c b/flashutils/flashutils.c index 958476c..de45e87 100644 --- a/flashutils/flashutils.c +++ b/flashutils/flashutils.c @@ -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;