KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
update.h File Reference

Facilitates the update process. More...

#include <stdbool.h>
#include <stdint.h>
#include <cfg_soc.h>
#include "errorcode.h"

Go to the source code of this file.

Data Structures

struct  _UpdImgInfo
 

Macros

#define UPD_CHUNK_SIZE   512
 chunk size for updates, in bytes
 
#define UPD_CHUNK_MAX   ( FLASH_SPACING / UPD_CHUNK_SIZE )
 
#define E_UPD_SOMECHUNKS   ( E_UPD + 0x01 )
 Some chunks lost, check chunkLostList.
 
#define E_UPD_SOMECHUNKS_DESCR   "Some chunks lost"
 
#define E_UPD_MANYCHUNKS   ( E_UPD + 0x02 )
 Too many chunks lost, redo update.
 
#define E_UPD_MANYCHUNKS_DESCR   "Too many chunks lost"
 
#define E_UPD_CHECKSUM   ( E_UPD + 0x03 )
 The checksum failed, redo update.
 
#define E_UPD_CHECKSUM_DESCR   "Image checksum invalid"
 
#define E_UPD_PROTECTED   ( E_UPD + 0x04 )
 Protection is not cleared.
 
#define E_UPD_PROTECTED_DESCR   "Protection present"
 
#define UPD_IMGTYPE_NONE   ((int8_t)-1)
 There is no image at the specified location.
 
#define UPD_IMGTYPE_UNKNOWN   0
 There is an image, but it has no meta-data.
 
#define UPD_IMGTYPE_GOLDEN   1
 Golden image.
 
#define UPD_IMGTYPE_RUNTIME   2
 Runtime image.
 
#define UPD_IMGTYPE_BASE   3
 Base image.
 
#define UPD_IMGTYPE_CALIB   4
 Calibration image.
 

Typedefs

typedef struct _UpdImgInfo UpdImgInfo
 

Functions

bool updInit ()
 Initializes the update module. More...
 
bool updStart (int imageIdx, uint32_t chunkCount)
 Starts an image update. More...
 
bool updWrite (uint32_t chunkNo, uint8_t *chunk)
 Write a update chunk. More...
 
bool updEnd (uint32_t *chunkLostList, uint32_t *chunksCount)
 Ends the update. More...
 
void updCancel ()
 Aborts the update. More...
 
bool updVerify (uint32_t imgNo, uint32_t chunkNo, uint8_t *chunk, bool *result)
 Verify a chunk. More...
 
bool updIsUpdating (int *index)
 Returns whether or not the storage is in update mode. More...
 
bool updUnlock ()
 Unlocks the golden image for writing. More...
 
bool updImgInfo (uint32_t imgNo, UpdImgInfo *imgInfo)
 Retrieve image information for the specified location. More...
 
bool updLock ()
 Locks the golden image for writing. More...
 

Variables

const int updMaxImages
 Maximum no of images.
 

Detailed Description

Facilitates the update process.

Definition in file update.h.

Function Documentation

void updCancel ( )

Aborts the update.

May leave an invalid image in he persistent storage.

Definition at line 178 of file update.c.

bool updEnd ( uint32_t *  chunkLostList,
uint32_t *  chunksCount 
)

Ends the update.

Returns an array of chunks which have not been received or written correctly. When this function returns false the update process will not be stopped.

Parameters
chunkLostListA pointer to an array of lost chunk indexes.
chunksCountThe number of lost chunks.
Return values
trueUpdate completed, image valid.
falseThe update was not completed, update not ended.

Definition at line 163 of file update.c.

bool updImgInfo ( uint32_t  imgNo,
UpdImgInfo imgInfo 
)

Retrieve image information for the specified location.

Parameters
imgNoThe image number.
imgInfoPointer to an image information structure to fill.
Return values
trueCommand successful.
falseCommand failed, check error module for code and message

Definition at line 193 of file update.c.

bool updInit ( )

Initializes the update module.

Check whether or not protection of golden image is in place, and if not, puts it there.

Definition at line 64 of file update.c.

bool updIsUpdating ( int *  index)

Returns whether or not the storage is in update mode.

Parameters
indexThe pointer is filled with the image currently updated, if at all. Index may be null.
Return values
trueThe system is in update mode.
falseThe system is not in update mode.

Definition at line 188 of file update.c.

bool updLock ( )

Locks the golden image for writing.

Normally the golden image is locked after a succesful update.

Return values
trueThe image was locked
falseThe image was not locked.

Definition at line 230 of file update.c.

bool updStart ( int  imageIdx,
uint32_t  chunkCount 
)

Starts an image update.

The password is required for the golden image (image index 0), once it is protected using the updProtectGolden() command.

Parameters
imageIdxThe image index you wish to update.
chunkCountThe no of chunks send.
Return values
trueSystem is ready to receive the updates.
falseSystem is not ready to recieve the updates, check errCode().

Definition at line 81 of file update.c.

bool updUnlock ( )

Unlocks the golden image for writing.

Return values
trueThe image was unlocked.
falseThe image was not unlocked.

Definition at line 225 of file update.c.

bool updVerify ( uint32_t  imgNo,
uint32_t  chunkNo,
uint8_t *  chunk,
bool *  result 
)

Verify a chunk.

Parameters
imgNoThe image number.
chunkNoThe chunk number
chunkThe chunk data
resultpointer to the result, either true - they are the same, false - there are differences
Return values
trueCommand successful.
falseCommand failed, check error module for code and message

Definition at line 143 of file update.c.

bool updWrite ( uint32_t  chunkNo,
uint8_t *  chunk 
)

Write a update chunk.

Parameters
chunkNoThe index of the chunk to write.
chunkPointer to a array of chunkSize bytes.
Return values
trueUpdate chunk written.
falseThe update could not be written, check errCode().

Definition at line 102 of file update.c.