ESP8266 Developer Zone The Official ESP8266 Forum 2017-12-01T05:11:27+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=8581 2017-12-01T05:11:27+08:00 2017-12-01T05:11:27+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8581&p=18488#p18488 <![CDATA[Re: spi_flash_erase_sector() speed]]> Statistics: Posted by blubb — Fri Dec 01, 2017 5:11 am


]]>
2017-11-30T04:38:41+08:00 2017-11-30T04:38:41+08:00 https://bbs.espressif.com:443/viewtopic.php?t=8581&p=18461#p18461 <![CDATA[spi_flash_erase_sector() speed]]>
I've tried to measure spi_flash_erase_sector() speed and I got surprisingly slow results... It takes more than 3000000 to cycles to erase the sector 4096 bytes long. The average value is about 3500000. Assuming we have 80MHz and 4Mb memory full memory erase should take about 50 sec, but esptool does it much faster (10 times I think). Is it really so slow? Most probably I'm doing something wrong (measurement, calculation or wrong function usage). Please, point me out to my mistake.

Code:

uint32_t getCycleCount()
{
   uint32_t ccount;
   __asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount));
   return ccount;
}

#define BEGIN_MEASURE startTime = getCycleCount();
#define PRINT_TIME(x)                           \
   endTime = getCycleCount();                     \
   printf(x);                                 \
   printf("%d \r\n", endTime - startTime);

...
   uint32_t addr = 0x160000;
   portTickType startTime, endTime;
   BEGIN_MEASURE
      if (flashEraseSector((addr / SPI_FLASH_SEC_SIZE)) != SPI_FLASH_RESULT_OK)
         printf("error erase sector\n");
   PRINT_TIME("erase sector: ")

   BEGIN_MEASURE
      if (flashEraseSector((addr / SPI_FLASH_SEC_SIZE)  + 1) != SPI_FLASH_RESULT_OK)
         printf("error erase sector\n");
   PRINT_TIME("erase sector: ")

Statistics: Posted by WickedCode — Thu Nov 30, 2017 4:38 am


]]>