Modbus Master component causes panic when writing to flash

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

Modbus Master component causes panic when writing to flash

Postby maldus » Sat Jan 23, 2021 11:57 am

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.

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus Master component causes panic when writing to flash

Postby ESP_alisitsyn » Thu Jan 28, 2021 1:03 pm

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.
Last edited by ESP_alisitsyn on Tue Feb 09, 2021 7:52 am, edited 1 time in total.

maldus
Posts: 83
Joined: Wed Jun 06, 2018 1:41 pm

Re: Modbus Master component causes panic when writing to flash

Postby maldus » Sat Jan 30, 2021 8:58 am

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.
Attachments
sdkconfig.7z
(5.19 KiB) Downloaded 255 times

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus Master component causes panic when writing to flash

Postby ESP_alisitsyn » Mon Feb 08, 2021 8:59 pm

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.
Attachments
bugfix_backport_latest_modbus_fixes_v40.zip
modbus fix for release/v4.0 branch
(43.03 KiB) Downloaded 282 times
simple_modbus_fixesv40_.zip
simple modbus project with integrated patch
(186.53 KiB) Downloaded 265 times

ESP_alisitsyn
Posts: 203
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus Master component causes panic when writing to flash

Postby ESP_alisitsyn » Tue Feb 23, 2021 3:56 pm

Hi @maldus,

Do you have any results update?

Thanks.

Who is online

Users browsing this forum: HamGuy, OSCPUDEV and 106 guests