Mayank Gupta / Mbed OS pelion-example-frdm

Dependencies:   FXAS21002 FXOS8700Q

Embed: (wiki syntax)

« Back to documentation index

pal_update.h File Reference

pal_update.h File Reference

PAL update. This file contains the firmware update APIs and is a part of the PAL service API. More...

Go to the source code of this file.

Functions

palStatus_t pal_imageInitAPI (palImageSignalEvent_t CBfunction)
 Sets the callback function that is called before the end of each API except `imageGetDirectMemAccess`.
palStatus_t pal_imageDeInit (void)
 Clears all the resources used by the `pal_update` APIs.
palStatus_t pal_imagePrepare (palImageId_t imageId, palImageHeaderDeails_t *headerDetails)
 Prepares to write an image with an ID (`imageId`) and size (`imageSize`) in a suitable memory region.
palStatus_t pal_imageWrite (palImageId_t imageId, size_t offset, palConstBuffer_t *chunk)
 Writes the data to the chunk buffer with the chunk `bufferLength` in the location of `imageId`, adding the relative offset.
palStatus_t pal_imageFinalize (palImageId_t imageId)
 Flushes the image data and sets the version of `imageId` to `imageVersion`.
palStatus_t pal_imageGetDirectMemoryAccess (palImageId_t imageId, void **imagePtr, size_t *imageSizeInBytes)
 Verifies whether the image (`imageId`) is readable and sets `imagePtr` to point to the beginning of the image in the memory and `imageSizeInBytes` to the image size.
palStatus_t pal_imageReadToBuffer (palImageId_t imageId, size_t offset, palBuffer_t *chunk)
 Reads the maximum of chunk (`maxBufferLength`) bytes from the image with relative offset and stores it in the chunk buffer.
palStatus_t pal_imageActivate (palImageId_t imageId)
 Sets an image as the active image used after the device reset.
palStatus_t pal_imageGetActiveHash (palBuffer_t *hash)
 Retrieves the hash value of the active image to the hash buffer with the max size hash (`maxBufferLength`) and sets the hash size to hash `bufferLength`.
palStatus_t pal_imageGetFirmwareHeaderData (palImageId_t imageId, palBuffer_t *headerData)
 Retrieves the data value of the image header.
palStatus_t pal_imageGetActiveVersion (palBuffer_t *version)
 Retrieves the version of the active image to the version buffer with the size set to version `bufferLength`.
palStatus_t pal_imageWriteDataToMemory (palImagePlatformData_t dataId, const palConstBuffer_t *const dataBuffer)
 Writes data to a memory accessible to the bootloader. Currently, only hash is available.
char * pal_imageGetFolder (void)
 This function gets the working directory for the firmware.

Detailed Description

PAL update. This file contains the firmware update APIs and is a part of the PAL service API.

It provides the read, write and activation functionalities for the firmware.

Definition in file pal_update.h.


Function Documentation

palStatus_t pal_imageActivate ( palImageId_t  imageId )

Sets an image as the active image used after the device reset.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.

Definition at line 238 of file pal_update.c.

palStatus_t pal_imageDeInit ( void   )

Clears all the resources used by the `pal_update` APIs.

Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 79 of file pal_update.c.

palStatus_t pal_imageFinalize ( palImageId_t  imageId )

Flushes the image data and sets the version of `imageId` to `imageVersion`.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.
Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 194 of file pal_update.c.

palStatus_t pal_imageGetActiveHash ( palBuffer_t *  hash )

Retrieves the hash value of the active image to the hash buffer with the max size hash (`maxBufferLength`) and sets the hash size to hash `bufferLength`.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[out]hashA struct containing the hash and actual size of hash read.

Definition at line 284 of file pal_update.c.

palStatus_t pal_imageGetActiveVersion ( palBuffer_t *  version )

Retrieves the version of the active image to the version buffer with the size set to version `bufferLength`.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[out]versionA struct containing the version and actual size of version read.

Definition at line 309 of file pal_update.c.

palStatus_t pal_imageGetDirectMemoryAccess ( palImageId_t  imageId,
void **  imagePtr,
size_t *  imageSizeInBytes 
)

Verifies whether the image (`imageId`) is readable and sets `imagePtr` to point to the beginning of the image in the memory and `imageSizeInBytes` to the image size.

In case of failure, sets `imagePtr` to NULL and returns the relevant `palStatus_t` error.

Parameters:
[in]imageIdThe image ID.
[out]imagePtrA pointer to the beginning of the image.
[out]imageSizeInBytesThe size of the image.
Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 209 of file pal_update.c.

palStatus_t pal_imageGetFirmwareHeaderData ( palImageId_t  imageId,
palBuffer_t *  headerData 
)

Retrieves the data value of the image header.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.
[out]headerDataA struct containing the headerData and actual size of header.

Definition at line 246 of file pal_update.c.

char* pal_imageGetFolder ( void   )

This function gets the working directory for the firmware.

Returns:
full path of the firmware working folder

Definition at line 57 of file pal_update.c.

palStatus_t pal_imageInitAPI ( palImageSignalEvent_t  CBfunction )

Sets the callback function that is called before the end of each API except `imageGetDirectMemAccess`.

WARNING: Do not change this function! This function loads a callback function received from the upper layer, the service. The callback should be called at the end of each function except `pal_plat_imageGetDirectMemAccess`. The callback receives the event type that just occurred, defined by the ENUM `palImageEvents_t`.

If you do not call the callback at the end, the service behavior will be undefined. The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]CBfunctionA pointer to the callback function.
Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 63 of file pal_update.c.

palStatus_t pal_imagePrepare ( palImageId_t  imageId,
palImageHeaderDeails_t *  headerDetails 
)

Prepares to write an image with an ID (`imageId`) and size (`imageSize`) in a suitable memory region.

The space available is verified and reserved. The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.
[in]headerDetailsThe size of the image.
Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 92 of file pal_update.c.

palStatus_t pal_imageReadToBuffer ( palImageId_t  imageId,
size_t  offset,
palBuffer_t *  chunk 
)

Reads the maximum of chunk (`maxBufferLength`) bytes from the image with relative offset and stores it in the chunk buffer.

Also sets the chunk `bufferLength` value to the actual number of bytes read.

Note:
Use this API in case an image is not directly accessible via the `imageGetDirectMemAccess` function.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.
[in]offsetThe offset to start reading from.
[out]chunkA struct containing the data and actual bytes read.

Definition at line 217 of file pal_update.c.

palStatus_t pal_imageWrite ( palImageId_t  imageId,
size_t  offset,
palConstBuffer_t *  chunk 
)

Writes the data to the chunk buffer with the chunk `bufferLength` in the location of `imageId`, adding the relative offset.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.
[in]offsetThe offset to write the data into.
[in]chunkA pointer to struct containing the data and the data length to write.
Returns:
PAL_SUCCESS(0) in case of success, or a negative value indicating a specific error code in case of failure.

Definition at line 174 of file pal_update.c.

palStatus_t pal_imageWriteDataToMemory ( palImagePlatformData_t  dataId,
const palConstBuffer_t *const   dataBuffer 
)

Writes data to a memory accessible to the bootloader. Currently, only hash is available.

The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]dataIdThe data to be written to memory. One of the members of the `palImagePlatformData_t` enum.
[in]dataBufferA struct containing the data and actual bytes to be written.

Definition at line 317 of file pal_update.c.