[riot-notifications] [RIOT-OS/RIOT] esp8266: Hangs when erasing spi sector on mtd0 if using esp_wifi (#16281)

iosabi notifications at github.com
Tue Apr 6 00:20:27 CEST 2021

Maybe @gschorcht has some info.

#### Debugging
I enabled `ENABLE_DEBUG` in `cpu/esp_common/periph/flash.c` and I can see that the device hangs in the erase function. Adding a few printf I see that it always hangs inside `spi_flash_erase_sector`.

My guess is that this is related to a WiFi-related ISR triggering while we are waiting for the flash to erase a block. Erasing a block happens in the ROM function `SPI_sector_erase`, which is inside a block of `Cache_Read_Disable_2` and `Cache_Read_Enable_2` when called from `spi_flash_erase_sector`.

I listed the ISR handlers in the `_xt_interrupt_table` and handlers 8 (ETS_WDT_INUM, registered to `esp_task_wdt_isr`) and 10 (registered to ets_timer_handler_dsr) are the only ones in 0x402xxxxx address range (IROM - flash), while others are in IRAM. I don't know if this makes a difference.

I replaced ISR 10 with a wrapper in IRAM that raises a GPIO, then calls the original handler and then lowers the GPIO after returning from the handler. I can see ISR 10 firing every 100ms in the esp_wifi case. This doesn't occur at all when esp_wifi module is not compiled (the ISR 10 is also not registered to anything). 

My guess would be that the CPU is trying to execute something from flash (IROM) but the flash is disabled / not mapped or something like that which causes the CPU to stall, and my guess would be that this code is the ISR 10; however I don't see the GPIO high when the CPU hangs which would indicate that's not inside the ISR 10.

Any other idea of where could it be hanging? I couldn't get the JTAG debugger to work so I don't know what's the CPU doing before WDT triggers. I'll try to debug a bit more but I'm out of ideas.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210405/a26b9f44/attachment-0001.htm>

More information about the notifications mailing list