taskENABLE_INTERRUPTS
/taskDISABLE_INTERRUPTS
causing panic resets on ESP32
#2342
Labels
ESP32
This is only a problem on ESP32-based devices
I'm seeing an issue with interrupts on ESP32, causing panic resets.
My js code is pretty simple:
After a few log lines, I'm seeing the following error dumped
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.
With some cpu register dump and then a reboot.
After some digging, I'm pretty sure the cause to this error are the calls to
taskENABLE_INTERRUPTS()
andtaskDISABLE_INTERRUPTS();
injshInterruptOn
andjshInterruptOff
respectively, under the targets/esp32 implementaion.When I did the following (probably very irresponsible) change locally to the
targets/esp32/jshardware.c
, I stopped getting these panics, and interrupts worked wellgpio_intr_handler
doesn't push a new event ifintr_enabled
is false. this is done only after the interrupt is read and clearedjshInterruptOff
andjshInterruptOn
to changeintr_enabled
instead of callingtaskDISABLE_INTERRUPTS
/taskENABLE_INTERRUPTS
This resulted in consistent operation of interrupts and got the
setWatch
working properly.That said, I guess my code is really naïve, as i'm not too familiar with the internals of the ESP32 libs and parallelism in this specific case.
I guess there's a more elegant solution here, but if this is something you think should be introduced as presented above, I'd be happy to create a PR,.
The text was updated successfully, but these errors were encountered: