Debugging with STLINK using bootloader and ext USB

Hi,

I am trying to use the stlink-v3minie to debug the daisy seed (2.0, dfm). I am using the bootloader and the external usb (c). I am using the SRAM memory (APP_TYPE = BOOT_SRAM) as my program exceeds the 128kb internal flash. Has anyone had success using the stlink to debug with the bootloader? Just being able to print variables would be a big upgrade.

I have attempted using Logger<LOGGER_SEMIHOST> with PrintLine() without success. I am on Mac using VScode. I struggle to find documentation on how to attempt this, so if you know of any, or if you have succeeded in something similar, please let me know! :slight_smile:

Cheers,
Simon

1 Like

Hi,

to debug with bootloader you need to force hard breakpoints. With OpenOCD you can achieve this using gdb_breakpoint_override hard command.

For semihosting you need to link with rdimon, enable semihosting on debug server (monitor arm semihosting enable in GDB console or arm semihosting enable OpenOCD command) and call initialise_monitor_handles(); before you print your messages.

All together, if we take DaisyExamples/seed/Blink as an example, with OpenOCD as GDB server, VSCode + Cortex Debug and ST-Link adapter:

Makefile: Add

APP_TYPE=BOOT_SRAM
LDFLAGS=--specs=rdimon.specs -lrdimon

.vscode/launch.json: Change openOCDLaunchCommands key

      "openOCDLaunchCommands": [
        "init",
        "reset init",
        "gdb_breakpoint_override hard",
        "arm semihosting enable"
      ],

Blink.cpp: Add

extern "C" void initialise_monitor_handles(void);

before int main(void) and

initialise_monitor_handles();

after hardware.Init();

Keep in mind that it will raise a fault if no debugger with semihosting enabled is attached.

Build, flash, attach and in the Terminal under gdb-server tab you’ll see debug messages and breakpoints will work too.

You can read more here: Introduction to ARM Semihosting | Interrupt