Skip to content

Commit b896fa9

Browse files
committed
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>
1 parent b1ac266 commit b896fa9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ports/stm32/boards/LEGO_HUB_NO6/board_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ void board_mboot_state_change(int state, uint32_t arg) {
198198
// The FS-load update is about to start. Program the update key and FS-load elements
199199
// into the flash so they can be retrieved if there is a power failure during the update.
200200
mp_spiflash_erase_block(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR);
201+
mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR + 4, ELEM_DATA_SIZE, ELEM_DATA_START);
201202
uint32_t key = SPIFLASH_UPDATE_KEY_VALUE;
202203
mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR, 4, (const uint8_t *)&key);
203-
mp_spiflash_write(MBOOT_SPIFLASH_SPIFLASH, SPIFLASH_UPDATE_KEY_ADDR + 4, ELEM_DATA_SIZE, ELEM_DATA_START);
204204
} else if (state == MBOOT_STATE_FSLOAD_END) {
205205
// The FS-load update completed (either with success or failure), so erase the
206206
// update key and write the result of the FS-load operation into flash.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy