|
15 | 15 | #include "suit_ram_sink.h" |
16 | 16 | #include "zcbor_noncanonical_decode.h" |
17 | 17 |
|
| 18 | +#ifdef CONFIG_FLASH_IPUC |
| 19 | +#include <drivers/flash/flash_ipuc.h> |
| 20 | +#endif /* CONFIG_FLASH_IPUC */ |
| 21 | + |
18 | 22 | LOG_MODULE_REGISTER(dfu_cache_helpers, CONFIG_SUIT_LOG_LEVEL); |
19 | 23 |
|
| 24 | +#ifdef CONFIG_FLASH_IPUC |
| 25 | +/* This function returns true if the given cache pool is an IPUC-based cache |
| 26 | + * but is not initialized yet. |
| 27 | + */ |
| 28 | +static bool is_cache_ipuc_uninitialized(struct dfu_cache_pool *cache_pool) |
| 29 | +{ |
| 30 | + uintptr_t ipuc_address; |
| 31 | + size_t ipuc_size; |
| 32 | + bool ipuc_possible = |
| 33 | + flash_cache_ipuc_check((uintptr_t)cache_pool->address, &ipuc_address, &ipuc_size); |
| 34 | + |
| 35 | + if (ipuc_possible) { |
| 36 | + if (flash_ipuc_find((uintptr_t)cache_pool->address, cache_pool->size, &ipuc_address, |
| 37 | + &ipuc_size) == NULL) { |
| 38 | + return true; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + return false; |
| 43 | +} |
| 44 | +#endif /* CONFIG_FLASH_IPUC */ |
| 45 | + |
20 | 46 | suit_plat_err_t suit_dfu_cache_partition_slot_foreach(struct dfu_cache_pool *cache_pool, |
21 | 47 | partition_slot_foreach_cb cb, void *ctx) |
22 | 48 | { |
@@ -49,6 +75,12 @@ suit_plat_err_t suit_dfu_cache_partition_slot_foreach(struct dfu_cache_pool *cac |
49 | 75 | break; |
50 | 76 | } |
51 | 77 |
|
| 78 | +#ifdef CONFIG_FLASH_IPUC |
| 79 | + if (is_cache_ipuc_uninitialized(cache_pool)) { |
| 80 | + return SUIT_PLAT_ERR_CBOR_DECODING; |
| 81 | + } |
| 82 | +#endif /* CONFIG_FLASH_IPUC */ |
| 83 | + |
52 | 84 | err = suit_dfu_cache_memcpy(partition_header_storage, current_address, read_size); |
53 | 85 |
|
54 | 86 | if (err != SUIT_PLAT_SUCCESS) { |
@@ -168,6 +200,12 @@ suit_plat_err_t suit_dfu_cache_partition_is_empty(struct dfu_cache_pool *cache_p |
168 | 200 | const size_t chunk_size = sizeof(buffer); |
169 | 201 | suit_plat_err_t ret = SUIT_PLAT_SUCCESS; |
170 | 202 |
|
| 203 | +#ifdef CONFIG_FLASH_IPUC |
| 204 | + if (is_cache_ipuc_uninitialized(cache_pool)) { |
| 205 | + return SUIT_PLAT_SUCCESS; |
| 206 | + } |
| 207 | +#endif /* CONFIG_FLASH_IPUC */ |
| 208 | + |
171 | 209 | while (remaining > 0) { |
172 | 210 | size_t read_size = MIN(chunk_size, remaining); |
173 | 211 |
|
|
0 commit comments