Update firmware after deep sleep

Seems I painted myself into a corner :tired_face:

I made a simple datalogger with one of my photons and at the end of its code it goes into SLEEP_MODE_DEEP, however now I cant update its code…
Even if I press the reset button on the photon, it executes the user code and goes to sleep, even if a build tab is currently trying to send new firmware to it.

First off, whats the procedure to get it back to life, will I have to factory reset? I did the cli update with 0.4 part files, so hopefully a factory reset wont brick it ?
-Or is there a easyier way to load new firmware/reset to tinker firmware ?

Second, is it possible to see on startup why we started? on AVR you can read a register and see if the chip was freshly booted, reset by using reset pin, watchdog, sleep timer expired, etc. maybe the photon has something like it ?

You could try safe mode instead of factory reset
Have a look here

Or you can use Particle CLI and Listening DFU mode (yellow flashing) to flash via USB

particle flash --usb tinker

(Thanks @Moors7 for correcting the mode confusion! :+1:)

1 Like

Thanks, safemode allowed me to update the firmware via webinterface, very nice.
Still looking for a good way to detect that reset button was used, so I can prevent the device going to sleep in that case, as a workaround untill the queued firmware distribution works, which IMO is pretty essential.

1 Like

I’d have to check with some of the bare metal geeks, but for the time being, you could use a user button that you keep pressed during setup() which forces your code into an update branch.

  pinMode(userButton, INPUT_PULLUP); // wire a button to GND
  if(!digitalRead(userButton))       // if button is pressed
    while(true)                      // keep servicing the cloud forever

Edit: Checked back at :spark: Particle and the answer was: “No, there is no way to know, after application code has started running again.”

1 Like

True, its not really an improvement over safemode though, unless the photon is inside an enclosure.

Also notice that the leds are going on every time it wakes up, so not sure how energy friendly the deep sleep is after all, well see how much life I get out of these AAA.

I am trying to replace some NRF24 with photons to make the setup cleaner, but will need at least 6 months battery life to make sense.

@MORA, you may want to consider Bluz :wink:

Yea looks interesting, but 3 months away, my test photon “died” this morning after about 6 days of running on 3xAAA.
However this is without a booster since I dont have a suitable one atm, so theres still a bit of power left in the batteries, the voltage is just too low for VIN now.

So in the meantime I will probably route a power cable for it, or a bigger battery pack, 1000mah@5V per week seems doable.