Specifications
If you are using nios2-bsp, you disable the driver for the uart0 device as follows:
nios2-bsp hal my_bsp --cmd set_driver none uart0r
Use the --cmd option to call a Tcl command on the command line. The nios2-bsp-create-settings
command also supports the --cmd option. Alternatively, you can put the set_driver command in a Tcl
script and pass the script to nios2-bsp or nios2-bsp-create-settings with the --script option.
You replace the default driver for uart0 with a specific version of a driver as follows:
nios2-bsp hal my_bsp --cmd set_driver altera_avalon_uart:6.1 uart0r
Creating a Custom Version of newlib
The Nios II EDS comes with a number of precompiled libraries. These libraries include the newlib
libraries (libc.a and libm.a). The Nios II SBT allows you to create your own custom compiled version of the
newlib libraries.
To create a custom compiled version of newlib, set a BSP setting to the desired compiler flags. If you are
using nios2-bsp, type the following command:
nios2-bsp hal my_bsp --set hal.custom_newlib_flags "-O0 -pg"r
Because newlib uses the open source configure utility, its build flow differs from other files in the BSP.
When Makefile builds the BSP, it runs the configure utility. The configure utility creates a makefile in the
build directory, which compiles the newlib source. The newlib library files are copied to the BSP directory
named newlib. The newlib source files are not copied to the BSP.
Note:
The Nios II SBT recompiles newlib whenever you introduce new compiler flags. For example, if
you use compiler flags to add floating point math hardware support, newlib is recompiled to use
the hardware. Recompiling newlib might take several minutes.
Controlling the stdio Device
The build tools offer several ways to control the details of your stdio device configuration, such as the
following:
• To prevent a default stdio device from being chosen, use the following command:
nios2-bsp hal my_bsp --default_stdio noner
• To override the default stdio device and replace it with uart1, use the following command:
nios2-bsp hal my_bsp --default_stdio uart1r
• To override the stderr device and replace it with uart2, while allowing the default Tcl script to
choose the default stdout and stdin devices, use the following command:
nios2-bsp hal my_bsp --set hal.stderr uart2r
In all these cases, if you run nios2-bsp again to update your BSP, you must provide the original
command-line options again to prevent the default Tcl script from choosing its own default stdio
devices. Alternatively, you can call --default_stdio with the DONT_CHANGE keyword to prevent the
default Tcl script from changing the stdio device settings.
Configuring Optimization and Debugger Options
By default, the Nios II SBT creates your project with the correct compiler options for debugging
environments. These compiler options turn off code optimization, and generate a symbol table for the
debugger.
NII5V2
2015.05.14
Creating a Custom Version of newlib
4-17
Nios II Software Build Tools
Altera Corporation
Send Feedback