1.4 QSPI Flash Bootloader
This example application shows how to use the Serial Memory Bootloader Library to bootload an application from QSPI Flash memory (SST26) to Internal Flash.
Serial Memory Bootloader Applications Block Diagram
Bootloader Application
This is a bootloader application which resides from
The starting location of the flash memory region for SAM devices
The starting location of the Boot flash memory region for PIC32MZ devices
Uses a Custom linker script btl.ld to place it in Boot flash memory
Performs Below Operation:
Sets up the QSPI Flash (SST26) using the SST26 driver and QSPI/SQI peripheral Library
Checks if a firmware update is required by reading the MetaData stored in the last sector of QSPI Flash
If Firmware update is required then it jumps to Step 4
If there was no firmware update request through MetaData, then it checks for any trigger implemented in application main()
Here we use the On-board Switch to force trigger firmware update.
If no trigger is found then it jumps to Step 7
If firmware update is required then it
Reads the programmer application binary stored from start of QSPI flash memory (0x0)
Programs the read binary to application space in Internal Flash
Once programming is done it generates a CRC32 value over programmed space and verifies it against the CRC32 stored in QSPI Flash MetaData
If CRC32 verification fails it goes into Error State
If CRC32 verification is successful, It clears the firmware update required flag in the QSPI Flash MetaData and triggers a Soft Reset
After reset, bootloader starts from Step 1 through Step 3 to do firmware update check and then jump to Step 7
If there was no firmware update required then it
Calls the SYS_Deinitialize() function which releases the resources used. This Function is device specific and has to be implemented based on application requirement
Jumps to application space to run the programmer application
Programmer Application
This is a QSPI Flash programmer application which resides from
The end of bootloader size in device flash memory for SAM devices
The start of Program Flash memory for PIC32MZ devices
Uses a Custom linker script app_mz.ld to place it in Program flash memory
It will be loaded into internal flash memory from QSPI Flash Memory by bootloader application
It blinks an LED every 500Ms and has capabilty to program QSPI Flash memory (SST26) using SST26 Driver and QSPI/SQI peripheral Library
It uses the Virtual Com port of the device (EDBG port or External USB to UART converters) to receive the binary to be programmed in QSPI Flash from host PC
As the application running in internal flash should have capability to program QSPI Flash memory, we send the programmer application binary itself via UART to be programmed in QSPI Flash Memory
It calls the APP_INPUT_Tasks() function which receives the binary to be programmed into QSPI flash memory over UART channel
It uses the UART bootloader protocol but is updated to run along with other tasks
Once the binary is received and programmed from start location of QSPI Flash memory it generates a CRC32 value over programmed QSPI Flash space and verifies it against the CRC32 sent from host PC
It Also Updates the CRC32 value received in the QSPI Flash MetaData used by bootloader
If CRC32 verification fails it goes into Error State then resets the APP_INPUT_Tasks() state to receive new binary
If verification is successful then it
Waits for one of below user event to update the MetaData and trigger bootloader via soft reset to program new binary in Internal Flash OR
A Switch press OR
A Reboot command from Host PC
Waits for a new binary to be programmed in QSPI Flash memory.
Development Kits The following table provides links to documentation on how to build and run QSPI Flash bootloader on different development kits