Merge pull request #13405 from kaspar030/introduce_riotboot_slot_offset

sys/riotboot: provide riotboot_slot_offset()
This commit is contained in:
Koen Zandberg 2020-02-20 13:03:29 +01:00 committed by GitHub
commit 640cbfe77e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -93,6 +93,11 @@ static inline void riotboot_slot_print_hdr(unsigned slot)
riotboot_hdr_print(riotboot_slot_get_hdr(slot)); riotboot_hdr_print(riotboot_slot_get_hdr(slot));
} }
/**
* @brief Get the offset (in flash, in bytes) for a given slot.
*/
size_t riotboot_slot_offset(unsigned slot);
/** /**
* @brief Dump the addresses of all configured slots * @brief Dump the addresses of all configured slots
* *

View File

@ -93,3 +93,8 @@ const riotboot_hdr_t *riotboot_slot_get_hdr(unsigned slot)
return riotboot_slots[slot]; return riotboot_slots[slot];
} }
size_t riotboot_slot_offset(unsigned slot)
{
return (size_t)riotboot_slot_get_hdr(slot) - CPU_FLASH_BASE;
}

View File

@ -85,8 +85,7 @@ static int _cond_comp_offset(suit_v4_manifest_t *manifest, int key, nanocbor_val
(void)key; (void)key;
uint32_t offset; uint32_t offset;
nanocbor_get_uint32(it, &offset); nanocbor_get_uint32(it, &offset);
uint32_t other_offset = (uint32_t)riotboot_slot_get_hdr(riotboot_slot_other()) \ uint32_t other_offset = (uint32_t)riotboot_slot_offset(riotboot_slot_other());
- CPU_FLASH_BASE;
LOG_INFO("Comparing manifest offset %u with other slot offset %u\n", LOG_INFO("Comparing manifest offset %u with other slot offset %u\n",
(unsigned)offset, (unsigned)other_offset); (unsigned)offset, (unsigned)other_offset);
return other_offset == offset ? 0 : -1; return other_offset == offset ? 0 : -1;