Pytrack i2c causes system to freeze

  • Hi,
    I'm trying to connect a GPy to a Pytrack, check GPS and battery, run some other code, then turn the pytrack and gpy off.
    Half of the time I'm getting I2c errors, garbage GPS output and battery readings, but those I can try/catch.
    The problem I can't wrap my head around are random freezes when initializing the pytrack.
    Those cause the entire board to cease function with only a reset returning it to working condition.

    This is the code that causes the freeze. I try to initialize as shown in the documentation with an added try / catch / repeat if there are i2c errors which is the case most of the time.
    This is ~10s after starting, since waiting to init i2c helped for others. I also tried to reinstall the pytrack firmware, gpy firmware and tried a wipy and another gpy instead, all with the code freshly uploaded.

    def initPyCoProc():
        global py
        pydone = False # is the init successful and done?
        while not pydone:
                py = Pytrack() # init happens here, freeze also.
                pydone = True
                print("pytrack init success")
            except Exception as e: # try to catch whatever causes the connection to fail
                time.sleep(2) # try again after 2 seconds
        py.gps_state(gps=True) # unrelated function added to pycoproc lib to turn gps on / off independently. No effect on freeze behavior if removed

    The only thing that can stop the freeze is a manual reset or one through a WDT. I'd like to not have to add WDT code through my entire codebase.

    Are there any known solutions for this apart from the somewhat hacky watchdog timer reset? Is there any known reason for this behavior?
    Ideally, I'd like my code to run reliably...

  • This post is deleted!

  • @crumble Thanks, it seems to be more stable with the new firmware. Pybytes is a whole new rabbit hole of problems though. I might try @andreas firmware later.

    It would be really nice to have more documentation from pycom regarding the versions and differences, as well as all functions of their various libraries while we're at it.

  • @Peter-Ehses

    This is not the latest one. You will get 1.20.1(r1) only if you choose the pybytes option.

    Version 1.20.0.x is based on IDF 3.1, version 1.20.1 on IDF 3.2.
    IDF is the development environment from Xtensa for its ESP32 microcontroler. Version 3.2 fixed a lot of issues regarding i2c. With 1.20.0.x I got a lot of garbage from the L76 as well.

    You will get 1.20.1 from pycom only when you select pybytes. No account needed.
    Not all users liked the pybyte behaviour and compiled their own firmware. @andreas hosts some of them.

  • @crumble the lastest firmware I see in the pycom firmware update tool (dev builds enabled or not) is 1.20.0rc13
    I don't see a newer version here either.
    My Pytrack is on firmware 0.0.8 which seems to be the latest.
    Did you flash from a file or would this be due to differences between lopy and gpy?

  • Since version 1.20.1(r1)? my communication problems between LoPy and pytrack are gone.

    There is only one left, which seems to be related to the L76. Init fails sometimes. In this case I have to reboot the L76. Cause you cannot communicate with the chip, you have to cut the power supply . Either manually or by calling the pytracks deepsleep method with GPS parameter.

Log in to reply

Pycom on Twitter