stm32f2x: Increase options write timeout
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Tue, 4 Oct 2016 11:26:10 +0000 (13:26 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Tue, 4 Oct 2016 15:16:59 +0000 (16:16 +0100)
Large flash parts time out when unlocking. Mass erase time is specified
as 32 seconds worst case for some parts. Automatic mass erase is
probably not using x8 parallelism, though, but a too large timeout
shouldn't hurt.

Also, use the new define instead of hardcoded timeout when mass
erasing.

Change-Id: Ib5af60d52ed7d53277bfe7176c4c44f79d3a26bc
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3738
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nor/stm32f2x.c

index 1acab8222d523be2755332be591ee490abcc0f0d..4d750951ca332e237e4fe3224d0a597bb9dad3e3 100644 (file)
 #define FLASH_ERASE_TIMEOUT 10000
 #define FLASH_WRITE_TIMEOUT 5
 
+/* Mass erase time can be as high as 32 s in x8 mode. */
+#define FLASH_MASS_ERASE_TIMEOUT 33000
+
 #define STM32_FLASH_BASE    0x40023c00
 #define STM32_FLASH_ACR     0x40023c00
 #define STM32_FLASH_KEYR    0x40023c04
@@ -399,8 +402,8 @@ static int stm32x_write_options(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
-       /* wait for completion */
-       retval = stm32x_wait_status_busy(bank, FLASH_ERASE_TIMEOUT);
+       /* wait for completion, this might trigger a security erase and take a while */
+       retval = stm32x_wait_status_busy(bank, FLASH_MASS_ERASE_TIMEOUT);
        if (retval != ERROR_OK)
                return retval;
 
@@ -1257,7 +1260,7 @@ static int stm32x_mass_erase(struct flash_bank *bank)
        if (retval != ERROR_OK)
                return retval;
 
-       retval = stm32x_wait_status_busy(bank, 30000);
+       retval = stm32x_wait_status_busy(bank, FLASH_MASS_ERASE_TIMEOUT);
        if (retval != ERROR_OK)
                return retval;