2

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'm really quite new to this, and most of my success thus far has been thanks to quite in-depth tutorials.
  • I'm using ubuntu and openOCD for programming
  • I'm not sure what I need to put in my program in order to get debug/console info out (and I'm not even sure what I would do to receive it on my computer).

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!

Sylhare
  • 3,058
  • 4
  • 36
  • 51
Helpful
  • 532
  • 3
  • 13
  • ST-Link V2 what exactly one you have, STM-original, form the nucleo/discovery board or the Chinese one? All work but yoo will need to define configuration files. – 0___________ Aug 12 '17 at 18:18
  • It's the chinese one, the small usb-flash-drive looking one. – Helpful Aug 14 '17 at 14:37

1 Answers1

2

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.

  • I've got the flashing working properly, it's the debugging I'm struggling with. Right now I've got it ghetto'd to the point where I can send serial debug through an arduino to get it to a serial monitor on the computer. That's... not ideal. I'm trying to figure out how I can print debug strings back through the st-link to get back to the computer. – Helpful Aug 15 '17 at 02:49