[Resolved] Fixing the crash on Particle 0.7.0 firmware

The crash is fixed in the Carloop library version 2.1.0

To upgrade your application running in the Particle Web IDE open the Carloop library version 2.1.0, click Include in project and select your application.

To upgrade your application built with the Particle CLI, run particle library add carloop

To get your Photon or Electron back online if it’s in a loop of booting, connecting to the cloud then blinking red and crashing, hold the SETUP button, tap RESET and let go of SETUP. The device will connect to the Particle Cloud and start breathing magenta instead of cyan. This is called Safe mode. You will then be able to flash your application that includes the fixed version of the library.

Original thread

With the release of Particle firmware 0.7.0 for the Photon and Electron the Carloop library started crashing in the begin() method.

I’ll document how I’m investigating the issue in this thread.

First, I’ll download the latest Particle firmware and Carloop library.

git clone https://github.com/carloop/carloop-library.git
git clone https://github.com/particle-iot/firmware.git
cd firmware
git checkout -t origin/release/v0.7.0

To debug effectively I’ll create a local build of the Particle firmware and the Carloop library I can run using the Programmer Shield.

Before building the firmware, I have to install the local build tools. I downloaded gcc 5.3 for ARM to compile the 0.7.0 firmware.

I copied the Carloop library files and the minimal example into a new folder of the Particle firmware at user/applications/carloop. There are other ways to build the firmware with a user application, but this one is straightforward.

ls user/applications/carloop/
carloop.cpp  carloop.h  carloop_minimal.cpp  TinyGPS++.cpp  TinyGPS++.h

Then I started following the steps for using a debugger with the Particle Photon

To build a debugger friendly firmware, I used this command:

cd main
make clean all PLATFORM=photon USE_SWD_JTAG=y MODULAR=n APP=carloop

After a while the build succeeds and I get these lines:

arm-none-eabi-size --format=berkeley ../build/target/main/platform-6/carloop.elf
   text	   data	    bss	    dec	    hex	filename
 485336	   2228	  41744	 529308	  8139c	../build/target/main/platform-6/carloop.elf
arm-none-eabi-objdump -h -S ../build/target/main/platform-6/carloop.elf > ../build/target/main/platform-6/carloop.lst

I flashed the debug build by putting the Photon in DFU mode (hold SETUP, tap RESET and hold SETUP until the LED blinks yellow then release SETUP) then running

cd main
make program-dfu PLATFORM=photon USE_SWD_JTAG=y MODULAR=n APP=carloop

After flashing completed I got the blinking red crash as expected. Time to fire up the debugger!

Note to myself for when I’m done: remember to put the Photon back to a non-debug firmware otherwise I will be very confused why I can’t flash from the Web IDE or CLI next time I use my Carloop.

cd modules
make clean all program-dfu PLATFORM=photon

The I used the OpenOCD and gdb tools as described in the debugger guide to connect to the Photon.

openocd -f interface/ftdi/particle-ftdi.cfg -f target/stm32f2x.cfg -c "gdb_port 3333"
arm-none-eabi-gdb -ex "target remote localhost:3333" build/target/main/platform-6/carloop.elf

I was now able to restart the microcontroller stopping at the first instruction, set breakpoints in the code and run the code.

monitor reset halt
break setup

Putting a breakpoint on setup then tracing the calls leads to this part of the Carloop setup:

If I put a breakpoint on the panic_ function which is called when the Photon crashes I see that the function executing when the crash happens is

So the culprit is pretty clearly something wrong in the thread handling.

Since the crash is in the GPS handler, a workaround to use Carloop until the issue is fixed is to disable the GPS (i.e. enable the CAN bus only).

1 Like

this is an amazing write up, @jvanier!

I was able to reproduce the issue with a minimal Particle program. The following code works with 0.6.3 but crashes with 0.7.0 on a Photon.

#include "application.h"

Thread t;

int count = 0;

void run() {
  while(true) {

void setup() {
  t = Thread("count", run);

void loop() {
  Serial.printlnf("count=%d", count);

I reported this regression to the Particle firmware team.

In the mean time I was able to figure out a workaround. I’ll release a new version of the Carloop library with the workaround.

1 Like

Alright, the fix is out with the Carloop library version 2.1.0.

Instructions for upgrading are in the first post of this thread.

1 Like

@alanm & @jvanier,

Thanks for looking into this and supporting the community!!!

Thanks so much for the fix and continued support!

Thanks @jvanier for the solution !