Template:GLSDK QSPI Temp

Using QSPI Boot
QSPI is a serial peripheral interface like SPI the major difference being the support for Quad read, uses 4 data lines for read compared to 2 lines used by the traditional SPI.

Supported boot modes

 * QSPI Production Boot mode
 * QSPI Development Boot mode

QSPI Production Boot Mode
This boot mode also called as 'spl_early_boot' in GLSDK


 * In this boot mode SPL(first stage of Uboot) directly boots the Linux kernel and if IPU late attach is enabled, it boots the IPU slave core
 * The executables - MLO, DRA7-EVM.dtb, uImage & IPU are stored in QSPI flash memory. Refer the "Memory Layout" section for offset details.
 * eMMC partition 2 contains the filesystem & is mounted as rootfs.

SYS BOOT Switch Settings
change the boot switches to QSPI boot mode as: SW2[5:0] = 110110 Also SW5.4 = 0 (OFF)

Memory Layout of QSPI Flash
++ 0x00000 |     MLO       | |               | ++ 0x020000 |  u-boot.img   | |               | ++ 0x090000 |  DRA7-evm.dtb | ++ 0x100000 |               | |     uImage     | |               | |                | ++ 0x700000 |               | |     IPU exe    | |               | ++

Flashing the Image to QSPI from linux
Unzip the mk-qspi-boot.sh from mk-qspi-boot.sh runs on the target. It reads the executables from MMC/SD & flashes into QSPI flash memory for 'spl_early_boot'. Also format & flash the rootfs into eMMC parition 2.

Usage: target#mk-qspi-boot.sh --device1 --device2 --bootmode

--device1 - devfs entry for qspi flash as char device node e.g /dev/mtd0

--device2 - devfs entry for eMMC flash as block device node e.g /dev/mmcblk1

--bootmode - 'spl_early_boot' & 'two_stage_boot' spl_early_boot - ROM=>SPL=>uImage two_stage_boot - ROM=>SPL=>u-boot.img=>uImage e.g target#: mk-qspi-boot.sh --device1 /dev/mtd0 --device2 /dev/mmcblk1 --bootmode spl_early_boot

QSPI Development Boot Mode
This boot mode also called as 'two_stage_boot' in GLSDK


 * In this boot mode SPL(first stage of Uboot) brings-up u-boot.img(second part of u-boot) and if IPU late attach is enabled, it also boots the IPU slave core
 * The second stage of u-boot, then, loads & boots the Linux kernel.
 * Only MLO and u-boot.img are stored in QSPI flash memory.
 * DTB & uImage are stored in MMC/SD boot parition.
 * IPU executable is stored in /lib/firmware/dra7-ipu2-fw.xem4.
 * The rootfs is mounted from MMC/SD partition 2

SYS BOOT Switch Settings
change the boot switches to QSPI boot mode as:

SW2[5:0] = 100110 Also, SW5.4 = 0 (OFF)

Flashing UBoot to QSPI from linux
mk-qspi-boot.sh script can be used to flash the MLO and u-boot.img file into QSPI flash memory. Unzip the mk-qspi-boot.sh from mk-qspi-boot.sh runs on the target. It reads the executables from MMC/SD & flashes into QSPI flash memory for 'two_stage_boot'

target#mk-qspi-boot.sh --device1 --device2 --bootmode

--device1 - devfs entry for qspi flash as char device node e.g /dev/mtd0

--device2 - devfs entry for eMMC flash as block device node e.g /dev/mmcblk1

--bootmode - 'spl_early_boot' & 'two_stage_boot' spl_early_boot - ROM=>SPL=>uImage two_stage_boot - ROM=>SPL=>u-boot.img=>uImage e.g target#: mk-qspi-boot.sh --device1 /dev/mtd0 --device2 /dev/mmcblk1 --bootmode two_stage_boot

Also QSPI flash can be accessed from kernel through MTD device.

Following commands demonstrate how to flash MLO and u-boot from SD card to QSPI.

target# mount /dev/mmcblk0p1 /mnt target# cat /proc/mtd target# flash_erase -N /dev/mtd0 0 10 target# mtd_debug write /dev/mtd0 0x0 $(ls -l /mnt/MLO | awk '{ print $5 }') /mnt/MLO target# mtd_debug write /dev/mtd0 0x20000 $(ls -l /mnt/u-boot.img | awk '{ print $5 }') /mnt/u-boot.img

Flashing UBoot to QSPI from UBoot
UBoot can be flashed to QSPI from any boot mode, here we are using MMC boot mode as an example.

Boot from SD card and at the U-Boot prompt, Choose the mmc card to read from uboot# mmc dev 0 uboot# mmc0 is current device

Load the MLO and u-boot.img to DDR

uboot#fatload mmc 0 0x82000000 MLO uboot#fatload mmc 0 0x83000000 u-boot.img


 * Probe the flash to see if there is a device connected,

NOTE: Do NOT copy-paste the commands, please type them at the prompt
 * 1) sf probe 0

SF: Detected S25FL256S with page size 64 KiB, total 32 MiB, mapped at 5c000000


 * Erase the flash, sf erase <size = currently we cannot erase more than 64K = 0x10000)

NOTE: Do NOT copy-paste the commands, please type them at the prompt
 * 1) sf erase 0x0 0x10000
 * 2) sf erase 0x10000 0x10000
 * 3) sf erase 0x20000 0x10000
 * 4) sf erase 0x30000 0x10000
 * 5) sf erase 0x40000 0x10000
 * 6) sf erase 0x50000 0x10000
 * 7) sf erase 0x60000 0x10000
 * 8) sf erase 0x70000 0x10000
 * Write MLO (to offset 0x0) and u-boot.img(to offset 0x20000) to the flash,
 * 1) sf write 0x82000000 0x0 0x10000
 * 2) sf write 0x83000000 0x20000 0x60000

After reset, you should be able to boot from QSPI flash.

NOTE: QSPI_4 boot mode is not supported.