bitluni / ESP32Lib

http://bitluni.net/esp32-vga/
451 stars 79 forks source link

Interrupt modes crash when accessing SPIFFS or Wifi #39

Closed Martin-Laclaustra closed 3 years ago

Martin-Laclaustra commented 4 years ago

Dear Matthias, thank you for all your work. You have been an inspiration for my interest in microcontrollers.

The part of your code that uses DMA interrupt works if used alone, but crashes when using SPIFFS and/or wifi, which is a big limitation for their use. Your appreciation of the problem in #31 ("interrupt based version of the driver [...] needs a lot of cpu power") was no spot-on this time. I tested it this way: initialized/connected SPIFFS or Wifi (with server) before vga.init. The microcontroller was stable (occasional crash) until a request to the server was done, or SPIFFS was accessed File root = FILESYSTEM.open("/","r");. Then, an exception was raised: Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed) The exception decoder showed that flash was being accessed (through SPI) (also happened in wifi usage, without SPIFFS), and the conflict was in the static function interrupt of the I2S object. All documentation of the error pointed to lack of use of IRAM attribute for functions and DRAM for consts.

I tracked this error to several problems:

I worked out a solution, which is implemented in pull request #37. Unfortunately wifi usage caused losing vSync and the screen needed some seconds to recover. Thus, I further worked on a solution, to make hSync and vSync independent of the rendering routine in the interrupt, which is implemented in pull request #38. (You can ignore the previous pull request, which is there to provide you with understanding of the changes) This code suffers only almost imperceptible glitches during wifi usage.

I hope that you find these changes interesting and worthwhile.

By the way, VGA6BitI had an error in https://github.com/bitluni/ESP32Lib/blob/222d95318fc5c61033dbdbd92c56f8a7d3a60129/src/VGA/VGA6BitI.h#L150 which is also fixed.

Martin-Laclaustra commented 3 years ago

This is included in the "development" branch here and eventually it will be merged into "master".