|
25 | 25 | #ifdef CONFIG_SUIT_CACHE_RW |
26 | 26 | #include <suit_dfu_cache_rw.h> |
27 | 27 | #endif |
| 28 | +#ifdef CONFIG_FLASH_IPUC |
| 29 | +#include <drivers/flash/flash_ipuc.h> |
| 30 | +#endif /* CONFIG_FLASH_IPUC */ |
28 | 31 |
|
29 | 32 | #include <zephyr/logging/log.h> |
30 | 33 | LOG_MODULE_DECLARE(suitfu_mgmt, CONFIG_MGMT_SUITFU_LOG_LEVEL); |
@@ -87,27 +90,43 @@ static int suitfu_mgmt_img_upload(struct smp_streamer *ctx) |
87 | 90 | return MGMT_ERR_EINVAL; |
88 | 91 | } |
89 | 92 |
|
| 93 | + device_info.fdev = NULL; |
90 | 94 | if (req.image == 0) { |
91 | 95 | suit_plat_err_t err = suit_dfu_partition_device_info_get(&device_info); |
92 | 96 |
|
93 | 97 | if (err != SUIT_PLAT_SUCCESS) { |
94 | 98 | LOG_ERR("DFU Partition not found"); |
95 | 99 | return MGMT_ERR_ENOENT; |
96 | 100 | } |
97 | | - |
98 | 101 | } else { |
| 102 | +#ifdef CONFIG_FLASH_IPUC |
| 103 | + device_info.partition_offset = 0; |
| 104 | + device_info.erase_block_size = 1; |
| 105 | + device_info.write_block_size = 1; |
| 106 | + device_info.fdev = flash_image_ipuc_create( |
| 107 | + req.image, NULL, NULL, (uintptr_t *)&device_info.mapped_address, |
| 108 | + &device_info.partition_size); |
| 109 | + if (device_info.fdev != NULL) { |
| 110 | + LOG_INF("Found IPUC for image %d (0x%lx, 0x%x)", req.image, |
| 111 | + (uintptr_t)device_info.mapped_address, |
| 112 | + device_info.partition_size); |
| 113 | + } |
| 114 | +#endif /* CONFIG_FLASH_IPUC */ |
99 | 115 | #ifdef CONFIG_SUIT_CACHE_RW |
100 | | - uint32_t cache_pool_id = req.image - 1; |
101 | | - suit_plat_err_t err = |
102 | | - suit_dfu_cache_rw_device_info_get(cache_pool_id, &device_info); |
103 | | - |
104 | | - if (err != SUIT_PLAT_SUCCESS) { |
105 | | - LOG_ERR("Cache pool %d not found", cache_pool_id); |
| 116 | + if (device_info.fdev == NULL) { |
| 117 | + uint32_t cache_pool_id = req.image - 1; |
| 118 | + suit_plat_err_t err = suit_dfu_cache_rw_device_info_get( |
| 119 | + cache_pool_id, &device_info); |
| 120 | + |
| 121 | + if (err != SUIT_PLAT_SUCCESS) { |
| 122 | + LOG_ERR("Cache pool %d not found", cache_pool_id); |
| 123 | + return MGMT_ERR_ENOENT; |
| 124 | + } |
| 125 | + } |
| 126 | +#endif /* CONFIG_SUIT_CACHE_RW */ |
| 127 | + if (device_info.fdev == NULL) { |
106 | 128 | return MGMT_ERR_ENOENT; |
107 | 129 | } |
108 | | -#else |
109 | | - return MGMT_ERR_ENOENT; |
110 | | -#endif |
111 | 130 | } |
112 | 131 |
|
113 | 132 | if (req.size > device_info.partition_size) { |
@@ -165,9 +184,12 @@ static int suitfu_mgmt_img_upload(struct smp_streamer *ctx) |
165 | 184 | LOG_INF("Candidate envelope stored"); |
166 | 185 | rc = suitfu_mgmt_candidate_envelope_stored(); |
167 | 186 | } else { |
168 | | - uint32_t cache_pool_id = image_id - 1; |
169 | | - |
170 | | - LOG_INF("Cache pool %d updated with RAW image", cache_pool_id); |
| 187 | + uint32_t cache_pool_id = req.image - 1; |
| 188 | +#ifdef CONFIG_FLASH_IPUC |
| 189 | + flash_image_ipuc_release(image_id); |
| 190 | +#endif /* CONFIG_FLASH_IPUC */ |
| 191 | + LOG_INF("Cache pool %d or image %d updated with RAW image", |
| 192 | + cache_pool_id, req.image); |
171 | 193 | } |
172 | 194 |
|
173 | 195 | image_size = 0; |
|
0 commit comments