From c5c7d2b4f26f52f1dfb425ebde83328606b65d4f Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Fri, 11 Feb 2022 12:27:29 -0800 Subject: [PATCH] [BACKPORT] stm32h7:flash can not use usleep commit 328374f4658d11655f268f968f4c6c7a3942f320 changed the wait to use usleep. This killed the write performace from the published values in the datasheet of ~100 us to 2 mS per 256 bits. On a 1000 per tick config. It can be 10 X worse on the default 100 per tick config. This changes uses up_udelay. --- arch/arm/src/stm32h7/stm32_flash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32h7/stm32_flash.c b/arch/arm/src/stm32h7/stm32_flash.c index 7b1a008d3a2..0ec5d8f75b0 100644 --- a/arch/arm/src/stm32h7/stm32_flash.c +++ b/arch/arm/src/stm32h7/stm32_flash.c @@ -155,7 +155,7 @@ #define PROGMEM_NBLOCKS STM32_FLASH_NBLOCKS #define FLASH_NPAGES (STM32_FLASH_SIZE / FLASH_PAGE_SIZE) -#define FLASH_TIMEOUT_VALUE 500000 /* 5s */ +#define FLASH_TIMEOUT_VALUE 5000000 /* 5s */ /**************************************************************************** * Private Types @@ -429,7 +429,7 @@ static int stm32h7_wait_for_last_operation(FAR struct stm32h7_flash_priv_s break; } - usleep(1000); + up_udelay(1); } if (timeout)