1.2.5 PIC32CX-BZ3 Standalone Bootloader Component Help
PIC32CX-BZ3 bootloader is a standalone harmony component, Using it, one can generate bootloader which is a program that typically is loaded in to the boot flash memory and gets executed every time the device powers up or resets. Due to the size of the internal flash, PIC32CX-BZ3 bootloader supports external flash. The external flash that is supported in this component is SST26 (available on WBZ351 curiosity board)
Bootloader can be used to upgrade firmware on a target device without the need for an external programmer or debugger. It does not fully operate on the device, but can perform various functions prior to starting the main application
- Loads firmware images to embedded flash/external flash over the serial connection using a tool or python script, known as Device Firmware Upgrade (DFU)
- Provides application protection for firmware (Secured device)
- Upgrades application firmware to newer revision
- Controls which application can run based on Sequence number and other metadata information embedded in the OTA image.
Memory Information and Layout of PIC32CXBZ3 device (WBZ351 Curiosity Board)
Memory Area | Purpose |
---|---|
Boot Flash Size is 0x0080_0000 to 0x0080_3FFF (16KB) | The memory where bootloader code runs |
Embeded Flash Slot 0 base address - 0x01000000 | The memory where the application firmware runs and the memory where the bootloader copies the new application firmware |
Embedded Flash Slot 1 base address - 0x01040000 | The memory where the received image(Either through DFU or any other way) gets stored. and the memory where bootloader looks for the new image to copy into the Slot 0 |
External Flash Slot 0 (SST26) | Start Address (relative):0x00000; Size 512KB |
External Flash Slot 1(SST26) | Start Address (relative): 0x80000; Size 512KB |
Boot Flash
In PIC32CXBZ3, 16KB boot flash memory is separated from the main execution memory. This boot flash is used for bootloader code
Metadata Header
Format of image meta-data header is described in the Secure Boot ROM Help page - PIC32CX-BZ3 Secure Boot ROM Help
Working of Bootloader
when the application receives new image from a server or via a tool, it will/should store in the Slot 1 location with meta data header & firmware or in the external flash and it should trigger software reset so that bootloader code runs
- Erases Slot 0
- Copies the new image (DFU or OTA) image to Slot 0
- Verifies the Copy
Bootloader usage with DFU
Bootloader programmed to the MCU (in DFU mode) receives an application image from the host over serial interface and writes it to the external flash or internal flash slot 1 . After loading new image on external flash or internal flash slot 1, if reset is triggered, then bootloader erases the slot 0, copies the image to slot 0, verifies the copy. Then bootloader jumps to application which is the new application image
Bootloader stores information about the image in Meta Data Header. This is basically size of 0x200 bytes and gets stored at the start of slot. Bootloader reads this meta data header and does the authentication procedure based on the information in meta data header
Flow Diagram of Bootloader
The detailed flow diagram of bootloader with the optional DFU block can be found below