AWS IoT Over-the-air Update  v3.1.0
Client library for AWS IoT OTA
ota_platform_interface.h
Go to the documentation of this file.
1 /*
2  * AWS IoT Over-the-air Update v3.1.0
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 
28 #ifndef OTA_PLATFORM_INTERFACE
29 #define OTA_PLATFORM_INTERFACE
30 
31 /* *INDENT-OFF* */
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 /* *INDENT-ON* */
36 
37 #include "ota_private.h"
38 
67 typedef uint32_t OtaPalStatus_t;
68 
72 typedef uint32_t OtaPalSubStatus_t;
73 
78 typedef enum OtaPalMainStatus
79 {
97 
111 /* @[define_ota_err_code_helpers] */
112 #define OTA_PAL_ERR_MASK 0xffffffUL
113 #define OTA_PAL_SUB_BITS 24U
114 #define OTA_PAL_MAIN_ERR( err ) ( ( OtaPalMainStatus_t ) ( uint32_t ) ( ( uint32_t ) ( err ) >> ( uint32_t ) OTA_PAL_SUB_BITS ) )
115 #define OTA_PAL_SUB_ERR( err ) ( ( uint32_t ) ( err ) & ( uint32_t ) OTA_PAL_ERR_MASK )
116 #define OTA_PAL_COMBINE_ERR( main, sub ) ( ( ( uint32_t ) ( main ) << ( uint32_t ) OTA_PAL_SUB_BITS ) | ( uint32_t ) OTA_PAL_SUB_ERR( sub ) )
117 /* @[define_ota_err_code_helpers] */
118 
139 typedef OtaPalStatus_t ( * OtaPalAbort_t )( OtaFileContext_t * const pFileContext );
140 
164 typedef OtaPalStatus_t (* OtaPalCreateFileForRx_t)( OtaFileContext_t * const pFileContext );
165 
190 typedef OtaPalStatus_t ( * OtaPalCloseFile_t )( OtaFileContext_t * const pFileContext );
191 
211 typedef int16_t ( * OtaPalWriteBlock_t ) ( OtaFileContext_t * const pFileContext,
212  uint32_t offset,
213  uint8_t * const pData,
214  uint32_t blockSize );
215 
228 typedef OtaPalStatus_t ( * OtaPalActivateNewImage_t )( OtaFileContext_t * const pFileContext );
229 
242 typedef OtaPalStatus_t ( * OtaPalResetDevice_t ) ( OtaFileContext_t * const pFileContext );
243 
266  OtaImageState_t eState );
267 
292 
297 typedef struct OtaPalInterface
298 {
299  /* MISRA rule 21.8 prohibits the use of abort from stdlib.h. However, this is merely one of the
300  * OTA platform abstraction layer interfaces, which is used to abort an OTA update. So it's a
301  * false positive. */
302  /* coverity[misra_c_2012_rule_21_8_violation] */
312 
313 /* *INDENT-OFF* */
314 #ifdef __cplusplus
315  }
316 #endif
317 /* *INDENT-ON* */
318 
319 #endif /* ifndef OTA_PLATFORM_INTERFACE */
OtaPalAbortFailed
@ OtaPalAbortFailed
Error trying to abort the OTA.
Definition: ota_platform_interface.h:90
OtaPalStatus_t
uint32_t OtaPalStatus_t
The OTA platform interface return status. Composed of main and sub status.
Definition: ota_platform_interface.h:67
OtaPalInterface_t::setPlatformImageState
OtaPalSetPlatformImageState_t setPlatformImageState
Set the state of the OTA update image.
Definition: ota_platform_interface.h:309
OtaPalInterface_t::getPlatformImageState
OtaPalGetPlatformImageState_t getPlatformImageState
Get the state of the OTA update image.
Definition: ota_platform_interface.h:310
OtaPalCreateFileForRx_t
OtaPalStatus_t(* OtaPalCreateFileForRx_t)(OtaFileContext_t *const pFileContext)
Create a new receive file for the data chunks as they come in.
Definition: ota_platform_interface.h:164
OtaFileContext_t
OTA File Context Information.
Definition: ota_private.h:382
OtaImageState_t
OtaImageState_t
OTA Image states.
Definition: ota_private.h:314
OtaPalUninitialized
@ OtaPalUninitialized
Result is not yet initialized from PAL.
Definition: ota_platform_interface.h:81
OtaPalNullFileContext
@ OtaPalNullFileContext
The PAL is called with a NULL file context.
Definition: ota_platform_interface.h:83
OtaPalInterface_t::activate
OtaPalActivateNewImage_t activate
Activate the file received over-the-air.
Definition: ota_platform_interface.h:307
OtaPalActivateNewImage_t
OtaPalStatus_t(* OtaPalActivateNewImage_t)(OtaFileContext_t *const pFileContext)
Activate the newest MCU image received via OTA.
Definition: ota_platform_interface.h:228
OtaPalInterface_t::writeBlock
OtaPalWriteBlock_t writeBlock
Write a block of data to the specified file at the given offset.
Definition: ota_platform_interface.h:306
OtaPalRxFileTooLarge
@ OtaPalRxFileTooLarge
The OTA receive file is too big for the platform to support.
Definition: ota_platform_interface.h:86
OtaPalInterface_t::closeFile
OtaPalCloseFile_t closeFile
Authenticate and close the receive file.
Definition: ota_platform_interface.h:305
OtaPalAbort_t
OtaPalStatus_t(* OtaPalAbort_t)(OtaFileContext_t *const pFileContext)
Abort an OTA transfer.
Definition: ota_platform_interface.h:139
OtaPalInterface_t::abort
OtaPalAbort_t abort
Abort an OTA transfer.
Definition: ota_platform_interface.h:303
ota_private.h
Macros, enums, variables, and definitions internal to the OTA Agent module and shared by other OTA mo...
OtaPalSubStatus_t
uint32_t OtaPalSubStatus_t
The OTA platform interface sub status.
Definition: ota_platform_interface.h:72
OtaPalFileClose
@ OtaPalFileClose
Error in low level file close.
Definition: ota_platform_interface.h:95
OtaPalSuccess
@ OtaPalSuccess
OTA platform interface success.
Definition: ota_platform_interface.h:80
OtaPalImageState_t
OtaPalImageState_t
OTA Platform Image State.
Definition: ota_private.h:331
OtaPalSignatureCheckFailed
@ OtaPalSignatureCheckFailed
The signature check failed for the specified file.
Definition: ota_platform_interface.h:84
OtaPalRxFileCreateFailed
@ OtaPalRxFileCreateFailed
The PAL failed to create the OTA receive file.
Definition: ota_platform_interface.h:85
OtaPalInterface_t::createFile
OtaPalCreateFileForRx_t createFile
Create a new receive file.
Definition: ota_platform_interface.h:304
OtaPalOutOfMemory
@ OtaPalOutOfMemory
Out of memory.
Definition: ota_platform_interface.h:82
OtaPalGetPlatformImageState_t
OtaPalImageState_t(* OtaPalGetPlatformImageState_t)(OtaFileContext_t *const pFileContext)
Get the state of the OTA update image.
Definition: ota_platform_interface.h:291
OtaPalCommitFailed
@ OtaPalCommitFailed
The acceptance commit of the new OTA image failed.
Definition: ota_platform_interface.h:92
OtaPalMainStatus_t
OtaPalMainStatus_t
The OTA platform interface main status.
Definition: ota_platform_interface.h:79
OtaPalCloseFile_t
OtaPalStatus_t(* OtaPalCloseFile_t)(OtaFileContext_t *const pFileContext)
Authenticate and close the underlying receive file in the specified OTA context.
Definition: ota_platform_interface.h:190
OtaPalBadSignerCert
@ OtaPalBadSignerCert
The signer certificate was not readable or zero length.
Definition: ota_platform_interface.h:88
OtaPalInterface_t
OTA pal Interface structure.
Definition: ota_platform_interface.h:298
OtaPalWriteBlock_t
int16_t(* OtaPalWriteBlock_t)(OtaFileContext_t *const pFileContext, uint32_t offset, uint8_t *const pData, uint32_t blockSize)
Write a block of data to the specified file at the given offset.
Definition: ota_platform_interface.h:211
OtaPalActivateFailed
@ OtaPalActivateFailed
The activation of the new OTA image failed.
Definition: ota_platform_interface.h:93
OtaPalRejectFailed
@ OtaPalRejectFailed
Error trying to reject the OTA image.
Definition: ota_platform_interface.h:91
OtaPalBadImageState
@ OtaPalBadImageState
The specified OTA image state was out of range.
Definition: ota_platform_interface.h:89
OtaPalInterface_t::reset
OtaPalResetDevice_t reset
Reset the device.
Definition: ota_platform_interface.h:308
OtaPalBootInfoCreateFailed
@ OtaPalBootInfoCreateFailed
The PAL failed to create the OTA boot info file.
Definition: ota_platform_interface.h:87
OtaPalFileAbort
@ OtaPalFileAbort
Error in low level file abort.
Definition: ota_platform_interface.h:94
OtaPalSetPlatformImageState_t
OtaPalStatus_t(* OtaPalSetPlatformImageState_t)(OtaFileContext_t *const pFileContext, OtaImageState_t eState)
Attempt to set the state of the OTA update image.
Definition: ota_platform_interface.h:265
OtaPalResetDevice_t
OtaPalStatus_t(* OtaPalResetDevice_t)(OtaFileContext_t *const pFileContext)
Reset the device.
Definition: ota_platform_interface.h:242