sys/riotboot/flashwrite: when invalidating erase checksum as well
This commit is contained in:
parent
85caf7cbc7
commit
6baadad152
@ -30,11 +30,6 @@
|
|||||||
#define LOG_PREFIX "riotboot_flashwrite: "
|
#define LOG_PREFIX "riotboot_flashwrite: "
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Magic number used to invalidate a slot
|
|
||||||
*/
|
|
||||||
#define INVALIDATE_HDR 0xAA
|
|
||||||
|
|
||||||
static inline size_t min(size_t a, size_t b)
|
static inline size_t min(size_t a, size_t b)
|
||||||
{
|
{
|
||||||
return a <= b ? a : b;
|
return a <= b ? a : b;
|
||||||
@ -178,10 +173,14 @@ int riotboot_flashwrite_invalidate(int slot)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t data_flash[4];
|
/* invalidate header (checksum and magic number must be invalidated),
|
||||||
memset(data_flash, INVALIDATE_HDR, sizeof(data_flash));
|
write the whole header to avoid running in memory alignment issues
|
||||||
|
with FLASHPAGE_WRITE_BLOCK_SIZE */
|
||||||
|
riotboot_hdr_t tmp_hdr;
|
||||||
|
memset(&tmp_hdr, (~FLASHPAGE_ERASE_STATE), sizeof(riotboot_hdr_t));
|
||||||
|
|
||||||
flashpage_write((void *)riotboot_slot_get_hdr(slot), data_flash, sizeof(data_flash));
|
flashpage_write((void *)riotboot_slot_get_hdr(slot), &tmp_hdr,
|
||||||
|
sizeof(riotboot_hdr_t));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user