The flash driver provided in the SDK package can communicate with the flashes as listed in Flash.
If a different external flash is being used, the flash driver will need certain modifications and configuration changes to work properly. This guide will help in the process of developing/modifying the flash driver to suit the custom external flash being used.
The QSPI interface present in the SOC can support only the 1S-1S-1S mode or the 1S-1S-4S modes for reading from the flash.
qspi_flash_transfer
example : QSPI Flash TransferThe flash driver in the SDK composes of two layers :
The application should only use the APIs from the generic flash layer, this makes sure that there is no dependency on a particular flash type. This layer mostly needs no modifications to support a new flash. The generic flash driver has 5 major functions which will internally just call registered callbacks specific to the device. They are :
Out of these, the Flash_open is the most important one. That is where the flash would be configured to work in a specific mode and also set the NOR SPI controller to talk to the flash. The callbacks to these will be implemented in the device specific layer.
There are 3 files needed per flash in the device specific layer as per the current driver structure :
flash_nor_qspi.c
flash_nor_qspi.h
flash_nor_qspi_device_<flash-part-number>.c
These files need to be located in the ${SDK_ROOT_DIRECTORY}/source/board/flash
folder. For example we have flash_nor_qspi.c
, flash_nor_qspi.h
and flash_nor_qspi_device_MX25V1635F.c
files for the MX25V1635F device. These can be edited to support the new flash device. The implementation of the 5 callbacks mentioned in the above section can be found in flash_nor_qspi.c
. A new device data file (similar to flash_nor_qspi_device_MX25V1635F.c
) needs to created with the appropriate flash part number. Copy from the existing file and change just the flash part numbers for now. Other details can be updated in a while.
To enable build support for this file, add it to the makefile ${SDK_ROOT_DIRECTORY}/source/board/makefile.{soc}.{core}.ti-arm-clang
under FILES_common.
The flash sysconfig also should be updated so that later in examples the flash can be selected appropriately. For this open the /source/board/.meta/flash/flash_{soc}.syscfg.js
file. The object flash_devices
will have a number of entries corresponding to the currently supported flashes. Add a new entry corresponding the new flash.
flash_nor_qspi_device_<flash_part_number>.c
filenamegFlashNorQspiFxns
Confirm that the files build and the new flash device is selectable in sysconfig. We can now update the files according to the new flash device.
In order to program the flash device and NOR SPI controller these are the bare minimum data required from the flash :
This section can be ignored if the flash supports SFDP.
All the details regarding the flash including fast read opcodes, supported erase sizes, dummy clocks needed for each instruction and flash configuration registers information will be available from the flash data sheet.
flash_nor_qspi_device_<flash_part_number>.c
file. Make necessary changes in the Flash_norQspiOpen
function to set the 4 byte addressing mode correctly. If it is a case of separate opcodes, you only need to set this for the NOR SPI controller. If it needs a register write to one of the flash config registers, then that needs to be done.flash_nor_qspi.c
file, Flash_norQspiQuadReadEnableEnable
function. For this flash QE is bit 1 of the status register 2. Status register 1 is read using Read Status instruction 0x05
. Status register 2 is read using instruction 0x35
. QE is set via Write Status instruction 01h with two data bytes where bit 1 of the second byte is one. Update the implementation of this function as specified in the datasheet.qspi_flash_transfer
example QSPI Flash Transfer using SysConfig GUI to select the new flash device you have added.qspi_flash_transfer
example, update the example.syscfg for QSPI bootloader (sbl_qspi
) SBL QSPI and flash writer (sbl_uart_uniflash
) SBL UART Uniflash