1.5.5.3 Configuring the Library

The PRIME Firmware Upgrade service library is configured to work in conjunction with the MEMORY driver, so any non-volatile memory can be used to store the downloaded images. The configuration options and the memory backend depend on the type of PRIME node and on the device.

The main parameters of the Firmware Upgrade service are:

  • Firmware Upgrade Region Size: It is in hexadecimal, the reserved space in memory for file downloading. This size must be equal to or less than the size of the chosen memory.
  • Buffer to write in Flash: The size of the write buffer must be at least the size of the write block size of the chosen memory in bytes.
  • Buffer to read in Flash: The size of the read buffer must be at least the size of the read block size of the chosen memory in bytes.
  • Enable user-defined signature: It allows the use of a user-defined signature.
  • External bootloader FU profile: when enabled, the firmware-upgrade image is staged in external memory and a boot-mode record instructs the bootloader to install it on the next reset, instead of the standard internal-flash upgrade. It is enabled by default on the SAMD20 and is read-only on other devices.

Base Node

The Base Node is available on PIC32CX MT devices. It uses the parameters listed above; in addition, when the Base Node is managed with an operating system (and the corresponding Harmony module has been added), the RTOS settings are available.

Figure 1-34. PRIME Firmware Upgrade Configuration for a Base Node
The RTOS parameters define:
  • the task priority for the PRIME Firmware Upgrade service
  • the task delay in milliseconds

Service Node

The Service Node is available on PIC32CX MT and SAMD20 devices. It stores the downloaded image in the non-volatile memory managed by the MEMORY driver; the memory backend depends on the device.

PIC32CX MT

The SEFC0 driver is configured as the download area, although other areas can be selected as long as the bootloader application is also modified accordingly (refer to its documentation in the smartenergy_prime_apps repository). In the applications provided by Microchip for the PIC32CX MT device, SEFC0 is used as the associated memory; the parameters are the same for all memories.

Figure 1-35. Configuration of SEFC0 in PIC32CX MT
  • NVM Media Start Address: Starting address of the memory area where the downloaded files will be stored.
  • NVM Media Size (KB): Length of the Firmware Upgrade Region size. The value should be the same as the one specified in the Firmware Upgrade PRIME service configuration.

SAMD20

The MEMORY driver is configured over the external SST26 serial Flash (on SERCOM1). The firmware-upgrade image is staged in that external memory and installed by the external-memory bootloader on the next reset, so the External bootloader FU profile is enabled.

Figure 1-36. PRIME Firmware Upgrade Configuration for a Service Node on the SAMD20

Cryptographic Configuration

To configure the cryptographic algorithms required for the signature verification, the following must be selected in the wolfCrypt module:
Figure 1-37. Crypto Configuration

On PIC32CX MT devices, the ECDSA and SHA algorithms are computed by the hardware cryptographic engine, so the hardware implementation is selected. On the SAMD20, which has no hardware cryptographic engine, both are computed in software (wolfCrypt).