Embedded Design Handbook

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

5.3.5.7. Booting CFI or EPCS/EPCQ Flash From On-Chip Memory

In this section, use the Intel® Quartus® Prime software to program the boot copier in the boot_rom memory of the FPGA, and then use the Nios® II flash programmer to program the test application boot record in either CFI or EPCS/EPCQ flash memory.

Note: If you intend to boot directly from CFI flash memory, this section does not apply. Booting directly from CFI flash memory is covered in the “Booting Directly From CFI Flash Memory” section.

To program the boot copier in the FPGA’s boot_rom memory, perform the following steps:

  1. In a Nios® II command shell, change to the subdirectory
  2. To generate the memory initialization file for the boot_rom memory that contains the boot copier, type the following command:
    elf2hex advanced_boot_copier.elf <boot_rom_start_address>
    <boot_rom_end_address> --width=32 --little-endian-mem --create- lanes=0 
    ../../../eth_std_main_system_boot_rom.hex
    
    //Press ENTER
  3. On the Intel® Quartus® Prime Processing menu, click Start Compilation to compile the project.
  4. When compilation is complete, on the Tools menu, click Programmer.
  5. Make sure the <project> \niosii_ethernet_standard_<board> .sof filename appears in the File column.
  6. Make sure the Program/Configure option is turned on.
  7. Click Start to configure your FPGA with the .sof file.

    The boot_rom memory on the FPGA now contains an executable image of the example boot copier.

To program the test application in flash memory, perform the following steps:

  1. In a Nios® II command shell, change to the subdirectory: <project> /boot_copier_sw/app/hello_world of your Intel® Quartus® Prime project directory.
  2. Set the offset in flash memory at which to locate the hello_world boot image, by typing one of the following commands:
    1. If you are booting from CFI flash memory, type the following command:
      bin2flash --input=hello_world.elf.flash.bin \
      --output=hello_world.flash \
      --location=0x00240000 
      
      //Press ENTER
      
    2. If you are booting from EPCS/EPCQ device, type the following command:
      bin2flash --input=hello_world.elf.flash.bin \
      --output=hello_world.flash \
      --location=0x00060000 
      
      //Press ENTER

    Set the offset to 0x00240000 or 0x00440000 when booting from CFI flash memory, and to 0x00060000 or 0x00080000 when booting from an EPCS/EPCQ device, because in boot from the respective flash memory, these are the two locations where the boot copier expects boot images 1 and 2, respectively. In both cases, 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.

    Note: If you edited the flash image offsets in advanced_boot_copier.c, specify the --location value as one of the image offsets you defined in advanced_boot_copier.c, not the offsets mentioned here.
  3. Program the hello_world boot image in flash memory by typing the one of the following commands:
    1. If you are booting from CFI flash memory, type the following command:
      nios2-flash-programmer --base=<flash_base> \
      hello_world.flash 
      
      //Press ENTER
    2. If you are booting from EPCS/EPCQ device, type the following command:
      nios2-flash-programmer --base=<flash_base> \
      --epcs hello_world.flash 
      
      //Press ENTER

      where <flash_base> is the base address of the CFI or EPCS/EPCQ flash component in your Platform Designer system.