Flashing my Photon does not change the firmware running on the Photon

Hello,

I’m a very happy user of multiple different particle devices and have been building private projects in my home for quite a while now. I’m new to this forum because I now ran into a problem twice, which I am unable to solve and I couldn’t find any info in the forum as well.

For a week now I have two devices which I cannot change the firmware on anymore. Neither via the IDE nor via build.particle.io or the CLI. All three give tell me that the compile and the flash were successful, my devices start to blink and reboot, but they always reboot into the old firmware.
Neither flashing the tinker firmware nor blink examples changed anything, the devices always come up fine, but with the old software.

All the other Photons in my household respond fine to flash attempts and execute the new software, but these odd two don’t work anymore.

Did anybody ever encounter this behaviour? Are the devices getting old and flashing the storage is not possible anymore?
Any help or idea is greatly appreciated.

Kind regards,
Simon

With the desktop IDE you have to make sure you hit the SAVE button before compiling for the latest code changes to be added, compiled, and then sent to your device. If you don’t hit the SAVE button first your old code will be sent.

That’s how it works for me at least. :slight_smile:

Hi, thanks for the tip. I had some bitter hours with that behaviour when using the IDE for the first time :smiley:
In the case at hand it’s not the problem, I was trying via different routes and with different photons. All things the same the others work, these don’t…

Are they new Photons? What version firmware are they running?

No, they are pretty old, I’m guessing one year.
To be completely honest I cannot say which firmware Version they are running right now. I tried flashing 0.6.3 and 0.7.0-rc6.
I guess the last successful flash was about two weeks ago, probably with 0.6.3…

Are they perhaps part of a product in the console?

When you say you tried flashing via CLI, what command exactly?
What’s the output and what does the RGB LED do?

You can investigate about the current state of the device via CLI

particle identify
particle serial inspect

Hi @Moors7, I never used the console up until now and just checked to make sure: No, there are no products defined and my Photons not associated with a product.

Hi @ScruffR, below you find the commands I used to flash via CLI. I tried the blink example and the tinker firmware. The RGB LED behaves as I’d expect it to:

  1. magenta led

  2. white led (as my old firmware was in SEMI_AUTOMATIC mode)

  3. D7 led (as this indicates, that my photon has not connected to my MQTT broker yet - again, old firmware)

  4. green flash for about a second

  5. cyan flash for about a second

  6. D7 and RGB LED go black as soon as the cloud and MQTT broker are connected and the Photon does its usual business. Sadly it the usual business is the old firmware…

    Simon-Kaisers-iMac:Desktop simonkaiser$ particle compile photon blink.ino

    Compiling code for photon

    Including:
    blink.ino
    attempting to compile firmware
    downloading binary from: /v1/binaries/5a50fe74d67baa452220c6f4
    saving to: photon_firmware_1515257456274.bin
    Memory use:
    text data bss dec hex filename
    4860 8 1456 6324 18b4 /workspace/target/workspace.elf

    Compile succeeded.
    Saved firmware to: /Users/simonkaiser/Desktop/photon_firmware_1515257456274.bin
    Simon-Kaisers-iMac:Desktop simonkaiser$ particle flash PhotonRGBWEsstisch blink.ino
    Including:
    blink.ino
    attempting to flash firmware to your device PhotonRGBWEsstisch
    Flash device OK: Update started
    Simon-Kaisers-iMac:Desktop simonkaiser$ particle flash PhotonRGBWEsstisch tinker
    attempting to flash firmware to your device PhotonRGBWEsstisch
    Flash device OK: Update started
    Simon-Kaisers-iMac:Desktop simonkaiser$

Could you try DFU mode, and then Particle update and the same for Particle flash --usb tinker?

1 Like

I did, this seems to have worked fine. It updated:

Simon-Kaisers-iMac:Desktop simonkaiser$ particle update

> Your device is ready for a system update.
> This process should take about 30 seconds. Here goes!

! System firmware update successfully completed!

> Your device should now restart automatically.

And then I was able to load the tinker firmware. This works everytime I tried it so far.

Simon-Kaisers-iMac:Desktop simonkaiser$ particle flash --usb tinker
Found DFU device 2b04:d006
spawning dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D /usr/local/lib/node_modules/particle-cli/binaries/photon_tinker.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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 2b04:d006
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 = 0x080a0000, size = 3952
Download	[=========================] 100%         3952 bytes
Download done.
File downloaded successfully

Flash success!

The Photon goes back to breathing cyan and is showing up in my Particle App in iOS as “Tinker” and can be tinkered with.

I have a file lying on my Desktop name blink.ino with the following contents:

// Copy me to blinky.ino
#define PIN D7
int state = 0;

void setup() {
    //tell the device we want to write to this pin
    pinMode(PIN, OUTPUT);
}
void loop() {
    //alternate the PIN between high and low
    digitalWrite(PIN, (state) ? HIGH : LOW);

    //invert the state
    state = !state;

    //wait half a second
    delay(500);
}

My next steps are:

Simon-Kaisers-iMac:Desktop simonkaiser$ particle compile photon blink.ino

Compiling code for photon

Including:
    blink.ino
attempting to compile firmware 
downloading binary from: /v1/binaries/5a5200c89cb7ea1486591ba1
saving to: photon_firmware_1515323588731.bin
Memory use: 
   text	   data	    bss	    dec	    hex	filename
   4860	      8	   1456	   6324	   18b4	/workspace/target/workspace.elf

Compile succeeded.
Saved firmware to: /Users/simonkaiser/Desktop/photon_firmware_1515323588731.bin
Simon-Kaisers-iMac:Desktop simonkaiser$ particle flash --usb photon_firmware_1515323588731.bin 
Found DFU device 2b04:d006
spawning dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D photon_firmware_1515323588731.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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 2b04:d006
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 = 0x080a0000, size = 4868
Download	[=========================] 100%         4868 bytes
Download done.
File downloaded successfully

Flash success!

The Photon reboots multiple times, after a brief moment of green flashing and cyan flashing it starts to flash magenta “randomly”. It looks like an HDD led indicating read/write processes (sorry, I have no better description).
After some flashing magenta it starts again: brief white light, green flashing, cyan flashing, magenta random flashes.
In the iOS App the devices shows up breathing cyan, no “Tinker” label to be seen.

Going back to the tinker firmware by DFU is not an issue, it works.

Could you place the device in listening mode and issue ‘particle identify’ to see what version of system firmware is installed?

That very much sounds like an auto-update triggerd by a firmware update that was targeted at a higher system version than the system installed on the device.
This would cause 3-4 reboots before your actual firmware update would stick.
Let the device finish all these reboots without interference.

What version CLI are you using? (particle --version)

You can also target your firmware via particle compile photon blink.ino --target 0.6.2

1 Like
Simon-Kaisers-iMac:Desktop simonkaiser$ particle --version
1.22.0

OK, interesting.
I compiled the blink.ino for 0.7.0-rc.6 and everything seems to go fine, in the end the device returns to breathing cyan. Still no D7 action.

I searched a little for breathing magenta and came to the following site and tried to flash the system anew.
https://docs.particle.io/faq/particle-devices/led-troubleshooting/photon/#breathing-magenta

Simon-Kaisers-iMac:Desktop simonkaiser$ dfu-util -d 2b04:d006 -a 0 -s 0x8020000 -D system-part1-0.6.3-photon.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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 2b04:d006
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 = 0x08020000, size = 260600
Download	[=========================] 100%       260600 bytes
Download done.
File downloaded successfully
Simon-Kaisers-iMac:Desktop simonkaiser$ dfu-util -d 2b04:d006 -a 0 -s 0x8060000:leave -D system-part2-0.6.3-photon.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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 2b04:d006
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 = 0x08060000, size = 214668
Download	[=========================] 100%       214668 bytes
Download done.
File downloaded successfully

The Photon breathes magenta afterwards as well.
I returned to Particle Dev, compiling for 0.6.3 and flashing the blink.ino example: The device restarts and updates and returns to breathe magenta.
I go back in DFU mode and flash via the command line.

Simon-Kaisers-iMac:Desktop simonkaiser$ particle compile photon blink.ino --target 0.6.3
particle-cli v1.22.0

! A newer version (1.27.0) of particle-cli is available.
! Upgrade now by running: npm install -g particle-cli


Compiling code for photon
Targeting version: 0.6.3

Including:
    blink.ino
attempting to compile firmware 
downloading binary from: /v1/binaries/5a52517b25ce2d372c122045
saving to: photon_firmware_1515344247389.bin
Memory use: 
   text	   data	    bss	    dec	    hex	filename
   4860	      8	   1456	   6324	   18b4	/workspace/target/workspace.elf

Compile succeeded.
Saved firmware to: /Users/simonkaiser/Desktop/photon_firmware_1515344247389.bin
Simon-Kaisers-iMac:Desktop simonkaiser$ particle flash --usb photon_firmware_1515344247389.bin 
Found DFU device 2b04:d006
spawning dfu-util -d 2b04:d006 -a 0 -i 0 -s 0x080A0000:leave -D photon_firmware_1515344247389.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/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Deducing device DFU version from functional descriptor length
Opening DFU capable USB device...
ID 2b04:d006
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 = 0x080a0000, size = 4868
Download	[=========================] 100%         4868 bytes
Download done.
File downloaded successfully

Flash success!

Now it works.
I have no clue why it does.
And for the first time at all it told me, that there is a new CLI available.

I’m pretty surprised and have no clue, what changed. Does anybody else?
I tried my best to document every step I took in this thread as I’m usually able to debug my way out of situations like this and was at the end of any reasonable ideas. Can somebody make sense of what happened here to make the last steps successful compared to before?

Kind regards,
Simon

Long story short: system firmware version < user firmware version = magenta.

It’s as @ScruffR mentioned, and I suspected, a mismatch between firmware versions. Considering you’ve got an older version of the CLI (as shown by @ScruffR’s command), you’ll end up with an older version of system firmware (which my command would’ve shown). Seeing as you’re then compiling your user code for the highest version available (0.7.x), the device doesn’t know how to handle it, and will revert to Safe Mode. There it’ll try to auto-update (safe-mode healer), where it either got stuck, or was interrupted prematurely.

After compiling your user code for a version =< system version, it worked as expected.

2 Likes

particle update will update to that version that was current when CLI was released but particle compile will target the current default version (0.6.4).
The most recent version of CLI is 1.27.0 and should default to 0.6.4 system firmware.
IIRC 1.22.0 was at the time of 0.6.2

Thanks @Moors7 and @ScruffR, that clears up where I went wrong.
I never came across issues with different firmware versions, so I was pretty lost.
I must have missed the particle identify hint, sorry. Just read it… Sorry for not heeding the advice from the beginning there.

Thanks for your help!

2 Likes