Specifications

Enable Compiler Optimizations
To enable compiler optimizations, use the -Os command-line option for the nios2-elf-gcc compiler. The
-Os option sets a compiler optimization level that optimizes for code size, and enables all -O2
optimizations that do not increase code size. You can specify this command-line option through a BSP
setting.
With this option turned on, the Nios II compiler compiles code with the maximum optimization
available, for both size and speed.
Note: You must set this option for both the BSP and the application project.
Related Information
Specifying BSP Defaults on page 4-34
Use Reduced Device Drivers
Some devices provide two driver variants, a fast variant and a small variant. The feature sets provided by
these two variants are device specific. The fast variant is full-featured, and the small variant provides a
reduced code footprint.
By default the HAL always uses the fast driver variants. You can select the reduced device driver for all
hardware components, or for an individual component, through HAL BSP settings.
The small footprint option might also affect other peripherals. Refer to each peripheral’s data sheet for
complete details of its driver’s small footprint behavior.
Table 6-8: Altera Peripherals Offering Small Footprint Drivers
Peripheral Small Footprint Behavior
UART Polled operation, rather than IRQ-driven
JTAG UART Polled operation, rather than IRQ-driven
Common flash interface
controller
Driver excluded in small footprint mode
LCD module controller Driver excluded in small footprint mode
EPCS serial configura‐
tion device
Driver excluded in small footprint mode
Reduce the File Descriptor Pool
The file descriptors that access character mode devices and files are allocated from a file descriptor pool.
You can change the size of the file descriptor pool through a BSP setting. The default is 32.
Use /dev/null
At boot time, standard input, standard output, and standard error are all directed towards the null device,
that is, /dev/null. This direction ensures that calls to printf() during driver initialization do nothing and
therefore are harmless. After all drivers are installed, these streams are redirected to the channels
configured in the HAL. The footprint of the code that performs this redirection is small, but you can
eliminate it entirely by selecting null for stdin, stdout, and stderr. This selection assumes that you
want to discard all data transmitted on standard out or standard error, and your program never receives
6-28
Enable Compiler Optimizations
NII5V2
2015.05.14
Altera Corporation
Developing Programs Using the Hardware Abstraction Layer
Send Feedback