summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com>2024-01-20 13:00:52 +0100
committernightwalker-87 <15526941+Nightwalker-87@users.noreply.github.com>2024-01-20 13:00:52 +0100
commit0145baeb2e3bac31bf9d3cbd0dab38d70618d46b (patch)
tree70fc7d329e00fa1f0c71807202c5b8b262e8f94f
parent8c581c3eec91248de028c332a06ea276bbb2e969 (diff)
Fixed memory alignment for STM32L5/U5/H5 chips
(Closes #1362)
-rw-r--r--src/stlink-lib/common_flash.c2
-rw-r--r--src/stlink-lib/flash_loader.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/stlink-lib/common_flash.c b/src/stlink-lib/common_flash.c
index 6a519f1..aa8db5b 100644
--- a/src/stlink-lib/common_flash.c
+++ b/src/stlink-lib/common_flash.c
@@ -1140,7 +1140,7 @@ int32_t stlink_erase_flash_page(stlink_t *sl, stm32_addr_t flashaddr) {
// set bank 1 for erasure
val &= ~(1 << FLASH_L5_NSCR_NSBKER);
}
- // sec 7.9.9 for U5, 6.9.9 for L5 (for L7 we have 7 bits instead 8 bits for U5 but
+ // sec 7.9.9 for U5, 6.9.9 for L5 (for L7 we have 7 bits instead of 8 bits for U5 but
// the bit position for 8th bit reserved.
// Maybe the best solution is to handle each one separately.
val &= ~(0xFF << 3);
diff --git a/src/stlink-lib/flash_loader.c b/src/stlink-lib/flash_loader.c
index 9511c92..16c717c 100644
--- a/src/stlink-lib/flash_loader.c
+++ b/src/stlink-lib/flash_loader.c
@@ -748,6 +748,11 @@ int32_t stlink_flashloader_write(stlink_t *sl, flash_loader_t *fl, stm32_addr_t
sl->flash_type == STM32_FLASH_TYPE_G4 ||
sl->flash_type == STM32_FLASH_TYPE_L5_U5_H5 ||
sl->flash_type == STM32_FLASH_TYPE_C0) {
+
+ if (sl->flash_type == STM32_FLASH_TYPE_L5_U5_H5 && (len % 16)) {
+ WLOG("Data size is aligned to 16 byte");
+ len += 16 - len%16;
+ }
DLOG("Starting %3u page write\n", len / sl->flash_pgsz);
for (off = 0; off < len; off += sizeof(uint32_t)) {
uint32_t data;