Embedded Design Handbook

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

5.2.3.3.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

  1. Open the Nios® II SBT tool and create the Nios® II processor HAL BSP based on the .sopinfo created from Platform Designer generation.
  2. Right-click on the BSP that you have created and select Nios II > BSP Editor.
  3. Configure the Settings.Advanced.hal.linker and the Linker Section mappings in the BSP Editor based on your boot options. Refer to the table below.
    Table 34.  BSP Editor Mappings
    Boot Option BSP Editor: Linker Script Settings.Advanced.hal.linker
    Nios II processor application executes in place from EPCQ flash
    • Set .text Linker Section to EPCQ (epcq_controller_0_avl_mem)
    • Set other Linker Sections (.heap, .rwdata, .rodata, .bss, .stack) to OCRAM
      Note: If there is no OCRAM, then external RAM is used.

    If the exception vector is set to OCRAM, enable the following settings in Settings.Advanced.hal.linker:

    • allow_code_at_reset
    • enable_alt_load
    • enable_alt_load_copy_rodata
    • enable_alt_load_copy_rwdata
    • enable_alt_load_copy_exceptions

    If the exception vector is set to EPCQ, enable the following settings in Settings.Advanced.hal.linker:

    • allow_code_at_reset
    • enable_alt_load
    • enable_alt_load_copy_rodata
    • enable_alt_load_copy_rwdata
    Figure 90. Settings.Advanced.hal.linker for Execute-In-Place Method if Exception Vector is Set to OCRAMThis figure displays the settings if the Exception Vector is set to OCRAM.
    Figure 91. Settings.Advanced.hal Linker for Execute-in-Place Method if Exception Vector is Set to EPCQThis figure displays the settings if the Exception Vector is set to EPCQ.
    Figure 92. Linker Section Mappings for Execute-In-Place Method
  4. Click Generate. Make sure the BSP generation is successful.
  5. Click Exit to close the BSP editor.

HEX File Generation

  1. Point your application to the BSP location that you have created in the previous section.
  2. Once the application development finishes, right-click on the project in Project Explorer and select Build Project. A *.elf file is created under the project folder.
  3. Next, generate the HEX file using the mem_init_generate utility. Right-click on the project in Project Explorer and select Make Targets > Build. The Make Targets window opens as shown below.
    Figure 93. Make Targets Window
  4. Select mem_init_generate and click Build. Make sure epcq_controller_0.hex is created under the mem_init folder.