need help with nrf51822 and openocd

ChibiOS public support forum for topics related to the Nordic nRF51 family of micro-controllers.

Moderator: utzig

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

need help with nrf51822 and openocd

Postby ep.hobbyiest » Thu Feb 16, 2017 7:58 pm

Hi,

I configured openOCD and gcc compiler. But i got following error. i gave following command on terminal.

i created one file that is manual.cfg and contain in that file as follows.

Code: Select all

 #nRF52832 Target
source [find interface/stlink-v2.cfg]

transport select hla_swd

source [find target/nrf52.cfg]

and ran following command.

Code: Select all

openocd -d2 -f manual.cfg
and i got following output on terminal.

Code: Select all

fish@fish-VirtualBox:~/openocd$ openocd -d2 -f manual.cfg
Open On-Chip Debugger 0.7.0 (2013-10-22-17:42)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.sourceforge.net/doc/doxygen/bugs.html
debug_level: 2
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


I googled for the same, but didn't help that much.

I tried again following.

Code: Select all

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
    http://openocd.sourceforge.net/doc/doxygen/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:

Code: Select all

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
    http://openocd.sourceforge.net/doc/doxygen/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:

Code: Select all

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
    http://openocd.sourceforge.net/doc/doxygen/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

utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 20 times
Contact:

Re: need help with nrf51822 and openocd

Postby utzig » Fri Feb 17, 2017 9:31 pm

The one I use is on the repo:

https://github.com/ChibiOS/ChibiOS-Cont ... penocd.cfg

Your OpenOCD seems not to be able to find the MCU target. I would suggest updating to at least revision 0.9.0.

Cheers,
Fabio Utzig

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

Re: need help with nrf51822 and openocd

Postby ep.hobbyiest » Sat Feb 18, 2017 7:11 pm

i was trying to use that one, but got following error.

Code: Select all

make: *** No rule to make target `chcoreasm_v6m.S', needed by `build/obj/chcoreasm_v6m.o'.  Stop.


few of them are resolve, but i have no idea how to resolve this one.

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

Re: need help with nrf51822 and openocd

Postby ep.hobbyiest » Sat Feb 18, 2017 9:16 pm

i think there are some changes in hal/port/NRF5/. Changes might be because of change in file names.

bcoz i am getting following errors.

Code: Select all

make -j4 all
Compiling hal.c
Compiling st.c
Compiling hal_queues.c
Compiling hal_mmcsd.c
In file included from C:/ChibiStudio/chibios30/os/hal/include/hal.h:69:0,
                 from C:/ChibiStudio/chibios30/os/hal/src/st.c:25:
C:/ChibiStudio/chibios30/os/hal/include/st.h:46:20: fatal error: st_lld.h: No such file or directory
 #include "st_lld.h"
                    ^
compilation terminated.
In file included from C:/ChibiStudio/chibios30/os/hal/include/hal.h:69:0,
                 from C:/ChibiStudio/chibios30/os/hal/src/hal_queues.c:38:
C:/ChibiStudio/chibios30/os/hal/include/st.h:46:20: fatal error: st_lld.h: No such file or directory
 #include "st_lld.h"
                    ^
compilation terminated.
In file included from C:/ChibiStudio/chibios30/os/hal/include/hal.h:69:0,
                 from C:/ChibiStudio/chibios30/os/hal/src/hal.c:25:
C:/ChibiStudio/chibios30/os/hal/include/st.h:46:20: fatal error: st_lld.h: No such file or directory
 #include "st_lld.h"
                    ^
compilation terminated.
In file included from C:/ChibiStudio/chibios30/os/hal/include/hal.h:69:0,
                 from C:/ChibiStudio/chibios30/os/hal/src/hal_mmcsd.c:25:
C:/ChibiStudio/chibios30/os/hal/include/st.h:46:20: fatal error: st_lld.h: No such file or directory
 #include "st_lld.h"
                    ^
compilation terminated.
make: *** [build/obj/hal_queues.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [build/obj/hal.o] Error 1
make: *** [build/obj/st.o] Error 1
make: *** [build/obj/hal_mmcsd.o] Error 1


compiler is not able to search the file.

utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 20 times
Contact:

Re: need help with nrf51822 and openocd

Postby utzig » Sun Feb 19, 2017 10:52 pm

The ChibiOS-Contrib repo tries to keep up to date with ChibiOS master (or trunk). The file naming scheme has changed some time last year and now follows a hal_*_lld.(h|c) nomenclature. You may update you local copy to undo this change or update you ChibiOS to a more recent version.

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

Re: need help with nrf51822 and openocd

Postby ep.hobbyiest » Wed Feb 22, 2017 5:44 pm

Thanks.
I Synced the code with latest. Modified some makefiles. And it got compiled.
I opened openOCD. But how to flash the device. I ran some commands like in putty like

Code: Select all

Open On-Chip Debugger
> flash write_image erase build/ch.hex 0
auto erase enabled
couldn't open build/ch.hex

> flash write_image erase build\ch.hex 0
auto erase enabled
couldn't open buildch.hex

> flash write_image erase build\ch.bin 0
auto erase enabled
couldn't open buildch.bin

> flash write_image erase build/ch.bin 0
auto erase enabled
couldn't open build/ch.bin


which path need to mention?
Is it possible to flash it through eclipse itself?
We don't have debug file there.

utzig
Posts: 359
Joined: Sat Jan 07, 2012 6:22 pm
Location: Brazil
Has thanked: 1 time
Been thanked: 20 times
Contact:

Re: need help with nrf51822 and openocd

Postby utzig » Wed Feb 22, 2017 7:53 pm

The NRF51 demos output object files at the build directory. Your project is probably using some other place. You should use the ch.bin file, '/' forward slashes and the command looks correct (flash write_image erase build/ch.bin 0). Also, keep in mind that you are using relative paths in openocd, so you should be in a directory that is the parent of build.

ep.hobbyiest
Posts: 94
Joined: Sun Jun 26, 2016 5:22 pm
Has thanked: 4 times
Been thanked: 1 time

Re: need help with nrf51822 and openocd

Postby ep.hobbyiest » Thu Feb 23, 2017 6:31 pm

Initially i gave same path. Later i tried on Desktop(copied hex file there also) as well. Later i tried in projects root path(copied hex and bin file). then also no success.
I gave telnet connection via putty, isn't it matter, right?
here are the commands i tried.

Code: Select all

Open On-Chip Debugger 0.10.0-dev-00371-g81631e4 (2016-09-18-00:02)
Licensed under GNU GPL v2
For bug reports, read
   http://openocd.org/doc/doxygen/bugs.html
Warn : Interface already configured, ignoring
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : clock speed 950 kHz
Info : STLINK v2 JTAG v27 API v2 SWIM v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 3.255446
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'telnet' connection on tcp/4444
nrf51.cpu: target state: halted
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0xc1000003 pc: 0xfffffffe msp: 0xffffffd8
auto erase enabled
Error: couldn't open build/ch.bin

auto erase enabled
Error: Invalid command argument
image.base_address option value ('ch.bin') is not valid

auto erase enabled
Error: couldn't open ch.bin

auto erase enabled
Error: couldn't open ch.hex

flash
  flash bank bank_id driver_name base_address size_bytes chip_width_bytes
            bus_width_bytes target [driver_options ...]
  flash banks
  flash erase_address ['pad'] ['unlock'] address length
  flash erase_check bank_id
  flash erase_sector bank_id first_sector_num last_sector_num
  flash fillb address value n
  flash fillh address value n
  flash fillw address value n
  flash info bank_id ['sectors']
  flash init
  flash list
  flash padded_value bank_id value
  flash probe bank_id
  flash protect bank_id first_sector [last_sector|'last'] ('on'|'off')
  flash read_bank bank_id filename offset length
  flash verify_bank bank_id filename offset
  flash write_bank bank_id filename offset
  flash write_image [erase] [unlock] filename [offset [file_type]]
gdb_flash_program ('enable'|'disable')
mflash
  mflash bank soc_type base_addr pin_id target
  mflash init
nand
nrf51
  nrf51 mass_erase
program <filename> [address] [verify] [reset] [exit]
flash : command requires more arguments
in procedure 'flash'
auto erase enabled
auto unlock enabled
Error: couldn't open ch.bin
in procedure 'flash'
Info : dropped 'telnet' connection

debug file
nrf (OpenOCD, Flash and Run).7z
(1.09 KiB) Downloaded 479 times


Return to “nRF51 Support”

Who is online

Users browsing this forum: No registered users and 7 guests