Jan 23, 2015

Concise Guide to Troubleshooting the Spark Core

I snatched up a Spark Core from Kickstarter when they first were offered. That was 2013. Then the poor thing languished in a box, forlorn and unloved in a dark corner of the closet. Lately I renewed my interest in the Internet of Things when I started playing with IFTTT and became enamored with its power. I decided to give the Core a whirl.

I had never set this thing up - it was still pristine in its box. That's probably a good thing. There were a number of "issues" getting this early Core working that took Spark and its community time to work out and document. Like the X-Files, The Truth is Out There.

Provided you search for it...and search, and search. Yes, the fixes are out there. Problem is, they're splattered all over the place.

Really, you're calling this a "Concise Guide"?!? Yes! The information here is as complete as possible and will save you lots of time.

Note that this applies to the Core, especially early Core, and not necessarily the Photon.

Required First Steps

  • Sign up for an account at spark.io
  • Download the Spark Core app for your device, either Android or iPhone
  • Since the Core is 802.11b/g only, make sure your router is set up to handle this
Here's the first hurdle: b/g connectivity. I have a dual-band (2.4/5Ghz) Asus N56U router. With stock settings, the Core would not connect. Change to "Legacy" on the 2.4GHz band.

OK, All set up so far?  Connect the Spark to a power source. It can work off computer USB power, but it's better to power it with an external adapter of 1A to make sure it has enough power.

It's blinking... a blue LED.

What do the Colors Mean?
There are two LEDs on the Core. The big fat one in the middle is a full-color RGB LED that shows you the status of the Core's internet connection. The other small blue LED is the user LED; it's hooked up to D7, so when you turn the D7 pin HIGH or LOW, it turns on and off, respectively.
The RGB LED could show the following states:
  • Flashing blue: Listening mode, waiting for network information.
  • Solid blue: Smart Config complete, network information found.
  • Flashing green: Connecting to local Wi-Fi network.
  • Flashing cyan: Connecting to Spark Cloud.
  • High-speed flashing cyan: Spark Cloud handshake.
  • Slow breathing cyan: Successfully connected to Spark Cloud.
  • Flashing yellow: Bootloader mode, waiting for new code via USB or JTAG.
  • White pulse: Start-up, the Core was powered on or reset.
  • Flashing white: Factory Reset initiated.
  • Solid white: Factory Reset complete; rebooting.
  • Flashing magenta: Updating firmware.
  • Solid magenta: May have lost connection to the Spark Cloud. Pressing the Reset (RST) button will attempt the update again.
The RGB LED can also let you know if there were errors in establishing an internet connection. A red LED means an error has occurred. These errors might include:
  • Two red flashes: Connection failure due to bad internet connection. Check your network connection.
  • Three red flashes: The Cloud is inaccessible, but the internet connection is fine. Check our Twitter feed78to see if there have been any reported outages; if not, visit our support page90 for help.
  • Four red flashes: The Cloud was reached but the secure handshake failed. Visit our support page90 for help.
  • Flashing yellow/red: Bad credentials for the Spark Cloud. Contact the Spark team (hello@spark.io).

I started up the app (on Android) and filled in the network information for my SSD. I got a solid blue light, meaning the network information went over. So, the app was talking to the Core, at least. This was soon followed by a flashing green, connecting to the local WiFi network...and flashing green, and flashing green. Nope, not connecting.

I tried the procedure for connecting directly via USB, on a Mac. The command for me was :
        $ screen /dev/tty.usbmodemfa131 9600

There was no prompt on the serial terminal through screen. I typed "i" for the Core identifier and hit enter. Got a number back. OK, we're communicating with the Core. Next, I typed in "w" to supply my WiFi credentials. After a moment, the Core started flashing green. And stayed that way. No help here. 

Since this was an early model of the Core, there was a problem with firmware on the CC3000 TI WiFi chip itself, distinct from firmware on the Core. I saw a post about this issue as late as July 2014, so this may still be affecting some.

Be prepared - you're going to be downloading several items and doing a lot of button pushing on the Core in these next steps. I've written this for the Mac, there's another set of instructions here for Windows. These steps will detail installing the DFU utility and its prerequisites, homebrew for Mac and the GCC (compiler) toolchain for ARM architecture . While we're at it, let's install the spark CLI (Command Line Interface), which can flash the CC3000 for us.

Installs for Firmware Upgrades
        (From a Terminal)
  • Install homebrew
    • ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    • brew doctor
    • do as the Doctor says!
  • Install the GCC Toolchain for ARM
    • brew tap PX4/homebrew-px4
    • brew update
    • brew install gcc-arm-none-eabi-48
  • Install DFU utility
    • brew install dfu-util
  • Install the Spark CLI
    • sudo npm install -g spark-cli
The following instructions are using *.bin files from the downloaded gits. You don't have to do the make/build process.

Flashing the Firmware
          (With the Spark Core attached to USB)
  • Get the CC3000 Program Patch
    • Download from github
    • Unzip the download
    • Go to your Download directory
    • cd to Downloads/cc3000-patch-programmer-master/build
    • spark flash --usb cc3000
  • Now, load the Spark Core firmware
    • Download from github 
      • NOTE: Newer firmware may be available - CHECK!
    • Unzip the download
    • Go to your Download directory
  • Put the Core into dfu-mode:
    • Hold down BOTH buttons (RST and MODE)
    • Release only the RST button, while holding down the MODE button.
    • Wait for the LED to start flashing yellow
    • Release the MODE button
    • Then, with your Core blinking yellow
      • go to Downloads/firmware-spark_2/build
      • dfu-util -d 1d50:607f -a 0 -s 0x08005000:leave -D core-firmware.bin
If you're successful, you should get a the LED to show:
  • Flashing White - reset initiated
  • Flashing Magenta - updating firmware
  • Solid White - rebooting
  • Flashing Blue - listening mode
Now, open up the Spark Core app on your device. I used iPhone, entered my WiFi credentials, and after a few moments, was greeted with the fabulous Slow Breathing Cyan, and the app continued with the Claim, letting me name my Core. I had also tried this on Android and never got to the Claim, but the Breathing Cyan kicked in.

If you see any errors or omissions in this process, please leave corrections in the comments.

No comments:

Post a Comment