Embedded Studio Library IO

From SEGGER Wiki
Revision as of 13:02, 29 July 2021 by Nino (talk | contribs) (STD)
Jump to: navigation, search

The debugger and the Runtime Library of Embedded Studio support different mechanisms for debug input and output. The mechanism to be used in a project can easily be selected in the project options at Library -> Library I/O and does not require any additional file or configuration.

Library I/O Mechanisms

There are different mechanisms for different application requirements.

RTT

Use SEGGER Real-Time Transfer (RTT), which enables super fast output without halting the system. The target application writes the output string to a buffer in RAM. The J-Link reads the buffer while the target is running.

Suitable for applications with real-time requirements.

Available on all Cortex-M based systems.

SWO

The target application writes the output string to the ITM stimulus ports. The J-Link reads the SWO pin while the target is running.

Suitable for applications with real-time requirements.

Available on all Cortex-M based systems with a SWO pin.

SEMIHOST

Halt the target CPU for I/O operations. On halt, the debugger reads and executes the operation command and parameters.

Available on all targets (Cortex-M, Cortex-A, Cortex-R, RISC-V)

SEMIHOST host-formatted

With host formatting printf output is processed by the debugger instead of on the target. The debugger reads the format string and the parameters from the target and feeds it to its formatter to be printed. No code for formatting is required on the target, saving 1 - 3 kiloBytes of ROM.

Recommended for minimum size.

SEMIHOST buffered

Output is written to a small buffer in target RAM and flushed to the debugger via semihosting when the buffer is filled or on end of output.

SEMIHOST unbufferd

Output is immediately flushed to the debugger instead of buffered, which requires less RAM but is slower because the target is halted for every output operation.

STD

Use user-supplied I/O mechanisms, such as output on a UART.

When STD is selected as Library I/O, the user has to supply an implementation of int __SEGGER_RTL_X_file_write(__SEGGER_RTL_FILE *__stream, const char *__s, unsigned __len); for output and int __SEGGER_RTL_X_file_read(__SEGGER_RTL_FILE *__stream, char *__s, unsigned __len); for input which can be used to route character output/input to any resource, such as a UART or other terminal.

Return values are:

  • >=0: OK
  • < 0: Error

STD Deprecated

---The following implementation was changed in ES V5.50. So for that a newer versions use the implementation above. For older versions the one below.---

When STD is selected as Library I/O, the user has to supply an implementation of int __SEGGER_RTL_stdout_putc_std(int c); which can be used to route character output to any resource, such as a UART or other terminal.