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

    boot.py won't run automatically. Only via pymakr plugin or machine.reset() from repl.

    Scheduled Pinned Locked Moved LoPy
    lopy4pymakrbootpymakr upload
    7 Posts 3 Posters 1.5k 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.
    • J Offline
      JonasDe
      last edited by

      Hi everyone!

      I apologize if this is not the correct forum for this question, feel free to move this post if that's the case.

      I am using a PyTrack+LoPy4 and I'm encountering problems with boot.py unless I manually upload the code via pymakr. It only runs when I re-upload the code through pymakr, which obviously doesn't work in a headless/detached scenario.

      This is my boot.py:

      # boot.py -- run on boot-up
      import time
      from machine import UART
      import machine
      import os
      import led
      
      uart = UART(0, baudrate=115200)
      os.dupterm(uart)
      l = led.LED()
      l.cycle()
      machine.main('main.py')
      

      l.cycle() simply sets the led to blue once that code is run. If I plug the USB and let the LoPy4 power up it does not switch the led on. However, if I upload the code via Pymakr it does run boot.py and correctly turns the led on.

      I can manually connect via minicom /dev/ttyACM0 and access the repl by pressing CTRL-C. Here I can not access any of the variables or imports from boot.py. Doing

      >>> import machine
      >>> machine.reset()
      

      will reset the device which then runs boot.py correctly and turns the led on.
      The folder structure is

      /flash/
         boot.py
         main.py
         led.py
         cert/
         sys/
         lib/
      

      Is there something crucial that I have missed?

      Thanks in advance,
      Jonas

      1 Reply Last reply Reply Quote 0
      • J Offline
        JonasDe
        last edited by

        I tried connecting it directly to a power outlet instead of via the serial port - that seems to do the trick.
        This is however a major problem. What I want to do is capture the stdout of the device automatically.
        This can be done easily via minicom or similar. The problem herein lies in that I have to first push the code through the pymakr-atom plugin.

        My planned sequence is:

        1. Edit some code
        2. run flash.sh which is a script that :
          2.1 removes everything except lib, sys, cert, boot.py.
          2.2 copies everything in the current folder to the device
          2.3 resets the device
          2.4 captures the output into a log-file

        Being forced to open atom and manually upload the code during step 2.2 makes this a very tedious process when editing a lot of code.

        If anyone has a better option I'm open to suggestions, or if you know a way to force boot.py to run even if the code isn't uploaded via pymakr. Clearly the device can receive enough power to run boot.py since it's being run when manually forced to, but just not from the start.

        Thanks in advance,
        Jonas

        sebS 1 Reply Last reply Reply Quote 0
        • sebS Offline
          seb @JonasDe
          last edited by

          @jonasde

          Can you test the latest firmware, there was an issue with the onboard LED where if the heartbeat was disabled and a colour were sent to soon after, the led would not work. This has been fixed in the latest firmware. Let me know if this solves your issue if not we can investigate further

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            JonasDe @seb
            last edited by JonasDe

            @seb

            I have flashed with 1.17.3.b1 but the problem persists. I am quite certain it doesn't lie with the led since I added the led to debug the main issue, which was that the LoPy4 didn't run any of the code in main.py. There I am printing to stdout and also sending a packet over the LoRa network, and neither code seems to run.
            When I upload the code with pymakr everything works fine. boot.py runs, main.py also runs and it starts sending packets and is printing to stdout. But booting only by powering the LoPy4 with the serial port won't start anything other than the normal heartbeat LED. I do have access to the REPL when connecting via serial port (where I can do machine.reset(), which then will run boot.py).

            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @JonasDe
              last edited by

              @jonasde From V1.16.0.b1 there is this nice "feature" that Ctrl-F will boot the device in a kind of safe boot state, ignoring boot.py and main.py. That is used by PyMakr to bring the device in a known state, where it responds to REPL. This crooked state will not go away until you perform a hard reset.
              Maybe it's that what you see here.

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                JonasDe @robert-hh
                last edited by

                @robert-hh

                It does seem like it for sure. All the symptoms of a safe boot is there, but how can I prevent this from happening then when I have it connected to the computer?
                It doesn't do it if I plug it into the wall with an adapter, so I'm guessing it's either a power issue (if the serial port doesn't provide enough power for it to boot normally) or something with it recognizing that it's being connected on a serial port which in itself will force it into safe boot?

                robert-hhR 1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @JonasDe
                  last edited by robert-hh

                  @jonasde For verification, you can use a different and dump terminal software like Putty (Windows), screen (mac, linux) or picocom (Linux).
                  Just make sure that any kind of handshake is disabled.
                  For fil etranfer you can use an ftp client like filezilla or fireftp.

                  1 Reply Last reply Reply Quote 0

                  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