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:
- Open the Nios CPU MegaWizard® Plug-In Manger (double clicking the CPU in the SOPC Builder).
- Make sure Enable Advanced Configuration Controls is checked.
- Select the Software Configuration tab.
- 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
- Edit the makefile in the inc or lib directory.
- omit the /NR_Printf.o \ line when using Nios 32 designs.
- omit the /NR_Printf.o \ line when using Nios 16 designs.
- Remake the libraries by performing make -s all in the inc directory.
- Rebuild the code that uses printf.