MCUXpresso IDE and Semihosting

Document created by Anthony Huereca Employee on Mar 30, 2017Last modified by Megan Hansen on Apr 5, 2017
Version 3Show Document
  • View in full screen mode

Semihosting printf with MCUXpresso IDE

When importing MCUXpresso SDK projects into MCUXpresso IDE, they will be configured by default to use “semihosting” for the terminal output. This means the project will use the debugger connection to send terminal characters instead of the UART. More information on semihosting can be found on this Community document and in Section 11.4 of the MCUXpresso User Guide.

 

Note that the information in this post is only applicable when using the MCUXpresso IDE, as the projects for other IDEs will use the UART by default when opening up their respective MCUXpresso SDK projects. Also semihosting only works when there is an active debug connection to the device. 

 

printf with semihosting:

 

printf with UART Terminal (with TeraTerm):

 

How to choose UART output during the project import

In order to use the UART for MCUXpresso IDE projects, some configuration settings need to be modified when importing in the project. First, you will need to uncheck the “Enable semihosting” option to clear the box. This will tell the project to use the normal libraries and not the semihosting libraries.

 

Then on the next screen, you’ll want to uncheck the “Redirect SDK “PRINTF” to C library “printf”” box to clear it. This will tell the project to use the MCUXpresso SDK source files for printf instead of the generic C files. This allows you to debug, and modify if desired, the printf functionality found inside the MCUXpresso SDK. Section 5.1.2 of the MCUXpresso IDE User Guide describes the options on this screen in more detail.

 

 

Switching between semihosting and UART

If you’re already imported the project and wish to switch between using semihosting or the UART, you can do this from the “Quick Settings” menu inside the Quickstart panel. 

 

If moving from semi-hosting to UART, this will change the library used to “nohost-nf” and set SDK_DEBUGCONSOLE define to 1 inside the pre-processor settings.

If moving from UART to semi-hosting, this will change the library to “semihost-nf” and set SDK_DEBUGCONSOLE define to 0. 

 

If you're not seeing any printf output, double check you have the right settings. 

 

Note that when importing the project initially and “Enable semihosting” is deselected and “Redirect SDK “PRINTF” to C library “printf”” is deselected in order to use the UART for terminal output, there is no SDK_DEBUGCONSOLE defined in the project settings. However inside the debug console SDK code itself, there is a #if statement so that if that value is not defined, then that define is set to 1, and hence why the SDK debug console is still used in that case.

3 people found this helpful

Attachments

    Outcomes