Rename br_image_addr to br_image_off.
The boot response returns a flash offset, not a flash address. This is
causing confusion and leading to crashes on some platforms which don't
have flash at address 0.
Rename the field to make it more clear what its purpose is; future
patches can start fixing up usages.
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/boot/bootutil/include/bootutil/bootutil.h b/boot/bootutil/include/bootutil/bootutil.h
index 0947f50..7f76877 100644
--- a/boot/bootutil/include/bootutil/bootutil.h
+++ b/boot/bootutil/include/bootutil/bootutil.h
@@ -51,10 +51,10 @@
/**
* The flash offset of the image to execute. Indicates the position of
- * the image header.
+ * the image header within its flash device.
*/
uint8_t br_flash_id;
- uint32_t br_image_addr;
+ uint32_t br_image_off;
};
/* you must have pre-allocated all the entries within this structure */
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index c4a292a..74c297c 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -1288,7 +1288,7 @@
/* Always boot from the primary slot. */
rsp->br_flash_id = boot_img_fa_device_id(&boot_data, 0);
- rsp->br_image_addr = boot_img_slot_off(&boot_data, 0);
+ rsp->br_image_off = boot_img_slot_off(&boot_data, 0);
rsp->br_hdr = boot_img_hdr(&boot_data, slot);
out:
diff --git a/boot/bootutil/test/src/boot_test_utils.c b/boot/bootutil/test/src/boot_test_utils.c
index 30297c8..54fa338 100644
--- a/boot/bootutil/test/src/boot_test_utils.c
+++ b/boot/bootutil/test/src/boot_test_utils.c
@@ -505,7 +505,7 @@
TEST_ASSERT(memcmp(rsp.br_hdr, slot0hdr, sizeof *slot0hdr) == 0);
TEST_ASSERT(rsp.br_flash_id == boot_test_img_addrs[0].flash_id);
- TEST_ASSERT(rsp.br_image_addr == boot_test_img_addrs[0].address);
+ TEST_ASSERT(rsp.br_image_off == boot_test_img_addrs[0].address);
boot_test_util_verify_flash(slot0hdr, orig_slot_0,
slot1hdr, orig_slot_1);
diff --git a/boot/mynewt/src/main.c b/boot/mynewt/src/main.c
index 9cf4737..2af6680 100755
--- a/boot/mynewt/src/main.c
+++ b/boot/mynewt/src/main.c
@@ -70,7 +70,7 @@
rc = boot_go(&rsp);
assert(rc == 0);
- hal_system_start((void *)(rsp.br_image_addr + rsp.br_hdr->ih_hdr_size));
+ hal_system_start((void *)(rsp.br_image_off + rsp.br_hdr->ih_hdr_size));
return 0;
}
diff --git a/boot/zephyr/main.c b/boot/zephyr/main.c
index 9791f26..c6f4376 100644
--- a/boot/zephyr/main.c
+++ b/boot/zephyr/main.c
@@ -45,7 +45,7 @@
* consecutively. Manually set the stack pointer and jump into the
* reset vector
*/
- vt = (struct arm_vector_table *)(rsp->br_image_addr +
+ vt = (struct arm_vector_table *)(rsp->br_image_off +
rsp->br_hdr->ih_hdr_size);
irq_lock();
sys_clock_disable();
@@ -61,7 +61,7 @@
{
void *start;
- start = (void *)(rsp->br_image_addr + rsp->br_hdr->ih_hdr_size);
+ start = (void *)(rsp->br_image_off + rsp->br_hdr->ih_hdr_size);
/* Lock interrupts and dive into the entry point */
irq_lock();
@@ -92,7 +92,8 @@
;
}
- BOOT_LOG_INF("Bootloader chainload address: 0x%x", rsp.br_image_addr);
+ BOOT_LOG_INF("Bootloader chainload address offset: 0x%x",
+ rsp.br_image_off);
BOOT_LOG_INF("Jumping to the first image slot");
do_boot(&rsp);