Project

General

Profile

Building the QSPI NOR Flash Image 18.1

The MitySOM-5CSx family of modules are capable of booting, running from and accessing the onboard Quad-SPI NOR flash. Depending on the specific module either 16MiB, 32MiB, 48MiB or more QSPI NOR memory may be installed. Once you have loaded U-Boot, you are free to complete system initialization in whatever means fits your design. You can continue to boot and run from NOR using a RAM based filesystem (or flash-based filesystem such as JFFS or UBIFS).

Note: Modules with greater than 16MiB of NOR memory there will be two individual memory chips installed. The first chip is always 16MiB in size and uses the QSPI CS0 signal. If present the second memory will be 16MiB or greater and uses the QSPI CS1 signal. The second memory cannot be used for booting the module but can be accessed from U-Boot for the Kernel and beyond.

Configuration requirements

There are several items which all have to be addressed to successfully use the NOR flash:
  • The BSEL pins must be set to 0x6 (110b) since the device uses 1.8V. Note: 0x7 (111b) is for a 3.3V device, so don't use it.
  • The CSEL pins must be strapped to match your clock configuration.
  • The MSEL pins must be strapped to match your desired FPGA configuration.
  • The preloader must be written to NOR flash at offset 0x0.
  • The U-Boot image must be written to NOR flash at the offset specified in the bsp-editor when you created the preloader.
  • On modules with more than one QSPI NOR chip, the preloader and U-Boot must reside in the first (CS0) chip.

Prerequisites

The following files are required:
  • preloader-mkpimage.bin
  • ubootenv.bin
  • dev_5cs.dtb
  • zImage
  • dev_5cs.rbf

Note: The zImage and DTB will be located in /boot within the filesystem tarball if built with Yocto.

Building the QSPI NOR flash image

This is the minimal image contents required to boot U-Boot. The Linux kernel and FPGA .rbf can be included at offsets 0x0E0000 and 0x8E0000 respectively. Note: Any offset can be chosen for any section as long as the U-Boot environment is configured properly, with the exceptions of the preloader which must be at offset 0x0 and U-Boot which must be at the offset specified in building the Preloader and U-Boot.

Offset Size File Function
Required 0x000000 0x040000 preloader-mkpimage.bin Preloader
Required 0x040000 0x010000 ubootenv.bin U-Boot Environment
Required 0x050000 0x010000 dev_5cs.dtb Device Tree Blob
Required 0x060000 0x080000 u-boot.img U-Boot
Optional 0x0E0000 0x600000 zImage Linux Kernel
Optional 0x8E0000 0xXXXXXX dev_5cs.rbf FPGA Configuration
  1. Create an image large enough for all desired sections.
    • Minimal image.
      dd if=/dev/zero of=image bs=64k count=14
      
    • Full image. Note: <rbf blocks> is the size of dev_5cs.rbf divided by 64kiB.
      dd if=/dev/zero of=image bs=64k count=$((142 + <rbf blocks>))
      
  2. Copy in the required sections.
    dd if=preloader-mkpimage.bin of=image bs=64k seek=0 count=4 conv=notrunc
    dd if=ubootenv.bin of=image bs=64k seek=4 count=1 conv=notrunc
    dd if=dev_5cs.dtb of=image bs=64k seek=5 count=1 conv=notrunc
    dd if=u-boot.img of=image bs=64k seek=6 count=8 conv=notrunc
    
  3. Copy in the optional sections.
    dd if=zImage of=image bs=64k seek=14 count=96 conv=notrunc
    dd if=dev_5cs.rbf of=image bs=64k seek=142 count=<rbf blocks> conv=notrunc
    

Programming the QSPI NOR flash

Through U-Boot

If you have a first stage boot device on your carrier board such as an SD card you can initially boot the preloader and U-Boot from the SD card and then program the QSPI NOR from U-Boot. This method allows you to access a number of peripherals (Ethernet, SD card, serial, etc.) for transfer of any application image file you wish to write to the QSPI NOR.
  1. Transfer file to memory on the module to then be written to the NOR memory by one of the 3 methods below.
    1. SD Card
      1. Store the image on a FAT partition of a bootable SD Card.
      2. Stop the boot process in U-Boot and load the image from the FAT partition. Note: '0:1' is device 0, partition 1.
        mmc rescan
        fatload mmc 0:1 2000000 <filename>
        
    2. TFTP
      1. Stop the boot process in U-Boot and load the image from a TFTP server.
        tftp 2000000 myserver:/path/to/<filename>
        
    3. YModem
      1. Stop the boot process in U-Boot and load the image over a serial line.
        loady 2000000
        
      2. Send the image using YMODEM.
      3. Select the image.
      4. Example output in U-Boot terminal.
        ### Ready for binary (ymodem) download to 0x00020000 at 115200 bps...
        CCxyzModem - CRC mode, 158(SOH)/0(STX)/0(CAN) packets, 6 retries
        ### Total Size      = 0x00004e60 = 20064 Bytes
        
  2. Erase the flash memory area you wish to reprogram. Note: The file address, offset, and size parameters are hexadecimal without the leading 0x, and $filesize is automatically set by fatload.
    sf probe 0
    sf erase 0 $filesize
    
  3. Program the image into the flash memory.
    sf write 2000000 0 $filesize
    

Through JTAG

If NOR flash is the only boot medium you have, you will have to program the flash before being able to boot the module. To do this you will need to program both the preloader and U-Boot over JTAG initially. Note: Programming over the JTAG can be quite slow.
  1. Connect the USB blaster to the HPS JTAG on the Drive PX board (J2).
  2. Launch the Quartus Embedded Command Shell.
    /opt/intelFPGA/18.1/embedded/embedded_command_shell.sh
    
  3. Write the contents of boot_image.bin to the NOR flash at offset 0x0. Note: This assumes the cable number is 1 (-c 1). Run jtagconfig to determine the cable number. Run quartus_hps --help for help on this command.
    quartus_hps -c 1 --operation=P boot_image.bin
    

QSPI NOR access from Linux or a Linux application

You can also access the QSPI NOR flash memory from within Linux or a Linux application with the MTD utilities. To enable the QSPI MTD devices, the following kernel config options must be set.

  • CONFIG_SPI_CADENCE_QSPI
  • CONFIG_MTD_M25P80
    • CONFIG_SPI_MASTER && CONFIG_MTD_SPI_NOR

The QSPI partitions must be defined in the device tree (i.e. arch/arm/boot/dts/socfpga_mitysom5cs.dtsi - qspi: spi@ff705000 ...).

Go to top
Add picture from clipboard (Maximum size: 1 GB)