NRF52840 DK debugging


Atousa Duprat
 

I am new in Zaphyr and I have just started playing with samples. I
have NRF52840 Dk and seems that the development kit has J-Link OB
included? Following the instruction I haven't been able to debug the
sample codes. For example I just want to add a simple printf in teh
code and see it. Could anyone guide me?

Atousa,


Moń, Tomasz
 

On Mon, 2022-10-17 at 10:53 -0700, Atousa Duprat via lists.zephyrproject.org wrote:
I am new in Zaphyr and I have just started playing with samples. I
have NRF52840 Dk and seems that the development kit has  J-Link OB
included? Following the instruction I haven't been able to debug the
sample codes. For example I just want to add a simple printf in teh
code and see it.  Could anyone guide me?
You can launch gdb debug session using west debug. For example, from
zephyrproject directory run:
$ west build -b nrf52840dk_nrf52840 -d build-cdc-acm zephyr/samples/subsys/usb/cdc_acm
$ west debug -d build-cdc-acm

Inside gdb you can switch to source code view with layout src:
(gdb) layout src

Then you can single step with "step" and step over with "next".
To break at main, type "break main" then "continue" to let the program
run.

J-Link OB serial port on Linux is visible as e.g. /dev/ttyACM0. It can
be opened with various tools (115200 8N1, no flow control). I generally
use GTKTerm but putty or microcom works as well. When running the cdc
acm example as described above you should see some debug output on the
serial port.


Tomasz Moń | Senior Firmware Engineer
P +48 882 826 111 | Wrocław, Poland
nordicsemi.com | devzone.nordicsemi.com


Rodrigo Peixoto
 

Atousa, when you plug the board into the computer, is a folder being opened on the files explorer as a storage device? If so, you'll need to disable the Mass Storage feature using Jlink software to see the "printfs". The "west debug" command will work properly as well after the change. You can see how to proceed by following this link: https://docs.zephyrproject.org/latest/develop/flash_debug/nordic_segger.html#disabling-the-mass-storage-device-functionality

Hope it helps.
Best regards,
Rodrigo

Em ter., 18 de out. de 2022 às 08:08, Moń, Tomasz via lists.zephyrproject.org <tomasz.mon=nordicsemi.no@...> escreveu:

On Mon, 2022-10-17 at 10:53 -0700, Atousa Duprat via lists.zephyrproject.org wrote:
> I am new in Zaphyr and I have just started playing with samples. I
> have NRF52840 Dk and seems that the development kit has  J-Link OB
> included? Following the instruction I haven't been able to debug the
> sample codes. For example I just want to add a simple printf in teh
> code and see it.  Could anyone guide me?

You can launch gdb debug session using west debug. For example, from
zephyrproject directory run:
$ west build -b nrf52840dk_nrf52840 -d build-cdc-acm  zephyr/samples/subsys/usb/cdc_acm
$ west debug -d build-cdc-acm

Inside gdb you can switch to source code view with layout src:
(gdb) layout src

Then you can single step with "step" and step over with "next".
To break at main, type "break main" then "continue" to let the program
run.

J-Link OB serial port on Linux is visible as e.g. /dev/ttyACM0. It can
be opened with various tools (115200 8N1, no flow control). I generally
use GTKTerm but putty or microcom works as well. When running the cdc
acm example as described above you should see some debug output on the
serial port.


Tomasz Moń        | Senior Firmware Engineer
P +48 882 826 111 | Wrocław, Poland
nordicsemi.com    | devzone.nordicsemi.com







--
Rodrigo J. S. Peixoto


Martin Schröder
 

I prefer working with nordic in renode. So what I do is setup a resc script that loads my firmware and then I call "machine StartGdbServer <port>" to start the gdb server and connect to it using GDB. This works both for interactive mode and automated test mode done with robot framework. No hardware needed for debugging the code. Of course the process is very similar to debugging over JTAG - only difference is that debug server exposes renode simulation instead of the real core. 


On Mon, 17 Oct 2022 at 19:57, Atousa Duprat <atousa.p@...> wrote:
I am new in Zaphyr and I have just started playing with samples. I
have NRF52840 Dk and seems that the development kit has  J-Link OB
included? Following the instruction I haven't been able to debug the
sample codes. For example I just want to add a simple printf in teh
code and see it.  Could anyone guide me?

Atousa,







--
Best regards,

Martin Schröder
Embedded Firmware Consultant

Swedish Embedded Consulting Group AB