Ok, I think I’ve figured out how to run a debugger on a mac.
Prerequisites: Install openocd from homebrew or some other similar environment.
brew install openocd
The openocd that comes with the arduino-proffieboard plugin doesn’t seem to work.
Step #1: Start OpenOCD
Open up a terminal window and find your arduino-proffieboard pluggin directory. In my case it was
To start openocd, run it as:
opencd -f $HOME/Library/Arduino15/packages/proffieboard_beta/hardware/stm32l4/3.4.0/variants/STM32L433CC-Proffieboard/openocd_scripts/stm32l433cc_butterfly.cfg
Instead of loading it from the plugin dir, you could also check out the config file from github.
When you run openocd, you should see this:
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 500 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.246123
Info : STM32L433.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for STM32L433.cpu on 3333
Info : Listening on port 3333 for gdb connections
Step #2, run gdb
Before we can start GDB, we need to find where arduino keeps it’s temporary files.
Go into arduino preferences and make compilation verbose so you can find the compilation directory. When you compile something, a bunch of temporary files are saved somewhere that are important for debugging. In my case they were in
/var/folders/j2/4n85ntms6pgdm7r218lxgl38000kmj/T/arduino_build_771137. Since that’s a pain in the butt to type every time, I set a variable:
(Do this in the terminal that you want to run GDB in, not the same one as used for openocd…)
Gdb is also in the arduino plugin directory, but in the tools sub-section, so in my case, I found it in:
Again, let’s use a variable:
Now we can start gdb like so:
$GDB -d ~/ProffieOS/ $BUILD/ProffieOS.ino.elf -ex 'target remote localhost:3333'
(This assumes that your ProffieOS source directory is ~/ProffieOS)