Skip to content
Permalink
Browse files

drivers: flash: stm32: Fix insufficient wait time

flash_erase cannot erase a page from the STM32xx SOC flash. It seems
that the erase wait time is not enough and against to what the SOC's
datasheet states. As a result this patch doubles the wait time.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
  • Loading branch information...
gon1332 authored and ioannisg committed Jul 4, 2019
1 parent eb57607 commit a1d815ea9bc6fe9c7db5fb16c7bd97fb1f951a15
Showing with 12 additions and 6 deletions.
  1. +12 −6 drivers/flash/flash_stm32.c
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2017 Linaro Limited
* Copyright (c) 2017 BayLibre, SAS.
* Copyright (c) 2019 Centaur Analytics, Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,24 +17,29 @@

/* STM32F0: maximum erase time of 40ms for a 2K sector */
#if defined(CONFIG_SOC_SERIES_STM32F0X)
#define STM32_FLASH_TIMEOUT (K_MSEC(40))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40))
/* STM32F3: maximum erase time of 40ms for a 2K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F3X)
#define STM32_FLASH_TIMEOUT (K_MSEC(40))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(40))
/* STM32F4: maximum erase time of 4s for a 128K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F4X)
#define STM32_FLASH_TIMEOUT (K_MSEC(4000))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000))
/* STM32F7: maximum erase time of 4s for a 256K sector */
#elif defined(CONFIG_SOC_SERIES_STM32F7X)
#define STM32_FLASH_TIMEOUT (K_MSEC(4000))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(4000))
/* STM32L4: maximum erase time of 24.47ms for a 2K sector */
#elif defined(CONFIG_SOC_SERIES_STM32L4X)
#define STM32_FLASH_TIMEOUT (K_MSEC(25))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25))
/* STM32WB: maximum erase time of 24.5ms for a 4K sector */
#elif defined(CONFIG_SOC_SERIES_STM32WBX)
#define STM32_FLASH_TIMEOUT (K_MSEC(25))
#define STM32_FLASH_MAX_ERASE_TIME (K_MSEC(25))
#endif

/* Let's wait for double the max erase time to be sure that the operation is
* completed.
*/
#define STM32_FLASH_TIMEOUT (2 * STM32_FLASH_MAX_ERASE_TIME)

#define CFG_HW_FLASH_SEMID 2

/*

0 comments on commit a1d815e

Please sign in to comment.
You can’t perform that action at this time.