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

I am using the Particle Workbench. I have code that compiles correctly for Electron and runs correctly after I flash it from the CLI:
particle flash --usb firmware.bin
where firmware.bin is in the Target folder.

When I switch the Workbench to Photon (using the button on the bottom) and recompile, it compiles fine, but when I try to flash using the CLI:
particle flash --usb firmware.bin
I get the error Error writing firmware: Incorrect platform id (expected 6, parsed 10), use --force to override (I made sure that the firmware.bin had updated after I swithched to Photon.)
I checked the similar instances of this error, but they were a bit different and seemed to have been reported as fixed. Also it wasn’t using the Workbench.

Are you trying to flash a binary compiled for a Photon onto an Electron?

An Electron should only have binaries compiled for an Electron flashed to it.

Workbench sometimes has issues with switching platforms and reusing prebuilt binaries not realising they won’t fit the target platform.
In such cases you should perform a clean build via one of these

(tagging @m_m to keep count of how often this annoyance comes up in the community :wink:)

nrobinson: No, I have code that works for Electron, then recompile it for Photon using the button on the bottom of the Workbench where you choose the platform. I then clean the application and OS per ScruffR’s suggestion, and recompile, and the code does not run.

Thanks ScruffR. I did the Clean app and OS.
That helped - it allowed me to flash the Photon, however the code does not run: the LEDs go into a pattern of red flashes for 15 seconds, then the Photon tries to connect to the Cloud (it goes through the green LEDS flashing, then on to the cyan LEDs flashing), then it goes back to red flashes for 15 seconds and this repeats permanently.

The same exact code does work fine on the Electron (same except compile for Electron that is).

I guess this is a SOS panic - we’d need to know how many slow flashes you see between the SOS codes - or post a video of it.

What device OS version are you targeting?
Can you show the code?
Can you check particle binary inspect <yourFirmware.bin>?

BTW, don’t use the --force switch with DFU updates.