The QuadSPI bootloader found in the MQX installation folder needs an SD card that contains the images to load in iRAM or DDR. This means that the bootloader does not flash the application in QSPI memory, and using this bootloader in the field implies the need of an SD card every time the application needs to restart.
This document uses as reference MQX 4.1.1
The attached project is a modified bootloader_vybrid_qspixip project that works in the next way:
- The bootloader and applications are stored in QuadSPI memory.
- An application or bootloader upgrade can be performed, placing the new images in an SD card. The SD card is needed only to re-flash the QuadSPI memory.
- If and SD card is detected by the bootloader at startup and correct configurations and images are found, the bootloader will flash the images in QuadSPI. If it is not detected, the bootloader will execute the current image found in QuadSPI memory.
The next figures show an example of the implementation.
The BootROM code loads the MQX Bootloader from QuadSPI in iRAM. When the MQX Bootloader starts, it checks if there is a mounted SD. If the SD contains valid application binary files and a valid configuration file it flash the images into the SD.
To get this behavior a simple change in the QuadSPI driver from the BSP is required. In the file qspi_quadspi.c file of the BSP change line 898 to this:
quadspi_reg_ptr->BUF3CR = (quadspi_reg_ptr->BUF3CR & ~QuadSPI_BUF3CR_ADATSZ_MASK) | QuadSPI_BUF3CR_ADATSZ(128); /* AHB prefetch size: 128*8byte */
The attached file contains the modified files that have to be used in the MQX bootloader_vybrid_qspixip project.