Support for flashing Spark Core using dfu-util in Atom

I think it can easily be baked into firmware like how we are checking the CC3000 firmware version.

Yeah just use spark cli to call the function!

spark call core_name dfu should work if I remember the syntax correctly ;))

For now, we just have to do it manually since not everyone might like having the function exposed :slight_smile:

2 Likes

This is brilliant. Thanks a lot @suda !

In my case we have to put the void setup() and the void loop() at the end of my code. Otherwise it stops compiling and telling you that functions are not declared. But that´s so easy. Hope in a future package and with the final release of the local :cloud: suda put´s the OTA feature to the package!

again and again - great work - great community!

2 Likes

I am little confused.
Is this available for Windows 8.1?
I would love an IDE rather than the web IDE.

Think that is what ya need.
You can try to install ATOM IDE via Chocolatey and then try to use the package from suda. I did not know if that works. But give it a try!

1 Like

Unfortunately it won’t work with Windows. It contains binary versions of gcc-arm-none-eabi, make and dfu-util which are only compatible with OS X.

3 Likes

I tried this in OSX and it worked the first time, I was able to upload the Blink sketch to the Spark no problem.
However when i try to load anything now it does nothing but gives this message -

Building core-common-lib
make[1]: Nothing to be done for 'all'.
Building core-communication-lib
make[1]: Nothing to be done for 'all'.

Any idea why? It does show the picture to press the core buttons but does nothing after that. Core just keeps flashing yellow.

First try to build the project (Packages -> Spark Core -> Build / Verify) and check if log contains any information about errors inside the code.

I get the same thing.
I also tried the blink example again and it does the same.

Could you try closing and opening new window with this project? It should create new temporary directory for build.

1 Like

I closed it completely.
So just to check that I am not doing something silly -
I open Atom.
Click VIEW - Developer - Open in Dev Mode - choose Blink.ino
Click Packages - Spark Core - Build/Verify

I get Build Failed Many errors including -

/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h: In member function 'bool IPAddress::operator==(const IPAddress&)':
/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h:54:72 warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
bool operator==(const IPAddress& addr) { return (((uint32_t)_address)) == (((uint32_t)addr._address)); };

As I said, it worked the first time and I uploaded this sketch to the Core.
Confusing

Usually actual error with code is hidden in the last error message. Could you post both code and errors?

The code is the default blink sketch.

 // Define the pins we're going to call pinMode on
    int led = D0;  // You'll need to wire an LED to this one to see it blink.
// Define the pins we're going to call pinMode on
int led = D0;  // You'll need to wire an LED to this one to see it blink.
int led2 = D7; // This one is the built-in tiny one to the right of the USB jack
    // This routine runs only once upon reset
    void setup() {
      // Initialize D0 + D7 pin as output
      // It's important you do this here, inside the setup() function rather than outside it or in the loop function.
      pinMode(led, OUTPUT);
      pinMode(led2, OUTPUT);
    }
    
    // This routine gets called repeatedly, like once every 5-15 milliseconds.
    // Spark firmware interleaves background CPU activity associated with WiFi + Cloud activity with your code.
    // Make sure none of your code delays or blocks for too long (like more than 5 seconds), or weird things can happen.
    void loop() {
      digitalWrite(led, HIGH);   // Turn ON the LED pins
      digitalWrite(led2, HIGH);
      delay(1000);               // Wait for 1000mS = 1 second
      digitalWrite(led, LOW);    // Turn OFF the LED pins
      digitalWrite(led2, LOW);
      delay(1000);               // Wait for 1 second in off mode
    }

    eBuilding core-common-libe
    make[1]: Nothing to be done for `all'.
    eBuilding core-communication-libe
    make[1]: Nothing to be done for `all'.
    eBuilding project file: /Users/macowner/Dropbox/blink.inoe
    eInvoking: ARM GCC CPP Compilere
    mkdir -p obj/
    arm-none-eabi-gcc -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/libraries//Serial2 -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/CMSIS/Include -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/CMSIS/Device/ST/STM32F10x/Include -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/STM32F10x_StdPeriph_Driver/inc -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/STM32_USB-FS-Device_Driver/inc -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/CC3000_Host_Driver -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-common-lib/SPARK_Firmware_Driver/inc -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-communication-lib/lib/tropicssl/include -I/Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/../core-communication-lib/src -I. -I/Users/macowner/Dropbox -ffunction-sections -Wall -fmessage-length=0 -MD -MP -MF obj/blink.o.d -DUSE_STDPERIPH_DRIVER -DSTM32F10X_MD -DDFU_BUILD_ENABLE -DSPARK=1 -DRELEASE_BUILD -include /Users/macowner/.atom/packages/atom-spark-core/src/arduino/inc/binary.h -fno-exceptions -fno-rtti -x c++ -c -include /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/application.h -o obj/blink.o /Users/macowner/Dropbox/blink.ino
    In file included from /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring.h:37:0,
                     from /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/application.h:29,
                     from :0:
    /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h: In member function 'IPAddress::operator uint32_t()':
    /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h:53:52 warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      operator uint32_t() { return *((uint32_t*)_address); };
                                                        ^
    /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h: In member function 'bool IPAddress::operator==(const IPAddress&)':
    /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h:54:72 warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
                                                                            ^
    /Users/macowner/.atom/packages/atom-spark-core/src/core-firmware/inc/spark_wiring_ipaddress.h:54:105 warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
                                                                                                             ^

@suda:
Updating the package should work like:

  1. View
  2. Toggle Command Palette
  3. Settings View: Install Package
    --- Now it checks if all packages are up to date

:heartbeat: All your installed packages are up to date

To be sure you can search for the package "Atom Spark Core" and goto Settings. On that tab you see the latest Version 2.5. Here is the Github Link for verification: GitHub - suda/spark-dfu-util: Support for flashing Spark Core with dfu-util

Very nice, congratulations! :+1:

I guess @suda is going to face sooner or later the same issues I’ve experienced with the Spark Core framework when I tried to add support for the board to embedXcode.

1 Like

It doesn’t look that there are any errors (only bunch of warnings you can ignore). I’ll have to try reproduce it.

@clyde I’ve just updated to 0.2.6 with fresh core-firmware and core-common-lib :smile:

@rei_vilo wow man, embedXcode looks awesome! I’ll have to give it a try with Arduino

3 Likes

Thx will do update immediately :wink:

that is awesome. im gonna put that code in all my "in development" apps.

hey @coolnewt i just added it to the smartbbq board for now, its making life a lot easier :smile:

1 Like

Hi @suda.

Update did not work for me. Seems to take ages. So I cleaned the /Users /myuser/.atom/packages/atom-spark-core and download a fresh copy from your GIT Repository: https://github.com/suda/atom-spark-core
Unziped it and copied the atom-spark-core-master to the same place as it was before. Then I opend up ATOM and voila :wink: there we go!

1 Like

Unable to download https://www.atom.io/api/packages/atom-spark-core/versions/0.2.6/tarball: 503

:frowning:

Try once again first it did not worked for me now it does
or try: https://github.com/suda/atom-spark-core/archive/master.zip