Does the DEBUG_PRINT_ON_SWO define work?

Firmware/software/electronics/mechanics
Post Reply
dblockil
Beginner
Posts: 9
Joined: Thu Jan 01, 2015 7:29 pm

Does the DEBUG_PRINT_ON_SWO define work?

Post by dblockil »

Looking at Debug.h I noticed there was a define DEBUG_PRINT_ON_SWO. I am thinking that the intent of this define is when active the DEBUG_PRINT command will print to the console of the GDB (connected through the debug adapter and the ST-LINK/V2) instead of printing to the CFClient Console.
I modified the Makefile
CFLAGS += -DDEBUG_PRINT_ON_SWO

But when I "make clean" and the "make" the firmware I receive a compiler error.

Is there any way to get this working. Am I correct that if this works it will print the DEBUG_PRINT messages to the GDB console?
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by tobias »

I think it has worked at one point but what I can remember it did not work well.
dblockil
Beginner
Posts: 9
Joined: Thu Jan 01, 2015 7:29 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by dblockil »

Does the DEBUG_PRINT_ON_SEGGER_RTT flag work? Would I need a different debugger than the ST_LINK V2? Does this different debugger work with GDB in VS Code?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by arnaud »

I just tried RTT and it does work with OpenOCD and with ST-Link V2/V3! The crazyflie firmware needs to be built with "DEBUG_PRINT_ON_SEGGER_RTT=1" in config.mk or on the command line.

I added a "make rtt" target to the makefile to enable it: https://github.com/bitcraze/crazyflie-f ... 76bdef00e3

Unfortunatly openocd cannot print the RTT messages on the console, it does make it available on a TCP socket so typing "telnet localhost 2000" in another console will make the Crazyflie console visible over RTT.
dblockil
Beginner
Posts: 9
Joined: Thu Jan 01, 2015 7:29 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by dblockil »

Could you step me through the procedure to try this out. I have not had success yet to get OpenOCD working. It looks like openocd does not like the rtt command on my end.
Here is what I tried:
I cloned the latest crazyflie firmware just in case I missed something.
I made config.mk and uncommented the line DEBUG_PRINT_ON_SEGGER_RTT = 1
make clean
make (I had to change the Makefile back to using stlink-v2.cfg instead of stlink.cfg) stlink.cfg could not be found
then I created launch.json as per wiki, and copied STM32F405.svd into my firmware folder.
then in VS Code went to Run Debug and launched the debugger. That worked and I was able to step through the code.
then I ran make rtt. This seemed to not work, below is what I received in the console

openocd -d2 -f interface/stlink-v2.cfg -f target/stm32f4x.cfg -c init -c targets -c "rtt setup 0x20000000 262144 \"SEGGER RTT\"" -c "rtt start" -c "rtt server start 2000 0"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
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: 2000 kHz
adapter_nsrst_delay: 100
none separate
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Info : STLINK v2 JTAG v29 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 2.922835
Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
TargetName Type Endian TapName State
-- ------------------ ---------- ------ ------------------ ------------
0* stm32f4x.cpu hla_target little stm32f4x.cpu running
invalid command name "rtt"


Is the problem that I do not have the stlink.cfg file and am using the stlink-v2.cfg file. Or is my openocd the wrong version?
Thanks
dblockil
Beginner
Posts: 9
Joined: Thu Jan 01, 2015 7:29 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by dblockil »

I installed openocd 0.11 from source and now "make rtt" works. Thanks. It is not quite what I am wanting though. Maybe I am asking for too much but I would both like be able to single set through the CF code and have the DEBUG_PRINT messages print to the telnet session. Is that possible?

Here are the steps I took to build openocd 0.11 from source:

git clone git:://git.code.sf.net/p/openocd/code openocd
./bootstrap
./configure
make
sudo make install
openocd --version
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by tobias »

Have you tried it? Does single stepping and RTT not work at the same time?
dblockil
Beginner
Posts: 9
Joined: Thu Jan 01, 2015 7:29 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by dblockil »

Yes I have tried to run both at the same time. I am testing this on a Ubuntu 18.04 machine, not the virtual machine.
Here are the steps I tried:
1. In a separate terminal from VSCode, I changed to the firmware's folder and ran make rtt. This launches fine.
2. Then inside VSCode I click the green arrow close to Cortex_Debug and this does not launch correctly. In the output tab of VSCode the following error is printed
Error: couldn't bind tcl to socket on port 6666: Address already in use

In the output of the terminal running make rtt it states
Info : Listening on port 6666 for tcl connections
so I guess both sessions are trying to use this same tcl connection.
jonasdn
Expert
Posts: 132
Joined: Mon Mar 01, 2021 3:13 pm

Re: Does the DEBUG_PRINT_ON_SWO define work?

Post by jonasdn »

Hi!

This is not something we have seen, perhaps can this issue on the cortex-debug Github help?: https://github.com/Marus/cortex-debug/issues/216
Post Reply