Spark-core debugging via JTAG/SWD

Im trying to setup debugging with OpenOCD. This is my spark_core.cfg file:

source [find interface/stlink-v2.cfg]
set WORKAREASIZE 0x5000
source [find target/stm32f1x_stlink.cfg]
reset_config srst_only srst_nogate

Im able to successfully connect to my Spark Core (using SWD, not JTAG). When I start gdb server and do:

target remote localhost:3333
monitor reset halt
jump Reset_Handler

It just doesn't seem to get into my setup() and loop() routines at all, this is what i see whenever I CTRL-C:

(gdb) where
#0  GPIO_Init (GPIOx=0xdf2855ce, GPIO_InitStruct=GPIO_InitStruct@entry=0x20004f44)
    at MCU/STM32F1xx/STM32_StdPeriph_Driver/src/stm32f10x_gpio.c:232
#1  0x0800f7ac in LED_Init (Led=Led@entry=LED1) at MCU/STM32F1xx/SPARK_Firmware_Driver/src/hw_config.c:393
#2  0x0800fe8a in Set_System () at MCU/STM32F1xx/SPARK_Firmware_Driver/src/hw_config.c:159
#3  0x0800e716 in HAL_Core_Config () at src/core-v1/core_hal.c:81
#4  0x08008212 in LoopFillZerobss () at ../build/arm/startup/spark_init.S:3
#5  0x08008212 in LoopFillZerobss () at ../build/arm/startup/spark_init.S:3
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Is this because I use SWD? I cant use JTAG because I need the ports it uses.

Sometimes, after several gdb commands:

jump Reset_Handler

I get to app_setup_and_loop and eventually to setup.

  • What does Reset_Handler actually do and why do i need to issue it 2x with CTRL-C?

When in setup code, i can run all the lines until i hit:

delay(10);

This seems to hang gdb, the timer seems to not be updated in function HAL_Timer_Get_Milli_Seconds(void). But again, I can get past this by issuing:

set variable system_1ms_tick = 10
  • Why is the variable system_1ms_tick not being updated? Are interrupts disabled or something when Spark core runs under gbd by default?

Essentially I have the same problems as with st-util:

but im witnessing the same symptoms as when using st-util: