1.10 PRIME Bootloader (External Memory)
The PRIME Bootloader (External Memory) application is a bare-metal bootloader for the SAMD20 that manages the device firmware images. The images are received either through the PRIME firmware-upgrade protocol (handled by the application) or over a serial interface, and are staged in an external SST26 serial Flash memory.
The bootloader is intentionally simple and robust. It does not validate the images itself but relies on the validation already performed by the application (through the PRIME firmware upgrade) or by the operator on the serial side. It reports its state through an LED and, in Recovery mode, over the serial interface.
This project is bare-metal (without operating system) and is not generated with MCC. The following table shows the available project.
| Name | Path | Boards |
|---|---|---|
| PRIME Bootloader (External Memory) | \smartenergy_prime_apps\apps\prime_apps\prime_sn_boot_external_mem | SAMD20 Xplained Pro + PL460-EK + FLASH 2 Click (SST26VF064B serial Flash) + ATMBUSADAPTER-XPRO |
External memory is used because the SAMD20 internal Flash (256 KB) is nearly full with the Service Node modem application, leaving no room for a second image during a firmware upgrade. The external SST26 serial Flash holds the staging and backup zones, so the bootloader itself fits in the 8 KB protected boot region.
Unlike the internal Flash bootloader described in PRIME Service Bootloader (which targets PIC32CX devices and stores its data in the User Signature), this bootloader runs on the SAMD20 and manages the images in the external SST26 serial Flash.
How the Bootloader Works
The bootloader runs on every reset and decides what to do from the boot-mode record stored in the external serial Flash. The following figure shows the boot sequence.
On reset, the bootloader initializes its peripherals (LED, SPI, the external SST26 serial Flash, and the NVMCTRL). If the SW0 button is held at power-up, it enters serial recovery mode directly, regardless of any pending operation (see UART Recovery Mode). Otherwise, it reads the boot-mode record from the BOOT_FLAG sector of the SST26 and acts accordingly: it jumps to the application when no operation is pending, or installs or reverts a firmware image otherwise.
The bootloader itself does not load the PL360 binary. After it jumps to the
application (at Flash offset 0x2000), the application's PAL loads
the PL360 binary from the SST26 into the PL460. The Boot modes and the install and
revert details (bundle format, backup and restore, and power-loss recovery) are
described in Firmware Upgrade Flow.
The bootloader reports its state through an LED: a fast blink while waiting or during a fatal error, and a slow blink while a serial session is active.
