Embedded Design Handbook

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

5.2.4.2.2. Application

In the Nios® II SBT window, select either:
  • File > New > Nios® II Application to develop a Nios® II application.

    or

  • File > New > Nios® II Application and BSP from Template to create a template to use for the Nios® II application.

BSP Editor Settings

You must edit the BSP editor settings according to the selected Nios® II processor boot options.

  1. In the Nios® II SBT tool, right click on your BSP project in the Project Explorer window. Select Nios® II > BSP Editor... to open the Nios® II BSP Editor.
  2. In Nios® II BSP Editor, expand into Advanced.hal.linker under Settings.

Table 38.  BSP Editor Settings
Exception Vector Memory Set to OCRAM or External RAM Set to QSPI Flash
BSP Editor Setting: Settings Advanced.hal.linker

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_exceptions

Enable the following settings:

  • allow_code_at_reset
  • enable_alt_load
  • enable_alt_load_copy_rodata
  • enable_alt_load_copy_rwdata
BSP Editor Setting: Linker Script
  • Set .text Linker Section to QSPI flash (Generic Serial Flash Interface IP)
  • Set other Linker Sections (.heap, .rwdata, .rodata, .bss, .stack) to OCRAM or External RAM

  1. If exception vector memory is set to OCRAM or External RAM, enable the following:
    • allow_code_at_reset
    • enable_alt_load
    • enable_alt_load_copy_rodata
    • enable_alt_load_copy_rwdata
    • enable_alt_load_copy_exceptions
    Figure 120. Advanced.hal.linker SettingsThese are the settings if exception vector is set to OCRAM or external RAM.
  2. If exception vector memory is set to QSPI flash, enable the following:
    • allow_code_at_reset
    • enable_alt_load
    • enable_alt_load_copy_rodata
    • enable_alt_load_copy_rwdata
    Figure 121. Advanced.hal.linker SettingsThese are the settings if exception vector is set to QSPI flash.
  3. Click on the Linker Script tab in the Nios® II BSP Editor.
  4. Set the .text item in the Linker Section Name to the QSPI flash in the Linker Region Name. Set the rest of the items in the Linker Section Name list to the Onchip Memory (OCRAM) or external RAM.
    Figure 122. Linker Region Settings
  5. Click Generate. Make sure the BSP generation is successful.
  6. Click Exit to close the BSP editor.
  7. Build the project to generate the ELF file.

HEX File Generation

A HEX file must be generated from the ELF file so that the HEX file can be used in generating the JIC file and program to the flash devices.

  1. Launch Nios® II Command Shell.
  2. For Nios® II processor application execute-in-place (XIP) from QSPI flash, use the following command line to convert the ELF to HEX for your application.

    elf2hex <input ELF filename>.elf <base address of GSFI AVL MEM> <end address of GSFI AVL MEM> --width=8 --little-endian-mem --create-lanes=0 <output HEX filename>.hex

  3. The command creates one HEX file (<output HEX filename>.hex).