debuggingstm32openocdnrf51

nrf51822 + ST-Link V2 Debugging


I'm working on a project where I need to program an NRF51822 using an ST-Link V2 (well, perhaps I don't have to do it this way, but that's what I'm currently doing/own).

I'm pretty sure it's running properly, but I really need a debug console to get some information back from the NRF51 module to make sure things are connected OK.

I'm not going to lie:

I would really appreciate some help on:

  1. What to add to my program to log info to the console, and
  2. How to view that debug console on my computer.

Thank you very much!


Solution

  • You need to use such OpenOCD config file to connect with ST-Link

    #nRF51822 Target
    source [find interface/stlink-v2-1.cfg]
    
    transport select hla_swd
    
    set WORKAREASIZE 0x4000
    source [find target/nrf51.cfg] 
    

    You need to insert your version stlink-v2-1.cfg or stlink-v2.cfg

    Also you need to add this to your makefile to write program

    flash: $(OUTPUT_BINARY_DIRECTORY)/$(HEX)
        $(OPENOCD) -d2 -f $(TEMPLATEROOT)/openocd.cfg -c 'init_reset halt; program $(OUTPUT_BINARY_DIRECTORY)/$(HEX) verify; reset; exit'
    

    Debug is more complex. You'd better set eclipse with OpenOCD/GDB to make it. For console solution you can follow this lesson

    This worked for me. Good luck.