Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    stuck in endless deep sleep loop, unable to access serial or reflash firmware

    Scheduled Pinned Locked Moved Discussion
    deep sleeplopymicropython
    7 Posts 3 Posters 1.8k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • philwilkinsonP Offline
      philwilkinson
      last edited by

      I have copied the Quick Usage Example of sleep onto a Lopy on a PySense (connected power and comms via serial through USB cable) and restarted the board.
      Unfortunately as the sample code runs deepsleep, I have immediately lost access to the serial comms. I am now of course also unable to access the Lopy serial comms (via USB) to stop the endless loop by Ctrl-C...
      Having tried various approaches (Atom Pymakr addin cannot open port, neither can screen, Rshell etc)

      I have given up, and have now been trying to just reflash the firmware.

      However, I cannot even do this as the firmware update tool will not connect to the serial port (while it runs the endless loop...)

      Help! How can I access the board/stop the program/reflash the firmware?

      Another point is how on earth was the Quick Usage Example of sleep expected to work? How was the user expected to access serial comms and read the print statements once the loop ran its first deepsleep and wake loop?

      would appreciate any help on this as I am completely stuck...!

      X 1 Reply Last reply Reply Quote 1
      • X Offline
        Xykon administrators @philwilkinson
        last edited by

        @philwilkinson Did you update the firmware of the Pysense before trying the firmware updater? Have you been able to use the firmware updater before uploading the problematic code?

        Is the com port visible if you plug in the Pysense without any module?

        Christian Ehlers

        1 Reply Last reply Reply Quote 0
        • philwilkinsonP Offline
          philwilkinson
          last edited by philwilkinson

          thanks for responding @Xykon
          Yes, the Pysense firmware is up to date.
          Yes, I used the firmware updater a few hours ago to update the LoPy firmware. It ran fine
          Yes, the firmware updater tool does see the port (dev/ttyACM0) when the module is removed.

          I should also have mentioned that the module appears to be running the Quick usage example of sleep OK too. I know this as when I shake the accelerometer there is a slight delay then a red LED flash.

          robert-hhR X 2 Replies Last reply Reply Quote 1
          • robert-hhR Offline
            robert-hh @philwilkinson
            last edited by robert-hh

            @philwilkinson What happens if you do a safe boot? Tie P12 to 3.3V and reset the device. During a safe boot, boot.py and main.py are ignored.

            philwilkinsonP 1 Reply Last reply Reply Quote 1
            • X Offline
              Xykon administrators @philwilkinson
              last edited by

              @philwilkinson Can you please try the following?

              Plug the Pysense into your computer without the module. Run the firmware updater until you get to the Communication page where you select the serial port. Make sure the correct port is selected. Now select "Erase flash file system" but do not click "Continue" yet.

              Next unplug the Pysense, mount the module (make sure it's aligned correctly), and plug in the USB cable while pressing the reset button next to the RGB LED on the LoPy. Keep pressing the reset button until you select "Continue" in the firmware update tool and you see the message "Please wait, reading information about the board". Now release the reset button and the firmware updater should flash the board and erase all your scripts at the same time. It might take two or three attempts.

              Christian Ehlers

              philwilkinsonP 1 Reply Last reply Reply Quote 1
              • philwilkinsonP Offline
                philwilkinson @robert-hh
                last edited by

                thanks @robert-hh I had completely forgotten the safe boot option. This allowed me to get a serial connection, then amend the code.
                I will put in a check, to allow the user to push the Pysense user button, to not enter the loop, which should solve the problem.

                Another (better) option would be for the ESP32 to confirm if the USB is connected (UART0 uart.any=1 ??) before entering the loop. However I am not sure if you can create uart objects on uart0 bus, like the following. Is there a more elegant way of doing this?

                from machine import UART
                uart=UART(0, 115200)
                if uart.any>0:
                    ## leave the main loop
                else:
                    continue #on with the main loop
                
                1 Reply Last reply Reply Quote 1
                • philwilkinsonP Offline
                  philwilkinson @Xykon
                  last edited by

                  @xykon thanks for this note.
                  In this case I didn't need to reflash the firmware, however I will remember your advice as I am sure to need it soon enough!

                  1 Reply Last reply Reply Quote 1

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post

                  Pycom on Twitter

                  Pycom