Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

6.14.3. Customizing the Boot Sequence

You can provide your own implementation of the start-up sequence by simply defining alt_main() in your Nios II project. This gives you complete control of the boot sequence, and allows you to selectively enable HAL services. If your application requires an alt_main() entry point, you can copy the default implementation as a starting point and customize it to your needs.

Function alt_main() calls function main(). After main() returns, the default alt_main() enters an infinite loop. Alternatively, your custom alt_main() might terminate by calling exit(). Do not use a return statement.

The following line of code is the prototype for alt_main():

void alt_main (void)

The HAL build environment includes mechanisms to override default HAL BSP code. This lets you override boot loaders, as well as default device drivers and other system code, with your own implementation.

alt_sys_init.c is a generated file, which you must not modify. However, the Nios II SBT enables you to control the generated contents of alt_sys_init.c. To specify the initialization sequence in alt_sys_init.c, you manipulate the auto_initialize and alt_sys_init_priority properties of each driver, using the set_sw_property Tcl command.

For more information about generated files and how to control the contents of alt_sys_init.c, refer to the "Nios II Software Build Tools" chapter.

For more information about alt_sys_init.c, refer to the "Developing Device Drivers for the Hardware Abstraction Layer" chapter.

For more information about the set_sw_property Tcl command, refer to the "Nios II Software Build Tools" chapter.