Spark-cli: Always cloud flash the newest firmware

I have found myself using the spark cli more and more these days.

I have been using

spark compile *directoryname*

Then once I get the firmware bin file back, i am doing

spark flash corename firmware-xxxxx.bin

I got sick and tired of tracking down the newest firmware binary filename each time....so i used this fun little trick. it always flashes the newest firmware-xxxx.bin file in the current directory.

spark flash *corename-replaceme* `ls -tr firmware* | tail -1`

I hope that helps someone shave a few seconds off their spark dev time!

2 Likes

That’s so cool :slight_smile: Good to know @avidan!

Also, i edited the commands you entered to the correct ones Hope you don’t mind.

Maybe you’re not on the latest spark-cli version that’s why! perform a npm update -g spark-cli

im on the newest version of spark-cli. which command did you change? i cant tell.

i now have compile and upload in a single command.

spark cloud compile *directoryname* ; spark cloud flash *corename* `ls -tr firmware* | tail -1`
1 Like

Just “compile” and not “cloud compile” as well as “flash” and not “cloud flash”

I just realised both works. That’s weird…

@Dave is that supposed to be a duplicate?

Hey @kennethlimcp,

Good question! Yes! I wanted to make sure when we updated the CLI commands that the old ones would keep working so the transition would be super smooth. :slight_smile:

The CLI documentation is still a bit lacking, I also hid a parameter in there to set the output binary filename:

spark compile . --saveTo project.bin

or

spark flash .

or

spark flash . --usb

All suggestions on improving the CLI welcome! I was using it a lot myself this weekend on a new project, and I’m eager to keep improving it. :slight_smile:

Thanks!
David

3 Likes

@avidan,

i now use this command often:

rm `ls -tr firmware_* | tail -1`;spark compile .; spark flash --usb `ls -tr firmware_* | tail -1`

This helps me clear the old firmware before compiling and flash via DFU :wink:

1 Like