Page 1 of 1

Modbus Master component causes panic when writing to flash

Posted: Sat Jan 23, 2021 11:57 am
by maldus
Hello everyone,
I'm looking for some insight on a problem that occurred to me yesterday.
I am working on a custom ESP32 board that needs to have its firmware updated via OTA. I also have a secondary task continuously communicating with another device via Serial Modbus (RS232, master RTU).
I noticed that the OTA procedure was failing due to the ESP32 panicking with the following message : "Guru Meditation Error: Cache disabled but cached memory region accessed". This is normally due to some interrupt executing non-IRAM code during a flash write operation.
I realized that by cancelling the Modbus task during the update procedure everything went smoothly - which is a definitive solution, because I don't need to keep up the updates during firmware upload. However I would like to understand why the Modbus Communication was causing this panic (if that is the culprit), as I was not directly enabling any interrupt for the UART peripheral.

Re: Modbus Master component causes panic when writing to flash

Posted: Thu Jan 28, 2021 1:03 pm
by ESP_alisitsyn
Hello @maldus,

Could you please provide more information about your project:

1. What version of ESP-IDF you are using?
2. Could you provide Modbus and application logs and sdkconfig file?
3. Did you try using some Modbus patches for older release branches (if old version is used)?
4. Are you using the CONFIG_FMB_TIMER_ISR_IN_IRAM to place timer and UART ISR into IRAM?

The Modbus uses the timer group interrupts that can be placed into FLASH or into IRAM memory. The CONFIG_FMB_TIMER_ISR_IN_IRAM=y causes the CONFIG_UART_ISR_IN_IRAM=y and place UART ISR into IRAM. If your interrupt handlers placed into FLASH and you do not disable Modbus while OTA it causes the above issue because flash cache is disabled during update.

Thanks.

Re: Modbus Master component causes panic when writing to flash

Posted: Sat Jan 30, 2021 8:58 am
by maldus
Thank you for your time, @ESP_alisitsyn.
Could you please provide more information about your project:
1. I am on branch `release/v4.0`
2. I attached my sdkconfig. Unfortunately I cannot provide logs, as my application needs to use every available UART
3. No
4. I don't seem to have that config option available; perhaps it was added in a later version?
The Modbus uses the timer group interrupts that can be placed into FLASH or into IRAM memory. The CONFIG_FMB_TIMER_ISR_IN_IRAM=y cases the CONFIG_UART_ISR_IN_IRAM=y and place UART ISR into IRAM. If your interrupt handlers placed into FLASH and you do not disable Modbus while OTA it cases the above issue because flash cache is disabled during update.
That could explain the panic. Again, I can't find those options in the configuration menu (I only have similar options for SPI transactions), so I'm guessing my idf version is too old. Regardless, stopping all modbus operations during the update procedure is a definitive solution for me, so it's not an issue.

Re: Modbus Master component causes panic when writing to flash

Posted: Mon Feb 08, 2021 8:59 pm
by ESP_alisitsyn
Hi @maldus,

This is known bug in the v4.0 which causes the "Guru Meditation Error: Cache disabled but cached memory region accessed".

Please use the patch below to fix this issue and it allows to select "CONFIG_FMB_TIMER_ISR_IN_IRAM".

Please try the patch and let me know if you still have any issues.

Thank you.

Re: Modbus Master component causes panic when writing to flash

Posted: Tue Feb 23, 2021 3:56 pm
by ESP_alisitsyn
Hi @maldus,

Do you have any results update?

Thanks.