Using OSX or another unix based computer with Particle? Today I’ve written particle compile and then particle serial flash just too many times. I wanted to find a way to just execute a shell script that can do the compile and upload in one without me cutting and pasting. Here’s what I came up with:
line=`particle compile photon | grep 'firmware to:' | sed 's/^.*: //'`
echo "particle serial flash $line"
eval "particle serial flash $line"
#eval "particle serial monitor --follow"
The first bit compiles and then parses the output that comes after the string "firmware to: " into a variable called $line. We then output and execute this. The fourth line is commented, but if you want to see the serial output after uploading, just remove the hash sign. Press Control+c to exit the serial monitor.
If you put this in a file named “makeit.sh” in your project folder and make it executable (“chmod +x makeit.sh”), you can then just run it to flash the device connected via USB. It’ll stop at the prompt “Press ENTER when your device is blinking BLUE” but just ignore this warning and press Enter to flash