Unable to flash electron over USB

I created a simple program to count up from 50 and send it over serial. I was able to upload the original over the cloud, but when I flash using --serial or --usb, there is no change. I still get the results from the original program, which was just sending me zeros because I forgot to increment the variable.

Here is my code.
int num = 50;

void setup(){
Serial.begin(115200);
Serial.println(“connected, using new code”);
}

void loop(){
Serial.println(num);
num=num+1;
delay(1000);
}

How exactly does your flash command look and what’s the output of CLI when you do?
Did you build the binary via CLI or downloaded it from Build?
Also could you double check, that the binary you are flashing is not an old one?

I use particle dev. every time i compile, i get two new files. one is core firmware, the other is electron firmware. I have tried flashing both and there is no difference.

A few hours later, I reconnected the particle and it loaded the new code all by itself. I was not able to get it to load this code via USB or OTA before I disconnected and walked away from it. Now, I still can’t get it to accept new code. It acts like the flash went smoothly, but it continues to run the old code.

How do you manage that? :confused:
There should only be one binary built for the device you have selected.
What size do these binaries have?
If you have CLI installed try building that same project via CLI and compare the output.

You could also post a screenshot of your Dev window.

Oddly, I deleted the core firmware file and it didn’t come back. Only an electron firmware file did. Sometimes it doesn’t, but a new electron firmware with new numbers at the end always appears.

Here is what I get when i try a DFU flash with the file. It still runs the old code.

Just a thought but if you’re using git for version control you might as well overwrite the binary file each time you compile so you don’t get confused on which to use… here’s my one liner that compiles and flashes. You never need to change it because it writes to the same file :smile:

particle compile electron myProjectFolder --saveTo myProjectFolder/firmware.bin && particle flash --usb myProjectFolder/firmware.bin

One thing to watch out for: The dot to the right of the filename tab, pointed to by the purple arrow, indicates that the file was not saved. I ran into a problem in the past where Command-S did not actually save the file. Save All from the File menu did, however. Then it started working again.

That was it! I wasn’t saving first. Such a simple mistake. Thank you!

1 Like

What IDE is that?

@Jean-Pierre, that is Particle Dev