Embedded Design Handbook

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

5.3.5.6. Booting Directly From CFI Flash Memory

To use the Nios® II flash programmer to program the boot copier and the test application in CFI flash memory, perform the following steps:

Note: If you intend to boot from on-chip memory, this section does not apply. Skip ahead to “Booting CFI or EPCS/EPCQ Flash From On-Chip Memory” on page 16.
  1. In the Intel® Quartus® Prime software, on the Tools menu, click Programmer.
  2. Make sure the <project> \niosii_ethernet_standard_<board>.sof filename appears in the File column.
  3. Make sure the Program/Configure option is turned on.
  4. Click Start to configure your FPGA with the .sof file.
  5. In a Nios® II command shell, change to the directory: <project> /boot_copier_sw/app/hello_world.
  6. Set the offset in flash memory at which to locate the hello_world boot image, by typing the command:
    bin2flash --input=hello_world.elf.flash.bin \
    --output=hello_world.flash \
    --location=0x00240000 
    
    //Press ENTER

    Set the offset to 0x00240000 or 0x00440000, because in boot from CFI flash mode, these are the two locations where the boot copier expects boot images 1 and 2, respectively. The two addresses work equally well.

    You can also change these default locations by editing the #define statements for BOOT_IMAGE_1_OFFSET and BOOT_IMAGE_2_OFFSET in the <project> /boot_copier_sw/app/advanced_boot_copier/advanced_boot_copier.c file, and then rebuilding the boot copier.

  7. Program the hello_world boot image in flash memory by typing the following command:
    nios2-flash-programmer --base=<flash_base>\
    hello_world.flash 
    
    //Press ENTER
    , where <flash_base> is the base address of the CFI flash component in your Platform Designer system.
  8. In a Nios® II command shell, change to the directory: <project> /boot_copier_sw/app/advanced_boot_copier.
  9. Create the flash memory file for the boot copier by typing the following command:
    make flash 
    
    //Press ENTER

    This command creates the file <flash_component>.flash, where <flash_component> is the name of the CFI flash component in your Platform Designer system.

  10. Program the boot copier to flash memory by typing the following command:
    nios2-flash-programmer --base=<flash_base> \
    <flash_component>.flash 
    
    //Press ENTER
  11. Skip ahead to the “Running the Advanced Boot Copier Example” section.