espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.72k stars 7.3k forks source link

ESP32S3, double flash setup hangs in esp_flash_erase_region(), function rom_spiflash_api_funcs->start(chip) (IDFGH-8613) #10060

Open marbalon opened 2 years ago

marbalon commented 2 years ago

Answers checklist.

IDF version.

v5.0-beta1-427-g4532e6e0b2

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

No response

Development Kit.

Custom board

Power Supply used.

External 5V

What is the expected behavior?

Continue erasing with external flash.

What is the actual behavior?

I have a project with ESP32S3 + LCD 800x480 over RGB + 8MByte PSRAM. ESP-IDF 5.0.

Because I have a problem with refreshing LCD described here https://github.com/espressif/esp-idf/issues/10010

I've decided to add a second flash to my setup and it is W25Q128JVPIM connected to SPI3 - so different than main SPI chip and PSRAM. The problem I'm having now is random hang in the function esp_flash_erase_region() in lines:

esp_rom_printf("==> esp_flash_erase_region start: %d\n\r", __LINE__);
err = rom_spiflash_api_funcs->start(chip); //somtimes this function never return
esp_rom_printf("==> esp_flash_erase_region: %d\n\r", __LINE__);        
if (err != ESP_OK) {
      break;
}
bus_acquired = true;

My application does not use any WiFi/Bluetooth functions, Just UART communication and LCD. What is strange is that it hangs in one task that is kind of a garbage collector for my custom file system, but another task can still read images from this flash.

What is also interesting is that when the flash is initialized I'm erasing all sectors and everything is fine, only in the parallel tasks it seems to be a problem. But in my driver, I can easily switch between external flash partitions and build-in partitions this problem never happened on the main flash.

I saw this issue https://github.com/espressif/esp-idf/issues/9332 but seems to not be related.

Steps to reproduce.

Nothing special here.

Debug Logs.

No response

More Information.

No response

marbalon commented 2 years ago

One more question, because I haven't found the answer to this.

If I'm reading/writing to the same partition from two tasks should I use any mutex/semaphore for this? Or it is sorted out by the partition/SPI flash API ?

I'm asking because I've just found that my task also hangs on function esp_partition_read().

Strange thing is that it was working on the main flash without the problem, the problem is only when we have two chips configuration.

weilian1977 commented 1 year ago

关注一下