Syntax Error



  • Is there anyway to trap a 'syntax error' from boot.py & use it to redirect program execution to main.py?



  • @kjm have you checked this thread: https://forum.pycom.io/topic/3705/lopy4-exp-board-syntax-error-after-deepsleep

    Apparently there were changed in a previous version of the firmware (possibly linked to underlying ESP-IDF changes) that supposedly fixed the issue, but there seems to be a difference between FAT and LittleFS.

    Also you’ll find references to use of wdt_on_boot and try ... except.

    If none of those work you may want to try other firmware versions to see if that helps, or maybe another GPy to make sure it’s not just the one you have which is faulty.



  • @jcaron Fairly sure it's not power supply related. Do you know if there is a micropython command I can use to identify which program is actually running, boot.py or main.py?



  • @kjm said in Syntax Error:

    @jcaron In my RPi days I had a hook file that started 2 programs on power up, the sensor reading/server communicating central program and a 2nd internet governance program that rebooted the Pi if server comms ceased (usually because the central program froze). Is it possible to do something similar on the gpy?

    If you mean restart the GPy if things go awry, then that would be the task of the WDT (watchdog timer), but if your issue is that the code that could set up the WDT doesn't even run, then obviously that doesn't meet your needs. You could add that to frozen byte code, though, if that one runs correctly.

    But, again, how is you GPy powered? Many power supplies are just not adapted to the current spike on boot.



  • @jcaron In my RPi days I had a hook file that started 2 programs on power up, the sensor reading/server communicating central program and a 2nd internet governance program that rebooted the Pi if server comms ceased (usually because the central program froze). Is it possible to do something similar on the gpy?



  • @kjm I I think we’ve seen reports of very similar issues in the past. Too lazy to search the forum, but it’s quite likely it was related to a power issue in most cases.

    How is your module powered? There’s usually a pretty big spike in current at boot and not all power supplies can handle that correctly.



  • @kjm There are two other scripts which are executed before boot.py. These are _boot.py and _main.py or _main_pybytes,. They are embedded into the flash. With the new pybytes firmware, _main_pybytes.py is pretty large and imports even more core. See https://github.com/pycom/pycom-micropython-sigfox/tree/Dev/esp32/frozen/Pybytes
    But still it should be create an syntax error. SInce it does and the lines are random, I would consider a hardware or power supply related fault.



  • @robert-hh I've got everything wrapped in try/except Rob. But every so often the gpy wakes from deepsleep & announces a syntax error at some random line where there wasn't one before. This happens before boot.py actually runs. It's almost like the micropython is compiled rather than interpreted.



  • @kjm try/except also catches syntax errors.


Log in to reply
 

Pycom on Twitter