1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

riotboot: Add function to retrieve the slot size

This commit is contained in:
Koen Zandberg 2020-09-26 22:01:19 +02:00
parent fc794d9a21
commit a00314bfc4
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
2 changed files with 24 additions and 8 deletions

View File

@ -104,6 +104,27 @@ size_t riotboot_slot_offset(unsigned slot);
*/
void riotboot_slot_dump_addrs(void);
/**
* @brief Get the size of a slot
*
* @param[in] slot slot nr to get the size from
*
* @returns The slot size in bytes
*/
static inline size_t riotboot_slot_size(unsigned slot)
{
switch(slot) {
case 0:
return SLOT0_LEN;
#if NUM_SLOTS==2
case 1:
return SLOT1_LEN;
#endif
default:
return 0;
}
}
/**
* @brief Number of configured firmware slots (incl. bootloader slot)
*/

View File

@ -34,15 +34,10 @@ static inline size_t min(size_t a, size_t b)
return a <= b ? a : b;
}
size_t riotboot_flashwrite_slotsize(const riotboot_flashwrite_t *state)
size_t riotboot_flashwrite_slotsize(
const riotboot_flashwrite_t *state)
{
switch (state->target_slot) {
case 0: return SLOT0_LEN;
#if NUM_SLOTS==2
case 1: return SLOT1_LEN;
#endif
default: return 0;
}
return riotboot_slot_size(state->target_slot);
}
int riotboot_flashwrite_init_raw(riotboot_flashwrite_t *state, int target_slot,