15
15
#endif
16
16
#include <dfu/suit_dfu.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_target_suit , CONFIG_DFU_TARGET_LOG_LEVEL );
19
23
20
24
#define IS_ALIGNED_32 (POINTER ) (((uintptr_t)(const void *)(POINTER)) % 4 == 0)
@@ -59,19 +63,40 @@ int dfu_target_suit_init(size_t file_size, int img_num, dfu_target_callback_t cb
59
63
return - ENODEV ;
60
64
}
61
65
66
+ device_info .fdev = NULL ;
62
67
if (ENVELOPE_IMAGE_NUMBER == img_num ) {
63
68
/* Get info about dfu_partition to store the envelope */
64
69
err = suit_dfu_partition_device_info_get (& device_info );
65
70
} else {
71
+ #ifdef CONFIG_FLASH_IPUC
72
+ device_info .partition_offset = 0 ;
73
+ device_info .erase_block_size = 1 ;
74
+ device_info .write_block_size = 1 ;
75
+ device_info .fdev = flash_image_ipuc_create (img_num , NULL , NULL ,
76
+ (uintptr_t * )& device_info .mapped_address ,
77
+ & device_info .partition_size );
78
+ if (device_info .fdev != NULL ) {
79
+ LOG_INF ("Found IPUC for image %d (0x%lx, 0x%x)" , img_num ,
80
+ (uintptr_t )device_info .mapped_address , device_info .partition_size );
81
+ }
82
+ #endif /* CONFIG_FLASH_IPUC */
66
83
#ifdef CONFIG_DFU_TARGET_SUIT_CACHE_PROCESSING
67
84
/* Cache partitions ids starts from 0, whereas image number 0 is reserved for
68
85
* dfu_partition. Decrease img_num value by 1 to reach the correct DFU cache
69
86
* partition id.
70
87
*/
71
- err = suit_dfu_cache_rw_device_info_get (img_num - 1 , & device_info );
72
- #else
73
- return - ENOTSUP ;
74
- #endif
88
+ if (device_info .fdev == NULL ) {
89
+ err = suit_dfu_cache_rw_device_info_get (img_num - 1 , & device_info );
90
+ if (device_info .fdev != NULL ) {
91
+ LOG_INF ("Found cache pool %d (0x%lx, 0x%x)" , img_num - 1 ,
92
+ (uintptr_t )device_info .mapped_address ,
93
+ device_info .partition_size );
94
+ }
95
+ }
96
+ #endif /* CONFIG_DFU_TARGET_SUIT_CACHE_PROCESSING */
97
+ if (device_info .fdev == NULL ) {
98
+ return - ENOTSUP ;
99
+ }
75
100
}
76
101
77
102
if (err != SUIT_PLAT_SUCCESS ) {
@@ -140,6 +165,9 @@ int dfu_target_suit_write(const void *const buf, size_t len)
140
165
141
166
int dfu_target_suit_done (bool successful )
142
167
{
168
+ #ifdef CONFIG_FLASH_IPUC
169
+ struct stream_flash_ctx * stream = dfu_target_stream_get_stream ();
170
+ #endif /* CONFIG_FLASH_IPUC */
143
171
stream_flash_in_use = false;
144
172
145
173
int err = dfu_target_stream_done (successful );
@@ -156,6 +184,11 @@ int dfu_target_suit_done(bool successful)
156
184
LOG_ERR ("suit_dfu_candidate_envelope_stored error %d" , err );
157
185
return err ;
158
186
}
187
+ #ifdef CONFIG_FLASH_IPUC
188
+ } else {
189
+ flash_image_ipuc_release (image_num );
190
+ stream -> fdev = NULL ;
191
+ #endif /* CONFIG_FLASH_IPUC */
159
192
}
160
193
161
194
if (successful ) {
@@ -187,6 +220,9 @@ int dfu_target_suit_schedule_update(int img_num)
187
220
188
221
int dfu_target_suit_reset (void )
189
222
{
223
+ #ifdef CONFIG_FLASH_IPUC
224
+ struct stream_flash_ctx * stream = dfu_target_stream_get_stream ();
225
+ #endif /* CONFIG_FLASH_IPUC */
190
226
int rc = dfu_target_stream_reset ();
191
227
192
228
if (rc != 0 ) {
@@ -196,6 +232,11 @@ int dfu_target_suit_reset(void)
196
232
197
233
int err = suit_dfu_cleanup ();
198
234
235
+ #ifdef CONFIG_FLASH_IPUC
236
+ flash_image_ipuc_release (image_num );
237
+ stream -> fdev = NULL ;
238
+ #endif /* CONFIG_FLASH_IPUC */
239
+
199
240
stream_flash_in_use = false;
200
241
stream_buf_bytes = 0 ;
201
242
image_num = 0 ;
0 commit comments