Skip to content

Commit

Permalink
Fixed memory alignment for STM32L5/U5/H5 chips
Browse files Browse the repository at this point in the history
(Closes #1362)
  • Loading branch information
Nightwalker-87 committed Jan 20, 2024
1 parent 8c581c3 commit 0145bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/stlink-lib/common_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/stlink-lib/flash_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0145bae

Please sign in to comment.