AN 730: Nios II Processor Booting Methods in MAX 10 FPGA Devices
AN 730: Nios II Processor Booting Methods in MAX 10 FPGA Devices
AN 730: Nios II Processor Booting Methods in MAX 10 FPGA Devices
Subscribe
Send Feedback
Contents
Contents
1.1 Overview
This document describes the various boot or software execution options available with
the Nios II processor and MAX 10 FPGAs.
You can configure the Nios® II processor to boot and execute software from different
memory locations, including the MAX10 FPGA on-chip RAM and UFM.
MAX 10 FPGA devices contain on-chip flash that is segmented into two part:
• Configuration Flash Memory (CFM)—store the hardware configuration data for MAX
10 FPGAs.
• User Flash Memory (UFM)—stores the user data or software applications.
1.2 Abbreviations
Table 1. List of Abbreviations
Abbreviation Description
App Application
1 An ASCII text file with the extension of .hex that stores the initial memory values for a
memory block.
Intel Corporation. All rights reserved. Intel, the Intel logo, Altera, Arria, Cyclone, Enpirion, MAX, Nios, Quartus
and Stratix words and logos are trademarks of Intel Corporation or its subsidiaries in the U.S. and/or other
countries. Intel warrants performance of its FPGA and semiconductor products to current specifications in ISO
accordance with Intel's standard warranty, but reserves the right to make changes to any products and services 9001:2008
at any time without notice. Intel assumes no responsibility or liability arising out of the application or use of any Registered
information, product, or service described herein except as expressly agreed to in writing by Intel. Intel
customers are advised to obtain the latest version of device specifications before relying on any published
information and before placing orders for products or services.
*Other names and brands may be claimed as the property of others.
1 Nios II Processor Booting Methods in MAX 10 FPGA Devices
Abbreviation Description
1.3 Prerequisite
You are required to have the knowledge of instantiating and developing a Nios II
processor based system. Intel recommends you to go through the online tutorials and
training materials provided at http://www.altera.com/education/edu-index.html before
using this application note.
Related Links
• Nios II Gen2 Hardware Development Tutorial.
A step-by-step procedure to build a Nios II Gen2 processor system.
• Getting Started with the Graphical User Interface.
This document provides the details of the Nios II Software Build Tools using
graphical user interface.
User Flash Memory (sectors UFM0-1) Nios II processor application and/or user data
MAX 10 FPGA devices support several configuration modes and some of these modes
allow CFM1 and CFM2 to be used as an additional UFM region. The following table
shows the storage location of the FPGA configuration images based on the MAX 10
FPGA's configuration modes.
You must use the Altera On-chip Flash IP core to access to the flash memory in MAX
10 FPGAs. You can instantiate and connect the Altera On-chip Flash IP to the Nios II
processor using the Qsys system design tool in the Quartus II software. The Nios II
soft core processor uses the Avalon® Memory-Mapped (Avalon-MM) interface to
communicate with the Altera On-chip Flash IP.
Figure 1. Connection Example for The Altera On-chip Flash IP and the Nios II Processor
Related Links
• MAX 10 FPGA Configuration User Guide
• MAX 10 User Flash Memory User Guide
4 The maximum possible value, which is dependent on the configuration mode you select.
All MAX 10 FPGA devices except for the MAX 10 10M02 supports dual FPGA
configuration images. The ERAM preload is disabled when you select the dual
configuration images mode.
When the ERAM preload feature is set to OFF, features that require initialization of on-
chip RAM will not work. The ERAM preload option is set to OFF by default.
This solution is suitable for Nios II processor applications which require limited on-chip
memory usage. The alt_load() function operates as a mini boot copier which copies
the data sections (.rodata, .rwdata, or .exceptions) from boot memory to RAM
based on the BSP settings. The code section (.text), which is a read only section,
remains in the Altera On-chip Flash memory region. This setup minimizes the RAM
usage but may limit the code execution performance as access to the flash memory is
slower than the on-chip RAM.
The Nios II processor application is programmed into the UFM sector. The Nios II
processor's reset vector points to the UFM sector in order to execute code from the
UFM after the system resets.
If you are debugging the application using the source-level debugger, you must use a
hardware break-point to debug because the UFM does not support random memory
access. Random memory access is required for soft break-point debug.
MAX 10 FPGA
FPGA CFM .POF
Dynamic
Memory Logic SOF FPGA Data
Memory Controllers
ALT_onchipflash IP
CFM 1/2 .SOF
Nios II
UFM Nios II Software
Dynamic .HEX
Memory User
Software
Alt_load
Equivalent to the dynamic memory space usage during run time which is Executable code must not exceed the size of
the sum of the maximum heap and stack size. the UFM.
Boot Option 2: Nios II Processor Application Copied from UFM to RAM using
Boot Copier
Intel recommends this solution for MAX 10 FPGA Nios II processor system designs
where there may be multiple iterations of application software development and when
high system performance is required. The boot copier is located within the UFM at an
offset which is the same address with the reset vector. The Nios II application is
located next to the boot copier.
For this boot option, the Nios II processor starts executing the boot copier upon
system reset to copy the application from the UFM sector to the OCRAM or external
RAM. Once copying is complete, the Nios II processor transfers the program control
over to the application.
MAX 10 FPGA
CFM .POF
Dynamic FPGA
Memory Logic SOF FPGA Data
Memory Controllers
ALT_onchipflash IP
User CFM 1/2 .SOF
Nios II
Software
UFM Nios II Software
Dynamic .HEX
Memory User
Software
User
Software Boot
Copier
Equivalent to the executable code and dynamic memory Executable code and boot copier must not exceed the size
size required by user program. of the UFM.
Design
• Create your Nios II Processor based project using Qsys system.
For Option 1: For Option 2:
• Add hardware breakpoint • Ensure that there is external RAM or onchip RAM in the system design.
option to the Nios II • Instantiate the Altera Dual Configuration IP into your Qsys system if you opt for
processor. Dual Images configuration mode.
Download
• Program the .pof file into your MAX 10 device.
(1) Project re-compilation is needed if Initialize Flash Content option was checked in Altera On-Chip Flash IP. You can ignore this step
if Intialize Flash Content option was unchecked in Altera On-Chip Flash IP.
Related Links
MAX 10 FPGA Configuration User Guide, section Remote System Upgrade in Dual
Compressed Images.
2. In the Altera On-chip Flash IP parameter editor, set the Configuration Mode to
Single Uncompressed Image or Single Compressed Image.
5 You can set the exception vector for Boot Option 1 to OCRAM or External RAM (Option 1a) or
Altera On-chip Flash (option 1b) according to your design preference.
6 Boot option 1a which sets exception vector memory to OCRAM or External RAM is
recommended to make the interrupt processing faster.
3. Refer to the following table for the options to program UFM data (HEX file) and
settings required in Altera On-chip Flash IP.
Option 1: Initialize the Quartus II includes the UFM a. Check Initialize flash content
UFM data in the SOF initialization data in the SOF during b. If default path is used, add meminit.qip generated
compilation. SOF recompilation is during “make mem_init_generate” into Quartus II
needed if there are changes in the project. Refer to Figure 9 on page 13.
UFM data.
Make sure the generated HEX naming matches the
default naming.
c. If non-default path is selected, enable the Enable
non-default initialization file and specify the path
of the HEX file.
Note: For more information about Steps 2 and 3, refer
to HEX File Generation section.
Option 2: Combine UFM UFM data is combined with the Uncheck Initialize flash content
data with a compiled SOF compiled SOF during the
during programming files programming files conversion. SOF
(POF) conversion 7 recompilation is NOT needed even
if there are changes in the UFM
data.
7 This is the recommended method for application developer. You are not required to recompile
SOF file for application changes during development.
4. Ensure that the Altera On-chip Flash csr port is connected to the Nios II
processor data_master to enable write and erase operations.
Related Links
HEX File Generation on page 19
8 The size of UFM shown will vary according to your device selection.
Note: If the configuration mode setting in Quartus II software and Qsys parameter
editor is different, the Quartus II project compilation will fail with the
following error message.
Related Links
HEX File Generation on page 19
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, click on Advanced tab under Settings.
3. Click on hal to expand the list.
4. Click on linker to expand the list.
Related Links
• Qsys Settings on page 11
• Quartus II Software Settings on page 14
4. Click on Options/Boot info..., the MAX 10 Device Options dialog box appears.
5. Based on the Initialize flash content settings in the Altera On-chip Flash IP, do
one of the following:
— If Initialize flash content is checked, the UFM initialization data was
included in the SOF during Quartus II compilation. Select Page_0 for UFM
source: option. Click OK and proceed to next step.
— If Initialize flash content is not checked, choose Load memory file for
UFM source: option. Browse to the generated Altera On-chip Flash HEX file
(on_chip_flash.hex) in the File path: and click OK. This will add UFM data
separately to the SOF file during the programming file conversion.
Figure 21. Setting Page_0 for UFM Source if Initialize flash content is Checked
Figure 22. Setting Load Memory File for UFM Source if Initialize flash content is not
Checked
6. In the Convert Programming File dialog box, at the Input files to convert
section, click Add File... and point to the generated Quartus II .sof file.
9 You can set the exception vector for Boot Option 1 to OCRAM or External RAM (Option 1a) or
Altera On-chip Flash (option 1b) according to your design preference.
10 Boot option 1a which sets exception vector memory to OCRAM or External RAM is
recommended to make the interrupt processing faster.
2. In the Altera On-chip Flash IP parameter editor, set the Configuration Mode to
Dual Compressed Images.
3. Refer to the following table for the options to program UFM data (HEX file) and
settings required in Altera On-chip Flash IP.
Option 1: Initialize the Quartus II includes the UFM a. Check Initialize flash content
UFM data in the SOF initialization data in the SOF during b. If default path is used, add meminit.qip generated
compilation. SOF recompilation is during “make mem_init_generate” into Quartus II
needed if there are changes in the project. Refer to Figure 27 on page 26.
UFM data.
Make sure the generated HEX naming matches the
default naming.
c. If non-default path is selected, enable the Enable
non-default initialization file and specify the path
of the HEX file.
Note: For more information about Steps 2 and 3, refer
to HEX File Generation section.
Option 2: Combine UFM UFM data is combined with the Uncheck Initialize flash content
data with a compiled SOF compiled SOF during the
during programming files programming files conversion. SOF
(POF) conversion 11 recompilation is NOT needed even
if there are changes in the UFM
data.
Figure 26. Dual Compressed Images Mode with initialize flash content Turned-on
11 This is the recommended method for application developer. You are not required to recompile
SOF file for application changes during development.
Figure 28. Dual compressed Images with Non-default Initialization File Enabled
4. Ensure that the Altera On-chip Flash csr port is connected to the Nios II
processor data_master to enable write and erase operations.
Related Links
HEX File Generation on page 32
12 The size of UFM sector will vary according to your device selection.
Note: If the configuration mode setting in Quartus II software and Qsys parameter
editor is different, the Quartus II project compilation will fail with the
following error message.
Related Links
HEX File Generation on page 32
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, click on Advanced tab under Settings.
3. Click on hal to expand the list.
4. Click on linker to expand the list.
Related Links
• Qsys Settings on page 24
• Quartus II Software Settings on page 27
4. Click on Options/Boot info..., the MAX 10 Device Options dialog box appears.
5. Based on the Initialize flash content settings, do one of the following:
— If Initialize flash content was checked, make sure Page_0 or Page_1 is
selected for UFM source: option. Click OK.
Note: UFM data (.HEX file) can be included in either Page_0 or Page_1 only.
The Altera On-chip flash does not support two .HEX files for Dual
Compressed images configuration mode.
— If Initialize flash content was not checked, choose Load memory file for
UFM source: option. Browse to the generated Altera On-chip Flash HEX file
(on_chip_flash.hex) in the File path: and click OK.
Figure 39. Setting Page_0 or Page_1 for UFM Source If Initialize flash content is
Checked
Figure 40. Setting Load Memory File for UFM Source if Initialize flash content is not
Checked
6. In the Convert Programming File dialog box, at the Input files to convert
section, click Add File... and point to the first generated Quartus II .sof file to add
the .sof file at page_0.
7. Click on Add Sof Page to create additional page for .sof file. This creates SOF
data Page_1 automatically. Click Add File... and point to the second generated
Quartus II .sof file to add the .sof file at page_1.
Figure 41. Input Files to Convert in Convert Programming Files for Dual Images Mode
MAX 10 FPGA
CFM .POF
FPGA
Logic .SOF FPGA Data .SOF
ALT_onchipflash IP
UFM
Equivalent to the executable code and dynamic memory size required by Not applicable for this boot option.
user program.
Design
• Create your Nios II Processor based project using the Qsys system.
• Ensure that there is onchip RAM in the system design.
Download
• Program the .pof file into your MAX 10 device.
2. In the Altera On-chip Flash IP parameter editor, set the Configuration Mode to
Single Uncompressed Image with Memory Initialization or Single
Compressed Image with Memory Initialization. Leave the Initialize flash
content unchecked. This is because the Altera On-chip flash initialization data will
not be enabled.
Figure 45. Configuration Mode with Memory Initialization Selection and Initialize Flash
Content Setting
3. In the Altera On-chip Memory (RAM or ROM) IP parameter editor, check Initialize
flash content. If default path is used, add meminit.qip generated during
“make mem_init_generate” into Quartus II project. Refer to Figure 47 on page
40. Make sure the generated HEX naming matches the default naming. If non-
default path is selected, check Enable non-default initialization file and specify
the path of the HEX file (onchip_memory2_0.hex).
Note: The meminit.qip stores the location information of the initialization files.
Figure 46. Enable Initialize Memory Content with Default Initialization File in On-Chip
Memory Parameter Editor Settings
Figure 48. Enable Initialize Memory Content with Non-default Initialization File in On-
Chip Memory Parameter Editor Settings
4. Ensure that Altera On-chip Flash csr port is connected to the Nios II processor
data_master to enable write and erase operations.
13 The size of UFM sector will vary according to your device selection.
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, click on Advanced tab under Settings.
3. Click on hal to expand the list.
4. Click on linker to expand the list.
Note: If you are using Quartus II software version 15.0 and above, you can skip all the steps
in this section. From Quartus II 15.0 onwards, the Quartus II software will generate
both SOF and POF files. Since boot option 3 comprises single image, you may use the
generated POF file to program into the MAX 10 FPGA device directly.
1. In Quartus II, click on Convert Programming Files from the File tab.
2. Choose Programmer Object File as Programming file type:.
3. Set Mode to Internal Configuration.
4. Click on Options/Boot info..., the MAX 10 Device Options dialog box appears.
5. Make sure Page_0 is set as the UFM source: option. Click OK.
6. In the Convert Programming File dialog box, at the Input files to convert
section, click Add File... and point to the generated Quartus II .sof file to add
the .sof file at page_0.
This option is suitable for Nios II processor applications which require code space that
is larger than the UFM and/or limited on-chip memory usage. It has a similar concept
to boot option 1 where the Nios II processor application execute-in-place from UFM
but with more memory space due to use of QSPI flash (depending on QSPI chip
selection) instead of the UFM. This is an advantage for supporting larger or multiple
software applications.
The alt_load() function operates as a mini boot copier that initializes and copies the
writable memory sections only to OCRAM or external RAM. The code section (.text),
which is a read-only section, remains in the QSPI flash memory region. Retaining the
read-only section in QSPI minimizes RAM usage but may limit the code execution
performance. The Nios II processor application is programmed into the QSPI flash.
The Nios II processor reset vector points to the QSPI flash to allow code execution
after the system resets. If you are debugging the application using the source-level
debugger, you must use a hardware break-point because the QSPI cannot support
random memory access.
Memory Controllers
.SOF
ALT_onchipflash IP
Nios II CFM 1/2
QSPI User
Flash Software Dynamic
Memory
Dynamic UFM
Memory
Equivalent to the dynamic memory space usage during run time which is Executable code must not exceed the size of
the sum of the maximum heap and stack size. the QSPI flash.
Option 5: Nios II Processor Application Copied from QSPI Flash to RAM Using
Boot Copier
Using a boot copier to copy the Nios II application from QSPI flash to RAM is suitable
when multiple iterations of application software development and high system
performance are required. It has a similar concept to boot option 2 where Nios II
processor application copied from QSPI flash to RAM using boot copier but with larger
memory space due to QSPI flash (depending on QSPI chip selection). This is an
advantage for supporting software applications that require larger program space and
high software performance (compared to XIP).
The Nios II SBT tool 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). The boot copier is located at the base address of the HEX
data, followed by the application.
For this boot option, the Nios II processor starts executing the boot copier software
upon system reset that copies the application from the QSPI to the on-chip memory or
external RAM. Once this process is complete, the Nios II processor transfers the
program control over to the application.
.POF
Nios II Software
.HEX MAX 10 FPGA
FPGA CFM .POF
Logic SOF FPGA Data
QSPI User
Memory Controllers
ALT_onchipflash IP
CFM 1/2 .SOF
Flash Software Nios II
Boot Copier
Dynamic
Dynamic Memory
Memory User
User Software UFM
Software
Table 10. RAM and ROM Size Requirement for Boot Option 5
RAM Size Requirement ROM Size Requirement
Equivalent to the executable code and dynamic memory Executable code and boot copier must not exceed the size of
size required by user program. the QSPI flash.
Figure 60. Configuration and Booting Flow for Option 4 and Option 5
Design
• Create your Nios II Processor based project using Qsys system.
• Ensure that there is external RAM or onchip RAM and Generic Quad SPI controller IP in the system design.
• Instantiate the Altera Dual Configuration IP into your Qsys system if you opt for Dual Images configuration mode.
Download
• Using Quartus II programmer, program the parallel loader .sof into the device to enable parallel loader.
• Once the programming is completed, click on Auto Detect button. Make sure the QSPI flash is detected.
• Program the converted .pof (Nios II application) into the QSPI flash.
• Program the hardware .pof file (from Quartus II) into the MAX10 device.
Related Links
MAX 10 FPGA Configuration User Guide, section Remote System Upgrade in Dual
Compressed Images.
Note: The maximum input clock for Generic Quad SPI Controller IP is 25 MHz. The input
clock must not exceed this maximum value.
14 You can set the exception vector for Boot Option 4 to OCRAM/ External RAM (Option 4a) or
QSPI Flash (Option 4b) according to your design preference.
15 Boot option 4a which sets exception vector memory to OCRAM/External RAM is recommended
to make the interrupt processing faster.
2. Open Altera Generic Quad SPI controller parameter editor. Change the
Configuration device type to the QSPI flash selection and make sure the I/O
mode is set to QUAD.
Note: SOF to POF file conversion is not required because there is only single
hardware image and Nios II application data will be loaded into the QSPI
flash separately. You can use the POF generated during Quartus II project
compilation to program into the MAX 10 FPGA.
Related Links
Programming Hardware Design POF File into the MAX10 FPGA on page 62
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, click on Advanced tab under Settings.
3. Click on hal to expand the list.
4. Click on linker to expand the list.
— For boot option 4b, 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
— For boot option 5, leave all the hal.linker settings unchecked.
Related Links
Software Programmer Object File (.pof) Generation on page 59
1. In Quartus II, click on Convert Programming Files (.pof) from the File tab.
2. Choose Programmer Object File as Programming file type.
3. Set Mode to 1-bit Passive Serial.
4. Set Configuration device to CFI_512Mb.
5. Change the File name to the desired path and name.
Related Links
• HEX File Generation on page 58
• POF file Programming into QSPI flash on page 60
• Quartus.ini file
e. Right click on the MAX 10 FPGA and select Edit -> Change File. Choose the
max_qpfl.sof file.
f. Check MAX 10 device under Program/Configure and click Start to start
programming.
g. Click on Auto Detect after max10_qpfl.sof is successfully programmed.
Click Yes if you are asked to overwrite the existing settings. A new QSPI flash
device will be shown on the screen.
Related Links
Software Programmer Object File (.pof) Generation on page 59
1.5.3.1.8 Programming Hardware Design POF File into the MAX10 FPGA
1. After you successfully programmed HEX data into Quad SPI flash, right click on
the MAX 10 FPGA and select Edit -> Change File. Choose the downloaded POF
file generated from Quartus II project compilation.
2. Check the MAX10's CFM0 and UFM under Program/Configure column and click
Start to start programming.
Related Links
Quartus II Software Settings on page 54
Note: The maximum input clock for Generic Quad SPI Controller IP is 25 MHz. The input
clock must not exceed this maximum value.
16 ) You can set the exception vector for Boot Option 4 to OCRAM/ External RAM (Option 4a) or
QSPI Flash (Option 4b) according to your design preference.
17 Boot option 4a which sets exception vector memory to OCRAM/External RAM is recommended
to make the interrupt processing faster.
2. There are two Nios II application data (HEX file) stored into the QSPI for
supporting dual configuration images. Reset vector memory offset has to set
correctly for the configuration images to call up the correct HEX data.
3. Set Reset vector memory offset of the Nios II Processor in first Qsys design to
address 0x00000000.
4. Set Reset vector memory offset of the Nios II Processor in second Qsys design to
another address to avoid overlapping. For example: Address 0x02000000 which is
half of the QSPI memory size (512Mb).
Figure 80. Reset Vector Offset Setting for First Qsys design
Figure 81. Reset Vector Offset Setting for Second Qsys design
5. Open Altera Generic Quad SPI controller parameter editor. Change the
Configuration device type to the QSPI flash selection and make sure the I/O
mode is set to QUAD.
Related Links
Programming Hardware Design POF File into the MAX10 FPGA on page 76
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, click on Advanced tab under Settings.
3. Click on hal to expand the list.
4. Click on linker to expand the list.
Note: The following steps apply to both first and second Nios II applications.
1. In the Nios II SBT tool, right click on your project in the Project Explorer
window.
2. Click Make Targets -> Build…, the Make Targets dialog box appears. You can
also press shift + F9 to trigger the Make Target dialog box.
3. Select mem_init_generate.
4. Click Build to generate the HEX file.
Related Links
Programming Hardware Design POF File into the MAX10 FPGA on page 76
1. In Quartus II, click on Convert Programming Files (.pof) from the File tab.
2. Choose Programmer Object File as Programming file type.
3. Set Mode to 1-bit Passive Serial.
4. Set Configuration device to CFI_512Mb.
5. Change the File name to the desired path and name.
6. Remove the SOF Page_0.
7. Click on Add HEX Data, choose the HEX file generated in HEX Generation
section. Select Absolute Addressing and click OK.
8. Repeat Step 7 to add second HEX file.
9. Click Generate to create the .pof file.
Related Links
Quartus.ini file
1.5.3.2.9 Programming Hardware Design POF File into the MAX10 FPGA
1. After you successfully programmed HEX data into Quad SPI flash, right click on
the MAX 10 FPGA and select Edit -> Change File. Choose the hardware POF file
generated from Hardware POF Generation section.
2. Check the MAX10's CFM0 and UFM under Program/Configure column and click
Start to start programming.
Related Links
• Quartus II Software Settings on page 66
• Hardware Programmer Object File (.pof) Generation on page 72
Table 11. Summary of Nios II Processor Vector Configurations and BSP Settings
Boot Option Reset Exception BSP Editor Setting: BSP Editor
Vector Vector Settings.Advanced.hal.linker Setting: Linker
Configurati Configuration Script
on
Option 1: Altera On- 1. OCRAM/ If the exception vector memory is set • Set .text
Nios II processor chip Flash External to OCRAM/ External RAM, enable the Linker Section
application execute-in- RAM, OR following settings in to Altera On-
place from Altera On-chip 2. Altera On- Settings.Advanced.hal.linker: chip Flash
Flash (UFM) chip Flash • allow_code_at_reset • Set other
• enable_alt_load Linker
Sections
• enable_alt_load_copy_rodata
(.heap, .rwd
• enable_alt_load_copy_rwdata ata, .rodata,
• enable_alt_load_copy_exceptions .bss, .stack)
If the exception vector memory is set to OCRAM/
to Altera On-chip Flash, enable the External RAM
following settings in
Settings.Advanced.hal.linker:
• allow_code_at_reset
• enable_alt_load
• enable_alt_load_copy_rodata
• enable_alt_load_copy_rwdata
Option 2: Altera On- OCRAM/ Make sure all settings in Make sure all
Nios II processor chip Flash External RAM Settings.Advanced.hal.linker are Linker Sections
application copied from left unchecked are set to
UFM to RAM using boot OCRAM/ External
copier RAM
Option 4: QSPI flash 1. OCRAM/ If the exception vector memory is set • Set .text
Nios II processor External to OCRAM/ External RAM, enable the Linker Section
application executes in- RAM, or following settings in to QSPI Flash
place from QSPI flash 2. QSPI Flash Settings.Advanced.hal.linker: • Set other
• allow_code_at_reset Linker
• enable_alt_load Sections(.hea
p, .rwdata, .r
• enable_alt_load_copy_rodata
odata, .bss, .
• enable_alt_load_copy_rwdata stack) to
• enable_alt_load_copy_ exceptions OCRAM/
If the exception vector memory is set External RAM
to QSPI Flash, 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
Option 5: QSPI flash OCRAM/ Make sure all settings in Make sure all
Nios II processor External RAM Settings.Advanced.hal.linker are Linker Sections
application copied from left unchecked are set to
QSPI flash to RAM using OCRAM/ External
boot copier RAM
The memcpy-based boot copier is used to support boot option 2 and 5. The memcpy-
based boot copier is automatically appended into the HEX file during memory
initialization file generation ("mem_init_generate" target). When you download
your .pof file into the FPGA, the boot copier will be placed at the beginning of the
UFM or QSPI sector and the software application will be placed at the end of the boot
copier.
The function of the memcpy-based boot copier is to copy the software application
image to the RAM which is the entry point indicated by the software application (ELF
file). Depending on the system design, RAM can be either OCRAM or external RAM .
Once the copying is done, the boot copier will pass the system control to the
application in RAM.
Figure 96. Memory Map of An Example System Using Default Boot Copier
Memory Map
RAM &
FPGA RAM
Application
RAM base
UFM Flash
Application
Boot Copier
UFM base
The alt_load() function can be enabled in the BSP Settings as shown in the following
table:
When required, the Nios II SBT tool automatically adds the Nios II processor memcpy-
based boot copier to the system when the executable file (.elf) is converted to
memory initialization file (.hex). This operation take place whenever the .text
section is located in a different memory that the reset vector points to, which indicates
a code copy is required. The file conversion happens during execution of “make
mem_init_generate” target.
The "make mem_init_generate" target generates different HEX file content based on
the specified boot options:
• For boot option 1, 3 and 4 the generated HEX file contains ELF loadable section.
• For boot option 2 and 5, the generated HEX file contains the boot copier and the
ELF payload.
Diagram shows the design was being used to run the MAX 10 FPGA boot time
performance analysis. The Nios II processor was configured with special settings for
some of the use cases.
MAX 10 FPGA (10M50DAF484C6GES)
CPU QSPI Flash QSPI
Data Master Controller Flash
Nios II
75 MHz Instruction DDR3 UniPHY, DDR3
Master 300 MHz
On-Chip Memory
On-Chip Flash
Boot Time
Performance
Counter Sysid JTAG UART
UART 0 Timer 10 μs
Regardless of the boot device, there are only 2 types of boot methods:
1. Nios II processor application execute-in-place.
2. Nios II processor application copied from boot device to RAM using boot copier.
For boot performance analysis, the Nios II processor application sizes varies between
10kB to 64kB.
The design example was tested on the MAX 10 10M50 Development Kit (Rev B) on
using the Quartus II software v15.0 build 145.
The design example boots from the Altera On-chip Flash (UFM). If you want to boot
from other boot memory device, you have to change the reset vector and BSP settings
according to Table 11 on page 77.
Related Links
Boot Time Performance Analysis Design Example
The boot time counter is controlled through software and it will stop once the driver
initialization completes.
6. Entry to main
void main ( void )
{ 7. Stop boot time counter
IOWR (BOOT_TIME_ Stop Boot Time Counter
COUNTER_BASE, 0, 0) ;
Nios II systems initialize all HAL peripherals before main() by default, therefore the
boot time has a dependency on the peripherals selected. Peripherals that are slow to
initialize or have external dependencies, will increase the boot time and potentially
make it less deterministic. If this occurs, you need to calibrate the external memory
such as DDR3 for it to work properly.
Figure 100. Nios II Design Block Diagram with Processor Caches Enabled
UART 0 Timer 10 μs
Using Nios II processor with higher clock speed improves the boot time. For example,
you can increase the Nios II processor speed from 75 Mhz to 125 MHz.
Figure 101. Nios II Design Block Diagram with Higher System Speed
On-Chip Memory
On-Chip Flash
Boot Time
Performance
Counter Sysid JTAG UART
UART 0 Timer 10 μs
Enable the Nios II flash accelerator when system resets from the MAX 10 FPGA on-
chip flash to improve the boot time.
Figure 102. Nios II Design Block Diagram with Flash Accelerator Enabled
UART 0 Timer 10 μs
Related Links
AN-740: Nios II Flash Accelerator Using MAX 10
1.7.3.1 Boot Time Performance for Design that Boots from On Chip Flash with
Flash Accelerator
The following bar graphs show the boot time performance for designs that boot from
on-chip flash (application code stored in on-chip flash) with and without the flash
accelerator (FA) unit. Three scenarios have been evaluated:
1. Design with EMIF that runs from external memory DDR3 (using boot copier).
2. Design without EMIF that runs from on-chip memory (using boot copier)
3. Design without EMIF that runs from on-chip flash (execute in-place)
Figure 103. Summary of Boot Times for Designs that Boot from On-Chip Flash with or
without Flash Accelerator
5.0
4.66 M
4.5 Without FA (9kB App)
3.0
2.70 M
2.68 M 2.6 M
2.5
2.14 M
2.0
1.5
1.0
0.75 M
0.63 M
0.5
0.17 M
25.8 k 5.5 k 25.8 k 5.7 k
Figure 104. Boot Time for Design with EMIF that runs from External Memory (DDR3)
5.0
4.66 M
4.5 Without FA
4.0 With FA
3.5
(Clock Cycle in millions)
Boot Time Counter
3.0
2.68 M 2.60 M
2.5
2.14 M
2.0
1.5
1.0
0.5
The boot time was reduced by ~20% and ~44% for 9 kB and 32 kB application sizes
respectively when the Nios II FA is enabled. Larger application sizes will result in
longer boot times because the code has to be copied from the on-chip flash to the
external memory during the boot process. Overall, the boot time for the scenario
where the boot code is running from the external memory is the slowest. This is due
to the long time taken by external memory calibration during system boot up and the
time taken to copy the application code to external memory.
Figure 105. Boot Time for Design without EMIF that runs from On-Chip Memory
3.0
2.70 M Without FA
With FA
2.5
2.0
1.0
0.75 M
0.63 M
0.5
0.17 M
The boot time was reduced by ~77% and ~76% for 9 kB and 32 kB application sizes
respectively when the Nios II FA is enabled. Running the boot code from the on-chip
memory is faster than running from external memory because the on-chip memory
does not need to go through memory calibration during system boot up. Additionally,
access time to the on-chip memory are faster than those for external DDR3 memory.
Figure 106. Boot Time for Design without EMIF that runs from On-Chip Flash (Execute In-
Place)
30
Without FA
25.8 k 25.8 k With FA
25
20
(Clock Cycle in thousands)
Boot Time Counter
15
10
5.5 k 5.7 k
5
The boot time was reduced by ~78% and ~77% for 9 kB and 32 kB application sizes
respectively when the Nios II FA is enabled. Running the boot code from the on-chip
flash (excute in-place) is faster than running from external memory and on-chip
memory. This is because the code executes in-place directly from the on-chip flash
and does not need to be copied into the external memory or on-chip memory for
execution which saves a lot of time.
The tables below show estimates of boot time for different MAX 10 FPGA boot
configurations. The boot time shown will help you to gauge the boot configuration
required for your system design.
Notes: • Instruction or data cache and flash accelerator are not enabled in the design.
• Boot time values are based on design with 75 MHz Nios II processor speed.
May 2016 2016.05.24 • Updated Configuration and Booting Flow figures for all boot options.
• Updated BSP Editor Settings for Boot option 3.
• Updated Summary of Nios II Processor Vector Configurations and BSP
Settings table.
• Updated Programming Hardware Design POF File into the MAX10 FPGA
step for Boot option 4 and 5 dual compressed images.
• Added note in Programmer Object File (.pof) Generation for Boot option 3.
November 2015 2015.11.19 • Added Boot Time Performance for Design that Boots from On Chip Flash
with Flash Accelerator subsection.
September 2015 2015.09.15 • Replaced MAX 10 FPGA Nios II Design Boot Time Estimation and Guidance
with Boot Time Performance Analysis and Estimation section.
• Restructure boot options and flow by combining boot options and
guidelines.
• Added Boot option 4 and boot option 5 supporting QSPI.
• Added Boot Time Performance Analysis design example information and
link.
June 2015 2015.06.15 • Added MAX 10 FPGA Nios II Design Boot Time Estimation and Guidance
section containing boot time performance analysis.
• Added The alt_load() function table.
• Added ROM Size Requirement to RAM and ROM Size Requirement For Each
Boot Option table.
• Added block diagrams for all boot options in Nios II Processor Booting
Options Using On-chip Flash.
• Added OCRAM size in UFM and CFM Array Size table.
• Added Boot Option: 3 Nios II processor application execute in-place from
Altera On-chip Memory.
• Updated 'Configuration and Booting Flow' to include Boot Option: 3.
• Updated Steps to Build a Bootable System to Guidelines to Build a
Bootable System.
• Updated Single Uncompressed/Compressed Image Bootable System
Guideline to support Single Compressed Image Mode.
• Added the third guideline; 'Single Uncompressed/Compressed Image with
Memory Initialization Bootable System Guideline'.
• Editorial changes.