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

  • Hi guys

    I am just starting out with the Getting Started tutorial, on the "My First Pymakr Project" section. I am using Pymakr for Atom. I have created a file and put into it the following example code from the tutorial:

    import pycom
    import time
    while True:
        print("Program is running...")
        pycom.rgbled(0x161600)  # Red
        pycom.rgbled(0x001616)  # Green
        pycom.rgbled(0x160016)  # Blue

    When I click "run" the program runs exactly as expected. However, when I click "upload", the files appear to upload succesfully, but when the board reboots, it reverts to the default heartbeat LED pattern and nothing is printed to the console. This suggests my program is not being started when the board reboots.

    I have checked the contents of on the board via Filezilla and they are correct, which suggests that there is no problem with Pymakr syncing the project files on the board.

    So unless I am misunderstanding, when the board boots up it should execute (which I have not put any code into) and then automatically, and I should not have to do anything else? The pycom and time modules are built into the firmware, so it could not be that they are missing and preventing from running. Any ideas what might be causing this?


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

  • Hi @flatmop,

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

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

  • @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, should run automatically without needing a

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

  • @james-matthews Ok thanks, created a 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 for this, it suggests as though should run anyway.

  • administrators

    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 in that version.

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

    Add this to

    from machine import UART
    import machine
    import os
    uart = UART(0, baudrate=115200)

  • @robert-hh I ordered from RS Components.

  • @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.

  • @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.

  • @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
    RX(P0)->TX(bridge) and
    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.

  • This is my firmware version:


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

  • @flatmop should run in any version. In Filezilla it should get visible at /flash/
    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

    you will see the version number(s).

  • @robert-hh Ok, I tried resetting the device by pressing the pushbutton but it made no difference. I also tried grounding P12 with a wire but this also made no difference.

    Is it possible to determine or change from the REPL whether or not the board is running in Safe Boot mode?

    Might be worth mentioning that I have not updated the firmware yet as I don't have any expansion boards. I guess I will have to order an Expansion Board 2.0 and update to the latest firmware, see if that makes any difference.

  • @flatmop Then it should be executed, unless the device is in safeboot mode. That is caused by.

    • booting with P12 at High level
    • software reboot from REPL with Ctrl-F.

    The latter method is used by pymakr, as far as I know (I'm not using pymakr). To exclude that, close pymakr and reboot by pushing the reset button on the device.

  • @robert-hh It seems it was uploaded to the board correctly, I checked with Filezilla (FTP client) and the file on the board contained my code correctly.

  • @flatmop I assume that the file was not uploaded permanently to the device. Please check with tools like ftp, that it was.

Pycom on Twitter