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
continue