Embedded Design Handbook

ID 683689
Date 8/28/2023
Public
Document Table of Contents

6.2.1.1.5. Nios® II Console View and stdio Library Functions

When debugging I/O behavior, you should be aware of whether your Nios® II software application outputs characters using the printf() function from the stdio library or the alt_log_printf() function. The two functions behave slightly differently, resulting in different system and I/O blocking behavior.

The alt_log_printf() function bypasses HAL device drivers and writes directly to the component device registers. The behavior of the two functions may also differ depending on whether you enable the reduced-driver option, whether you set your nios2-terminal session or the Nios® II Console view in the Nios® II Software Build Tools for Eclipse to use a UART or a jtag_uart as the standard output device, and whether the O_NONBLOCK control code is set. In general, enabling the reduced-driver option disables interrupts, which can affect blocking in jtag_uart devices.

To enable the reduced-drivers option, perform the following steps:

  1. In the Nios® II Software build Tools for Eclipse, in the Project Explorer window, right-click your BSP project.
  2. Point to Nios® II and click BSP Editor. The BSP Editor appears.
  3. In the BSP Editor, in the Settings tab, under Common, under hal, click enable_reduced_device_drivers.
  4. Click Generate.

For more information about the alt_log_printf() function, refer to "Using Character-Mode Devices" in the Developing Programs Using the Hardware Abstraction Layer chapter of the Nios® II Gen2 Software Developer’s Handbook.