Nios® V Embedded Processor Design Handbook

ID 726952
Date 1/27/2025
Public
Document Table of Contents

4.6.2.2. Software Design Flow

This section provides the design flow to generate and build the Nios® V processor software project. To ensure a streamlined build flow, you are encouraged to create a similar directory tree in your design project. The following software design flow is based on this directory tree.

To create the software project directory tree, follow these steps:

  1. In your design project folder, create a folder called software.
  2. In the software folder, create two folders called hal_app and hal_bsp.
    Figure 73. Software Project Directory Tree

Creating the Application BSP Project

To launch the BSP Editor, follow these steps:

  1. Enter the Nios® V Command Shell.
  2. Invoke the BSP Editor with niosv-bsp-editor command.
  3. In the BSP Editor, click File > New BSP to start your BSP project.
  4. 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.
  5. Click OK.
Figure 74. Configure New BSP

Configuring the BSP Editor and Generating the BSP Project

  1. Go to Main > Settings > Advanced > hal.linker
  2. Leave all settings unchecked.
    Figure 75. Advanced.hal.linker Settings
  3. Click on the Linker Script tab in the BSP Editor.
  4. Set all regions in the Linker Section Name list to the On-Chip Memory (OCRAM) or external RAM.
    Figure 76. Linker Region Settings
  5. Click Generate to generate the BSP project.

Generating the User Application Project File

  1. Navigate to the software/hal_app folder and create your application source code,
  2. Launch the Nios® V Command Shell.
  3. Execute the command below to generate the application CMakeLists.txt.
    niosv-app --app-dir=software/hal_app --bsp-dir=software/hal_bsp \
    --srcs=software/hal_app/<user application>
    

Building the User Application Project

You can choose to build the user application project using Ashling* RiscFree* IDE for Intel® FPGAs or through the command line interface (CLI).

If you prefer using CLI, you can build the user application using the following command:
cmake -G "Unix Makefiles" -B software/hal_app/build -S software/hal_app
make -C software/hal_app/build

The application (.elf) file is created in software/hal_app/build folder.

Generating the HEX File

You must generate a .hex file from your application .elf file, so you can create a .pof file suitable for programming the devices.

  1. Launch the Nios® V Command Shell.
  2. For Nios® V processor application boot from general purpose QSPI flash, use the following command line to convert the ELF to HEX for your application. This command creates the user application (onchip_flash.hex) file.
  3. Select the suitable Bootloader via GSFI in the elf2flash command.
    elf2flash
    --boot <Intel Quartus Prime installation directory>/
    niosv/components/bootloader/<Bootloader via GSFI>
    --input software/hal_app/build/<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