Skip to content

Commit 1283bf3

Browse files
Fix silent failure of program when not aligned to flash blocks
1 parent e6e5a86 commit 1283bf3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

UpdaterApp.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ int main()
9191
}
9292

9393
// Copy the update image from internal flash to secondary BlockDevice
94-
secondary_bd->program(&_binary_SimpleApp_update_image_bin_start, 0, SimpleApp_update_image_bin_length);
94+
ret = secondary_bd->program(&_binary_SimpleApp_update_image_bin_start, 0, SimpleApp_update_image_bin_length);
95+
if (ret == 0) {
96+
tr_info("Image copied.");
97+
} else {
98+
tr_error("Cannot copy image: %d", ret);
99+
}
95100

96101
ret = secondary_bd->deinit();
97102
if (ret == 0) {

secondary_bd.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ mbed::BlockDevice* get_secondary_bd(void) {
1717

1818
// Use FlashIAP for the secondary BD.
1919
static FlashIAPBlockDevice flashBD(MBED_CONF_APP_SECONDARY_SLOT_FLASH_START_ADDR, MCUBOOT_SLOT_SIZE);
20-
return &flashBD;
20+
21+
// Our UpdaterApp needs to be able to program the flash with single-byte granularity
22+
static mbed::BufferedBlockDevice bufferedBD(&flashBD);
23+
24+
return &bufferedBD;
2125
}
2226

2327
#else

0 commit comments

Comments
 (0)