This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

flash nrf51822 using openocd giving error

Hi, I have install openocd on ubuntu. but i after running next line

openocd -f interface/stlink-v2.cfg cfg -f target/nrf51_stlink.tcl

i got these error.

Runtime Error: embedded:startup.tcl:47: Can't find target/nrf51_stlink.tcl
in procedure 'script' 
at file "embedded:startup.tcl", line 47

I have stlink2 connected. I will be using s120 softdevice. I think my start address will be

    APP_CODE_BASE 0x0001D000
    APP_RAM_BASE 0x20002800

So, i found following command,

 openocd -f interface/stlink-v2.cfg   -f target/nrf51_stlink.tcl -c "program output_directory/s120.hex 0x0001D000"

Is that right? Or am i missing something?

  • Any kind of help will be great. I tried Following things without luck. try 1:

    fish@fish-:~/openocd$ openocd -f interface/stlink-v2.cfg   -f target/nrf51_stlink.tcl
    Open On-Chip Debugger 0.7.0 (2013-10-22-17:42)
    Licensed under GNU GPL v2
    For bug reports, read
    	openocd.sourceforge.net/.../bugs.html
    Runtime Error: embedded:startup.tcl:47: Can't find target/nrf51_stlink.tcl
    in procedure 'script' 
    at file "embedded:startup.tcl", line 47
    

    try 2:

    fish@fish-:~/openocd$ openocd -f interface/stlink-v2.cfg   -f src/target/nrf51_stlink.tcl
    Open On-Chip Debugger 0.7.0 (2013-10-22-17:42)
    Licensed under GNU GPL v2
    For bug reports, read
    	openocd.sourceforge.net/.../bugs.html
    WARNING: target/nrf51_stlink.cfg is deprecated, please switch to target/nrf51.cfg
    Runtime Error: embedded:startup.tcl:47: Can't find target/nrf51.cfg
    in procedure 'script' 
    at file "embedded:startup.tcl", line 58
    at file "embedded:startup.tcl", line 47
    

    try 3:

    fish@fish-:~/openocd$ openocd -f interface/stlink-v2.cfg -d2 -f src/target/nrf51.cfg
    Open On-Chip Debugger 0.7.0 (2013-10-22-17:42)
    Licensed under GNU GPL v2
    For bug reports, read
    	openocd.sourceforge.net/.../bugs.html
    debug_level: 2
    Error: session's transport is not selected.
    Runtime Error: embedded:startup.tcl:20: 
    in procedure 'script' 
    at file "embedded:startup.tcl", line 58
    in procedure 'swj_newdap' called at file "src/target/nrf51.cfg", line 33
    in procedure 'transport' called at file "/usr/share/openocd/scripts/target/swj-dp.tcl", line 22
    in procedure 'ocd_bouncer' 
    at file "embedded:startup.tcl", line 20
    
  • I had a custom nRF52832 board programmed with a patched OpenOCD 0.10.0-rc1 via st-link v2 with:

    $ openocd -s /usr/local/share/openocd/scripts -f ./openocd_nrf52.cfg -c "program myfirmware.hex verify reset exit"
    

    openocd_nrf52.cfg is as follows:

    #nRF52832 Target
    source [find interface/stlink-v2.cfg]
    transport select hla_swd
    source [find target/nrf52.cfg]
    

    Your point might be to tell openocd where ".tcl" scripts are located with "-s" option, addressing a "Can't find target/nrf51_stlink.tcl" message in "try 1".

    UPD1. Or try setting a transport to "swd" or "hla_swd" in "try 3", e.g.:

    $ openocd -f interface/stlink-v2.cfg -d2 -c "transport select hla_swd" -f src/target/nrf51.cfg
    

    UPD2. So putting all that together, try these steps:

    1. Create a config file, e.g. stlink2_nrf51.cfg, containing:

      #nRF51822 Target source [find interface/stlink-v2.cfg] transport select hla_swd source [find target/nrf51.cfg]

    2. Upload a hex file, specifying openocd scripts location and your config:

      $ openocd -s your/openocd/scripts/directory -f ./stlink2_nrf51.cfg -c "program yourfirmware.hex verify reset exit"

Related