How can I print debug output and see it in the terminal or in VSCode?
When I do
int main(void)
{
patch.Init();
System::Delay(500);
patch.StartLog(true);
it hangs on the StartLog() line. I can debug in VSCode and see my variables.
How can I print debug output and see it in the terminal or in VSCode?
When I do
int main(void)
{
patch.Init();
System::Delay(500);
patch.StartLog(true);
it hangs on the StartLog() line. I can debug in VSCode and see my variables.
StartLog
starts the Logger Serial connection over USB. The true
argument means the seed will hang on that line until it detects the computer is connected.
You should get logging output if you connect the seed via USB. There are some VSCode extensions that will allow you to start the serial connection and watch the output there.
The logger uses the USB by default, you can however set a logger up to use semihosting, which will make the serial connection through the debugger.
That would look something like this:
using Log = Logger<LOGGER_SEMIHOSTING>;
// to write and so on
Log::StartLog(true);
Log::PrintLine("print this string");
TBH Iâve never actually tried this so Iâm not 100% what it looks like on the PC side and so on, you could probably use one of the previously mentioned Serial extensions.
I tried this
using Log = Logger<LOGGER_SEMIHOST>; Log::StartLog(true); Log::PrintLine("print this string\n", 18); Log::PrintLine("print this string\n", 18); Log::PrintLine("print this string\n", 18); Log::PrintLine("print this string\n", 18);
but no love. I tried a serial monitor in VSCode and Serial Tools
.
Also tried flashing via the dfu but the serial port doesnât appear if I connect directly without the STLINK
Did you try reading the log over USB without the semihosting stuff?
i.e. plugging USB straight into the daisy without the stlink and using your original code.
Nah, I tried but for some reason I canât program the dfu without the STLINK anymore.
â PickupMachine git:(main) â make program
openocd -s /usr/local/share/openocd/scripts -f interface/stlink.cfg -f target/stm32h7x.cfg
-c âprogram ./build/PickupMachine.elf verify reset exitâ
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
Info : auto-selecting first available session transport âhla_swdâ. To override use âtransport select â.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1800 kHz
Error: open failed
in procedure âprogramâ
** OpenOCD init failed **
shutdown command invoked
Looks like youâre running the program
task, which tries to use the debug probe. If itâs not connected itâll throw those errors.
Instead, you can flash over USB without the debug probe with the program-dfu
task.
Ctrl-P
on Windows or Command-P
on mac, then task build_and_program_dfu
.This is laid out nicely here with gifs and stuff.
Hope that helps!
Thanks, I was able to program the module via usb that way and was able to see some debug output!