Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

5.4.3.3. Managing Device Drivers

The Nios® II SBT creates an alt_sys_init.c file. By default, the SBT assumes that if a device is connected to the Nios® II processor, and a driver is available, the BSP must include the most recent version of the driver. However, you might want to use a different version of the driver, or you might not want a driver at all (for example, if your application accesses the device directly).

The SBT includes BSP Tcl commands to manage device drivers. With these commands you can control which driver is used for each device. When the alt_sys_init.c file is generated, it is set up to initialize drivers as you have requested.

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 uart0

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 uart0