forked from discreetmayor/ti154_collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oad_image_header.h
828 lines (694 loc) · 23.4 KB
/
oad_image_header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
/******************************************************************************
@file oad_image_header.h
@brief This file contains the image header definition and structures.
Group: WCS, BTS
$Target Device: DEVICES $
******************************************************************************
$License: BSD3 2017 $
******************************************************************************
$Release Name: PACKAGE NAME $
$Release Date: PACKAGE RELEASE DATE $
******************************************************************************/
/** ============================================================================
* @defgroup OAD_IMAGE_HEADER OAD Image Header
* @brief Structure definition for image header and segments, these are
* prepended to the over the air images.
*
* @{
*
* # Header Include #
* The OAD Image header file should be included in an OAD enabled application
* as follows:
* @code
* #include <common/cc26xx/oad/oad_image_header.h>
* @endcode
*
* # Overview #
*
* The OAD image header is a combined structure that is intended to be
* prepdended to a binary image before sending over the air.
* This file defines the structures that are used to build up an image header.
* Additionally, this header file can be used by the application to read fields
* within an image header.
*
* ## General Behavior #
* For code examples, see the use cases below.
*
* ### Creating a header structure
* - In a separate file, define header structure members like so:
* @code
* const imgHdr_t _imgHdr =
* {
* // First define core header (imgFixedHdr_t)
* {
* .imgID = OAD_IMG_ID_VAL,
* .crc32 = DEFAULT_CRC,
* .bimVer = BIM_VER,
* .metaVer = META_VER,
* // Define rest of core header below ...
* },
* // Image payload segment initialization
* {
* .segTypeImg = IMG_PAYLOAD_SEG_ID,
* .wirelessTech = OAD_WIRELESS_TECH_BLE,
* .rfu = DEFAULT_STATE,
* .startAddr = (uint32_t)&(_imgHdr.fixedHdr.imgID),
* }
* };
* @endcode
*
* - Note: A core image header and contiguous image header are required
* - When building the stack as a separate image, a boundary segment is
* required (boundarySeg_t)
*
* ### Placing/Using a header structure
* - The OAD image header must precede an executable OAD image
* - The OAD image header must be aligned on page boundary
* - The linker file is responsible for the two requirements above
* - A sample placement of the header in CCS
* @code
* #pragma DATA_SECTION(_imgHdr, ".image_header")
* #pragma RETAIN(_imgHdr)
* const imgHdr_t _imgHdr =
* @endcode
* - A sample placement for IAR
* @code
* #pragma location=".img_hdr"
* const imgHdr_t _imgHdr @ ".img_hdr" =
* @endcode
*
*
* @file oad_image_header.h
*
* @brief Structure definition for image header and segments, these are
* prepended to the over the air images.
*/
#ifndef OAD_IMAGE_HEADER_H
#define OAD_IMAGE_HEADER_H
#ifdef __cplusplus
extern "C"
{
#endif
/*******************************************************************************
* INCLUDES
******************************************************************************/
#include <stddef.h>
#include <stdint.h>
#ifndef __unix__
#include "hal_types.h"
#else
#define PACKED_TYPEDEF_STRUCT typedef struct
#endif
/*******************************************************************************
* CONSTANTS
******************************************************************************/
#ifdef OAD_ONCHIP
/*!
* BIM Variable Address
*
* The bim_var is a variable stored in RAM that is used to control switching
* between persistent and user application in the BIM
* On CC26xx platforms RAM is retained between resets and this is possible
*
* Warning! placement of the BIM variable must respect the following
* reserved RAM regions ( Valid for CC2640R2):
* - TI-RTOS in ROM reserved region: 0x20000100-0x20000280
* - BLE Stack memory: < ICALL_RAM0_START
* - Vector Table in RAM: 0x20000000-0x200000C8
* Failing to respect either of the above boundaries will result in a
* linker error
*/
#define BIM_VAR_ADDR 0x20000400
/*!
* BIM Argument variable
*
* The application is responsible for defining this variable for on-chip OAD
*/
extern uint32_t _bim_var;
#endif // OAD_ONCHIP
#define SIGN_FN_PTR 0x57fa0
extern uint32_t _sign_fnPtr;
/**
* @defgroup OAD_IMG_TYPE OAD image types
* @{
*/
/*!
* OAD on-chip persistent application image
*
* The persistent app is the permanently resident app used in on-chip OAD
* The persistent app is responsible for updating the user application
*/
#define OAD_IMG_TYPE_PERSISTENT_APP 0
/*!
* OAD user application image
*
* A user application of split app/stack type
*/
#define OAD_IMG_TYPE_APP 1
/*!
* OAD stack image
*
* An OAD enabled stack image of split image type
*/
#define OAD_IMG_TYPE_STACK 2
/*!
* OAD app + stack merge
*
* An OAD enabled image that is a merge of both app and stack that are of split
* image type.
*/
#define OAD_IMG_TYPE_APP_STACK 3
/*!
* OAD network processor image
*
* A network processor image. This image is intended to run an external
* processor
*/
#define OAD_IMG_TYPE_NP 4
/*!
* OAD network processor image
*
* A network processor image. This image is intended to run an external
* processor
*/
#define OAD_IMG_TYPE_FACTORY 5
/*!
* OAD Boot Image Manager (BIM) image
*
* A BIM image
* \note BIM upgrade is not currently supported
*/
#define OAD_IMG_TYPE_BIM 6
/*!
* OAD app + stack library image
*
* An OAD enabled executable where the app and stack are built and linked
* together as one image.
* \note This is different than @ref OAD_IMG_TYPE_APP_STACK which is a post
* build merge of two split images.
*/
#define OAD_IMG_TYPE_APPSTACKLIB 7
/*!
* OAD User defined image type begin
*
* This is the beginning of the range of image types reserved for the user.
* OAD applications will not attempt to use or load images with this type
*/
#define OAD_IMG_TYPE_USR_BEGIN 16
/*!
* OAD User defined image type end
*
* This is the end of the range of image types reserved for the user.
* OAD applications will not attempt to use or load images with this type
*/
#define OAD_IMG_TYPE_USR_END 31
/*!
* OAD Host image type begin
*
* An image for a host processor
*/
#define OAD_IMG_TYPE_HOST_BEGIN 32
/*!
* OAD Host image type end
*
* An image for a host processor
*/
#define OAD_IMG_TYPE_HOST_END 63
/*!
* OAD reserved image type begin
*
* \warning These fields are RFU
*/
#define OAD_IMG_TYPE_RSVD_BEGIN 64
/*!
* OAD reserved image type end
*
* \warning These fields are RFU
*/
#define OAD_IMG_TYPE_RSVD_END 255
/** @} End OAD_IMG_TYPE */
/**
* @defgroup OAD_WIRELESS_TECH OAD wireless technology fields
* @{
*/
/*!
* Image built for BLE
*/
#define OAD_WIRELESS_TECH_BLE 0xFFFE
/*!
* Image built for Sub1-GHz TI 15.4-Stack
*/
#define OAD_WIRELESS_TECH_TIMAC_SUBG 0xFFFD
/*!
* Image built for 2.4-GHz TI 15.4-Stack
*/
#define OAD_WIRELESS_TECH_TIMAC_2_4G 0xFFFB
/*!
* Image built for Zigbee
*/
#define OAD_WIRELESS_TECH_ZIGBEE 0xFFF7
/*!
* Image built for RF4CE
*/
#define OAD_WIRELESS_TECH_RF4CE 0xFFEF
/*!
* Image built for TI Open Thread
*/
#define OAD_WIRELESS_TECH_THREAD 0xFFDF
/*!
* Image built for EasyLink
*/
#define OAD_WIRELESS_TECH_EASYLINK 0xFFBF
/** @} End OAD_WIRELESS_TECH */
#ifndef __unix__
#ifdef DeviceFamily_CC26X2
#define OAD_IMG_ID_VAL {'C', 'C', '2', '6', 'x', '2', 'R', '1'}
#elif defined (DeviceFamily_CC13X2) || \
defined (DeviceFamily_CC13X2_V1) || \
defined (DeviceFamily_CC13X2_V2)
#define OAD_IMG_ID_VAL {'C', 'C', '1', '3', 'x', '2', 'R', '1'}
#elif defined (DeviceFamily_CC26X0R2)
#define OAD_IMG_ID_VAL {'O', 'A', 'D', ' ', 'I', 'M', 'G', ' '}
#elif defined (DOXYGEN)
/*!
* Magic number to identify OAD image header. It is recommended that the
* customer adjust these to uniquely identify their device
*
* This define will be filled in conditionally based on DeviceFamily_*
* - DeviceFamily_CC26X2: @code {'C', 'C', '2', '6', 'x', '2', 'R', '1'} @endcode
* - DeviceFamily_CC13X2: @code {'C', 'C', '1', '3', 'x', '2', 'R', '1'} @endcode
* - DeviceFamily_CC26X0R2: @code {'O', 'A', 'D', ' ', 'I', 'M', 'G', ' '} @endcode
* - Else an error will be thrown
*/
#define OAD_IMG_ID_VAL
#else
#error "Unknown Device Family"
#endif //DeviceFamily_CC26X2
#else
#define CC26X2_OAD_IMG_ID_VAL "CC26x2R1"
#define CC13X2_OAD_IMG_ID_VAL "CC13x2R1"
#define OAD_IMG_ID_VAL "OAD IMG "
#endif
/*!
* Magic number used by entries in the image header table at the beginning of
* external flash. Note this is different from @ref OAD_IMG_ID_VAL so that
* the application can determine the difference between an entry in the header
* table and the start of an OAD image
*
* \note This is only used by off-chip OAD
*/
#ifndef __unix__
#define OAD_EXTFL_ID_VAL {'O', 'A', 'D', ' ', 'N', 'V', 'M', '1'}
#else
#define OAD_EXTFL_ID_VAL "OAD NVM1"
#endif
/*!
* Delta Image built for the off-chip OAD memory configuration
*/
#define DELTA_IMG_MEMORY_CFG_OFFCHIP 0x01
/*!
* Delta Image built for the on-chip OAD memory configuration
*/
#define DELTA_IMG_MEMORY_CFG_ONCHIP 0x02
/**
* @defgroup OAD_OFFSETS OAD Image Header offsets
* @{
*/
/*!
* Offset in bytes of crc32 into the structure @ref imgFixedHdr_t
*/
#define CRC_OFFSET offsetof(imgHdr_t, fixedHdr.crc32)
/*!
* Offset in bytes of bimVer into the structure @ref imgFixedHdr_t
*/
#define BIM_VER_OFFSET offsetof(imgHdr_t, fixedHdr.bimVer)
/*!
* Offset in bytes of bimVer into the structure
* @ref imgFixedHdr_t. This is the start of data after the CRC bytes
*/
#define IMG_DATA_OFFSET BIM_VER_OFFSET
/*!
* Offset in bytes of imgCpStat into the structure @ref imgFixedHdr_t
*/
#define IMG_INFO_OFFSET offsetof(imgHdr_t, fixedHdr.imgCpStat)
/*!
* Offset in bytes of @ref IMG_INFO_OFFSET into the structure @ref imgFixedHdr_t
*/
#define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET
/*!
* Offset in bytes of CRC status into the structure @ref imgFixedHdr_t
*/
#define CRC_STAT_OFFSET offsetof(imgHdr_t, fixedHdr.crcStat)
/*!
* Offset in bytes of imgType into the structure @ref imgFixedHdr_t
*/
#define IMG_TYPE_OFFSET offsetof(imgHdr_t, fixedHdr.imgType)
/*!
* Offset in bytes of imgVal into the structure @ref imgFixedHdr_t
*/
#define IMG_VALIDATION_OFFSET offsetof(imgHdr_t, fixedHdr.imgVld)
/*!
* Offset in bytes of len into the structure @ref imgFixedHdr_t
*/
#define IMG_LEN_OFFSET offsetof(imgHdr_t, fixedHdr.len)
/*!
* Offset in bytes of the boundary segment into the structure @ref imgHdr_t
*/
#define BOUNDARY_SEG_OFFSET offsetof(imgHdr_t, fixedHdr.segTypeBd)
/*!
* Offset in bytes of the length field into the structure @ref boundarySeg_t
*/
#define SEG_LEN_OFFSET 4
/** @} End OAD_OFFSETS */
/*!
* Offset in bytes of the signerInfo field into the structure @ref securityInfoSeg_t
*/
#define SEG_SIGERINFO_OFFSET offsetof(imgHdr_t, secInfoSeg.secSignerInfo)
/*!
* Offset in bytes of the sign_r field into the structure @ref securityInfoSeg_t
*/
#define SEG_SIGNR_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r)
/*!
* Offset in bytes of the sign_r field into the structure @ref securityInfoSeg_t
*/
#define SEG_SIGNS_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_s)
/*!
* Offset in bytes of the sign_r field into the structure @ref securityInfoSeg_t
*/
#define SEC_VERIF_STAT_OFFSET offsetof(imgHdr_t, secInfoSeg.verifStat)
/*!
* Offset in bytes of the sign_r field into the structure @ref securityInfoSeg_t
*/
#define HDR_LEN_WITH_SECURITY_INFO offsetof(imgHdr_t, secInfoSeg.segTypeSecure) + sizeof(securityInfoSeg_t)
/*!
* Offset in bytes of the oldImgCrc field into the structure @ref deltaInfoSeg_t
*/
#define DELTA_OLD_IMG_CRC_OFFSET offsetof(imgHdr_t, deltaInfoSeg.oldImgCrc)
/*!
* Offset in bytes of image start address field into the structure @ref imgPayloadSeg_t
*/
#define IMG_START_ADDR_OFFSET offsetof(imgHdr_t, imgPayload.startAddr)
/** @} End OAD_OFFSETS */
/**
* @defgroup OAD_LENGTHS OAD image lengths
* @{
*/
/*!
* Length of @ref boundarySeg_t in bytes
*/
#define SEG_HDR_LEN 12
/*!
* Length of OAD image ID field, this is the length of @ref OAD_IMG_ID_VAL and
* @ref OAD_EXTFL_ID_VAL
*/
#define OAD_IMG_ID_LEN 8
/*!
* Length of software version in bytes
*/
#define OAD_SW_VER_LEN 4
/*!
* Length of @ref imgFixedHdr_t, this is the length of the core header
*/
#define OAD_IMG_HDR_LEN sizeof(imgFixedHdr_t)
/** @} End OAD_LENGTHS */
/**
* @defgroup OAD_SEG_CODES OAD segment op codes
* @{
*/
/*!
* Op code used to identify a boundary segment @ref boundarySeg_t
*/
#define IMG_BOUNDARY_SEG_ID 0x00
/*!
* Op code used to identify a contiguous image segment @ref imgPayloadSeg_t
*/
#define IMG_PAYLOAD_SEG_ID 0x01
/*!
* Op code used to identify a non-contiguous image segment.
*/
#define IMG_NONCOUNT_SEG_ID 0x02
/*!
* Op code used to identify a security segment.
*/
#define IMG_SECURITY_SEG_ID 0x03
/*!
* Op code used to identify a NV RAM segment.
*/
#define IMG_NVRAM_SEG_ID 0x04
/*!
* Op code used to identify a delta image metadata segment.
*/
#define IMG_DELTA_SEG_ID 0x05
/** @} End OAD_SEG_CODES */
#define OAD_IMG_FULL_HDR_LEN sizeof(imgHdr_t) /* The length of the OAD Header + Segments */
#define OAD_IMG_ID_LEN 8 /* OAD image identification bytes length */
#define OAD_SW_VER_LEN 4 /* OAD software version length in bytes */
#ifndef STACK_LIBRARY
#define BOUNDARY_SEG_LEN 0x18 //!< Length of the boundary segment */
#endif
#define SECURITY_SEG_LEN 0x55 //!< Length of the security segment */
#define DELTA_SEG_LEN 0x14 //!< Length of the delta segment */
#define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET /* Image copy status */
#define SEG_LEN_OFFSET 4 /* Offset from seg header to seg len */
#define SIG_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r) /* Offset from the start of security seg to sig */
#define ECDSA_KEY_LEN 32
#define ECDSA_SHA_TEMPWORKZONE_LEN ECDSA_KEY_LEN*6 /* space for six buffers finalHash, reverseHash, pubkeyX, pubKeyY, sign1, sign2 */
/*!
* Version of BIM this image is intended to work with
*
* \warning This is not intended to be changed
*/
#define BIM_VER 0x3
/*!
* Version of metadata that defined this image header
*
* \warning This is not intended to be changed
*/
#define META_VER 0x1
/*!
* Version of metadata that defined this image header
*
* \warning This is not intended to be changed
*/
#define SECURITY_VER 0x1
/*!
* Version of Turbo OAD header used for creating the delta image
*/
#define TOAD_META_VER 0x01
/*!
* Version of Turbo OAD used for creating the delta image
*/
#define TOAD_VER 0x01
/*!
* Default state of unprogrammed flash in an image header field
*/
#define DEFAULT_STATE 0xFF
/*!
* Flag for crcStat indicating the CRC of the image is
* valid
*/
#define CRC_VALID 0xFE
/*!
* Flag for crcStat indicating the CRC of the image is
* invalid
*/
#define CRC_INVALID 0xFC
/*!
* FlagimgCpStat indicating the image should be copied
*/
#define NEED_COPY 0xFE
/*!
* FlagimgCpStat indicating the image is already copied
*/
#define COPY_DONE 0xFC
/*!
* Flagimg verification status indicating the successful sign verification
*/
#define VERIFY_PASS 0xFE
/*!
* Flagimg verification status indicating the failed sign verification
*/
#define VERIFY_FAIL 0xFC
/*!
* Length of image external flash image header
*/
#define EFL_MATADATA_HDR_LEN OAD_IMG_HDR_LEN + 8
/*!
* An invalid address as shown by unprogrammed flash
*/
#define INVALID_ADDR 0xFFFFFFFF
/*!
* An invalid length as shown by unprogrammed flash.
*/
#define INVALID_LEN INVALID_ADDR
/*!
* An invalid address as shown by unprogrammed flash.
*/
#define DEFAULT_CRC 0xFFFFFFFF
/*!
* Size of Signer Info
*/
#define SIGNER_INFO_SIZE 8
/*!
* Size of Signature
*/
#define SIGNATURE_SIZE 64
/*******************************************************************************
* Typedefs
*/
/// @cond NODOC
#if defined (__IAR_SYSTEMS_ICC__)
#define TYPEDEF_STRUCT_PACKED __packed typedef struct
#elif defined __TI_COMPILER_VERSION || defined __TI_COMPILER_VERSION__
#define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((packed))
#elif defined (__GNUC__)
#define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((__packed__))
#endif
/// @endcond // NODOC
/*!
* Structure to hold the Signer Info and the Signature
*/
PACKED_TYPEDEF_STRUCT
{
uint8_t signerInfo[SIGNER_INFO_SIZE];
uint8_t signature[SIGNATURE_SIZE];
}signPld_ECDSA_P256_t;
/*!
* OAD Core image header structure definition
* \note This header is required to be part of all OAD images
*/
TYPEDEF_STRUCT_PACKED
{
uint8_t imgID[8]; //!< User-defined Image Identification bytes
uint32_t crc32; //!< Image's 32-bit CRC value
uint8_t bimVer; //!< BIM version
uint8_t metaVer; //!< Metadata version
uint16_t techType; //!< Wireless protocol type BLE/TI-MAC/ZIGBEE etc.
uint8_t imgCpStat; //!< Image copy status
uint8_t crcStat; //!< CRC status
uint8_t imgType; //!< Image Type
uint8_t imgNo; //!< Image number of 'image type'
uint32_t imgVld; //!< This field is RFU
uint32_t len; //!< Image length in bytes.
uint32_t prgEntry; //!< Program entry address
uint8_t softVer[4]; //!< Software version of the image
uint32_t imgEndAddr; //!< Address of the last byte of a contiguous image
uint16_t hdrLen; //!< Total length of the image header
uint16_t rfu; //!< Reserved bytes
}imgFixedHdr_t;
/*!
* OAD continuous image payload segment
*
* This segment is used to describe a contiguous region of an image
* The code data in this blob will be flashed to sequential addresses
*/
TYPEDEF_STRUCT_PACKED
{
uint8_t segTypeImg; //!< Segment type - for Contiguous image payload
uint16_t wirelessTech; //!< Wireless technology type
uint8_t rfu; //!< Reserved byte
uint32_t imgSegLen; //!< Payload segment length
uint32_t startAddr; //!< Start address of image on internal flash
}imgPayloadSeg_t;
/*!
* OAD boundary segment
*
* This segment is used to describe the RAM and Flash boundaries in a split
* image system.
*
* \note This segment is optional and not required if app and stack are linked
* together as one image.
*/
TYPEDEF_STRUCT_PACKED
{
uint8_t segTypeBd; //!< Segment type - for boundary segment
uint16_t wirelessTech; //!< Wireless technology type
uint8_t rfu; //!< Reserved byte
uint32_t boundarySegLen; //!< Boundary segment length
uint32_t stackStartAddr; //!< Start address of stack image on internal flash
uint32_t stackEntryAddr; //!< Stack start address
uint32_t ram0StartAddr; //!< RAM entry start address
uint32_t ram0EndAddr; //!< RAM entry end address
}boundarySeg_t;
/*! ECC signature pair */
typedef struct {
uint8_t sign_r[32];
uint8_t sign_s[32];
} eccSignature_t;
/*!
* OAD continuous image payload segment
*
* This segment is used to describe a contiguous region of an image
* The code data in this blob will be flashed to sequential addresses
*/
TYPEDEF_STRUCT_PACKED
{
uint8_t segTypeSecure; //!< Segment type - for Secuirty info payload
uint16_t wirelessTech; //!< Wireless technology type
uint8_t verifStat; //!< Verification status
uint32_t secSegLen; //!< Payload segment length
uint8_t secVer; //!< Security version */
uint32_t secTimestamp; //!< Security timestamp */
uint8_t secSignerInfo[8]; //!< Security signer info */
eccSignature_t eccSign; //!< Security signature */
}securityInfoSeg_t;
/*!
* Turbo OAD information segment
*
* This segment is used to contain required metadata for the process
* of reconstructing the application image from the delta image
*/
TYPEDEF_STRUCT_PACKED
{
uint8_t segTypeImg; //!< Segment type - for Contiguous image payload
uint16_t wirelessTech; //!< Wireless technology type
uint8_t rfu; //!< Reserved byte
uint32_t len; //!< Info segment length
uint8_t isDeltaImg; //!< True if the binary contains a delta payload
uint8_t toadMetaVer; //!< Turbo OAD header version */
uint8_t toadVer; //!< Turbo OAD version */
uint8_t memoryCfg; //!< Flash configuration used */
uint32_t oldImgCrc; //!< Crc of the current application image
uint32_t newImgLen; //!< Length of the new application image in bytes
}deltaInfoSeg_t;
/*!
* OAD Image Header
*
* This structure represents the complete header to be prepended to an OAD image
*
* It is an amalgamation of the structures defined above, and must contain a
* core header
*/
TYPEDEF_STRUCT_PACKED
{
imgFixedHdr_t fixedHdr; //!< Required core image header
#if (defined(SECURITY))
securityInfoSeg_t secInfoSeg; //!< Security information segment
#endif
#if (defined(FEATURE_TOAD))
deltaInfoSeg_t deltaInfoSeg; //!< Turbo OAD information segment
#endif
#if (!defined(STACK_LIBRARY) && (defined(SPLIT_APP_STACK_IMAGE)))
boundarySeg_t boundarySeg; //!< Optional boundary segment
#endif
imgPayloadSeg_t imgPayload; //!< Required contiguous image segment
} imgHdr_t;
TYPEDEF_STRUCT_PACKED
{
uint32_t *eccWorkzone; //!< Should be of length ECCROMCC26XX_NIST_P256_WORKZONE_SIGN_VERIFY_LEN_IN_BYTES*sizeof(uint32_t) bytes
uint8_t *SHAWorkzone; //!< SHA workzone buffer should be of size(SHA256_memory_t) bytes
uint8_t *tempWorkzone; //!< Should be size 6*ECDSA_KEY_LEN bytes
uint8_t *SHADataBuf; //!< this buff is used for reading data for calculating SHA2 hash, length depends on available RAM of calling application */
uint8_t SHADataBufLen; //!< length of allocate SHA data buffer
} ecdsaSigVerifyBuf_t;
/** @} End OAD_IMAGE_HEADER */
/*******************************************************************************
* Typedefs
*/
/* Function typdef for bim_payloadVerify() fxn defined in bim_main.c */
typedef uint8_t (*bimSignFnPtr_t)(uint8_t, uint32_t, uint32_t, uint8_t *,
uint8_t *, ecdsaSigVerifyBuf_t *);
#ifdef __cplusplus
}
#endif
#endif /* OAD_IMAGE_HEADER_H */