Hi!
I’ve already read the various topics on the forum, but I’m still unable to understand how to set up everything to be able to log successfully. I’ve tried both the default (serial) logging and semihosting (to use the debug console), but neither worked.
First I tried the default (serial) logging, by calling StartLog(true)
in main()
and PrintLine("test")
right after. I read that as soon as StartLog()
is called the Daisy is seen as a serial device. Two questions:
- Is this mode available when the ST-Link is connected? I’ve both the probe and the USB cable connected to the Mac. Maybe to use this mode I should disconnect the probe?
- Where is the logging printed? Should I connect to the Daisy somehow? How? Is it something that can be done in VSCode?
Then I tried using semihosting, adding to the Makefile:
LDFLAGS += --specs=rdimon.specs -lc -lrdimon
and to launch.json:
"postLaunchCommands": [
"monitor arm semihosting enable"
]
Then, before main()
, I’ve added:
#ifdef DEBUG
extern "C" void initialise_monitor_handles(void);
#endif
and at the beginning of main()
:
#ifdef DEBUG
if(CoreDebug->DHCSR & 0x01)
initialise_monitor_handles(); // remove when not semi-hosting
printf("showtime\n");
#endif
Launching the debugging I see this output in the gdb-server console:
semihosting is enabled
showtime
so I guess that this worked, but then if I place another printf()
in the code, even before my main loop, I don’t see anything in the console. Why is that?
Then I tried using Logger<LOGGER_SEMIHOST>
:
Logger<LOGGER_SEMIHOST> logger;
void InitLogger()
{
logger.StartLog(true);
}
void Debug(const char* format)
{
logger.PrintLine(format);
}
In main()
, I called InitLogger()
and then Debug("test")
, but “test” isn’t printed anywhere. I thought I’d have seen it in the debug console but no. By the way, in the debug console I see semihosting is enabled
, so I think that at least that is working.
Any suggestions?