Modules#

BootloaderStorageSlot_t

BootloaderStorageImplementationInformation_t

BootloaderStorageInformation_t

BootloaderEraseStatus_t

BootloaderStorageFunctions_t

Application Storage Interface#

Application interface for interfacing with the bootloader storage.

Note

  • These Bootloader APIs are not reentrant and should be wrapped in critical section where needed.

The Storage Interface is only available on bootloaders that declare they support BOOTLOADER_CAPABILITY_STORAGE.

Example#

Snippet for the OTA use case:

* ///OTA Example
* /// Assuming the user has an upgrade image downloaded which will be used to upgrade the application
*
* //Initialize the bootloader interface
* bootloader_init();
*
* //Erase the storage slot in internal/SPI flash memory
* bootloader_eraseStorageSlot(0);
*
* //Write the upgrade image (GBL file data) to the slot. blinkGbl  uint8 array holding the GBL data in memory
* bootloader_writeStorage(0, 0, blinkGbl, sizeof(blinkGbl));
*
* //Reboot into the bootloader to install the new image
* bootloader_rebootAndInstall();
*
* The general flow for bootloader interface APIs from the application is:
*
* ///General flow
*
* //Initialize the bootloader interface
* bootloader_init();
*
* //Interface API accesses
* ……………
* ……………
* ……………
*
* //De-initialize the bootloader interface
* bootloader_deinit();
* 

Enumerations#

enum
SPIFLASH
INTERNAL_FLASH
CUSTOM_STORAGE
}

Possible storage types.

Functions#

void
bootloader_getStorageInfo(BootloaderStorageInformation_t *info)

Get information about the storage component.

int32_t
bootloader_getStorageSlotInfo(uint32_t slotId, BootloaderStorageSlot_t *slot)

Get information about a storage slot.

int32_t
bootloader_readStorage(uint32_t slotId, uint32_t offset, uint8_t *buffer, size_t length)

Read data from a storage slot.

int32_t
bootloader_writeStorage(uint32_t slotId, uint32_t offset, uint8_t *buffer, size_t length)

Write data to a storage slot.

int32_t
bootloader_eraseWriteStorage(uint32_t slotId, uint32_t offset, uint8_t *buffer, size_t length)

Erase and write data to a storage slot.

int32_t

Erase all contents of a storage slot.

int32_t
bootloader_initChunkedEraseStorageSlot(uint32_t slotId, BootloaderEraseStatus_t *eraseStat)

Initialize chunked erase of a storage slot.

int32_t
bootloader_chunkedEraseStorageSlot(BootloaderEraseStatus_t *eraseStat)

Erase one page from a storage slot according to the struct BootloaderEraseStatus_t.

int32_t
bootloader_setImagesToBootload(int32_t *slotIds, size_t length)

Set a prioritized list of images to attempt to bootload.

int32_t
bootloader_getImagesToBootload(int32_t *slotIds, size_t length)

Get the prioritized list of images the bootloader will attempt to bootload.

int32_t

Append a single image to the list of images to attempt to bootload.

int32_t

Set a single image to attempt to bootload.

int32_t
bootloader_initVerifyImage(uint32_t slotId, void *context, size_t contextSize)

Initialize image verification.

int32_t
bootloader_continueVerifyImage(void *context, BootloaderParserCallback_t metadataCallback)

Continue image verification.

int32_t
bootloader_verifyImage(uint32_t slotId, BootloaderParserCallback_t metadataCallback)

Verify that the image in the given storage slot is valid.

int32_t
bootloader_getImageInfo(uint32_t slotId, ApplicationData_t *appInfo, uint32_t *bootloaderVersion)

Get application and bootloader upgrade metadata from the storage slot.

bool

Check whether the bootloader storage is busy.

int32_t
bootloader_readRawStorage(uint32_t address, uint8_t *buffer, size_t length)

Read raw data from storage.

int32_t
bootloader_writeRawStorage(uint32_t address, uint8_t *buffer, size_t length)

Write data to storage.

int32_t
bootloader_eraseRawStorage(uint32_t address, size_t length)

Erase data from storage.

int32_t

Get allocated DMA channel for MSC write.

Macros#

#define
BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE (384)

Context size for bootloader verification context.

#define
BOOTLOADER_STORAGE_INFO_VERSION (0x30000U)

Current version of the BootloaderStorageInformation_t struct.

#define
BOOTLOADER_STORAGE_IMPL_INFO_VERSION (0x0210U)

Current version of the BootloaderStorageImplementationInformation_t struct.

#define
BOOTLOADER_STORAGE_IMPL_INFO_VERSION_MAJOR (0x0200U)

Major version of the BootloaderStorageImplementationInformation_t struct.

#define
BOOTLOADER_STORAGE_IMPL_INFO_VERSION_MAJOR_MASK (0xFF00U)

Major version mask for BOOTLOADER_STORAGE_IMPL_INFO_VERSION.

#define
BOOTLOADER_STORAGE_IMPL_CAPABILITY_ERASE_SUPPORTED (1 << 0)

Spiflash capability indicating that it supports erase.

#define
BOOTLOADER_STORAGE_IMPL_CAPABILITY_PAGE_ERASE_REQUIRED (1 << 1)

Spiflash capability indicating it requires full page erases before new data can be written.

#define
BOOTLOADER_STORAGE_IMPL_CAPABILITY_BLOCKING_WRITE (1 << 2)

Spiflash capability indicating that the write function is blocking.

#define
BOOTLOADER_STORAGE_IMPL_CAPABILITY_BLOCKING_ERASE (1 << 3)

Spiflash capability indicating that the erase function is blocking.

#define
BOOTLOADER_STORAGE_ISSI_IS25LQ040B (1U << 0)

ISSI IS25LQ040B SPI Flash.

#define
BOOTLOADER_STORAGE_ISSI_IS25LQ020B (1U << 1)

ISSI IS25LQ020B SPI Flash.

#define
BOOTLOADER_STORAGE_ISSI_IS25LQ010B (1U << 2)

ISSI IS25LQ010B SPI Flash.

#define
BOOTLOADER_STORAGE_ISSI_IS25LQ512B (1U << 3)

ISSI IS25LQ512B SPI Flash.

#define
BOOTLOADER_STORAGE_ISSI_IS25LQ025B (1U << 4)

ISSI IS25LQ025B SPI Flash.

#define
BOOTLOADER_STORAGE_NUMONYX_M25P16 (1U << 5)

Numonyx M25P16 SPI Flash.

#define
BOOTLOADER_STORAGE_NUMONYX_M25P80 (1U << 6)

Numonyx M25P80 SPI Flash.

#define
BOOTLOADER_STORAGE_NUMONYX_M25P40 (1U << 7)

Numonyx M25P40 SPI Flash.

#define
BOOTLOADER_STORAGE_NUMONYX_M25P20 (1U << 8)

Numonyx M25P20 SPI Flash.

#define
BOOTLOADER_STORAGE_ADESTO_AT25SF041 (1U << 9)

Adesto AT25SF041 SPI Flash.

#define
BOOTLOADER_STORAGE_ATMEL_AT25DF081A (1U << 10)

Atmel AT25DF081A SPI Flash.

#define
BOOTLOADER_STORAGE_ATMEL_AT25DF041A (1U << 11)

Atmel AT25DF041A SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25R6435F (1U << 12)

Macronix MX25R6435F SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25R3235F (1U << 13)

Macronix MX25R6435F SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25U1635E (1U << 14)

Macronix MX25U1635E SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25L1606E (1U << 15)

Macronix MX25L1606E SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25R8035F (1U << 16)

Macronix MX25R8035F SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25L8006E (1U << 17)

Macronix MX25L8006E SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25L4006E (1U << 18)

Macronix MX25L4006E SPI Flash.

#define
BOOTLOADER_STORAGE_MACRONIX_MX25L2006E (1U << 19)

Macronix MX25L2006E SPI Flash.

#define
BOOTLOADER_STORAGE_WINBOND_W25Q80BV (1U << 20)

Winbond W25Q80BV SPI Flash.

#define
BOOTLOADER_STORAGE_WINBOND_W25X20BV (1U << 21)

Winbond W25X20BV SPI Flash.

#define
BOOTLOADER_STORAGE_SPANSION_S25FL208K (1U << 22)

Spansion S25L208K SPI Flash.

#define
BOOTLOADER_STORAGE_INTERNAL_STORAGE (1U << 30)

Internal storage.

#define
BOOTLOADER_STORAGE_JEDEC (1U << 31)

JEDEC Supported SPI Flash.

Enumeration Documentation#

BootloaderStorageType_t#

BootloaderStorageType_t

Possible storage types.

Enumerator
SPIFLASH

Storage backend is a SPI flash.

INTERNAL_FLASH

Storage backend is internal flash.

CUSTOM_STORAGE

Storage backend is custom.


Function Documentation#

bootloader_getStorageInfo#

void bootloader_getStorageInfo (BootloaderStorageInformation_t * info)

Get information about the storage component.

Parameters
TypeDirectionArgument NameDescription
BootloaderStorageInformation_t *[out]info

Information about the storage component.


bootloader_getStorageSlotInfo#

int32_t bootloader_getStorageSlotInfo (uint32_t slotId, BootloaderStorageSlot_t * slot)

Get information about a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot to get information about

BootloaderStorageSlot_t *[out]slot

Information about the storage slot

Returns


bootloader_readStorage#

int32_t bootloader_readStorage (uint32_t slotId, uint32_t offset, uint8_t * buffer, size_t length)

Read data from a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot

uint32_t[in]offset

Offset into the slot to start reading from

uint8_t *[out]buffer

Buffer to store the data

size_t[in]length

Amount of data to read

Returns


bootloader_writeStorage#

int32_t bootloader_writeStorage (uint32_t slotId, uint32_t offset, uint8_t * buffer, size_t length)

Write data to a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot

uint32_t[in]offset

Offset into the slot to start writing to

uint8_t *[in]buffer

Buffer to read data to write from

size_t[in]length

Amount of data to write

Note

  • If DMA-based MSC write is enabled on the bootloader, writing data from flash to flash is not supported on Series-1 devices. DMA-based MSC write is enabled, both offset and buffer should be word aligned. In case the buffer is not aligned, the normal write procedure is used instead of DMA.

Returns


bootloader_eraseWriteStorage#

int32_t bootloader_eraseWriteStorage (uint32_t slotId, uint32_t offset, uint8_t * buffer, size_t length)

Erase and write data to a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot

uint32_t[in]offset

Offset into the slot to start writing to

uint8_t *[in]buffer

Buffer to read data to write from

size_t[in]length

Amount of data to write

Note

  • This function automatically erases the following Flash page whenever the written data crosses a page boundary. In other words, the function can't be used to perform multiple sequential writes to the same address range unless the range starts at a page boundary. For a sequential write, the first call to this function should have a start address at a page boundary. Otherwise, the corresponding page of the starting address needs to be erased explicitly. If DMA-based MSC write is enabled on the bootloader, writing data from flash to flash is not supported on Series-1 devices.

Returns


bootloader_eraseStorageSlot#

int32_t bootloader_eraseStorageSlot (uint32_t slotId)

Erase all contents of a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot

Returns


bootloader_initChunkedEraseStorageSlot#

int32_t bootloader_initChunkedEraseStorageSlot (uint32_t slotId, BootloaderEraseStatus_t * eraseStat)

Initialize chunked erase of a storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot

BootloaderEraseStatus_t *[in]eraseStat

Erase status struct

Note

Returns


bootloader_chunkedEraseStorageSlot#

int32_t bootloader_chunkedEraseStorageSlot (BootloaderEraseStatus_t * eraseStat)

Erase one page from a storage slot according to the struct BootloaderEraseStatus_t.

Parameters
TypeDirectionArgument NameDescription
BootloaderEraseStatus_t *[in]eraseStat

Erase status struct

Note

Returns


bootloader_setImagesToBootload#

int32_t bootloader_setImagesToBootload (int32_t * slotIds, size_t length)

Set a prioritized list of images to attempt to bootload.

Parameters
TypeDirectionArgument NameDescription
int32_t *[in]slotIds

Prioritized list of slot IDs to attempt to bootload. The first image to pass verification will be bootloaded.

size_t[in]length

Length of the slotIds array

The last call to this function determines which slot will be installed when bootloader_rebootAndInstall is called.

Returns


bootloader_getImagesToBootload#

int32_t bootloader_getImagesToBootload (int32_t * slotIds, size_t length)

Get the prioritized list of images the bootloader will attempt to bootload.

Parameters
TypeDirectionArgument NameDescription
int32_t *[out]slotIds

Prioritized list of slot IDs to attempt to bootload. The first image to pass verification will be bootloaded.

size_t[in]length

Length of the slotIds array

Returns


bootloader_appendImageToBootloadList#

int32_t bootloader_appendImageToBootloadList (int32_t slotId)

Append a single image to the list of images to attempt to bootload.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]slotId

ID of the slot to append

Returns


bootloader_setImageToBootload#

int32_t bootloader_setImageToBootload (int32_t slotId)

Set a single image to attempt to bootload.

Parameters
TypeDirectionArgument NameDescription
int32_t[in]slotId

ID of the slot

Returns


bootloader_initVerifyImage#

int32_t bootloader_initVerifyImage (uint32_t slotId, void * context, size_t contextSize)

Initialize image verification.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot to check.

void *N/Acontext

Pointer to memory used to hold the parser context.

size_t[in]contextSize

Size of the context. An error is returned if the supplied context is too small.

Initialize verification of an upgrade image stored in a bootloader storage slot.

Note

  • This function must be called before calling bootloader_continueVerifyImage in a loop.

  • The context pointer must point to memory allocated by the caller. The caller must ensure that the context pointer is 32 bit aligned. The required size of this context may depend on the version of the bootloader. The required size for the bootloader associated with this version of the application interface is given by the define BOOTLOADER_STORAGE_VERIFICATION_CONTEXT_SIZE.

  • Instead of calling bootloader_initVerifyImage followed by bootloader_continueVerifyImage, call bootloader_verifyImage if no time-critical tasks are needed and sufficient stack space is available for the automatically allocated context. The purpose of the init-and-continue functions is to allow the caller to service system needs during verification.

Returns

  • BOOTLOADER_OK if the image parser was initialized, else error code.


bootloader_continueVerifyImage#

int32_t bootloader_continueVerifyImage (void * context, BootloaderParserCallback_t metadataCallback)

Continue image verification.

Parameters
TypeDirectionArgument NameDescription
void *N/Acontext

Pointer to a context structure that has been initialized by calling bootloader_initVerifyImage()

BootloaderParserCallback_t[in]metadataCallback

Function pointer, which is called when the binary metadata in the image is currently verified. Set to NULL if not required.

Continue verification of an upgrade image stored in a bootloader storage slot.

Note

Returns


bootloader_verifyImage#

int32_t bootloader_verifyImage (uint32_t slotId, BootloaderParserCallback_t metadataCallback)

Verify that the image in the given storage slot is valid.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot to check

BootloaderParserCallback_t[in]metadataCallback

Function pointer, which is called when binary metadata is present in the storage slot. Set to NULL if not required.

Note

Returns


bootloader_getImageInfo#

int32_t bootloader_getImageInfo (uint32_t slotId, ApplicationData_t * appInfo, uint32_t * bootloaderVersion)

Get application and bootloader upgrade metadata from the storage slot.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]slotId

ID of the slot to check

ApplicationData_t *[out]appInfo

Pointer to ApplicationData_t struct

uint32_t *[out]bootloaderVersion

Pointer to an integer representing bootloader version

Returns


bootloader_storageIsBusy#

bool bootloader_storageIsBusy (void )

Check whether the bootloader storage is busy.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • True if the storage is busy


bootloader_readRawStorage#

int32_t bootloader_readRawStorage (uint32_t address, uint8_t * buffer, size_t length)

Read raw data from storage.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]address

Address to start reading from

uint8_t *[out]buffer

Buffer to store the data

size_t[in]length

Amount of data to read

Returns


bootloader_writeRawStorage#

int32_t bootloader_writeRawStorage (uint32_t address, uint8_t * buffer, size_t length)

Write data to storage.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]address

Address to start writing to

uint8_t *[in]buffer

Buffer to read data to write from

size_t[in]length

Amount of data to write

Note

  • If DMA-based MSC write is enabled on the bootloader, writing data from flash to flash is not supported on Series-1 devices.

Returns


bootloader_eraseRawStorage#

int32_t bootloader_eraseRawStorage (uint32_t address, size_t length)

Erase data from storage.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]address

Address to start erasing from

size_t[in]length

Length of data to erase

Note

  • Erasing storage must adhere to the limitations of the underlying storage medium, such as requiring full page erases. Use bootloader_getStorageInfo to learn about the limitations of the configured storage medium.

Returns


bootloader_getAllocatedDMAChannel#

int32_t bootloader_getAllocatedDMAChannel (void )

Get allocated DMA channel for MSC write.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • A positive number channel. -1 if DMA-based MSC write is not enabled. Otherwise, the error code BOOTLOADER_ERROR_INIT_STORAGE.