|
@@ -69,6 +69,26 @@ static int cmp_or_dump(const void *a, const void *b, size_t len)
|
|
|
return r;
|
|
return r;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static void IRAM_ATTR fix_rom_func(void)
|
|
|
|
|
+{
|
|
|
|
|
+#ifdef CONFIG_IDF_TARGET_ESP32S2
|
|
|
|
|
+ esp_rom_spiflash_read_mode_t read_mode;
|
|
|
|
|
+# if defined CONFIG_ESPTOOLPY_FLASHMODE_QIO
|
|
|
|
|
+ read_mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
|
|
|
|
+# elif defined CONFIG_ESPTOOLPY_FLASHMODE_QOUT
|
|
|
|
|
+ read_mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
|
|
|
|
+# elif defined CONFIG_ESPTOOLPY_FLASHMODE_DIO
|
|
|
|
|
+ read_mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
|
|
|
|
+# elif defined CONFIG_ESPTOOLPY_FLASHMODE_DOUT
|
|
|
|
|
+ read_mode = ESP_ROM_SPIFLASH_DOUT_MODE;
|
|
|
|
|
+# endif
|
|
|
|
|
+ //Currently only call this can fix the rom_read issue, maybe we need to call more functions (freq, dummy, etc) in the future
|
|
|
|
|
+ spi_flash_disable_interrupts_caches_and_other_cpu();
|
|
|
|
|
+ esp_rom_spiflash_config_readmode(read_mode);
|
|
|
|
|
+ spi_flash_enable_interrupts_caches_and_other_cpu();
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void IRAM_ATTR test_read(int src_off, int dst_off, int len)
|
|
static void IRAM_ATTR test_read(int src_off, int dst_off, int len)
|
|
|
{
|
|
{
|
|
|
uint32_t src_buf[16];
|
|
uint32_t src_buf[16];
|
|
@@ -161,6 +181,8 @@ static void IRAM_ATTR test_write(int dst_off, int src_off, int len)
|
|
|
}
|
|
}
|
|
|
ESP_ERROR_CHECK(spi_flash_write(start + dst_off, src_buf + src_off, len));
|
|
ESP_ERROR_CHECK(spi_flash_write(start + dst_off, src_buf + src_off, len));
|
|
|
|
|
|
|
|
|
|
+ fix_rom_func();
|
|
|
|
|
+
|
|
|
spi_flash_disable_interrupts_caches_and_other_cpu();
|
|
spi_flash_disable_interrupts_caches_and_other_cpu();
|
|
|
esp_rom_spiflash_result_t rc = esp_rom_spiflash_read(start, dst_buf, sizeof(dst_buf));
|
|
esp_rom_spiflash_result_t rc = esp_rom_spiflash_read(start, dst_buf, sizeof(dst_buf));
|
|
|
spi_flash_enable_interrupts_caches_and_other_cpu();
|
|
spi_flash_enable_interrupts_caches_and_other_cpu();
|