drivers: flash: flash_stm32h7x: Fix STM32H7 unaligned read access

Due to source data pointer having no alignment constraint,
extra care needs to be taken when reading source data
as dword

Signed-off-by: Tomislav Milkovic <tomislav.milkovic95@gmail.com>
This commit is contained in:
Tomislav Milkovic 2023-06-15 10:57:04 +02:00 committed by Carles Cufí
commit 96869ff3ff

View file

@ -343,7 +343,8 @@ static int write_ndwords(const struct device *dev,
/* Perform the data write operation at the desired memory address */
for (i = 0; i < n; ++i) {
flash[i] = data[i];
/* Source dword may be unaligned, so take extra care when dereferencing it */
flash[i] = UNALIGNED_GET(data + i);
/* Flush the data write */
barrier_dsync_fence_full();