Skip to content

Commit 2777cc0

Browse files
ahasztagtomchy
authored andcommitted
suit: Fix IPUC cache issues
In a specific case (len == CACHE_ALIGNMENT) and unaligned address an aligned write was (incorrectly) performed, resulting in an error. Signed-off-by: Artur Hadasz <[email protected]>
1 parent 058612c commit 2777cc0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/flash/flash_ipuc/flash_ipuc.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,19 +121,19 @@ static int nrf_ipuc_write(const struct device *dev, off_t offset, const void *da
121121
return 0;
122122
}
123123

124-
/* Optimize: Use a single write call if all bytes can be transferred using stack-based
125-
* aligned buffer.
126-
*/
127-
if (len <= ARRAY_SIZE(unaligned_data_buf)) {
128-
unaligned_len = len;
129-
}
130-
131124
/* If the data buffer is not aligned to the cache lines:
132125
* - copy the unaligned part into stack-based aligned buffer
133126
* - write the internal buffer
134127
* - skip the unaligned bytes of the input buffer
135128
*/
136129
if (unaligned_len != CACHE_ALIGNMENT) {
130+
/* Optimize: Use a single write call if all bytes can be transferred using
131+
* stack-based aligned buffer.
132+
*/
133+
if (len <= ARRAY_SIZE(unaligned_data_buf)) {
134+
unaligned_len = len;
135+
}
136+
137137
memcpy(unaligned_data_buf, data, unaligned_len);
138138

139139
LOG_DBG("align: %p:%zu", (void *)data, unaligned_len);

subsys/suit/stream/stream_sinks/src/suit_dfu_cache_sink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ suit_plat_err_t suit_dfu_cache_sink_get(struct stream_sink *sink, uint8_t cache_
4444

4545
if (suit_dfu_cache_rw_device_info_get(cache_partition_id, &device_info) !=
4646
SUIT_PLAT_SUCCESS) {
47-
return SUIT_PLAT_ERR_NOT_FOUND;
47+
return SUIT_PLAT_ERR_UNSUPPORTED;
4848
}
4949

5050
suit_plat_err_t ret = SUIT_PLAT_SUCCESS;

0 commit comments

Comments
 (0)