Nios® V Processor Software Developer Handbook

ID 743810
Date 10/31/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

6.6.6.1. Enabling Logging

Logging is enabled by setting hal.log_port to a JTAG UART or a UART device. You can find the hal.log_port in the BSP Editor. The setting allows the HAL to send log messages to the specified device.

Once hal.log_port is set, ALT_LOG_ENABLE is defined in toolchain.cmake and the ALT_LOG_FLAGS flag is set to 0, the default value. If hal.log_port is not set, then ALT_LOG_ENABLE and ALT_LOG_FLAGS do not appear in toolchain.cmake.

The build tools also set the ALT_LOG_PORT_TYPE and ALT_LOG_PORT_BASE values in system.h to point to the specified device.

When logging is enabled without special options, the HAL prints out boot messages to the selected port. For typical software that uses the standard alt_main.c (such as the Hello World software example), the messages appear as in the following example.

Default Boot Logging Output

[crt0.S] Inst & Data Cache Initialized.
[crt0.S] Setting up stack and global pointers.
[crt0.S] Clearing BSS
[crt0.S] Calling alt_main.
[alt_main.c] Entering alt_main, calling alt_irq_init.
[alt_main.c] Done alt_irq_init, calling alt_os_init.
[alt_main.c] Done OS Init, calling alt_sem_create.
[alt_main.c] Calling alt_sys_init.
[alt_main.c] Done alt_sys_init. Redirecting IO.
[alt_main.c] Calling C++ constructors.
[alt_main.c] Calling main.
[alt_exit.c] Entering _exit() function.
[alt_exit.c] Exit code from main was 0.
[alt_exit.c] Calling ALT_OS_STOP().
[alt_exit.c] Calling ALT_SIM_HALT().
[alt_exit.c] Spinning forever.
Note: A write operation to the logging device stalls in ALT_LOG_PRINTF() until the characters are read from the logging device’s output buffer. To ensure that the Nios® V processor application completes initialization, run the juart-terminal command from the Nios® V Command Shell to accept the logging output.