Visual code and Logger<LOGGER_SEMIHOST>

Hi Guys,

I have this working fine from the command line with logging working to the OpenOCD output.

In Visual code with Cortex Debug though I cannot see any output anywhere!

I have added to the json:

      "postLaunchCommands": [
        "monitor arm semihosting enable"
      ],

Anyone got this working in visual code?

Cheers

Andy

Sure, semihosting works with Daisy Seed. I’m not using libDaisy myself, but it should work the same way.

AFAICT, that logger doesn’t do anything related to initialization and simply writes to STDOUT. So there are a few additions that are required besides that openocd command. Something like this must be added to your code:

#ifdef DEBUG
#warning "DEBUG uses printf and semihosting!"
  if(CoreDebug->DHCSR & 0x01)
    initialise_monitor_handles(); // remove when not semi-hosting
  printf("showtime\n");
#endif

Also, linker must receive this: -l rdimon --specs=rdimon.specs. And you’ll probably have to prevent the default syscall.c file from being compiled.

1 Like

Hi,

Thanks for the info, I already had the linker changes but did not have the initialise_monitor_handles(), interestingly semihosting logging was working fine without this using openocd/gdb from the command line.

Adding ‘initialise_monitor_handles()’ has now made it work in Visual Code, strange it works without it from the command line!

Thanks very much for the help, I now have logging :slight_smile:

Cheers

Andy

1 Like