If you get an error while flashing your device by USB, you may want to use the RESET button to reset the device and try again. If this does not work, some alternatives are:
One of the most common reasons is accidentally using a USB charging cable instead of a USB data cable. The inexpensive cables that come with devices that are powered or recharged by USB often don't have the data lines needed to program a Particle device, even though it will be powered.
Most devices have a USB 2.0 Micro B receptacle, however some devices have USB C.
Show device cable types
The first thing you should try is Device Restore USB. It may be helpful to put the device in DFU mode (blinking yellow) before using the tool:
Press and hold MODE (or SETUP), tap RESET, and continue holding down MODE until the status LED blinks yellow, then release.
Another option is to use the Particle CLI.
Press and hold MODE (or SETUP), tap RESET, and continue holding down MODE until the status LED blinks yellow, then release to put the device in DFU mode.
Use the CLI command:
If you get a last page not writeable error like this (the numbers will be different):
Downloading to address = 0x080a0000, size = 493844 dfu-util: Last page at 0x08118913 is not writeable
there are a few possible causes:
- You are flashing a binary for the wrong platform and using the
--forceoption. Use the correct image instead, you should never need to use
- The hardware is defective. This particular failure happens more often with Gen 2 devices (STM32F205) and can't be repaired because the failure is in the flash inside the MCU.
- See the less common scenarios below, as well.
In some cases, the device can't be restored by DFU, and can only be restored using SWD/JTAG. This requires a special programmer that allows the flash to be reprogrammed externally. See the SWD/JTAG guide for more information.
In rare cases, using the button combination to change into DFU mode may not work. In this case:
Disconnect the USB cable.
Hold down the MODE (or SETUP button) while plugging the USB cable back in.
Continue holding down MODE until the status LED blinks yellow, then release to put the device in DFU mode.
For Gen 2 devices (E Series, Electron, P1, Photon) if the blue D7 LED is on dimly and the status LED is off, the internal flash has been erased.
If this occurs, it can only be repaired using SWD/JTAG. See the SWD/JTAG guide for more information.