TI-OpenThread  1.08.02.01
CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file oad_storage.h
4 
5  @brief OAD Storage Header
6 
7  Group: CMCU, LPC
8  Target Device: cc13x2_26x2
9 
10  ******************************************************************************
11 
12  Copyright (c) 2017-2020, Texas Instruments Incorporated
13  All rights reserved.
14 
15  Redistribution and use in source and binary forms, with or without
16  modification, are permitted provided that the following conditions
17  are met:
18 
19  * Redistributions of source code must retain the above copyright
20  notice, this list of conditions and the following disclaimer.
21 
22  * Redistributions in binary form must reproduce the above copyright
23  notice, this list of conditions and the following disclaimer in the
24  documentation and/or other materials provided with the distribution.
25 
26  * Neither the name of Texas Instruments Incorporated nor the names of
27  its contributors may be used to endorse or promote products derived
28  from this software without specific prior written permission.
29 
30  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
32  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
33  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
34  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
35  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
36  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
37  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
39  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
40  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 
42  ******************************************************************************
43 
44 
45  *****************************************************************************/
46 #ifndef OADStorage_H
47 #define OADStorage_H
48 
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 /*********************************************************************
55  * INCLUDES
56  */
57 #include <stdint.h>
58 #include <stdbool.h>
59 
60 #include <oad_image_header.h>
61 
62 /*********************************************************************
63  * CONSTANTS
64  */
65 // OAD payload overheads
66 #define OADStorage_ATT_OVERHEAD 3
67 #define OADStorage_BLK_NUM_HDR_SZ 0 //4
68 
69 #ifndef OAD_BLOCK_SIZE
70 #define OADStorage_BLOCK_SIZE 128 + OADStorage_BLK_NUM_HDR_SZ
71 #else
72 #define OADStorage_BLOCK_SIZE OAD_BLOCK_SIZE + OADStorage_BLK_NUM_HDR_SZ
73 #endif
74 
76 typedef enum {
84 
85 /* Image Identify Payload */
86 typedef struct __attribute__((packed))
87 {
88  uint8_t imgID[8];
89  uint8_t bimVer;
90  uint8_t metaVer;
91  uint8_t imgCpStat;
92  uint8_t crcStat;
93  uint8_t imgType;
94  uint8_t imgNo;
95  uint32_t len;
96  uint8_t softVer[4];
98 
99 /*********************************************************************
100  * MACROS
101  */
102 
103 /*********************************************************************
104  * TYPEDEFS
105  */
106 
107 /*********************************************************************
108  * EXTERNAL VARIABLES
109  */
110 
111 
112 /*********************************************************************
113  * FUNCTIONS
114  */
115 
116 /*********************************************************************
117  * @fn OADStorage_init
118  *
119  * @brief Initialise the OAD Target Profile.
120  *
121  * @param None.
122  *
123  * @return None.
124  */
125 extern void OADStorage_init(void);
126 
127 /*********************************************************************
128  * @fn OADStorage_imgIdentifyRead
129  *
130 * @brief Read Image header and return number of blocks.
131  *
132  * @param imageType - image type indicating which image to read
133  * @param pImgHdr - pointer to image header data
134  *
135  * @return Total Blocks if image accepted, 0 if Image invalid
136  */
137 uint16_t OADStorage_imgIdentifyRead(uint8_t imageType, OADStorage_imgIdentifyPld_t* pImgId);
138 
139 /*********************************************************************
140  * @fn OADStorage_imgIdentifyWrite
141  *
142  * @brief Process the Image Identify Write. Determine from the received OAD
143  * Image Header if the Downloaded Image should be acquired.
144  *
145  * @param pValue - pointer to data to be written
146  *
147  * @return Total Blocks if image accepted, 0 if Image rejected
148  */
149 extern uint16_t OADStorage_imgIdentifyWrite(uint8_t *pValue);
150 
151 /*********************************************************************
152  * @fn OADStorage_imgBlockRead
153  *
154  * @brief Read Image Block.
155  *
156  * @param blockNum - block number to be written
157  * @param pBlockData - pointer for data to be read
158  *
159  * @return none
160  */
161 extern OADStorage_Status_t OADStorage_imgBlockRead(uint16_t blockNum, uint8_t *pBlockData);
162 
163 /*********************************************************************
164  * @fn OADStorage_imgInfoRead
165  *
166  * @brief Read an Image info.
167  *
168  * @param pimgInfo - pointer for data to be read
169  *
170  * @return none
171  */
172 extern void OADStorage_imgInfoRead(uint8_t *pimgInfo);
173 
174 /*********************************************************************
175  * @fn OADStorage_imgBlockWrite
176  *
177  * @brief Write Image Block.
178  *
179  * @param blockNum - block number to be written
180  * @param pBlockData - pointer to data to be written
181  * @param len - length fo block
182  *
183  * @return status
184  */
185 extern OADStorage_Status_t OADStorage_imgBlockWrite(uint32_t blockNum, uint8_t *pBlockData, uint8_t len);
186 
187 /*********************************************************************
188  * @fn OADStorage_eraseImgPage
189  *
190  * @brief Erases an Image page. Note this is only needed if an image
191  * page has been corrupted typically OADStorage_imgBlockWrite
192  * pre-erase all pages
193  *
194  * @param none
195  *
196  * @return OADStorage_Status_t
197  */
198 extern OADStorage_Status_t OADStorage_eraseImgPage(uint32_t page);
199 
200 /*********************************************************************
201  * @fn OADStorage_imgFinalise
202  *
203  * @brief Process the Image Block Write.
204  *
205  * @param none
206  *
207  * @return status
208  */
209 extern OADStorage_Status_t OADStorage_imgFinalise(void);
210 
211 /*********************************************************************
212  * @fn OADStorage_close
213  *
214  * @brief Releases the resource required for OAD stoarage.
215  *
216  * @param none
217  *
218  * @return none
219  */
220 extern void OADStorage_close(void);
221 
222 /*********************************************************************
223  * @fn OADStorage_createFactoryImageBackup
224  *
225  * @brief This function creates factory image backup of current running image
226  *
227  * @param None
228  *
229  * @return status OADStorage_Status_Success/OADStorage_FlashError
230  *
231  */
232 extern uint8_t OADStorage_createFactoryImageBackup(void);
233 /*********************************************************************
234  * @fn OADStorage_checkFactoryImage
235  *
236  * @brief This function check if the valid factory image exists on external
237  * flash
238  *
239  * @param None
240  *
241  * @return TRUE If factory image exists on external flash, else FALSE
242  *
243  */
244 extern bool OADStorage_checkFactoryImage(void);
245 /*********************************************************************
246  * @fn OADStorage_getFactoryImage
247  *
248  * @brief This function returns techType of the current factory image if
249  * it exists on external flash
250  *
251  * @param None
252  *
253  * @return factory image techType
254  *
255  */
256 extern uint16_t OADStorage_getFactoryImage(void);
257 /*********************************************************************
258 *********************************************************************/
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* OADStorage_H */
flash access error
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:80
OADStorage_Status_t OADStorage_imgBlockWrite(uint32_t blockNum, uint8_t *pBlockData, uint8_t len)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:292
void OADStorage_imgInfoRead(uint8_t *pimgInfo)
bool OADStorage_checkFactoryImage(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:597
void OADStorage_close(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:1292
OADStorage_Status_t
OADStorage_Status_t status codes.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:76
OADStorage_Status_t OADStorage_imgBlockRead(uint16_t blockNum, uint8_t *pBlockData)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:1265
uint16_t OADStorage_getFactoryImage(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:631
uint16_t OADStorage_imgIdentifyWrite(uint8_t *pValue)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:230
uint8_t OADStorage_createFactoryImageBackup(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:665
Acknowledgment or Response Timed out.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:79
OAD request rejected by application.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:82
void OADStorage_init(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:128
Fail.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:78
Canceled by application.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:81
OADStorage_Status_t OADStorage_eraseImgPage(uint32_t page)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:440
uint16_t OADStorage_imgIdentifyRead(uint8_t imageType, OADStorage_imgIdentifyPld_t *pImgId)
Success.
Definition: CC1352P_4_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:77
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.h:86
OADStorage_Status_t OADStorage_imgFinalise(void)
Definition: CC1352P_2_LAUNCHXL/thread/doorlock_oad_secure/oad/oad_storage.c:465
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale