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

    How do I get main.py to run when the WiPy board boots?

    Scheduled Pinned Locked Moved WiPy 2&3
    main.pywipybooterrorbug
    19 Posts 6 Posters 2.9k Views 7 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.
    • robert-hhR Offline
      robert-hh @flatmop
      last edited by

      @flatmop main.py should run in any version. In Filezilla it should get visible at /flash/main.py.
      You can also telnet to the device to get an REPL prompt. When you push Ctrl-B at the REPL prompt or issue the commands:

      import uos
      uos.uname()
      

      you will see the version number(s).

      F 1 Reply Last reply Reply Quote 0
      • F Offline
        flatmop @robert-hh
        last edited by

        This is my firmware version:

        0_1532028438554_7d9d5e56-c314-4318-b9e8-46c305f50d6d-image.png

        So I don't understand how main.py is not running unless there is a problem with the firmware...

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

          @flatmop That's strange. And that version also does not reboot on Ctrl-F. Besides that, upgrading the firmware is advisable. You do not need an expansion board. Any USB/UART bride with TTL output at 3.3V level will do as well. You have to connect
          GND,
          RX(P0)->TX(bridge) and
          TX(P1)->RX(bridge),
          connect P2 to GND and push reset. Then the device is in upload mode and you can run the firmware updater to do its magic.

          F 1 Reply Last reply Reply Quote 0
          • F Offline
            flatmop @robert-hh
            last edited by

            @robert-hh I don't have a USB to UART bridge with 3.3V TTL output to hand at the moment. I though it safer to just order the Expansion Board 2.0. When it arrives (despatch tommorow and next working day delivery, so Monday...), I will update the firmware and see if that fixes the issue. If it doesn't I guess my board must have some hardware defect, perhaps ESD damage to the flash memory or something.

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

              @flatmop I don't know whether you get an expansion board 2. AFAIK, they are not sold any more by PyCom. But distributors may have them still on stock.

              F 1 Reply Last reply Reply Quote 0
              • F Offline
                flatmop @robert-hh
                last edited by

                @robert-hh I ordered from RS Components.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  james.matthews
                  last edited by

                  boot.py tells the board what to do. If nothing is in boot then nothing will happen.

                  Add this to boot.py:

                  from machine import UART
                  
                  import machine
                  import os
                  
                  uart = UART(0, baudrate=115200)
                  os.dupterm(uart)
                  
                  machine.main('main.py')
                  
                  1 Reply Last reply Reply Quote 1
                  • X Offline
                    Xykon administrators
                    last edited by

                    You need to update the firmware first.

                    The WiPy2 firmware that is flashed during production is very old and from what I remember there was indeed an issue with loading the main.py in that version.

                    Christian Ehlers

                    F 1 Reply Last reply Reply Quote 0
                    • F Offline
                      flatmop
                      last edited by

                      @james-matthews Ok thanks, created a boot.py with this code in it, and it now runs my RGB program when the WiPy is reset. Success! I feel as though this is some sort of hack or workaround however, as nowhere in the "Getting Started" guide does it say that you need a boot.py for this, it suggests as though main.py should run anyway.

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

                        @flatmop That is the expected behavior, which you should get after an update of the firmware.

                        F 1 Reply Last reply Reply Quote 0
                        • F Offline
                          flatmop @Xykon
                          last edited by

                          @xykon I updated the firmware to the latest version with the Expansion Board 2.0, but that did not help. It was only when I tried @james-matthews's suggestion that I got it to work, which seems strange. The "getting started" guide gives the impression that once uploaded to the board, main.py should run automatically without needing a boot.py.

                          danD 1 Reply Last reply Reply Quote 0
                          • F Offline
                            flatmop @robert-hh
                            last edited by

                            @robert-hh I see. Perhaps they should make this more obvious in the "Getting Started" guide.

                            1 Reply Last reply Reply Quote 0
                            • danD Offline
                              dan @flatmop
                              last edited by

                              Hi @flatmop,

                              That is the case, main.py runs automatically (just tried it)

                              T 1 Reply Last reply Reply Quote 0
                              • T Offline
                                timh @dan
                                last edited by

                                @dan Yep I have never put anything in boot.py, have always had main.py run without intervention.

                                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