Erasing flash via pycom-fwtool-cli with barebones LoPy4
- 
					
					
					
					
 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-clitool. 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 downloadHowever, 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 headerIs 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-hh Thanks for the mention of the -coption! 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: - Run pycom-fwtool-cli -p COM7 lpwan- The correct output is shown, with the SMAC,SID,PACandLORA REGION
 
- The correct output is shown, with the 
- Run pycom-fwtool-cli -p COM7 lpwanonce again, without resetting LoPy- The same error occurs: Exception: Failed to connect to ESP32: Timed out waiting for packet header
 
- The same error occurs: 
 Now, with the -coption enabled, the procedure above works! Thanks so much!
 
- Run 
- 
					
					
					
					
 @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.
 
- 
					
					
					
					
 @robert-hh Thank you! So I uncovered what might be the problem: the commands coming from pycom-fwtool-clionly work once. Say, following this procedure:- Connect P2 to GND while LoPy4 powered off
- Power on LoPy4
- Send pycom-fwtool-cli -p COM7 erase_allcommand- This command works, flash is erased in 15.98 seconds
 
- Send pycom-fwtool-cli -p COM7 flash -t LoPy4-1.20.2.rc6.tar.gzto flash new firmware- This command does not work, throws Exception: Failed to connect to ESP32: Timed out waiting for packet header
 
- This command does not work, throws 
- Restart LoPy4 with P2 to GND
- Try pycom-fwtool-cli -p COM7 flash -t LoPy4-1.20.2.rc6.tar.gzagain- 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. 
 
- 
					
					
					
					
 @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.
 
- 
					
					
					
					
 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 makefsandmkfs(with the same arguments) in case you have a lower version.
 `
 
 
			
		