3.1.1.6. OSPI/QSPI

OSPI/QSPI is a serial peripheral interface like SPI the major difference being the support for Octal/Quad read, uses 8/4 data lines for read compared to 2 lines used by the traditional SPI. This section documents how to write files to the QSPI device and use it to load and then boot the Linux Kernel using a root filesystem also found on QSPI. At this time, no special builds of U-Boot are required to perform these operations on the supported hardware. For simplicity we assume the files are being loaded from an SD card. Using the network interface (if applicable) is documented in U-boot SPI section.

Note

Not all OSPI flashes can be supported. Users are recommended to check whether or not the OSPI flash part chosen for custom board designs meets all the criteria listed at https://e2e.ti.com/support/processors/f/791/t/946418

Note

The sf command is used to access SPI NOR flash, supporting read/write/erase and a few other functions. For more information on sf command in U-boot please refer to the u-boot documentation: here. And for accessing SPI NAND flash, the mtd command is used, supporting read/write/erase and bad block management.

AM62x Starter Kit (SK) has a Cypress S28HS512T flash and sysfw is bundled with tiboot3.bin.

Below are three methods which can be used to flash the OSPI device. For all methods, we will load the bootloders into memory and then flash each to OSPI at the respective addresses.

Flashing images to OSPI using TFTP server

In this example, use tftp-hpa in Ubuntu as tftp server. Assume bootloader names are ‘tiboot3.bin’, ‘tispl.bin’, ‘u-boot.img’. Verify ethernet connection between AM62x EVM and host machine before proceeding.

  1. Setup TFTP server in Host machine

# For complete instructions refer to: https://help.ubuntu.com/community/TFTP
$ sudo apt install tftp-hpa
$ sudo vi /etc/default/tftpd-hpa #optional to change tftp directory and other options
$ sudo chown -R tftp /tftp #change owner/group of new directory /tftp
$ sudo systemctl restart tftpd-hpa #restart server
  1. Setup U-boot environment for AM62x EVM

# Boot to U-boot prompt using a working boot method
=> setenv ipaddr <ip-address-for-EVM>
=> setenv serverip <ip-address-of-tftp-server>
=> saveenv #optional to save the U-boot ENV
  1. Use tftp command to load the bootloaders into memory and flash to OSPI

=> sf probe
=> tftp ${loadaddr} tiboot3.bin
=> sf update $loadaddr 0x0 $filesize
=> tftp ${loadaddr} tispl.bin
=> sf update $loadaddr 0x80000 $filesize
=> tftp ${loadaddr} u-boot.img
=> sf update $loadaddr 0x280000 $filesize
  1. Change boot mode pins to boot with OSPI boot mode and reboot EVM

Flashing images to OSPI using SD card

In this example, load binaries from SD card. Assume bootloader names are ‘tiboot3.bin’, ‘tispl.bin’, ‘u-boot.img’. Boot via SD card boot and stop at U-boot prompt before procceeding.

  1. Use fatload command to load the bootloaders into memory and flash to OSPI

=> sf probe
=> fatload mmc 1 ${loadaddr} tiboot3.bin
=> sf update $loadaddr 0x0 $filesize
=> fatload mmc 1 ${loadaddr} tispl.bin
=> sf update $loadaddr 0x80000 $filesize
=> fatload mmc 1 ${loadaddr} u-boot.img
=> sf update $loadaddr 0x280000 $filesize
  1. Change boot mode pins to boot with OSPI boot mode and reboot EVM

Flashing images to OSPI using DHCP server

The dhcp command can be used for obtaining a IP adress and for loading binaries over network. A DHCP server should be present for dhcp command to assign an IP to the board. Use this method only if there is already a DHCP server in your network. Assume bootloader names are ‘tiboot3.bin’, ‘tispl.bin’, ‘u-boot.img’. Verify ethernet connection between AM62x EVM and host machine before proceeding.

Warning

Setting up a custom DHCP server in company network may cause network issues, it is not the recommended method.

  1. Setup DHCP server

Please refer to the following documentation: Linux Academy for AM62x

  1. Setup U-boot environment for AM62x EVM

# Boot to U-boot prompt using a working boot method
=> setenv serverip <ip-address-of-tftp-server>
=> dhcp
  1. Verify IP is assigned

=> dhcp
link up on port 1, speed 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
DHCP client bound to address 192.168.42.107 (1017 ms)
  1. Use tftp or dhcp commands to load the bootloaders into memory and flash to OSPI

  1. dhcp commands as shown in <path-to-Processor-SDK>/bin/Ethernet_flash/am62xx-evm/uEnv_ethernet_ospi-nor_am62xx-evm.txt

  2. tftp commands as shown in step 3 of Flashing images to OSPI using TFTP server

  1. Change boot mode pins to boot with OSPI boot mode and reboot EVM

OSPI Boot Mode

Please refer to the AM62x TRM Section 5.3 for more information. The following command could also be used to change boot mode to OSPI after following one of the methods above. Verify to use the “reset” command which uses warm reset and not cold reset.

=> mw.l 0x43000030 0x00000273; reset

Phy calibration

Phy calibration allows for higher read performance. To enable phy, the phy calibration pattern must be flashed to OSPI at the start of the last erase sector. For the Cypress S28HS512T flash, this lies at the address 0x3fc0000.

Download the binary file containing the phy pattern from here. The commands below can be used to flash the phy pattern, with the location of the pattern depending on which flash is being used:

=> sf probe
=> tftp ${loadaddr} ospi_phy_pattern
=> sf update $loadaddr 0x3fc0000 $filesize

Flash layout for OSPI

      0x0 +----------------------------+
          |     ospi.tiboot3(512k)     |
          |                            |
  0x80000 +----------------------------+
          |     ospi.tispl(2m)         |
          |                            |
 0x280000 +----------------------------+
          |     ospi.u-boot(4m)        |
          |                            |
 0x680000 +----------------------------+
          |     ospi.env(128k)         |
          |                            |
 0x6c0000 +----------------------------+
          |   ospi.env.backup(128k)    |
          |                            |
 0x740000 +----------------------------+
          |      padding (768k)        |
 0x800000 +----------------------------+
          |     ospi.rootfs(ubifs)     |
          |                            |
0x3fc0000 +----------------------------+
          |   ospi.phypattern (256k)   |
          |                            |
          +----------------------------+

Enabling QSPI-NOR

To use QSPI-NOR Flash with the AM625x SoC, the following changes are needed to configure the bus-width to get 1-1-4 Mode working optimally. The OSPI module in the SoC is capable of supporting single, dual, quad (QSPI mode) or octal I/O instructions. Cypress s25hs512t QSPI-NOR Flash was tested to be working with the AM625x SoC after the following modifications in Device Tree.

diff --git a/arch/arm/dts/k3-am625-sk.dts b/arch/arm/dts/k3-am625-sk.dts
index bfe1e78ed895..980054144d20 100644
--- a/arch/arm/dts/k3-am625-sk.dts
+++ b/arch/arm/dts/k3-am625-sk.dts
@@ -32,8 +32,8 @@
    flash@0{
        compatible = "jedec,spi-nor";
        reg = <0x0>;
-       spi-tx-bus-width = <8>;
-       spi-rx-bus-width = <8>;
+       spi-tx-bus-width = <1>;
+       spi-rx-bus-width = <4>;
        spi-max-frequency = <25000000>;
        cdns,tshsl-ns = <60>;
        cdns,tsd2d-ns = <60>;
--
2.25.1

The reason for choosing tx-bus-width as 1 is due to the fact that writing to flashes is always a slow process and thus using multi I/O writes doesn’t really offer much performance boost. Hence, writes always take place in 1S mode. However, reads can happen much faster and hence we allow for Quad Mode rx-bus-width.