Storage#
Storage component.
This component provides the bootloader with multiple storage options. All storage implementations have to provide a slot-based API to access image files to be bootloaded.
Some storage implementations also support a raw storage API to access the underlying storage medium. This can be used by applications to store other data in parts of the storage medium that are not used for bootloading.
Storage Implementations#
Modules#
Flash Using JEDEC SFDP Standard
SPI Flash Configurations using SFDP
Functions#
Initialize the storage component.
Main function for storage component.
Shutdown storage component.
Get information about the storage component running on the device.
Get information about the layout of a storage slot.
Get information about the contents of a storage slot.
Initialize the context variable for checking a slot and trying to parse the image contained in it.
Check the given slot for a valid image.
Upgrade SE using image contained in a slot.
Bootload a bootloader image contained in a slot.
Bootload an image contained in a slot.
Erase the contents of a storage slot including all data and metadata.
Read a number of words from a storage slot.
Write a number of words to a storage slot.
Read number of words from raw storage.
Write a number of words to raw storage.
Get allocated DMA channel for MSC write.
Erase the raw storage.
Poll the storage implementation and check whether it is busy.
Get PPUSATD word of the (E)USART in use.
Macros#
Version number for bootloader storage functions struct.
Function Documentation#
storage_init#
int32_t storage_init (void )
Initialize the storage component.
N/A |
Returns
Error code indicating success or failure.
Return values
BOOTLOADER_OK: on success
BOOTLOADER_ERROR_INIT_STORAGE: on failure
68
of file platform/bootloader/storage/btl_storage.h
storage_main#
int32_t storage_main (void )
Main function for storage component.
N/A |
Returns
BOOTLOADER_OK on success, else error code
75
of file platform/bootloader/storage/btl_storage.h
storage_shutdown#
int32_t storage_shutdown (void )
Shutdown storage component.
N/A |
Returns
Error code indicating success or failure.
Return values
BOOTLOADER_OK: on success
BOOTLOADER_ERROR_INIT_STORAGE: on failure
84
of file platform/bootloader/storage/btl_storage.h
storage_getInfo#
void storage_getInfo (BootloaderStorageInformation_t * info)
Get information about the storage component running on the device.
[out] | info | Pointer to BootloaderStorageInformation_t struct |
91
of file platform/bootloader/storage/btl_storage.h
storage_getSlotInfo#
int32_t storage_getSlotInfo (uint32_t slotId, BootloaderStorageSlot_t * slot)
Get information about the layout of a storage slot.
[in] | slotId | Slot ID to get info about |
[out] | slot | Pointer to BootloaderStorageSlot_t struct |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
102
of file platform/bootloader/storage/btl_storage.h
storage_getSlotMetadata#
int32_t storage_getSlotMetadata (BootloaderParserContext_t * context, ApplicationData_t * appInfo, uint32_t * bootloaderVersion)
Get information about the contents of a storage slot.
[in] | context | Parsing context. Should be allocated by the application and initialized by calling storage_initParseSlot before calling this function. |
[out] | appInfo | Pointer to ApplicationData_t struct |
[out] | bootloaderVersion | Pointer to an unsigned integer representing the bootloader version number. |
Note
storage_initParseSlotmust be called before calling this function to initialize the context.
If the slot does not contain an application or a bootloader, the the corresponding values are set to zero.
Returns
BOOTLOADER_OK on success
123
of file platform/bootloader/storage/btl_storage.h
storage_initParseSlot#
int32_t storage_initParseSlot (uint32_t slotId, BootloaderParserContext_t * context, size_t contextSize)
Initialize the context variable for checking a slot and trying to parse the image contained in it.
[in] | slotId | Slot to check for valid image |
[in] | context | Pointer to BootloaderParserContext_t struct |
[in] | contextSize | Length of the context struct |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_PARSE_BASE range
138
of file platform/bootloader/storage/btl_storage.h
storage_verifySlot#
int32_t storage_verifySlot (BootloaderParserContext_t * context, BootloaderParserCallback_t metadataCallback)
Check the given slot for a valid image.
[in] | context | Pointer to BootloaderImageParsingContext_t struct |
[in] | metadataCallback | Functionpointer which will be called with any binary metadata that might be contained within the image. |
Call this function continuously until it stops returning. BOOTLOADER_ERROR_PARSE_CONTINUE.
The function returns BOOTLOADER_ERROR_PARSE_SUCCESS if the image in the slot was successfully verified. For detailed information on the parsed image, see imageProperties in the context variable.
Returns
BOOTLOADER_ERROR_PARSE_CONTINUE if the parsing is not complete, BOOTLOADER_ERROR_PARSE_SUCCESS on success.
159
of file platform/bootloader/storage/btl_storage.h
storage_upgradeSeFromSlot#
bool storage_upgradeSeFromSlot (uint32_t slotId)
Upgrade SE using image contained in a slot.
N/A | slotId | Slot ID to bootload from |
Note
This function assumes the image located in the slotId has been verified first.
Returns
True if the operation succeeded
172
of file platform/bootloader/storage/btl_storage.h
storage_bootloadBootloaderFromSlot#
bool storage_bootloadBootloaderFromSlot (uint32_t slotId, uint32_t version)
Bootload a bootloader image contained in a slot.
N/A | slotId | Slot ID to bootload from |
N/A | version | Version number of new bootloader |
Note
This function assumes the image located in the slotId has been verified first.
Returns
True if operation succeeded
185
of file platform/bootloader/storage/btl_storage.h
storage_bootloadApplicationFromSlot#
bool storage_bootloadApplicationFromSlot (uint32_t slotId, uint32_t version, uint32_t deltaGBLLen)
Bootload an image contained in a slot.
N/A | slotId | Slot ID to bootload from |
N/A | version | Cached version number of the image contained in the slot (used for downgrade prevention) |
N/A | deltaGBLLen | Length of the Delta GBL file. |
Note
This function assumes the image located in slotId has been verified first.
Returns
True if the operation succeeded
200
of file platform/bootloader/storage/btl_storage.h
storage_eraseSlot#
int32_t storage_eraseSlot (uint32_t slotId)
Erase the contents of a storage slot including all data and metadata.
N/A | slotId | ID of the slot. |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
210
of file platform/bootloader/storage/btl_storage.h
storage_readSlot#
int32_t storage_readSlot (uint32_t slotId, uint32_t offset, uint8_t * buffer, size_t numBytes)
Read a number of words from a storage slot.
N/A | slotId | ID of the slot. |
N/A | offset | The offset into the slot in bytes. |
N/A | buffer | Pointer to buffer to store read data in. |
N/A | numBytes | Number of bytes to read. |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
223
of file platform/bootloader/storage/btl_storage.h
storage_writeSlot#
int32_t storage_writeSlot (uint32_t slotId, uint32_t offset, uint8_t * data, size_t numBytes)
Write a number of words to a storage slot.
N/A | slotId | ID of the slot. |
N/A | offset | The offset into the slot in bytes. |
N/A | data | Pointer to data to write. |
N/A | numBytes | Length of data to write. Must be a multiple of 4. |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
239
of file platform/bootloader/storage/btl_storage.h
storage_readRaw#
int32_t storage_readRaw (uint32_t address, uint8_t * buffer, size_t numBytes)
Read number of words from raw storage.
N/A | address | The raw address of the storage. |
N/A | buffer | Pointer to the buffer to store read data in. |
N/A | numBytes | Number of bytes to read. |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
254
of file platform/bootloader/storage/btl_storage.h
storage_writeRaw#
int32_t storage_writeRaw (uint32_t address, uint8_t * data, size_t numBytes)
Write a number of words to raw storage.
N/A | address | The raw address of the storage. |
N/A | data | Pointer to data to write. |
N/A | numBytes | Length of data to write. Must be a multiple of 4. |
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
268
of file platform/bootloader/storage/btl_storage.h
storage_getDMAchannel#
int32_t storage_getDMAchannel (void )
Get allocated DMA channel for MSC write.
N/A |
Returns
A positive number channel. -1 if DMA-based MSC write is not enabled.
278
of file platform/bootloader/storage/btl_storage.h
storage_eraseRaw#
int32_t storage_eraseRaw (uint32_t address, size_t length)
Erase the raw storage.
N/A | address | Start address of the region to erase |
N/A | length | Number of bytes to erase |
Note
Some devices, such as Flash-based storages, have restrictions on the alignment and size of erased regions. The details of the limitations of a particular storage can be found by reading the BootloaderStorageInformation_t struct using storage_getInfo.
Returns
BOOTLOADER_OK on success, else error code in BOOTLOADER_ERROR_STORAGE_BASE range
294
of file platform/bootloader/storage/btl_storage.h
storage_isBusy#
bool storage_isBusy (void )
Poll the storage implementation and check whether it is busy.
N/A |
Returns
True if the storage is busy
301
of file platform/bootloader/storage/btl_storage.h
storage_getSpiUsartPPUSATD#
uint32_t storage_getSpiUsartPPUSATD (uint32_t * ppusatdNr)
Get PPUSATD word of the (E)USART in use.
N/A | ppusatdNr | PPUSATD register number |
Returns
Word representing the PPUSATD bit field of the (E)USART in use. 0 if not found.
311
of file platform/bootloader/storage/btl_storage.h