recovery: Allow custom bootloader msg offset in block misc
Squash of changes
* Allow custom bootloader msg offset in block misc
Change-Id: I6f3de1c2e3745c5535c3b95399abb8b2e2d01446
* recovery: Move bldrmsg offset symbols to bootloader_message.cpp
Change-Id: I2b902bcce7f5ca13472e0ac30ac01b4991294dbe
Adapted for Android.bp version of libbootloader_message
Change-Id: I5768660569d56b0d7c358f562e79483fd5f6db53
diff --git a/bootloader_message/Android.bp b/bootloader_message/Android.bp
index c81c67b..8a6fa08 100644
--- a/bootloader_message/Android.bp
+++ b/bootloader_message/Android.bp
@@ -26,4 +26,12 @@
"libfs_mgr",
],
export_include_dirs: ["include"],
+
+ product_variables: {
+ aosp: {
+ bootloader_message_offset : {
+ cflags: ["-DBOARD_RECOVERY_BLDRMSG_OFFSET=%d"],
+ },
+ },
+ },
}
diff --git a/bootloader_message/bootloader_message.cpp b/bootloader_message/bootloader_message.cpp
index aaeffdc..7ebd86a 100644
--- a/bootloader_message/bootloader_message.cpp
+++ b/bootloader_message/bootloader_message.cpp
@@ -29,6 +29,16 @@
#include <android-base/unique_fd.h>
#include <fs_mgr.h>
+// Spaces used by misc partition are as below:
+// 0 - 2K For bootloader_message
+// 2K - 16K Used by Vendor's bootloader (the 2K - 4K range may be optionally used
+// as bootloader_message_ab struct)
+// 16K - 64K Used by uncrypt and recovery to store wipe_package for A/B devices
+// Note that these offsets are admitted by bootloader,recovery and uncrypt, so they
+// are not configurable without changing all of them.
+static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = BOARD_RECOVERY_BLDRMSG_OFFSET;
+static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024 + BOOTLOADER_MESSAGE_OFFSET_IN_MISC;
+
static std::string get_misc_blk_device(std::string* err) {
std::unique_ptr<fstab, decltype(&fs_mgr_free_fstab)> fstab(fs_mgr_read_fstab_default(),
fs_mgr_free_fstab);
diff --git a/bootloader_message/include/bootloader_message/bootloader_message.h b/bootloader_message/include/bootloader_message/bootloader_message.h
index 95c19ae..975e94d 100644
--- a/bootloader_message/include/bootloader_message/bootloader_message.h
+++ b/bootloader_message/include/bootloader_message/bootloader_message.h
@@ -21,16 +21,6 @@
#include <stddef.h>
#include <stdint.h>
-// Spaces used by misc partition are as below:
-// 0 - 2K For bootloader_message
-// 2K - 16K Used by Vendor's bootloader (the 2K - 4K range may be optionally used
-// as bootloader_message_ab struct)
-// 16K - 64K Used by uncrypt and recovery to store wipe_package for A/B devices
-// Note that these offsets are admitted by bootloader,recovery and uncrypt, so they
-// are not configurable without changing all of them.
-static const size_t BOOTLOADER_MESSAGE_OFFSET_IN_MISC = 0;
-static const size_t WIPE_PACKAGE_OFFSET_IN_MISC = 16 * 1024;
-
/* Bootloader Message (2-KiB)
*
* This structure describes the content of a block in flash