Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d0c0028

Browse files
committedMar 20, 2025·
suit: Do not erase on IPUC write setup
Erasing of the IPUC took about 500ms of time, which led to many issues. The erasing was removed, instead different security measures were introduced, erasing parts when the seek offset is greater than the write peek offset. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent 634e1bb commit d0c0028

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed
 

‎subsys/suit/ipuc/src/suit_ipuc_sdfw.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,6 @@ suit_plat_err_t suit_ipuc_sdfw_write_setup(int ipc_client_id, struct zcbor_strin
297297
suit_plat_digest_cache_remove(component_id);
298298
#endif /* CONFIG_SUIT_DIGEST_CACHE */
299299

300-
if (ipuc_sink.erase == NULL ||
301-
ipuc_sink.erase(ipuc_sink.ctx) != SUIT_PLAT_SUCCESS) {
302-
LOG_ERR("Erase operation not supported or failed");
303-
if (ipuc_sink.release) {
304-
ipuc_sink.release(ipuc_sink.ctx);
305-
}
306-
k_mutex_unlock(&ipuc_mutex);
307-
return SUIT_PLAT_ERR_IO;
308-
}
309300

310301
if (ipuc_sink.release) {
311302
ipuc_sink.release(ipuc_sink.ctx);
@@ -371,6 +362,21 @@ suit_plat_err_t suit_ipuc_sdfw_write(int ipc_client_id, struct zcbor_string *com
371362
return SUIT_PLAT_ERR_IO;
372363
}
373364

365+
if ((ipuc_sink.write != NULL) && (offset > ipuc_entry->write_peek_offset)) {
366+
/* Erasing if necessary
367+
*/
368+
uint8_t erase_buffer[READ_CHUNK_MAX_SIZE] = {
369+
[0 ... READ_CHUNK_MAX_SIZE - 1] = 0xFF
370+
};
371+
372+
ipuc_sink.seek(ipuc_sink.ctx, ipuc_entry->write_peek_offset);
373+
for (size_t i = ipuc_entry->write_peek_offset; i < offset;
374+
i += READ_CHUNK_MAX_SIZE) {
375+
ipuc_sink.write(ipuc_sink.ctx, (uint8_t *)erase_buffer,
376+
MIN(sizeof(erase_buffer), slot_size - i));
377+
}
378+
}
379+
374380
if (ipuc_sink.seek == NULL ||
375381
ipuc_sink.seek(ipuc_sink.ctx, offset) != SUIT_PLAT_SUCCESS) {
376382
LOG_ERR("Seek operation not supported or failed");

0 commit comments

Comments
 (0)
Please sign in to comment.