The Main module contains the top level execution
loop. This loop repeats until a boot image has been received or directed to sleep by the M4.
The main loop has three different execution sub-paths based on the boot peripheral.
- Image Path This path is used by the OSPI, QSPI, SPI, and xSPI boot
modes. In these cases the image data can be directly read by both the R5 and the M4 in
place.
- Block Path This path is used by the I2C, USB-DFU, UART, eMMC, Ethernet,
eMMC/SD cards in raw mode. In this mode data is received from the peripheral in blocks.
Blocks are accumulated in the boot buffer until a full X.509 certificate header has been
received, at which point this full certificate and any subsequent blocks are passed to the
M4 as they arrive.
- Filesystem Path This path is used by the USB host (MSC) mode and
eMMC/SD cards in filesystem mode. This mode executes exactly like in the block path,
except that the boot image location is defined by a filesystem.
The main level is able to detect if a received
boot image is in the correct format and reject non-conforming images. In some cases,
detection of an invalid image is done after the initial data buffer has been sent to the M4.
In that case the R5 must inform the M4 that the image was in fact invalid and it will be
looking for the next image and try again.