This is an automated email from Gerrit.

"Matthijs Kooijman <matth...@stdin.nl>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7613

-- gerrit

commit aeb19ae0246c2491f2f8a6ec95b7cc181baa6842
Author: Matthijs Kooijman <matth...@stdin.nl>
Date:   Thu Apr 27 16:01:49 2023 +0200

    flash/nor/stm32f2x: Require stm32f2x otp enable for write-protecting
    
    The stm32f2x otp enable command sets an internal flag (it does not do
    any hardware unlock) that was already checked for regular writes to OTP
    memory, but not for the lock bytes. Since these are also OTP, it makes
    sense to protect them.
    
    This is a small compatibility change, but since OTP locking has never
    actually worked (and was only fixed recently), nobody should be relying
    on the old behavior.
    
    Change-Id: I5b0068be72bc9c855e04adff2c6b92bc51163674
    Signed-off-by: Matthijs Kooijman <matth...@stdin.nl>

diff --git a/src/flash/nor/stm32f2x.c b/src/flash/nor/stm32f2x.c
index 6b16def8bc..9631a9c50b 100644
--- a/src/flash/nor/stm32f2x.c
+++ b/src/flash/nor/stm32f2x.c
@@ -537,6 +537,11 @@ static int stm32x_otp_protect(struct flash_bank *bank, 
unsigned int first,
 
        assert((first <= last) && (last < bank->num_sectors));
 
+       if (!stm32x_is_otp_unlocked(bank)) {
+               LOG_ERROR("OTP memory bank is disabled for write commands.");
+               return ERROR_FAIL;
+       }
+
        retval = stm32x_unlock_reg(target);
        if (retval != ERROR_OK)
                return retval;

-- 

Reply via email to