TI BLE5-Stack API Documentation  2.01.02.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 
270 #if defined(DeviceFamily_CC26X2) || defined (DeviceFamily_CC26X2_V2)
271  #define OAD_IMG_ID_VAL {'C', 'C', '2', '6', 'x', '2', 'R', '1'}
272 #elif defined (DeviceFamily_CC13X2) || \
273  defined (DeviceFamily_CC13X2_V1) || \
274  defined (DeviceFamily_CC13X2_V2)
275  #define OAD_IMG_ID_VAL {'C', 'C', '1', '3', 'x', '2', 'R', '1'}
276 #elif defined (DeviceFamily_CC26X0R2)
277  #define OAD_IMG_ID_VAL {'O', 'A', 'D', ' ', 'I', 'M', 'G', ' '}
278 #elif defined (DOXYGEN)
279 
289  #define OAD_IMG_ID_VAL
290 #else
291  #error "Unknown Device Family"
292 #endif //DeviceFamily_CC26X2
293 
302 #define OAD_EXTFL_ID_VAL {'O', 'A', 'D', ' ', 'N', 'V', 'M', '1'}
303 
304 
313 #define CRC_OFFSET offsetof(imgHdr_t, fixedHdr.crc32)
314 
318 #define BIM_VER_OFFSET offsetof(imgHdr_t, fixedHdr.bimVer)
319 
324 #define IMG_DATA_OFFSET BIM_VER_OFFSET
325 
329 #define IMG_INFO_OFFSET offsetof(imgHdr_t, fixedHdr.imgCpStat)
330 
334 #define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET
335 
339 #define CRC_STAT_OFFSET offsetof(imgHdr_t, fixedHdr.crcStat)
340 
344 #define IMG_TYPE_OFFSET offsetof(imgHdr_t, fixedHdr.imgType)
345 
349 #define IMG_VALIDATION_OFFSET offsetof(imgHdr_t, fixedHdr.imgVld)
350 
354 #define BOUNDARY_SEG_OFFSET offsetof(imgHdr_t, fixedHdr.segTypeBd)
355 
359 #define SEG_LEN_OFFSET 4
360 
366 #define SEG_SIGERINFO_OFFSET offsetof(imgHdr_t, secInfoSeg.secSignerInfo)
367 
371 #define SEG_SIGNR_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r)
372 
376 #define SEG_SIGNS_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_s)
377 
381 #define SEC_VERIF_STAT_OFFSET offsetof(imgHdr_t, secInfoSeg.verifStat)
382 
386 #define HDR_LEN_WITH_SECURITY_INFO offsetof(imgHdr_t, secInfoSeg.segTypeSecure) + sizeof(securityInfoSeg_t)
387 
391 #define IMG_START_ADDR_OFFSET offsetof(imgHdr_t, imgPayload.startAddr)
392 
403 #define SEG_HDR_LEN 12
404 
409 #define OAD_IMG_ID_LEN 8
410 
414 #define OAD_SW_VER_LEN 4
415 
419 #define OAD_IMG_HDR_LEN sizeof(imgFixedHdr_t)
420 
432 #define IMG_BOUNDARY_SEG_ID 0x00
433 
437 #define IMG_PAYLOAD_SEG_ID 0x01
438 
439 
443 #define IMG_NONCOUNT_SEG_ID 0x02
444 
448 #define IMG_SECURITY_SEG_ID 0x03
449 
453 #define OAD_IMG_FULL_HDR_LEN sizeof(imgHdr_t)
454 #define OAD_IMG_ID_LEN 8
455 #define OAD_SW_VER_LEN 4
456 
457 #ifndef STACK_LIBRARY
458  #define BOUNDARY_SEG_LEN 0x18
459 #endif
460 #define SECURITY_SEG_LEN 0x55
461 
462 #define IMG_COPY_STAT_OFFSET IMG_INFO_OFFSET /* Image copy status */
463 
464 #define SEG_LEN_OFFSET 4 /* Offset from seg header to seg len */
465 #define SIG_OFFSET offsetof(imgHdr_t, secInfoSeg.eccSign.sign_r)
466 
467 #define ECDSA_KEY_LEN 32
468 
469 #define ECDSA_SHA_TEMPWORKZONE_LEN ECDSA_KEY_LEN*6
470 
471 
476 #define BIM_VER 0x3
477 
483 #define META_VER 0x1
484 
490 #define SECURITY_VER 0x1
491 
495 #define DEFAULT_STATE 0xFF
496 
501 #define CRC_VALID 0xFE
502 
507 #define CRC_INVALID 0xFC
508 
512 #define NEED_COPY 0xFE
513 
517 #define COPY_DONE 0xFC
518 
522 #define VERIFY_PASS 0xFE
523 
527 #define VERIFY_FAIL 0xFC
528 
532 #define EFL_MATADATA_HDR_LEN OAD_IMG_HDR_LEN + 8
533 
537 #define INVALID_ADDR 0xFFFFFFFF
538 
542 #define INVALID_LEN INVALID_ADDR
543 
547 #define DEFAULT_CRC 0xFFFFFFFF
548 
549 #if defined(SECURITY)
550 
553  #define SIGNER_INFO_SIZE 8
554 
558  #define SIGNATURE_SIZE 64
559 #endif
560 
561 /*******************************************************************************
562  * Typedefs
563  */
564 
566 #if defined (__IAR_SYSTEMS_ICC__)
567  #define TYPEDEF_STRUCT_PACKED __packed typedef struct
568 #elif defined __TI_COMPILER_VERSION || defined __TI_COMPILER_VERSION__
569  #define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((packed))
570 #elif defined (__GNUC__)
571  #define TYPEDEF_STRUCT_PACKED typedef struct __attribute__((__packed__))
572 #endif
573 
575 #if defined(SECURITY)
576 
579  PACKED_TYPEDEF_STRUCT
580  {
581  uint8_t signerInfo[SIGNER_INFO_SIZE];
582  uint8_t signature[SIGNATURE_SIZE];
583  }signPld_ECDSA_P256_t;
584 #endif
585 
591 {
592  uint8_t imgID[8];
593  uint32_t crc32;
594  uint8_t bimVer;
595  uint8_t metaVer;
596  uint16_t techType;
597  uint8_t imgCpStat;
598  uint8_t crcStat;
599  uint8_t imgType;
600  uint8_t imgNo;
601  uint32_t imgVld;
602  uint32_t len;
603  uint32_t prgEntry;
604  uint8_t softVer[4];
605  uint32_t imgEndAddr;
606  uint16_t hdrLen;
607  uint16_t rfu;
608 }imgFixedHdr_t;
609 
617 {
618  uint8_t segTypeImg;
619  uint16_t wirelessTech;
620  uint8_t rfu;
621  uint32_t imgSegLen;
622  uint32_t startAddr;
623 }imgPayloadSeg_t;
624 
635 {
636  uint8_t segTypeBd;
637  uint16_t wirelessTech;
638  uint8_t rfu;
639  uint32_t boundarySegLen;
640  uint32_t stackStartAddr;
641  uint32_t stackEntryAddr;
642  uint32_t ram0StartAddr;
643  uint32_t ram0EndAddr;
644 }boundarySeg_t;
645 
646 
648 typedef struct {
649  uint8_t sign_r[32];
650  uint8_t sign_s[32];
652 
660 {
661  uint8_t segTypeSecure;
662  uint16_t wirelessTech;
663  uint8_t verifStat;
664  uint32_t secSegLen;
665  uint8_t secVer;
666  uint32_t secTimestamp;
667  uint8_t secSignerInfo[8];
669 }securityInfoSeg_t;
670 
680 {
681  imgFixedHdr_t fixedHdr;
682 #if (defined(SECURITY))
683  securityInfoSeg_t secInfoSeg;
684 #endif
685 #if (!defined(STACK_LIBRARY) && (defined(SPLIT_APP_STACK_IMAGE)))
686  boundarySeg_t boundarySeg;
687 #endif
688  imgPayloadSeg_t imgPayload;
689 } imgHdr_t;
690 
692 {
693  uint32_t *eccWorkzone;
694  uint8_t *SHAWorkzone;
695  uint8_t *tempWorkzone;
696  uint8_t *SHADataBuf;
697  uint8_t SHADataBufLen;
698 } ecdsaSigVerifyBuf_t;
699 
704 /*******************************************************************************
705  * Typedefs
706  */
707 
713 typedef uint8_t (*bimSignFnPtr_t)(uint8_t, uint32_t, uint32_t, uint8_t *,
714  uint8_t *, ecdsaSigVerifyBuf_t *);
715 
716 #ifdef __cplusplus
717 }
718 #endif
719 
720 #endif /* OAD_IMAGE_HEADER_H */
uint16_t wirelessTech
Wireless technology type.
Definition: oad_image_header.h:619
uint16_t hdrLen
Total length of the image header.
Definition: oad_image_header.h:606
uint8_t crcStat
CRC status.
Definition: oad_image_header.h:598
uint32_t secTimestamp
Security timestamp */.
Definition: oad_image_header.h:666
uint32_t ram0EndAddr
RAM entry end address.
Definition: oad_image_header.h:643
uint8_t * tempWorkzone
Should be size 6*ECDSA_KEY_LEN bytes.
Definition: oad_image_header.h:695
uint8_t metaVer
Metadata version.
Definition: oad_image_header.h:595
uint8_t imgCpStat
Image copy status.
Definition: oad_image_header.h:597
uint8_t secSignerInfo[8]
Security signer info */.
Definition: oad_image_header.h:667
uint8_t verifStat
Verification status.
Definition: oad_image_header.h:663
uint32_t startAddr
Start address of image on internal flash.
Definition: oad_image_header.h:622
uint16_t techType
Wireless protocol type BLE/TI-MAC/ZIGBEE etc.
Definition: oad_image_header.h:596
uint8_t imgType
Image Type.
Definition: oad_image_header.h:599
uint32_t imgEndAddr
Address of the last byte of a contiguous image.
Definition: oad_image_header.h:605
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:696
TYPEDEF_STRUCT_PACKED
User-defined Image Identification bytes.
Definition: oad_image_header.h:591
eccSignature_t eccSign
Security signature */.
Definition: oad_image_header.h:668
uint32_t secSegLen
Payload segment length.
Definition: oad_image_header.h:664
uint8_t softVer[4]
Software version of the image.
Definition: oad_image_header.h:604
uint32_t ram0StartAddr
RAM entry start address.
Definition: oad_image_header.h:642
uint8_t * SHAWorkzone
SHA workzone buffer should be of size(SHA256_memory_t) bytes.
Definition: oad_image_header.h:694
uint8_t bimVer
BIM version.
Definition: oad_image_header.h:594
uint32_t imgVld
Image validation bytes, used by BIM.
Definition: oad_image_header.h:601
uint8_t SHADataBufLen
length of allocate SHA data buffer
Definition: oad_image_header.h:697
uint16_t rfu
Reserved bytes.
Definition: oad_image_header.h:607
uint32_t len
Image length in bytes.
Definition: oad_image_header.h:602
uint32_t boundarySegLen
Boundary segment length.
Definition: oad_image_header.h:639
uint32_t stackStartAddr
Start address of stack image on internal flash.
Definition: oad_image_header.h:640
Definition: oad_image_header.h:648
uint32_t stackEntryAddr
Stack start address.
Definition: oad_image_header.h:641
uint32_t imgSegLen
Payload segment length.
Definition: oad_image_header.h:621
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:713
uint8_t secVer
Security version */.
Definition: oad_image_header.h:665
uint32_t crc32
Image&#39;s 32-bit CRC value.
Definition: oad_image_header.h:593
imgPayloadSeg_t imgPayload
Required contiguous image segment.
Definition: oad_image_header.h:688
uint32_t prgEntry
Program entry address.
Definition: oad_image_header.h:603
uint8_t imgNo
Image number of &#39;image type&#39;.
Definition: oad_image_header.h:600
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale