From 53ce5aa3ddf17e588b245f0ab29e18073505684b Mon Sep 17 00:00:00 2001 From: Bruno Randolf Date: Thu, 20 Sep 2018 16:38:14 +0100 Subject: [PATCH] stm32:l4:flash: Fix option bytes programming FLASH_CR_OPTSTRT needs to be written to FLASH_CR, and there is no reason to mask the last two data bits. Signed-off-by: Bruno Randolf Reviewed-by: Karl Palsson (original code appeared to be badly copied from the flash_common_f24 codebase) --- lib/stm32/l4/flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stm32/l4/flash.c b/lib/stm32/l4/flash.c index 6381197b..2aff56a6 100644 --- a/lib/stm32/l4/flash.c +++ b/lib/stm32/l4/flash.c @@ -196,8 +196,8 @@ void flash_program_option_bytes(uint32_t data) flash_unlock_option_bytes(); } - FLASH_OPTR = data & ~0x3; - FLASH_OPTR |= FLASH_CR_OPTSTRT; + FLASH_OPTR = data; + FLASH_CR |= FLASH_CR_OPTSTRT; flash_wait_for_last_operation(); } /**@}*/