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

    Erasing flash via pycom-fwtool-cli with barebones LoPy4

    Scheduled Pinned Locked Moved Software Tools
    6 Posts 3 Posters 125 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.
    • D Offline
      d.alvrzx
      last edited by

      Hello all:

      I am attempting to erase the flash (and ultimately flash new firmware) to a LoPy4 that is barebones, connected to a breadboard, via the pycom-fwtool-cli tool. I currently have nothing else connected to the LoPy4 other than:

      • 5V power from external power supply
      • GND from external power supply
      • TX, RX and GND to an FTDI USB to Serial converter
      • GPIO0 (P2) connected to GND on boot (to enter bootloader mode)

      When entering bootloader mode, I get the following message:

      rst:0x1 (POWERON_RESET),boot:0x3 (DOWNLOAD_BOOT(UART0/UART1/SDIO_REI_REO_V2))
      waiting for download
      

      However, when I run pycom-fwtool-cli.exe -p COM7 erase_all, I get the following output:

      Running in FTDI mode
      Erasing the board can take up to 40 seconds.
      Exception: Failed to connect to ESP32: Timed out waiting for packet header
      

      Is it possible to do these sort of commands without an Expansion board? I am testing this on a breadboard because I want to be able to do this on a PCB I am working on.

      I have already tested lowering the baud rate, but no luck!

      Maybe, @Gijs, could you help me out?

      Best,

      Dan

      robert-hhR 1 Reply Last reply Reply Quote 0
      • techykermitT Offline
        techykermit
        last edited by

        If you are able to connect to the device and run code, you can run

        import os
        os.fsformat("/flash")
        

        If fsformat() doesn't work, it's because Pycom has changed the function name several times. Also try with makefs and mkfs (with the same arguments) in case you have a lower version.
        `

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

          @d-alvrzx Yes, you can do that without an expansion board. Did you close all other software connected to the LoPy4 before starting pycom-fwtool-cli?
          You may also try to use esptool.py itself, which is the heart of pycom-fwtool-cli.py.

          D 1 Reply Last reply Reply Quote 1
          • D Offline
            d.alvrzx @robert-hh
            last edited by d.alvrzx

            @robert-hh Thank you! So I uncovered what might be the problem: the commands coming from pycom-fwtool-cli only work once. Say, following this procedure:

            • Connect P2 to GND while LoPy4 powered off
            • Power on LoPy4
            • Send pycom-fwtool-cli -p COM7 erase_all command
              • This command works, flash is erased in 15.98 seconds
            • Send pycom-fwtool-cli -p COM7 flash -t LoPy4-1.20.2.rc6.tar.gz to flash new firmware
              • This command does not work, throws Exception: Failed to connect to ESP32: Timed out waiting for packet header
            • Restart LoPy4 with P2 to GND
            • Try pycom-fwtool-cli -p COM7 flash -t LoPy4-1.20.2.rc6.tar.gz again
              • This command works, firmware is flashed correctly.

            So it seems I need a reset between each command? Is this how it should work?

            EDIT: And yes, I did close all other software before opening the pycom fwtool.

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

              @d-alvrzx You do not have to erase flash everytime you upload new firmware. Only if you think the flash is corrupted.
              Besides that there is the -c option which you could try.

              D 1 Reply Last reply Reply Quote 1
              • D Offline
                d.alvrzx @robert-hh
                last edited by

                @robert-hh Thanks for the mention of the -c option! I did not know this, but it works! No more resets needed between commands.

                And yes, I understand that I do not need to erase the flash every time I load a new firmware. But my example was trying to show that any 2 commands in a row had the same behaviour, for example:

                1. Run pycom-fwtool-cli -p COM7 lpwan
                  • The correct output is shown, with the SMAC, SID, PAC and LORA REGION
                2. Run pycom-fwtool-cli -p COM7 lpwan once again, without resetting LoPy
                  • The same error occurs: Exception: Failed to connect to ESP32: Timed out waiting for packet header

                Now, with the -c option enabled, the procedure above works! Thanks so much!

                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