From 25482ba0d8c65b8413ef0b037a25aee9faa1bf94 Mon Sep 17 00:00:00 2001 From: Robin GAY <83076779+RobinGTM@users.noreply.github.com> Date: Mon, 10 Jul 2023 22:44:25 +0200 Subject: [PATCH] flash.c: fix write error for STM32H72x (#78) flash.c: fix write error for STM32H72x Add a flash lock/unlock sequence after erasing and before writing to the flash memory Signed off by: Robin Gay --- src/stm32/flash.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stm32/flash.c b/src/stm32/flash.c index ee0a711..50332ee 100644 --- a/src/stm32/flash.c +++ b/src/stm32/flash.c @@ -218,9 +218,15 @@ flash_write_block(uint32_t block_address, uint32_t *data) unlock_flash(); // Erase page - if (need_erase) + if (need_erase) { erase_page(page_address); + // avoid triggering STM32H72xx write security + if (CONFIG_MACH_STM32H7) { + lock_flash(); + unlock_flash(); + } + } // Write block write_block(block_address, data);