1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

sys/suit: avoid installing payload twice

This commit is contained in:
Francisco Molina 2021-08-17 14:11:33 +02:00
parent c032e40fba
commit e66ad95c4c
2 changed files with 10 additions and 3 deletions

View File

@ -196,7 +196,8 @@ typedef struct {
#define SUIT_COMPONENT_STATE_FETCHED (1 << 0) /**< Component is fetched */
#define SUIT_COMPONENT_STATE_FETCH_FAILED (1 << 1) /**< Component fetched but failed */
#define SUIT_COMPONENT_STATE_VERIFIED (1 << 2) /**< Component is verified */
#define SUIT_COMPONENT_STATE_FINALIZED (1 << 3) /**< Component successfully installed */
#define SUIT_COMPONENT_STATE_INSTALLED (1 << 3) /**< Component is installed, but has not been verified */
#define SUIT_COMPONENT_STATE_FINALIZED (1 << 4) /**< Component successfully installed */
/** @} */
/**

View File

@ -488,8 +488,14 @@ static int _dtv_verify_image_match(suit_manifest_t *manifest, int key,
LOG_INFO("Starting digest verification against image\n");
res = _validate_payload(comp, digest, img_size);
if (res == SUIT_OK) {
LOG_INFO("Install correct payload\n");
suit_storage_install(comp->storage_backend, manifest);
if (!suit_component_check_flag(comp, SUIT_COMPONENT_STATE_INSTALLED)) {
LOG_INFO("Install correct payload\n");
suit_storage_install(comp->storage_backend, manifest);
suit_component_set_flag(comp, SUIT_COMPONENT_STATE_INSTALLED);
}
if (suit_component_check_flag(comp, SUIT_COMPONENT_STATE_INSTALLED)) {
LOG_INFO("Verified installed payload\n");
}
}
else {
LOG_INFO("Erasing bad payload\n");