Keeping photon in DFU mode after flash

Is there a way to keep the photon in DFU mode after flashing new firmware via particle cli?

Can you elaborate about the reason for that request?

I dislike working via the Web IDE and prefer using my own editing tools. It’s tedious to have to set the device in DFU mode for each modification I make.

Hmm, if your device never gets out of DFU Mode how would you find out whether your last changes did actually do what you intended?
Or if you don't need to test between iterations, why flash the intermediate versions at all?

BTW, if you are using your own editing tools can you also automatise the flashing process?
If so, you can force the device into DFU Mode via a magic baud rate and soon to come via dedicated USB control requests.

Can you elaborate which these are?
Have you given Workbench a shot yet?

I use vim and have my own scripts for building and flashing the code. I don't want to use any IDE.

Or if you don’t need to test between iterations, why flash the intermediate versions at all?

Is there another way to do this? If I can put my code on the device without using DFU, the Web IDE, or workbench, I could do that as well. The proton board I have to use is currently built into a product. It's difficult to get to the switch, and I'm worried my fat fingers are going to break it every time I try to reach the buttons.

in that case you should be able to push the device into DFU Mode by opening its USB serial port with baudrate 14400.

To answer that, I'd need to know how you are doing it now?
dfu-util or CLI (particle flash --usb firmware.bin)
But yes, you can use Listening Mode and particle flash --serial firmware.bin or Y-Modem or in normal operation via CLI OTA update particle flash <deviceID> firmware.bin

Something like this at the moment:

#!/bin/bash
particle compile photon . --saveTo firmware.bin
particle flash --usb firmware.bin

Since you are using CLI to compile, you are already compiling in the cloud, so instead of downloading the binary you can actually have the binary directly delivered to the device OTA

IIRC

particle flash <deviceID> .

Oh cool, that works nicely. Thanks :slight_smile: Is it possible to compile offline?

Yes.
You either need to setup your own toolchain or use Workbench which brings its own toolchain(s) (and a debugger).

There’s a System.dfu() function. You could set up a Particle function callback to call that. Then you could use particle-cli or the phone app to call that function remotely to put your device into DFU mode. I’m not sure I’d want to go that route, though.