1.3 SPI Bootloader
The SPI bootloader Library can be used to upgrade firmware on a target device without the need for an external programmer or debugger.
Features
Supports PIC32M, PIC32C and SAM devices
Uses Harmony 3 SPI PLIB to communicate resulting in smaller bootloader size
Supports Fail Safe update
Takes Binary File as input
Receives Binary from an SPI Embedded Host Device
Running From SRAM (For SAM Devices)
Has capability to self update as it is running from SRAM
At reset the bootloader Reset handler copies the entire bootloader firmware into SRAM from Start location and start executing from SRAM
Once the application is called from bootloader, applications startup code takes control over SRAM and starts executing
SPI Bootloader Block Diagram
SPI Event Handler:
This is a callback function called from the underlying SPI PLIB. The callback function is called when an entire packet of data is received from the host. Data packet receiption starts when the Chip Select line is asserted and the packet is considered fully received when the Chip Select is deasserted.
If data is received from the host, it calls the BL_SPI_CommandParser routine where the received data is parsed. Depending on the command that is received from the host, it triggers the flash programming state machine.
If data is requested by the host, it calls the BL_SPI_SubmitWriteRequest routine and sends the requested data to the host
SPI Command Parser:
This function parses the packet received from the host. After the command is parsed, if the client is not busy, the SPI busy line is deasserted, otherwise the SPI busy line remains asserted until the client becomes ready to respond to commands from the host.
SPI Flash Task:
This task is responsible to Erase/Prgram/Verify the internal flash memory with data packet received
The task uses the NVM peripheral library to perform the Unlock/Erase/Write Operations
Once the flash operations are complete, the SPI busy line is deasserted