A newer version of this document is available. Customers should click here to go to the newest version.
4.6.1.2. Software Design Flow
Use the following steps to create the software project directory tree:
- In your design project folder, create a folder called software.
- In the software folder, create two folders called app and bsp.
Figure 59. Software Project Directory Tree
Creating the BSP Project Application
- Enter the Nios® V Command Shell.
- Invoke the BSP Editor with niosv-bsp-editor command.
- In the BSP Editor, click File > New BSP to start your BSP project.
- Configure the following settings:
- SOPC Information File name: Provide the SOPCINFO file (.sopcinfo).
- CPU name: Select Nios® V processor.
- Operating system: Select the operating system of the Nios® V processor.
- Version: Leave as default.
- BSP target directory: Select the directory path of the BSP project. You can pre-set it at <Project directory>/software/hal_bsp by enabling Use default locations.
- BSP Settings File name: Type the name of the BSP Settings File.
- Additional Tcl scripts: Provide a BSP Tcl script by enabling Enable Additional Tcl script.
- Click OK.
Figure 60. Configure New BSP
Configuring BSP Editor and Generating the BSP Project
You can define the processor’s exception vector either in On-Chip Memory (OCRAM) or QSPI Flash based on your design preference. Setting the exception vector memory to OCRAM/External RAM is recommended to make the interrupt processing faster.
- Go to Main > Settings > Advanced > hal.linker.
- If you select QSPI Flash as exception vector, follow these steps:
- Turn on the following settings:
- allow_code_at_reset
- enable_alt_load
- enable_alt_load_copy_rodata
- enable_alt_load_copy_rwdata
Figure 61. Advanced.hal.linker SettingsThis setting is available if exception vector memory is set to On-Chip Memory (OCRAM) - Click on the Linker Script tab in the BSP Editor.
- Set .exceptions and .text regions in the Linker Section Name to QSPI Flash.
- Set the rest of the regions in the Linker Section Name list to the On-Chip Memory (OCRAM) or external RAM.
Figure 62. Linker Region Settings (Exception Vector Memory: QSPI Flash) - Turn on the following settings:
- If you select OCRAM/External RAM as exception vector, follow these steps:
- Enable the following settings:
- allow_code_at_reset
- enable_alt_load
- enable_alt_load_copy_rodata
- enable_alt_load_copy_rwdata
- enable_alt_load_copy_exception
Figure 63. Advanced.hal.linker SettingsThis setting is available if exception vector memory is set to On-Chip Memory (OCRAM) or external RAM. - Click on the Linker Script tab in the BSP Editor.
- Set the .text regions in the Linker Section Name to QSPI Flash.
- Set the rest of the regions in the Linker Section Name list to the On-Chip Memory (OCRAM) or external RAM.
Figure 64. Linker Region Settings (Exception Vector Memory: OCRAM) - Enable the following settings:
- Navigate to the BSP Drivers tab.
- Turn off the Generic Serial Flash Interface driver (intel_generic_serial_flash_interface_top).
- Click Generate to generate the BSP project.
Generating the User Application Project File
- Navigate to the software/hal folder and create your application source code.
- Launch the Nios® V Command Shell.
- Execute the command below to generate the application CMakeLists.txt.
niosv-app --app-dir=software/app --bsp-dir=software/bsp \ --srcs=software/hal app/<user application>
Building the Application Project
You can choose to build the application project using the RiscFree* IDE for Intel FPGAs or through the command line interface (CLI).
If you prefer using CLI, you can build the application using the following command:
cmake -G "Unix Makefiles" -B software \ hal_app/build -S software/hal_app
make -C software/hal app/debug
The application (.elf) file is created in software/app/debug folder.
Generating HEX File
You must generate a .hex file from your application .elf file, so you can create a .pof file suitable for programming flash devices.
- Launch the Nios V Command Shell.
- For Nios® V processor application boot from QSPI flash, use the following commands line to convert the ELF to HEX for your application.
elf2flash --input software/hal_app/debug/<Nios V application>.elf \ --output flash.srec --reset <reset offset + base address of GSFI AVL MEM> \ --base <base address of GSFI AVL MEM> \ --end <end address of GSFI AVL MEM>
riscv32-unknown-elf-objcopy --input-target srec --output-target ihex \ flash.srec <Nios V application>.hex