Skip to content

Commit

Permalink
drivers: flash: stm32h7x: Fix wrong flash write offset
Browse files Browse the repository at this point in the history
The flash_stm32_write_range() function of the STM32H7x flash
driver partially uses a wrong flash program word size for certain
SOC types when calculating the flash write offset. If the used
SOC is not having a flash program word size of 256 bits / 32 bytes
the written data might get corrupted, as the flash write offset
value does not match the number of bytes that were actually
written.

Fixes zephyrproject-rtos#45568

Signed-off-by: Christoph Heller <[email protected]>
  • Loading branch information
chrihell authored and laxiLang committed May 30, 2022
1 parent f21ebaf commit 839abdc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/flash/flash_stm32h7x.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset,
const uint8_t nbytes = FLASH_NB_32BITWORD_IN_FLASHWORD * 4;
uint8_t unaligned_datas[nbytes];

for (i = 0; i < len && i + 32 <= len; i += 32, offset += 32U) {
for (i = 0; i < len && i + nbytes <= len; i += nbytes, offset += nbytes) {
rc = write_ndwords(dev, offset,
(const uint64_t *) data + (i >> 3),
ndwords);
Expand Down

0 comments on commit 839abdc

Please sign in to comment.