Article ID: 000083914 Content Type: Troubleshooting Last Reviewed: 09/11/2012

Does the printf routine in the Nios™ embedded processor software development kit (SDK) support floating-point data types?

Environment

BUILT IN - ARTICLE INTRO SECOND COMPONENT
Description

The Nios SDK has its own implementation of the printf routine and does not include support for floating-point types. The floating-point support which is available in the standard GNU printf was removed since most embedded applications do not use floating-point numbers. There is increased overhead involved in handling floating-point types. Using the standard printf routine will increase the S-Record File (.srec) size (typically 64 Kbytes).

If you require floating-point support, you can use the standard GNU printf rather than the Nios SDK printf by performing the steps below.

Nios 2.0

For each Nios CPU which you want floating-point support for printf, follow these steps:

  1. Open the Nios CPU MegaWizard® Plug-In Manger (double clicking the CPU in the SOPC Builder).
  2. Make sure Enable Advanced Configuration Controls is checked.
  3. Select the Software Configuration tab.
  4. Uncheck Use small printf.

Since floating-point support is implemented in software, you do not need to regenerate the HDL for the Nios embedded processor. You may uncheck the HDL box in the System Generation tab of the SOPC Builder if you have previously generated the system as long as this is the only change you are making.

The SOPC Builder always generates an SDK folder for each CPU. When compiling C code in the SDK folders, the appropriate version of the printf routine (floating-point or non-floating-point) will be linked in according to the Use small printf setting in the SOPC Builder for that particular CPU.

Nios 1.x

  1. Edit the makefile in the inc or lib directory.
    1. omit the /NR_Printf.o \ line when using Nios 32 designs.
    2. omit the /NR_Printf.o \ line when using Nios 16 designs.
  2. Remake the libraries by performing make -s all in the inc directory.
  3. Rebuild the code that uses printf.

Related Products

This article applies to 1 products

Intel® Programmable Devices