Is there a fast way build and flash your code to your Particle device

There might already be a way. If so then can someone guide me. I feel like that compiling code, then putting device in dfu mode and then flashing takes too long. Is there a faster way to do this??

write a script file? I compile locally (code size around 10,000 lines) compiles the full code in a minute (or so) on a macbook pro, dumping it into the device is another 15 - 20 seconds. All done by script file

A script is definitely the way to go.

You can put a device into dfu mode by setting the baud rate to 14400.

What OS are you using?

The command to set the baud rate differs across Linux, Mac, and Windows.

I am using a mac at work and windows at home. I have never written a script before though

Get you device into dfu mode without pressing any buttons with:

stty -f /dev/cu.<your device> 14400

is usually something like cu.usbmodemXXXX with XXXX being a number.

So make that stty command your first line in the script


Don’t do a separate compile and flash step. Instead, Start the flash, switch to another window and use Mode command to put into DFU, then wait for flash to complete.
(Windows use implied here…)

Oh should probably update this:
I solved it with a bash script (thanks guys)

Here is the script code: (MAC)

rm p1_*
stty -f /dev/tty.usbmodem14* 14400
particle compile p1 --target 1.0.0
particle flash --usb p1_*

How to use: (TWEAK code to your board type and targetVersion)

  1. Copy script code to a new file named (save it in project folder)
  2. change directory to project folder:
  3. run bash
1 Like

Great solution, and thanks for publishing the bash code!

This really should be part of the IDE. This is one of those ubiquitous issues where everyone has the exact same problem and the solutions will always look the same. It would be a nice time-saver for the community if Particle could officially support this and document it, so that everyone benefits, instead of only those who read this (or other similar) forum post.

It is in the works and will come to Particle Workbench.
However, it will not work via the magic baudrates but via newly incorporated USB control requests and hence needs some more testing before it will be released.

1 Like

Shameless plug, but I’ve had a solution to this problem for years.

My tool installs the Particle toolchain and necessary dependencies for local building on Mac and Linux and provides shortcuts for building projects and flashing firmware. It even works with Atom or Workbench.