Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

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. It provides the read/write and activation functionalities for the firmware. More...

Go to the source code of this file.

Functions

palStatus_t pal_imageInitAPI (palImageSignalEvent_t CBfunction)
palStatus_t pal_imageDeInit (void)
palStatus_t pal_imagePrepare (palImageId_t imageId, palImageHeaderDeails_t *headerDetails)
palStatus_t pal_imageWrite (palImageId_t imageId, size_t offset, palConstBuffer_t *chunk)
palStatus_t pal_imageFinalize (palImageId_t imageId)
palStatus_t pal_imageGetDirectMemoryAccess (palImageId_t imageId, void **imagePtr, size_t *imageSizeInBytes)
palStatus_t pal_imageReadToBuffer (palImageId_t imageId, size_t offset, palBuffer_t *chunk)
palStatus_t pal_imageActivate (palImageId_t imageId)
palStatus_t pal_imageGetActiveHash (palBuffer_t *hash)
palStatus_t pal_imageGetFirmwareHeaderData (palImageId_t imageId, palBuffer_t *headerData)
palStatus_t pal_imageGetActiveVersion (palBuffer_t *version)
palStatus_t pal_imageWriteDataToMemory (palImagePlatformData_t dataId, const palConstBuffer_t *const dataBuffer)
char * pal_imageGetFolder (void)
 This function gets the firmware working directory.

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 (`imageId`) as the active image (after the device reset). The function must call `g_palUpdateServiceCBfunc` before completing an event.

Parameters:
[in]imageIdThe image ID.

Definition at line 226 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 and a negative value indicating a specific error code in case of failure.

Definition at line 75 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 and a negative value indicating a specific error code in case of failure.

Definition at line 182 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 272 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 297 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 and a negative value indicating a specific error code in case of failure.

Definition at line 197 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 234 of file pal_update.c.

char* pal_imageGetFolder ( void   )

This function gets the firmware working directory.

Returns:
full path of the firmware working folder

Definition at line 53 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 (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 behaviour 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 and a negative value indicating a specific error code in case of failure.

Definition at line 59 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 and a negative value indicating a specific error code in case of failure.

Definition at line 88 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 (`imageId`) 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 the case 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 205 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 and a negative value indicating a specific error code in case of failure.

Definition at line 162 of file pal_update.c.

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

Writes the data of `dataId` stored in `dataBuffer` to a memory accessible to the bootloader. Currently, only hash is available. The function must call `g_palUpdateServiceCBfunc` before completing an event.

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

Definition at line 305 of file pal_update.c.