From 9e3ad13d5e8c966031601d2cda102935871813a6 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Wed, 11 Dec 2019 18:30:51 +0100 Subject: [PATCH] TARGET_STM: fix flash api 64bit address alignment on L4 and WB --- targets/TARGET_STM/TARGET_STM32L4/flash_api.c | 2 +- targets/TARGET_STM/TARGET_STM32WB/flash_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32L4/flash_api.c b/targets/TARGET_STM/TARGET_STM32L4/flash_api.c index 534894f08a..826e15e696 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/flash_api.c +++ b/targets/TARGET_STM/TARGET_STM32L4/flash_api.c @@ -205,7 +205,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, /* HW needs an aligned address to program flash, which data * parameters doesn't ensure */ - if ((uint32_t) data % 4 != 0) { + if ((uint32_t) data % 8 != 0) { volatile uint64_t data64; while ((address < (StartAddress + size)) && (status == 0)) { for (uint8_t i = 0; i < 8; i++) { diff --git a/targets/TARGET_STM/TARGET_STM32WB/flash_api.c b/targets/TARGET_STM/TARGET_STM32WB/flash_api.c index 3be8ad9248..8e708724d8 100644 --- a/targets/TARGET_STM/TARGET_STM32WB/flash_api.c +++ b/targets/TARGET_STM/TARGET_STM32WB/flash_api.c @@ -154,7 +154,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data, StartAddress = address; /* HW needs an aligned address to program flash, which data parameters doesn't ensure */ - if ((uint32_t) data % 4 != 0) { // Data is not aligned, copy data in a temp buffer before programming it + if ((uint32_t) data % 8 != 0) { // Data is not aligned, copy data in a temp buffer before programming it volatile uint64_t data64; while ((address < (StartAddress + size)) && (status == 0)) { for (uint8_t i = 0; i < 8; i++) {