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?