Support for flashing Spark Core using dfu-util in Atom

Hello fellow Spark users.

I wanted to show you my small side project: a Atom editor package, which allows quick flashing using bundled dfu-util. Just open an Arduino project, compile it using Spark CLI spark compile ., press F6 in Atom and have your code uploaded using DFU:

For now it only works on OS X, but I would be happy to add more platforms if someone could prepare all required binaries :wink:

If you want to try it, open Atom command palette -> Settings View: Install Packages and search for Spark Dfu Util.

Feel free to share your opinions :slight_smile:

19 Likes

Awesome! Ping for @zach who I think uses Atom :slight_smile:

That's sweet! Looks similar to Sublime Text... which leads me to the question, why Atom vs. Sublime Text? Is it just that it's free and open?

I've been trying to think of a better way to get the Core into DFU mode automatically... there is one suggestion that uses the Cloud which is quite novel, but not practical in the sense that you have to add special code to your Core with every application

1 Like

Thanks man!

Atom was chosen because it started as a ā€œSpark Studioā€ idea :wink: I wanted to create a standalone IDE for core and I needed an editor which license would alow that. But weā€™ll see how it goes.

With DFU I was looking into the same topic, but it would create additional problems. I can add this code before compiling, but then thereā€™s no guarantee that core is connected to cloud or which core is the one we want to flash. Only way I see is tinkering with DFU protocol on both core and desktop to be able to force DFU mode via dfu-util. But even with manual DFU it still beats cloud flash when it comes to speed (at least in EU) :wink:

3 Likes

This is AWESOME!!! I canā€™t wait to try it myself.

Have you thought about adding the option for flashing through the Cloud, in addition to flash over USB? You could use the Spark CLI:

I could imagine this working in two ways. First, you could call the CLI directly with exec; second, you could integrate the Node.js code from the CLI directly into the IDE. That would quickly give you the full power of the CLI, which would give you the OTA flash, and also the account management stuff (to login to your spark account so you donā€™t have to manually enter your access token)

3 Likes

What binaries are you looking at? Iā€™m 0 experience with this but if you could tell me what you need to port, letā€™s say Windows, Iā€™ll try :slight_smile:

Always wanted to do this and was looking at codebender.cc! Power of the open source community indeed :wink:

1 Like

@zach definitely! I want to integrate whole CLI along with OTA flash and all the other goodies it provides :smile: Iā€™ve looked into it and it should be pretty straightforward (just needs a few UI views).

@kennethlimcp I see that all tools (gcc-arm-embedded, make, dfu-util) actually already have binaries for Windows. Only the part with Zadig and replacing driver with libusbK (thanks for the tutorial BTW!) can be tricky from command line/script. Iā€™ll have to get hold of some Windows machine and try it out.

1 Like

Hey @suda, you donā€™t need that for the Web IDE.

The user needs to change the driver by themselves and maybe you just need to have a notice when they select dfu flashing in Windows?

Thanks for the great work! I really appreciate your effort :slight_smile:

@kennethlimcp I could ask user to do this, but it would be more ā€œmagicalā€ it it was done automatically :smiley:

I know that OTA flash is the preferred method, but in my case it takes around 1ā€²40ā€³ compared to 10ā€³ using USB.

1 Like

So are you at least taking advantage currently of the Cloud compiler?

You can compile in the cloud (1 second typically), download the BIN, then DFU over USB as normal :wink:

Compiling remotely and Flashing locally
http://docs.spark.io/cli/#running-from-source-advanced-spark-flash

1 Like

Hey @suda,

Thereā€™s an unofficial build source for Windows we can use!

http://atom.someguy123.com


Iā€™m just wondering, how do we update the bundled software in future? :smiley:

Also, iā€™m unable to build/verify/flash/toggle log view etcā€¦ Sorry to hijack here. Would be happy to resolve this with you offline? :wink:

@BDub I did not now about this :slight_smile: It looks like I wasted a lot of my time on bundling binaries and generating makefiles for nothing. Iā€™ll play around with it and probably use it as a default way of compiling in future versions.

@kennethlimcp Are you using this Windows build? We can Skype (my handle is suda_skype) and try to resolve any issues.

About update, core utils like gcc, make or dfu-util donā€™t have to be updated. Only core-firmware and libraries need to be up to date. There can be a schedule to update plugin once a week with new firmware. Although if cloud compile would be used, thereā€™s no need for that.

2 Likes

Iā€™m actually on Mac OSx :smiley: Do i need to install make etc? I only installed Atom followed by your plugin

You donā€™t have to install anything (itā€™s all bundled with plugin). Add me on Skype and weā€™ll try to figure it out.

1 Like

see you there. Mineā€™s kennethlimcp :wink:

@suda,

another thing to take note is that the Spark-CLI compile function via the :cloud: allows the file to be a .cpp and the folder name does not to be the same as the .cpp file :wink:

Something for the backlog maybe?

Thanks man! Iā€™ll loving this new tool on top of the existing Spark-CLI which brought me tons of joy :wink:

1 Like

Hi All.

What is this doing behind the scenes?

I want to compile an app locally (like the cloud IDE does), but donā€™t know what I need to do with make to compile an uploadable binary.

this is seriously cool. just locally compiled using Atom + pluginā€¦this might be my local IDE of choice. could not have been easier.

now if there was only a way to enter DFU mode without physically touching the core buttons.

2 Likes

@avidan, i think you need this :smiley:

https://github.com/kennethlimcp/Spark-Snippets/blob/master/Snippets/0002%20-%20DFU_using_spark.function.ino

1 Like

This plugin contains all required tools required to compile core-firmware with replacing application.cpp using your code. Then it launches dfu-util to flash the core :slight_smile:

So if youā€™re on OS X, itā€™s all you need to build and flash your code locally (without the cloud).

1 Like

this is awesome! now, assuming that i add this function all my applications (wish this could be built in by default!)....would i just make a rest call to "doDFU" before using the Atom plugin to compile / flash? it would be really great if we could modify the plugin to all "doDFU".

thoughts?