OpenOCD Debugger Setup on ARM Cortex-M0 Microcontrollers ( eg : STM32L0)



Open On-Chip Debugger (OpenOCD) is a free, open-source project that aims to provide debugging, in-system programming, and boundary scan using a debug adapter. The adapter is a hardware module that provides the right signals for the target to understand.


Step - 1

Build the project


Step - 2

Right click on your  project -> Debug As -> Debug Configurations -> STM32 C/C++ Application -> New Launch Configuration -> 

Set Debug probe: ST-LINK(OpenOCD)

In the Startup tab -> Initialization Commands -> (add this command), monitor arm semihosting enable

Apply & Close


Step - 3  

Right click on your  project -> Properties -> C/C++ build -> Settings -> Tool Settings -> MCU GCC Linker -> Miscelleanous

In Other flags -> New -> (add these line) -specs=rdimon.specs -lc -lrdimon

Apply & close


Step - 4

Go to src -> main.c -> (Add this line as the first line inside the main function.) -> initialise_monitor_handles();

(Add this line just before the main function.) -> 

extern void initialise_monitor_handles(void);


Step - 5

Right click on the src -> syscalls.c file -> Properties -> C/C++ Build -> check - Exclude resource from build


Step - 6

When you use a printf statement, you must use "\n"


Code  - Github Link


#include <stdio.h>

extern void initialise_monitor_handles(void);

int main(void){

initialise_monitor_handles();

printf("hello world\n");

for(;;);

}

Comments

Popular Posts