Embedded Design Handbook

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

5.2.1.2. Nios® II Processor Application Copied from Boot Flash to RAM Using Boot Copier

The boot copier included with the Nios® II processor, EDS, SBT, and HAL provides sufficient functionality for most Nios® II applications and is convenient to implement with the Nios® II software build tools development flow. If the system is not set up for OCRAM or XIP boot, then the Nios® II processor boot copier is automatically and transparently added to your system software when you convert your executable files to flash programming files.

When a boot copier is used, all linker sections (.text, .heap, .rwdata, .rodata, .bss, .stack) are set to internal or external RAM. Using the boot copier to copy a Nios® II processor application from boot flash7 to internal or external RAM for execution helps to improve the execution performance. The Nios® II SBT tool suite automatically adds the Nios® II processor memcpy-based boot copier to the system when the executable file (.elf) is converted to the Memory initialization file (.hex) because memory access times are faster for RAM.

The boot copier is placed at the reset address, if the runtime location of the .text section is outside of the boot memory. Otherwise, the boot copier is located at the base address of the image or file, followed by the application, unless the .text linker sections are set to the boot flash memory region. For this boot option, the Nios® II processor starts executing the boot copier software upon system reset. The software copies the application from the boot flash to the internal or external RAM. Once this is complete, the Nios® II processor transfers the program control over to the application.

The Nios® II SBT ensures that the processor software is linked and determines where the software resides in memory. It uses the exception addresses to calculate where each code section is linked. The Nios® II SBT positions the processor's code region in the memory component containing the exception address. Each processor has five default linker sections. The default linker sections are as follows:
  • .text—the executable code
  • .rodata—any read-only data used in the execution of the code
  • .rwdata—where read-write variables and pointers are stored
  • .heap—where dynamically allocated memory is located
  • .stack—where function-call parameters and other temporary data is stored
SBT ensure that these sections are linked and located at fixed addresses in memory.
Note: If the boot copier is in flash, then the alt_load () function does not need to be called because they both serve the same purpose.
7 Boot Flash is referring to UFM, EPCS, EPCQ, CFI, or QPSI flash devices.