I received my Spark Core module, but when plugged it on my computer the LED started to blink in purple color (BLUE and RED LEDs was on) and nothing was working.
Unfortunately this LED color error is neither documented here or at spark core forum.
Then I decided to compile to core-firmware and flash it again using OpenOCD with STLink-v2 as SWD programmer.
First clone Spark Core repositories:
$ git clone https://github.com/spark/core-firmware.git $ git clone https://github.com/spark/core-common-lib.git $ git clone https://github.com/spark/core-communication-lib.git
Then enter inside core-firmware/build/ and edit the makefile file replacing the linker script “linker_stm32f10x_md_dfu.ld” by “linker_stm32f10x_md.ld” this way the entry point will be 0x08000000 instead of 0x08500000.
Then execute the make command:
When the compilation is finished these files will be created:
Invoking: ARM GNU Create Flash Image arm-none-eabi-objcopy -O binary core-firmware.elf core-firmware.bin Invoking: ARM GNU Create Flash Image arm-none-eabi-objcopy -O ihex core-firmware.elf core-firmware.hex Invoking: ARM GNU Print Size arm-none-eabi-size --format=berkeley core-firmware.elf text data bss dec hex filename 65356 2920 6912 75188 125b4 core-firmware.elf
Copy the core-firmware.bin to your home renaming it to spark.bin to make it easy to type on GDB:
$ cp core-firmware.bin /home/username/spark.bin
Now you need to connect some wires from SWD programmer to Spark Core board…
You just need to connect STLink-v2 programmer pins this way:
STLink-v2 Spark Core ----------------------------- RESET RST GND GND SWDIO D7 SWDCLK D6
# openocd -f interface/stlink-v2.cfg -f target/stm32f1x_stlink.cfg
Then open another terminal and execute:
$ telnet 127.0.0.1 4444 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Open On-Chip Debugger > reset halt target state: halted target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc > flash probe 0 device id = 0x20036410 flash size = 128kbytes flash 'stm32f1x' found at 0x08000000 > stm32f1x mass_erase 0 stm32x mass erase complete > flash write_image /home/username/spark.bin 0x08000000 target state: halted target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000003a msp: 0xfffffffc wrote 68280 bytes from file /home/username/spark.bin in 2.082684s (32.016 KiB/s) > reset run > exit
Note: This is almost the same way I flashed my STM32VLDiscovery few days ago:
The board now started with the LED in WHITE (RED/GREEN/BLUE turned on) instead of purple, but nothing is working.
Then I decided download and compile NuttX to Spark Core, after compilation I copied nuttx.bin to my home directory and executed the above commands (just replacing spark.bin to nuttx.bin).
Now the LED should turn on with GREEN color, it means NuttX is running…
To have access to NuttX terminal (NSH) you just use a 3.3V USB/Serial adapter and to connect three wires: GND, TX and RX. Open a serial console configured to 115200 8N1 and voila!