summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-04-28 15:37:40 +1000
committerDamien George <damien@micropython.org>2024-05-01 15:44:32 +1000
commitb896fa9b1f5f17d9f92901dd9a75a0efdec39a92 (patch)
tree1dd7b0dff2088b7fa80c4b803cc5314b288cb162
parentb1ac266bb5cd0fcfa53539cb3230e7b3f323a09b (diff)
stm32/boards/LEGO_HUB_NO6: Write key after writing elements.
In case there is a power failure after during this operation, the key must be the last thing that is written, to indicate valid data. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/stm32/boards/LEGO_HUB_NO6/board_init.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/stm32/boards/LEGO_HUB_NO6/board_init.c b/ports/stm32/boards/LEGO_HUB_NO6/board_init.c
index 5e4e7791b..3a785859a 100644
--- a/ports/stm32/boards/LEGO_HUB_NO6/board_init.c
+++ b/ports/stm32/boards/LEGO_HUB_NO6/board_init.c
@@ -198,9 +198,9 @@ void board_mboot_state_change(int state, uint32_t arg) {
// The FS-load update is about to start. Program the update key and FS-load elements
// into the flash so they can be retrieved if there is a power failure during the update.
mp_spiflash_erase_block(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR);
+ mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR + 4, ELEM_DATA_SIZE, ELEM_DATA_START);
uint32_t key = SPIFLASH_UPDATE_KEY_VALUE;
mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR, 4, (const uint8_t *)&key);
- mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR + 4, ELEM_DATA_SIZE, ELEM_DATA_START);
} else if (state == MBOOT_STATE_FSLOAD_END) {
// The FS-load update completed (either with success or failure), so erase the
// update key and write the result of the FS-load operation into flash.