AlexGoodyear / agoodWatch

A TTGO-T-watch-2020 Arduino sketch
MIT License
75 stars 22 forks source link

Guru Mediation Error when returning from function call #9

Closed careyer closed 4 years ago

careyer commented 4 years ago

Hi Alex,

Thank you very much for your awesome work! It really makes for a better TTGO Watch 2020 ;-) I am using your sketch as basis to control my eScooter via Bluetooth Low Energy (BLE) from my wirst.

For some strange reason my code works just fine with v0.4 but it causes Guru Mediation errros all the time in v0.5. I spent dozens and dozens of hours to hunt down the problem already but to no avail. I hope that you might have some ideas where to look at next.

Let me explain what I do:

  1. I added a new "Scooter" menu
  2. The menu is populated with three (on/off) toggle switches (just like the WiFi menu)
  3. Each switch calls a function that sends a BLE command and returns a bool

Now when I trigger a BLE command by using one of the switches the Watch will call the function that sends the BLE command and I can see that the command is successfully sent and takes effect on my eScooter. I can also see that the function is competely processed and as a last thing returns a bool (true). Now the Watch is supposed to switch back to the gui code, update the switch status and happily continue working. However immediatly after returning the "true" the Watch will crash with a Guru Mediation error as follows:

image

As I mentioned the very same code works in v0.4. It somewhat feels like a timing or heap issue. Thanks for your help in advance

Best regards Thomas

AlexGoodyear commented 4 years ago

Mmm, not a lot I can help with really because the exception happens in your new code which you haven't uploaded. The LoadProhibited exception occurs with (as you said) heap access, rouge pointer values and incorrect memory usage. ISRs must be in IRAM for example. I have also experienced similar strange behaviour when running out of standard malloc space whilst manipulating images and had to switch to ps_malloc () instead.