TI BLE5-Stack API Documentation  2.01.03.00
oad_image_header.h
Go to the documentation of this file.
1 /******************************************************************************
2 
3  @file oad_image_header.h
4 
5  @brief This file contains the image header definition and structures.
6 
7  Group: WCS, BTS
8  $Target Device: DEVICES $
9 
10  ******************************************************************************
11  $License: BSD3 2017 $
12  ******************************************************************************
13  $Release Name: PACKAGE NAME $
14  $Release Date: PACKAGE RELEASE DATE $
15  ******************************************************************************/
16 
92 #ifndef OAD_IMAGE_HEADER_H
93 #define OAD_IMAGE_HEADER_H
94 
95 #ifdef __cplusplus
96 extern "C"
97 {
98 #endif
99 
100 /*******************************************************************************
101  * INCLUDES
102  ******************************************************************************/
103 #include <stddef.h>
104 #include <stdint.h>
105 #if defined(SECURITY)
106  #include "hal_types.h"
107 #endif
108 
109 /*******************************************************************************
110  * CONSTANTS
111  ******************************************************************************/
112 
113 
114 #ifdef OAD_ONCHIP
115 
130  #define BIM_VAR_ADDR 0x20000400
131 
137  extern uint32_t _bim_var;
138 #endif // OAD_ONCHIP
139 
140 #define SIGN_FN_PTR 0x57fa0
141 extern uint32_t _sign_fnPtr;
142 
143 
154 #define OAD_IMG_TYPE_PERSISTENT_APP 0
155 
161 #define OAD_IMG_TYPE_APP 1
162 
168 #define OAD_IMG_TYPE_STACK 2
169 
176 #define OAD_IMG_TYPE_APP_STACK 3
177 
184 #define OAD_IMG_TYPE_NP 4
185 
192 #define OAD_IMG_TYPE_FACTORY 5
193 
200 #define OAD_IMG_TYPE_BIM 6
201 
210 #define OAD_IMG_TYPE_APPSTACKLIB 7
211 
217 #define OAD_IMG_TYPE_RSVD_BEGIN 64
218 
224 #define OAD_IMG_TYPE_RSVD_END 255
225 
236 #define OAD_WIRELESS_TECH_BLE 0xFFFE
237 
241 #define OAD_WIRELESS_TECH_TIMAC_SUBG 0xFFFD
242 
246 #define OAD_WIRELESS_TECH_TIMAC_2_4G 0xFFFB
247 
251 #define OAD_WIRELESS_TECH_ZIGBEE 0xFFF7
252 
256 #define OAD_WIRELESS_TECH_RF4CE 0xFFEF
257 
261 #define OAD_WIRELESS_TECH_THREAD 0xFFDF
262 
266 #define OAD_WIRELESS_TECH_EASYLINK 0xFFBF
267 
271 #define OAD_WIRELESS_TECH_MIOTY 0xFF7F
272 
275 #if defined(DeviceFamily_CC26X2) || defined (DeviceFamily_CC26X2_V2)
276  #define OAD_IMG_ID_VAL {'C', 'C', '2', '6', 'x', '2', 'R', '1'}
277 #elif defined (DeviceFamily_CC13X2) || \
278  defined (DeviceFamily_CC13X2_V1) || \
279  defined (DeviceFamily_CC13X2_V2)
280  #define OAD_IMG_ID_VAL {'C', 'C', '1', '3', 'x', '2', 'R', '1'}
281 #elif defined (DeviceFamily_CC26X0R2)
282  #define OAD_IMG_ID_VAL {'O', 'A', 'D', ' ', 'I', 'M', 'G', ' '}
283 #elif defined (DOXYGEN)
284 
294  #define OAD_IMG_ID_VAL
295 #else
296  #error "Unknown Device Family"
297 #endif //DeviceFamily_CC26X2
298 
307 #define OAD_EXTFL_ID_VAL {'O', 'A', 'D', ' ', 'N', 'V', 'M', '1'}
308 
309 
318 #define CRC_OFFSET offsetof(imgHdr_t, fixedHdr.crc32)
319 
323 #define BIM_VER_OFFSET offsetof(imgHdr_t, fixedHdr.bimVer)
324 
329 #define IMG_DATA_OFFSET BIM_VER_OFFSET
330 
334 #define IMG_INFO_OFFSET offsetof(imgHdr_t, fixedHdr.imgCpStat)
335 
339 #define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET
340 
344 #define CRC_STAT_OFFSET offsetof(imgHdr_t, fixedHdr.crcStat)
345 
349 #define IMG_TYPE_OFFSET offsetof(imgHdr_t, fixedHdr.imgType)
350 
354 #define IMG_VALIDATION_OFFSET offsetof(imgHdr_t, fixedHdr.imgVld)
355 
359 #define BOUNDARY_SEG_OFFSET offsetof(imgHdr_t, fixedHdr.segTypeBd)
360 
364 #define SEG_LEN_OFFSET 4
365 
371 #define SEG_SIGERINFO_OFFSET offsetof(imgHdr_t, secInfoSeg.secSignerInfo)
372 
376 #define SEG_SIGNR_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r)
377 
381 #define SEG_SIGNS_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_s)
382 
386 #define SEC_VERIF_STAT_OFFSET offsetof(imgHdr_t, secInfoSeg.verifStat)
387 
391 #define HDR_LEN_WITH_SECURITY_INFO offsetof(imgHdr_t, secInfoSeg.segTypeSecure) + sizeof(securityInfoSeg_t)
392 
396 #define IMG_START_ADDR_OFFSET offsetof(imgHdr_t, imgPayload.startAddr)
397 
408 #define SEG_HDR_LEN 12
409 
414 #define OAD_IMG_ID_LEN 8
415 
419 #define OAD_SW_VER_LEN 4
420 
424 #define OAD_IMG_HDR_LEN sizeof(imgFixedHdr_t)
425 
437 #define IMG_BOUNDARY_SEG_ID 0x00
438 
442 #define IMG_PAYLOAD_SEG_ID 0x01
443 
444 
448 #define IMG_NONCOUNT_SEG_ID 0x02
449 
453 #define IMG_SECURITY_SEG_ID 0x03
454 
458 #define OAD_IMG_FULL_HDR_LEN sizeof(imgHdr_t)
459 #define OAD_IMG_ID_LEN 8
460 #define OAD_SW_VER_LEN 4
461 
462 #ifndef STACK_LIBRARY
463  #define BOUNDARY_SEG_LEN 0x18
464 #endif
465 #define SECURITY_SEG_LEN 0x55
466 
467 #define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET /* Image copy status */
468 
469 #define SEG_LEN_OFFSET 4 /* Offset from seg header to seg len */
470 #define SIG_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r)
471 
472 #define ECDSA_KEY_LEN 32
473 
474 #define ECDSA_SHA_TEMPWORKZONE_LEN ECDSA_KEY_LEN*6
475 
476 
481 #define BIM_VER 0x3
482 
488 #define META_VER 0x1
489 
495 #define SECURITY_VER 0x1
496 
500 #define DEFAULT_STATE 0xFF
501 
506 #define CRC_VALID 0xFE
507 
512 #define CRC_INVALID 0xFC
513 
517 #define NEED_COPY 0xFE
518 
522 #define COPY_DONE 0xFC
523 
527 #define VERIFY_PASS 0xFE
528 
532 #define VERIFY_FAIL 0xFC
533 
537 #define EFL_MATADATA_HDR_LEN OAD_IMG_HDR_LEN + 8
538 
542 #define INVALID_ADDR 0xFFFFFFFF
543 
547 #define INVALID_LEN INVALID_ADDR
548 
552 #define DEFAULT_CRC 0xFFFFFFFF
553 
554 #if defined(SECURITY)
555 
558  #define SIGNER_INFO_SIZE 8
559 
563  #define SIGNATURE_SIZE 64
564 #endif
565 
566 /*******************************************************************************
567  * Typedefs
568  */
569 
571 #if defined (__IAR_SYSTEMS_ICC__)
572  #define TYPEDEF_STRUCT_PACKED __packed typedef struct
573 #elif defined __TI_COMPILER_VERSION || defined __TI_COMPILER_VERSION__
574  #define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((packed))
575 #elif defined (__GNUC__)
576  #define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((__packed__))
577 #endif
578 
580 #if defined(SECURITY)
581 
584  PACKED_TYPEDEF_STRUCT
585  {
586  uint8_t signerInfo[SIGNER_INFO_SIZE];
587  uint8_t signature[SIGNATURE_SIZE];
588  }signPld_ECDSA_P256_t;
589 #endif
590 
596 {
597  uint8_t imgID[8];
598  uint32_t crc32;
599  uint8_t bimVer;
600  uint8_t metaVer;
601  uint16_t techType;
602  uint8_t imgCpStat;
603  uint8_t crcStat;
604  uint8_t imgType;
605  uint8_t imgNo;
606  uint32_t imgVld;
607  uint32_t len;
608  uint32_t prgEntry;
609  uint8_t softVer[4];
610  uint32_t imgEndAddr;
611  uint16_t hdrLen;
612  uint16_t rfu;
613 }imgFixedHdr_t;
614 
622 {
623  uint8_t segTypeImg;
624  uint16_t wirelessTech;
625  uint8_t rfu;
626  uint32_t imgSegLen;
627  uint32_t startAddr;
628 }imgPayloadSeg_t;
629 
640 {
641  uint8_t segTypeBd;
642  uint16_t wirelessTech;
643  uint8_t rfu;
644  uint32_t boundarySegLen;
645  uint32_t stackStartAddr;
646  uint32_t stackEntryAddr;
647  uint32_t ram0StartAddr;
648  uint32_t ram0EndAddr;
649 }boundarySeg_t;
650 
651 
653 typedef struct {
654  uint8_t sign_r[32];
655  uint8_t sign_s[32];
657 
665 {
666  uint8_t segTypeSecure;
667  uint16_t wirelessTech;
668  uint8_t verifStat;
669  uint32_t secSegLen;
670  uint8_t secVer;
671  uint32_t secTimestamp;
672  uint8_t secSignerInfo[8];
674 }securityInfoSeg_t;
675 
685 {
686  imgFixedHdr_t fixedHdr;
687 #if (defined(SECURITY))
688  securityInfoSeg_t secInfoSeg;
689 #endif
690 #if (!defined(STACK_LIBRARY) && (defined(SPLIT_APP_STACK_IMAGE)))
691  boundarySeg_t boundarySeg;
692 #endif
693  imgPayloadSeg_t imgPayload;
694 } imgHdr_t;
695 
697 {
698  uint32_t *eccWorkzone;
699  uint8_t *SHAWorkzone;
700  uint8_t *tempWorkzone;
701  uint8_t *SHADataBuf;
702  uint8_t SHADataBufLen;
703 } ecdsaSigVerifyBuf_t;
704 
709 /*******************************************************************************
710  * Typedefs
711  */
712 
718 typedef uint8_t (*bimSignFnPtr_t)(uint8_t, uint32_t, uint32_t, uint8_t *,
719  uint8_t *, ecdsaSigVerifyBuf_t *);
720 
721 #ifdef __cplusplus
722 }
723 #endif
724 
725 #endif /* OAD_IMAGE_HEADER_H */
uint16_t wirelessTech
Wireless technology type.
Definition: oad_image_header.h:624
uint16_t hdrLen
Total length of the image header.
Definition: oad_image_header.h:611
uint8_t crcStat
CRC status.
Definition: oad_image_header.h:603
uint32_t secTimestamp
Security timestamp */.
Definition: oad_image_header.h:671
uint32_t ram0EndAddr
RAM entry end address.
Definition: oad_image_header.h:648
uint8_t * tempWorkzone
Should be size 6*ECDSA_KEY_LEN bytes.
Definition: oad_image_header.h:700
uint8_t metaVer
Metadata version.
Definition: oad_image_header.h:600
uint8_t imgCpStat
Image copy status.
Definition: oad_image_header.h:602
uint8_t secSignerInfo[8]
Security signer info */.
Definition: oad_image_header.h:672
uint8_t verifStat
Verification status.
Definition: oad_image_header.h:668
uint32_t startAddr
Start address of image on internal flash.
Definition: oad_image_header.h:627
uint16_t techType
Wireless protocol type BLE/TI-MAC/ZIGBEE etc.
Definition: oad_image_header.h:601
uint8_t imgType
Image Type.
Definition: oad_image_header.h:604
uint32_t imgEndAddr
Address of the last byte of a contiguous image.
Definition: oad_image_header.h:610
uint8_t * SHADataBuf
this buff is used for reading data for calculating SHA2 hash, length depends on available RAM of call...
Definition: oad_image_header.h:701
TYPEDEF_STRUCT_PACKED
User-defined Image Identification bytes.
Definition: oad_image_header.h:596
eccSignature_t eccSign
Security signature */.
Definition: oad_image_header.h:673
uint32_t secSegLen
Payload segment length.
Definition: oad_image_header.h:669
uint8_t softVer[4]
Software version of the image.
Definition: oad_image_header.h:609
uint32_t ram0StartAddr
RAM entry start address.
Definition: oad_image_header.h:647
uint8_t * SHAWorkzone
SHA workzone buffer should be of size(SHA256_memory_t) bytes.
Definition: oad_image_header.h:699
uint8_t bimVer
BIM version.
Definition: oad_image_header.h:599
uint32_t imgVld
Image validation bytes, used by BIM.
Definition: oad_image_header.h:606
uint8_t SHADataBufLen
length of allocate SHA data buffer
Definition: oad_image_header.h:702
uint16_t rfu
Reserved bytes.
Definition: oad_image_header.h:612
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:607
uint32_t boundarySegLen
Boundary segment length.
Definition: oad_image_header.h:644
uint32_t stackStartAddr
Start address of stack image on internal flash.
Definition: oad_image_header.h:645
Definition: oad_image_header.h:653
uint32_t stackEntryAddr
Stack start address.
Definition: oad_image_header.h:646
uint32_t imgSegLen
Payload segment length.
Definition: oad_image_header.h:626
uint8_t(* bimSignFnPtr_t)(uint8_t, uint32_t, uint32_t, uint8_t *, uint8_t *, ecdsaSigVerifyBuf_t *)
OAD Image Pointer to BIM Function.
Definition: oad_image_header.h:718
uint8_t secVer
Security version */.
Definition: oad_image_header.h:670
uint32_t crc32
Image&#39;s 32-bit CRC value.
Definition: oad_image_header.h:598
imgPayloadSeg_t imgPayload
Required contiguous image segment.
Definition: oad_image_header.h:693
uint32_t prgEntry
Program entry address.
Definition: oad_image_header.h:608
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad_image_header.h:605
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale