"particle flash -- serial" usually fails on Electron

I’m new to the Particle platform and have an Electron board on loan from a colleague which I am trying to use for some rapid development. I am compiling in the web IDE, running the target in MANUAL mode and then flashing it locally with the downloaded .bin file from a Windows machine. I’m using PuTTY to read my local debug messages from the USB port and I make sure that PuTTY is not running when I’m trying to flash the board. I’m using the short USB cable that came with the Electron board.

All of this is working, except that flashing is unreliable. When the device is in listening state (blue flashing LED), more often than not, when I do the “Press ENTER when your device is blinking BLUE” bit, the blue flashing LED either goes off or stays on and the CLI reports:

! serial:
Error writing firmware...Timed out waiting for initial response from device

Very rarely (maybe one time in 10) does it go rapid-flashing-magenta and begin the download and often, when it does, the magenta goes solid and the download reports a time-out.

! serial:
Error writing firmware...TimeoutError: timed out after 10000ms
TimeoutError: timed out after 10000ms
    at onTimeout (C:\Users\rob\AppData\Roaming\npm\node_modules\particle-cli\node_modules\when\lib\decorators\timed.js:6
    at null._onTimeout (C:\Users\rob\AppData\Roaming\npm\node_modules\particle-cli\node_modules\when\lib\decorators\time
    at Timer.listOnTimeout (timers.js:92:15)

I am running firmware 0.5.1 on the device, Particle CLI version 1.14.2 on the Windows machine and using the Electron USB driver version

Any ideas what I’m doing wrong?

1 Like

Hey @RobMeades,

We’ll do our best to figure out what’s going on. First, can you confirm that you are building the firmware for the Electron? Make sure in the Web IDE that you’ve selected it from the Devices section.

If you are running in MANUAL mode, are you making sure to run updates

Another option is to write to the Electron directly over USB, instead of OTA. You’d instead put the Electron into DFU mode (yellow blinking) and flash with this command: particle flash --usb firmware.bin

You can also check out this thread that has more info on some of the advice above, but definitely let us know where you are at, and what you’ve tried! :slight_smile:

Hi there. Yes, it is built for an Electron. I’m not sure what you mean by “are you making sure to run updates”. I have the latest firmware I could find (0.5.1) and I only installed Particle CLI on Friday so I guess those are the latest. What other updates are there?

I’m not using OTA, everything is done locally with “particle flash --serial blah.bin”, there’s no OTA here. I thought “particle flash --usb blah.bin” was for core firmware updates only, not application software. I may be confused though…

I’ll also take a look at the link.

Same here… Electron acting weird since updated to 0.5.3
It keeps disconnecting from USB automatically and getting timeout when trying to flash.

The --serial flash can fail because your code runs at the same time as the update, and it’s easy to accidentally interfere with it. I prefer to use the --usb (DFU) flash mode:

Hold down the RESET and MODE button, release RESET and continue to hold down MODE while the main status LED blinks magenta, until it blinks yellow and then release MODE. This is DFU mode.

Then issue a command such as:

particle flash --usb firmware.bin

If you get an error that dfu-util is not found, then you’ll need to install it. For Windows, the easiest way is to run the Particle CLI installer; a link is at the bottom of the [Particle CLI page] (https://particle.io/cli). That page also has instructions for Mac and Linux.

Don’t worry about this message; it’s not really an error and will always occur:

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!

Thanks man! I needed to use the --usb and also connect it to the USB port on the rear of my PC and not on the front because it has more power on that USB port.

1 Like

Hi guys,

I detected same behavior when using a blocking loop-application:

void loop(void)
    while (!Serial.available()) {
        Serial.print("I'll never leave this loop!");

The update worked for me using:

void loop(void)
    if (!Serial.available()) Serial.print("I'll leave this loop in 100ms!");

Can anyone confirm this behavior?

Another fix is to start into rescue mode first ([RESET] + [MODE], release [RESET], wait for green blink and pressing [MODE] for several seconds again). OR, as others already proposed, to use the dfu mode.

I tired this on electron and getting the following error:

particle flash --usb ass_1.bin
Found DFU device 2b04:d00a

Error writing firmware…Incorrect platform id (expected 10, parsed 6), use --force to override

Moes-iMac-2:asset_tracker mtun009$ particle flash --usb ass_1.bin
Found DFU device 2b04:d00a

Error writing firmware…Incorrect platform id (expected 10, parsed 6), use --force to override

That means your ass_1.bin file was built for the Photon, not the Electron. Make sure you have an Electron selected with a gold star to the left of the name in the Devices tab.

Thanks. I’ve seen that error before with Bluz DK.

I’ve been updating the firmware on my Electron regularly without any trouble. But just today I started getting the same error message when trying to flash via --serial…

! serial:
Error writing firmware…Timed out waiting for initial response from device

I get this message when trying to flash via --USB…

attempting to flash firmware to your device --USB
Flash device failed.
I didn’t recognize that device name or ID, try opening https://api.particle.io/v1/devices?access_token=befa6a8cc04c6010513d8f725973a2653d2c1abc

I’ve tried loading a previous version of the firmware to make sure it’s not a problem with the firmware being compiled for the Photon - but no luck. I’ve tried flashing from the CLI using both --serial and --USB. No luck either way. I tried rebooting my laptop just in case. No luck there either.

Any tips would be greatly appreciated.

Did you use the command particle flash --serial electron3.bin or particle flash --usb electron3.bin?

I tried both of those. The two messages I posted are the results of each.

What does particle --version say?

I get:

KENMBP:Desktop kennethlimcp$ particle --version
KENMBP:Desktop kennethlimcp$ particle flash --usb test.bin 

!!! I was unable to detect any devices in DFU mode...

> Your device will blink yellow when in DFU mode.
> If your device is not blinking yellow, please:

1) Press and hold both the RESET/RST and MODE/SETUP buttons simultaneously.

2) Release only the RESET/RST button while continuing to hold the MODE/SETUP button.

3) Release the MODE/SETUP button once the device begins to blink yellow.

Error writing firmware...No DFU device found

With a device:

KENMBP:Desktop kennethlimcp$ particle flash --usb test.bin 
Found DFU device 2b04:d006

Error writing firmware...test.bin was empty!

(This is due to using a blank .bin but it still shows it works)

Here’s a screen grab…

C:\Files\Yellow Jacket\Particle IO Electron\Sketches>particle --version

Can you do the following:

  1. Place the electron in DFU mode
  2. Run the command particle flash --usb xxxx.bin
  3. Paste the full error command prompt info here

It just worked - for the first time. I was typing “–USB”, and I see you used “–usb”. Perhaps that was my problem flashing in USB mode, but I don’t understand why I’m having trouble flashing in serial mode.

In any event, this is the result…

C:\Files\Yellow Jacket\Particle IO Electron\Sketches>particle flash --usb electr
Found DFU device 2b04:d00a
spawning dfu-util -d 2b04:d00a -a 0 -i 0 -s 0x08080000:leave -D electron3.bin
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Opening DFU capable USB device…
ID 2b04:d00a
Run-time device DFU version 011a
Claiming USB DFU Interface…
Setting Alternate Setting #0
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08080000, size = 13972
Download [=========================] 100% 13972 bytes
Download done.
File downloaded successfully
Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release!!!

Flash success!

C:\Files\Yellow Jacket\Particle IO Electron\Sketches>

Unfortunately, although it seems to have flashed successfully, it doesn’t seem to be giving me any of my Serial.println() stuff when I run “particle serial monitor”. It’s as if the serial link is the problem.

Also - thanks very much for your help.

I tried flashing my Photon via serial, and it worked fine. So I then tried re-assigning the serial port on the Electron, and that fixed it as well. Curious that the USB mode wasn’t working. Perhaps that’s because I was using --USB in upper-case. I’ll do a test.

Thanks again.