Nios® V Embedded Processor Design Handbook

ID 726952
Date 5/26/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

4.5.2.1.4. Software Design Flow (User Application Project)

This section provides the design flow to generate and build the Nios® V processor user application.

Creating the User Application BSP Project

To launch the BSP Editor, follow these steps:
  1. In the Platform Designer window, select File > New BSP . The Create New BSP windows appears.
  2. For BSP setting file, navigate to the software/user_application/bsp folder and name the BSP as settings.bsp.

    BSP path: <project directory>/software/user_application/bsp/settings.bsp

  3. For System file (qsys or sopcinfo), select the Nios® V/m processor Platform Designer system (.qsys).
  4. For Quartus project, select the Quartus Project File.
  5. For Revision, select the correct revision.
  6. For CPU name, select the Nios V/m processor.
  7. Select the Operating system as Altera HAL.
  8. Click Create to create the BSP file.
Figure 59. Create New BSP Window

Configure BSP Editor and Generate the BSP Project

  1. Go to Main > Settings > Settings > Advanced > hal.linker.
  2. Enable the following settings:
    1. enable_alt_load
    2. enable_alt_load_copy_exceptions
    Figure 60. hal.linker Settings
  3. Click the BSP Linker Script tab in the BSP Editor.
    Figure 61. Linker Region Settings
  4. Set all the Linker Section Name list to the User Application RAM.
  5. Click Generate BSP. Make sure the BSP generation is successful.
  6. Close the BSP Editor.

Creating the User Application Project

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

Building the Application Project

You can choose to build the application project using the RiscFree* IDE for Intel FPGAs, Eclipse Embedded CDT, or through the command line interface (CLI).

With the CLI, you can build the user application using the following commands:

cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug \
 -B software/user_application/app/debug -S software/user_application/app
make -C software/user_application/app/debug

The user application (.elf) file is created in software/user_application/app/debug folder.

Generating the HEX File

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

  1. Launch the Nios V Command Shell.
  2. For Nios® V processor application copied from QSPI flash using SDM bootloader, use the following commands to convert the ELF to HEX for your application. These commands creates the user application (.hex) file.
elf2flash --input software/user_application/app/debug/<user application>.elf \
 --output flash.srec –epcs –-offset 0x0
riscv32-unknown-elf-objcopy --input-target srec \
--output-target ihex flash.srec \
 <user application>.hex