pimoroni / picosystem

PicoSystem libraries and examples.
MIT License
145 stars 33 forks source link

[MicroPython] Calling init() puts system into a bad state #99

Closed menehune23 closed 6 months ago

menehune23 commented 6 months ago

So, I was tinkering with my PicoSystem while looking over the MicroPython code. I noticed a function called init(), and I was curious if it was similar to start(). Now, my screen just flashes and goes back off, and I can't get my PicoSystem into a state where I can load new code on it. How can I remove the existing main.py?

Whether or not I can fix this, it seems that the MicroPython API could be updated to keep this from happening in case other folks accidentally do the same thing.

menehune23 commented 6 months ago

I had a theory that calling init() from the user's main.py would trigger an infinite loop. Turned out that was true. I was able to break the loop by hacking this repo's boot.py. See https://github.com/menehune23/picosystem/pull/1 for the solution. Hopefully this can help others if they run into the same thing.

I do think some sort of protection against this would be a nice addition.

menehune23 commented 6 months ago

I'll also note that the reason I thought it was OK to call init() is that it's documented in the API cheatsheet, and it's not clear that it's only for C++, based on that page.