You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/03/06 10:13:25 UTC
(nuttx) branch master updated: xtensa/esp32s3: Fix the issue of erasing a wide range of flash sectors
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 09960c5c7d xtensa/esp32s3: Fix the issue of erasing a wide range of flash sectors
09960c5c7d is described below
commit 09960c5c7d31c67424bb271138b859e762f2f2b0
Author: chenwen@espressif.com <ch...@espressif.com>
AuthorDate: Thu Feb 29 15:17:11 2024 +0800
xtensa/esp32s3: Fix the issue of erasing a wide range of flash sectors
Signed-off-by: chenwen@espressif.com <ch...@espressif.com>
---
arch/xtensa/src/esp32s3/esp32s3_spiflash.c | 37 ++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/arch/xtensa/src/esp32s3/esp32s3_spiflash.c b/arch/xtensa/src/esp32s3/esp32s3_spiflash.c
index 87297483c6..3054e60815 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_spiflash.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_spiflash.c
@@ -36,6 +36,7 @@
#include <nuttx/arch.h>
#include <nuttx/init.h>
#include <nuttx/kthread.h>
+#include <nuttx/signal.h>
#include "sched/sched.h"
@@ -730,6 +731,28 @@ static void IRAM_ATTR spiflash_flushmapped(size_t start, size_t size)
}
}
}
+
+/****************************************************************************
+ * Name: spiflash_os_yield
+ *
+ * Description:
+ * Yield to other tasks, called during erase operations.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * None.
+ *
+ ****************************************************************************/
+
+static inline void IRAM_ATTR spiflash_os_yield(void)
+{
+ /* Delay 1 tick */
+
+ useconds_t us = TICK2USEC(1);
+ nxsig_usleep(us);
+}
#endif /* CONFIG_ESP32S3_SPI_FLASH_DONT_USE_ROM_CODE */
/****************************************************************************
@@ -1105,19 +1128,25 @@ int spi_flash_erase_range(uint32_t start_address, uint32_t size)
int ret = OK;
uint32_t addr = start_address;
- spiflash_start();
-
for (uint32_t i = 0; i < size; i += FLASH_SECTOR_SIZE)
{
+ if (i > 0)
+ {
+ spiflash_os_yield();
+ }
+
+ spiflash_start();
wait_flash_idle();
enable_flash_write();
ERASE_FLASH_SECTOR(addr);
addr += FLASH_SECTOR_SIZE;
+ wait_flash_idle();
+ disable_flash_write();
+ spiflash_end();
}
- wait_flash_idle();
- disable_flash_write();
+ spiflash_start();
spiflash_flushmapped(start_address, FLASH_SECTOR_SIZE * size);
spiflash_end();