From 87fcd061a86dd5c050f17d2154bc9ef2eca4d71d Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Thu, 26 Sep 2019 13:57:17 +0200 Subject: [PATCH 1/2] sys/riotboot: provide riotboot_slot_offset() --- sys/include/riotboot/slot.h | 5 +++++ sys/riotboot/slot.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/sys/include/riotboot/slot.h b/sys/include/riotboot/slot.h index f1cbbba7b4..93a38b16f0 100644 --- a/sys/include/riotboot/slot.h +++ b/sys/include/riotboot/slot.h @@ -93,6 +93,11 @@ static inline void riotboot_slot_print_hdr(unsigned 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 * diff --git a/sys/riotboot/slot.c b/sys/riotboot/slot.c index fa4b79738c..472b02fc5b 100644 --- a/sys/riotboot/slot.c +++ b/sys/riotboot/slot.c @@ -93,3 +93,8 @@ const riotboot_hdr_t *riotboot_slot_get_hdr(unsigned slot) return riotboot_slots[slot]; } + +size_t riotboot_slot_offset(unsigned slot) +{ + return (size_t)riotboot_slot_get_hdr(slot) - CPU_FLASH_BASE; +} From 9ede06fbbb5742eba428020aff474c24a5c220ba Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 19 Feb 2020 10:08:47 +0100 Subject: [PATCH 2/2] sys/suit: make use of riotboot_slot_offset() --- sys/suit/v4/handlers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sys/suit/v4/handlers.c b/sys/suit/v4/handlers.c index ee79d1ff90..017d9dce9c 100644 --- a/sys/suit/v4/handlers.c +++ b/sys/suit/v4/handlers.c @@ -85,8 +85,7 @@ static int _cond_comp_offset(suit_v4_manifest_t *manifest, int key, nanocbor_val (void)key; uint32_t offset; nanocbor_get_uint32(it, &offset); - uint32_t other_offset = (uint32_t)riotboot_slot_get_hdr(riotboot_slot_other()) \ - - CPU_FLASH_BASE; + uint32_t other_offset = (uint32_t)riotboot_slot_offset(riotboot_slot_other()); LOG_INFO("Comparing manifest offset %u with other slot offset %u\n", (unsigned)offset, (unsigned)other_offset); return other_offset == offset ? 0 : -1;