Nios® V Embedded Processor Design Handbook

ID 726952
Date 4/04/2022
Public

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

Document Table of Contents

5.5.2.1.3. Software Design Flow (SDM Bootloader Project)

This section provides the design flow to generate and build the SDM Bootloader project.

Creating the SDM Bootloader 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/mailbox_bootloader/bsp folder and name the BSP as settings.bsp.

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

  3. For System file (qsys or sopcinfo), select the Nios V/m processor Platform Designer system (.qsys) file.
  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 52. Create New BSP Window

Configuring BSP Editor and Generating the BSP Project

  1. Go to BSP Editor > Main > Settings
  2. Configure the settings per the following figures:
    Figure 53. hal Settings
    Figure 54. hal.linker Settings
    Figure 55. hal.make Settings
  3. Go to BSP Software Package and enable altera_safeclib
    Figure 56. BSP Software Package
  4. Click the BSP Linker Script tab in the BSP Editor.
  5. Set the .text item in the Linker Section Name to the Bootloader ROM in the Linker Region Name. Set the rest of the items in the Linker Section Name list to the Bootloader RAM.
    Figure 57. Linker Region Settings
  6. Navigate to the BSP Driver tab and disable all drivers (except the Nios V Processor and Mailbox Client Intel FPGA IP).
    Figure 58. BSP Driver tab
  7. Click Generate BSP. Make sure the BSP generation is successful.
  8. Close the BSP Editor.

Create the SDM Bootloader Application Project

  1. Generate the example design files (Refer to SDM Bootloader Example Design). You do not need to build the example design.
  2. Navigate to the software/mailbox_bootloader/app folder in the SDM Bootloader Example Design project.
  3. Copy the SDM bootloader (mailbox_bootloader.c) into the software/mailbox_bootloader/app folder in your project.
  4. Redefine the PAYLOAD_OFFSET in mailbox_bootloader.c.
    Note: The SOF image size influences the PAYLOAD_OFFSET. The PAYLOAD_OFFSET is the start address of the Nios® V application HEX file in QSPI flash and must point to a location after the SOF image. You can determine the minimum PAYLOAD_OFFSET by using the configuration bitstream size from the device datasheet.

    For example, the estimated compressed configuration bitstream size for Intel Stratix 10 SX 2800 is 577 Mbits (72.125 MBytes). The actual size can be equal or smaller than this bitstream size. If the SOF image starts at address 0x0, the SOF image should reached until address 0x44C8FFF (0x44C8A48). With that, the minimum PAYLOAD_OFFSET you can select is 0x4500000.

  5. Launch the Nios V Command Shell.
  6. Execute the command below to generate the SDM bootloader application CMakeLists.txt.
    niosv-app --app-dir=software/mailbox_bootloader/app\
            --bsp-dir=software/mailbox_bootloader/bsp\
            --srcs=software/mailbox_bootloader/app/mailbox_bootloader.c

Building the SDM Bootloader Project

You can choose to build the SDM bootloader project using Eclipse Embedded CDT, or through the command line interface (CLI).

For more information about Eclipse Embedded CDT, refer to Related Information.

With the CLI , you can build the SDM bootloader using the following steps:

  1. Setup the PATH variables, refer to Setting Up Open-Source Tools.
  2. Execute the command below to build the SDM bootloader.
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -B \
        software/mailbox_bootloader/app/release -S \ 
        software/mailbox_bootloader/app
make -C software/mailbox_bootloader/app/release

The SDM bootloader (.elf) file is created in software/mailbox_bootloader/app/release folder.

Generating the HEX File and Initializing the Memory

A HEX file must be generated from the ELF file so that the HEX file can be used for memory initialization.

  1. Launch the Nios V Command Shell.
  2. For SDM bootloader, use the following command line to convert the ELF to HEX. This command creates the SDM bootloader (bootcopier_rom.hex) file.
elf2hex software/mailbox_bootloader/app/release/app.elf \
  -o bootcopier_rom.hex -b <base address of Bootloader ROM> \
  -w <data width of Bootloader ROM> -e <end address of Bootloader ROM> -r 4

Recompile the hardware design to memory-initialize the bootcopier_rom.hex into the Bootloader ROM.