CMSIS-Compiler Support  
Standard C Library File, I/O and OS Retargeting
No Matches
Low-Level I/O Retarget

CMSIS-Compiler splits low-level I/O retargeting into standard I/O stream related components and file stream related components.

The low-level I/O retarget decision tree is shown below:

Low-Level I/O Retarget Decision Tree

Low-Level I/O retargeting implementation checks whether the incoming stream is a standard stream (i.e. stderr, stdin, stdout) or a file system related stream and redirects incoming request to the appropriate software component. Chapters Standard Stream Components and File Interface Components explain these software components in detail.

Standard Stream Components

Software components that retarget the standard C library input/output streams are as follows:

Component Description
STDERR Standard error stream of the application to output diagnostic messages.
STDIN Standard input stream going into the application (scanf etc.).
STDOUT Standard output stream of the application (printf etc.).
TTY Teletypewriter, which is the last resort for error output.


  • TTY is only available for Arm Compiler toolchain.

Each component can have various Standard Stream Subcomponents.

Standard Stream Subcomponents

The subcomponent selection allows you to change the target hardware interface of the I/O stream.



The following subcomponents are available:

Variant Description
Breakpoint When the I/O stream is used, the application stops with BKPT instruction. No additional code is required.
Event Recorder STDOUT and STDERR can be redirected using the Event Recorder (especially interesting for targets without ITM (such as Cortex-M0/M0+/M23)).
ITM Use Instrumentation Trace Macrocell (ITM) for I/O communication via the debugger (only available for Cortex-M3/M4/M7/M33/M55/M85 processors).
Usually, data is shown in a dedicated window.
No additional code is required to output or input data through the ITM channel. However, you have to configure the ITM channel for tracing.
Custom Retarget I/O stream to a user defined interface (such as UART or other application specific interface).
See "Custom" Subcomponent for further details.


  • Depending on the selected subcomponent, certain #define are set in the header file RTE_Components.h that enable the appropriate code sections in the retarget core implementation.
  • Retargeting STDOUT and STDERR using the Event Recorder variant is available for all Cortex-M based devices.
  • The microlib of Arm Compiler C run-time library interfaces to the hardware via low-level functions. It implements a reduced set of high-level functions and therefore does not implement system I/O functions. Thus, in case of using the microlib, you cannot redefine the system I/O functions. Using any of the features of the Arm Compiler component provides the assert facility for microlib.

"Custom" Subcomponent

The Custom component provides code template that helps you to implement the retarget interface functionality for custom interfaces that are not mentioned above.

The following user code templates are available:

Component Name File Name
STDOUT:Custom STDOUT User template stdout_user.c
STDIN:Custom STDIN User template stdin_user.c
STDERR:Custom STDERR User template stderr_user.c
TTY:Custom TTY User template tty_user.c

File Interface Components

CMSIS-Compiler:File Interface software component provides generic shim layer interface between the C library and an arbitrary file system implementation.

Standard C library functions interact with files in a same manner as with standard I/O streams and offer the same retargeting interface. The existing interface is split to enable component interchangeability and File Interface API is used to enable quick file system retargeting.

Default components are as follows:

Component Description
Breakpoint When the file stream is used, the application stops with BKPT instruction. No additional code is required.
Custom Placeholder for custom File Interface implementation

Custom component is available to enable access to File Interface API header file when application provides an custom implementation. Custom implementation is typically needed when file system components do not provide its own implementation. To help you implement the functionality the File Interface:Custom component also provides the code template.