1.5.5.1 How the Library Works

The PRIME Firmware Upgrade service library is primarily used by the PRIME Stack, only few of its features are used by the user application. Once configured, the PRIME Stack manages the various operations.

The library must be initialized and maintained periodically.

Description of the Module

The Firmware Upgrade service uses the Memory driver to abstract from the different underlying hardware.

In the PIC32CX MT device, the SEFC0 driver is configured by allocating the reserved space for the images to be sent (Base Node) or received (Service Node).

On the SAMD20, the Memory driver is configured over the external SST26 serial Flash: the received image is staged there and installed by the external-memory bootloader on the next reset.

PRIME Firmware Upgrade in the Base Node

The PRIME Firmware Upgrade service temporarily stores the image to be transferred to the Service Node in the memory address configured in the Base Node. Then, the PRIME Stack in the Base Node can manage the firmware upgrade process.

PRIME Firmware Upgrade in the Service Node

The PRIME Firmware Upgrade service is responsible for storing the image transferred through the PRIME network in the memory of the Service Node. It also stores the state of the over-the-air update so it can resume even if an interruption occurs during the process: in GPBRs 0 to 3 on PIC32CXMT devices, and in the emulated EEPROM (non-volatile data slots 0 to 3) on the SAMD20.

The PRIME Firmware Upgrade service includes verification functions to check the CRC of the entire image as specified in the PRIME standard and incorporates the possibility of performing an integrity check using an ECDSA-256 signature, which allows the user to verify the authenticity of the downloaded image. For the ECDSA and SHA calculations, this service requires the H3 Cryptographic library.

Additionally, the user application can receive notifications from the PRIME Stack indicating that the available PRIME network version is different from the stack version in use. This allows the user application to decide to switch PRIME versions if both versions (v1.3.6 and v1.4) are stored in the Flash memory.