Logging/ST-Link

Hi!

So, i’m able to flash my daisy pod successfully with build_and_program (make clean; make; make program). But, for the sake of troubleshooting, I’m trying to just log simple outlooks and nothing works for me.

I’ve tried the Logger<> logger class, and i’ve tried just using pod.seed.PrintLine("foobar").
I’ve actually used both methods in the past when I didn’t have the ST-Link debugger, and they worked fine, but now that I’m using the ST-Link debugger, I can’t seem to log.

I’m able to see my daisy pod as an option in the serial monitor in arduino, but there’s no output.

logger.StartLog(true); seems to hault the program.
logger.StartLog(false); doesn’t hault the program, but i still dont get any output.

Even though flashing via the st-link debugger is succesful via build_and_program, i do still see this in the logs, maybe relevant?

Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Unable to match requested speed 4000 kHz, using 3300 kHz

Hi @NilPointer2000

The default logger implementation, and the seed’s logging/print methods are for USB serial.

Once StartLog has been run, the daisy should appear as a COM device on your computer.

Using StartLog(true) will halt the execution until a serial connection is made to the COM port (handy for debugging initialization states, etc.)

If you want to print out through the ST Link (semihosting), you can use the Logger<LOGGER_SEMIHOST> instead.

As for the Unable to match requested speed error, that’s pretty normal. openocd adjusts it’s frequency as needed. Nothing to worry about there :slight_smile:

1 Like

@shensley Thank you for quick response!!

So if i use the Logger<LOGGER_SEMIHOST> instead, do I need to change any of the board settings in arduino or vs code USB Support or U(S)ART, lastly, is using LOGGER_SEMIHOST, should i expect to see my logs via serial monitor or will they appear in the debug console? (sorry for the probably what are obvious questions, i’m new to the embedded world).

In Arduino, you’ll want to use the default Serial library that’s included with Arduino – the output will appear in the serial monitor from the USB connection on the daisy.

In libDaisy, with Logger<LOGGER_SEMIHOST> you’ll see output appear in the debug console.

If you use the Logger that’s bulit into the DaisySeed class (i.e. pod.seed.Print etc. ) that will appear in the serial monitor through the USB.

My experience with the semihosting is that it can be pretty slow, I do like using the ST-Link for breakpoints, checking variables, registers, etc. but when I need to print stuff, I generally go with the default Logger through USB.