HPM SDK
HPMicro Software Development Kit
hpm_bootheader.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_BOOT_HEADER_H
9 #define HPM_BOOT_HEADER_H
10 
11 #include "hpm_common.h"
12 
13 #define HPM_BOOTHEADER_TAG (0xBFU)
14 #define HPM_BOOTHEADER_MAX_FW_COUNT (2U)
15 
16 #ifndef HPM_BOOT_FW_COUNT
17 #define HPM_BOOT_FW_COUNT 1
18 #endif
19 
20 #if HPM_BOOT_FW_COUNT < 1
21 #error "HPM_BOOT_FW_COUNT can't be less than 1"
22 #endif
23 
24 typedef struct {
25  uint32_t offset; /* 0x0: offset to boot_header start */
26  uint32_t size; /* 0x4: size in bytes */
27  uint32_t flags; /* 0x8: [3:0] fw type: */
28  /* 0 - executable */
29  /* 1 - cmd container */
30  /* [11:8] - hash type */
31  /* 0 - none */
32  /* 1 - sha256 */
33  /* 2 - sm3 */
34  uint32_t reserved0; /* 0xC */
35  uint32_t load_addr; /* 0x10: load address */
36  uint32_t reserved1; /* 0x14 */
37  uint32_t entry_point; /* 0x18: application entry */
38  uint32_t reserved2; /* 0x1C */
39  uint8_t hash[64]; /* 0x20: hash value */
40  uint8_t iv[32]; /* 0x60: initial vector */
42 
43 typedef struct {
44  uint8_t tag; /* 0x0: must be '0xbf' */
45  uint8_t version; /* 0x1: header version */
46  uint16_t length; /* 0x2: header length, max 8KB */
47  uint32_t flags; /* 0x4: [3:0] SRK set */
48  /* [7:4] SRK index */
49  /* [15:8] SRK_REVOKE_MASK */
50  /* [19:16] Signature Type */
51  /* 1: ECDSA */
52  /* 2: SM2 */
53  uint16_t sw_version; /* 0x8: software version */
54  uint8_t fuse_version; /* 0xA: fuse version */
55  uint8_t fw_count; /* 0xB: number of fw */
56  uint16_t dc_block_offset; /* 0xC: device config block offset*/
57  uint16_t sig_block_offset; /* 0xE: signature block offset */
58  /*
59  * fw_info_table_t fw_info[HPM_BOOT_FW_COUNT]; [> 0x10: fw table <]
60  * uint32_t dc_info[]; [> <]
61  */
63 
64 #endif /* HPM_BOOT_HEADER_H */
Definition: hpm_bootheader.h:43
uint8_t fw_count
Definition: hpm_bootheader.h:55
uint32_t flags
Definition: hpm_bootheader.h:47
uint8_t tag
Definition: hpm_bootheader.h:44
uint16_t sw_version
Definition: hpm_bootheader.h:53
uint8_t fuse_version
Definition: hpm_bootheader.h:54
uint8_t version
Definition: hpm_bootheader.h:45
uint16_t dc_block_offset
Definition: hpm_bootheader.h:56
uint16_t sig_block_offset
Definition: hpm_bootheader.h:57
uint16_t length
Definition: hpm_bootheader.h:46
Definition: hpm_bootheader.h:24
uint32_t load_addr
Definition: hpm_bootheader.h:35
uint32_t reserved0
Definition: hpm_bootheader.h:34
uint32_t size
Definition: hpm_bootheader.h:26
uint32_t reserved2
Definition: hpm_bootheader.h:38
uint32_t entry_point
Definition: hpm_bootheader.h:37
uint32_t reserved1
Definition: hpm_bootheader.h:36
uint32_t flags
Definition: hpm_bootheader.h:27
uint32_t offset
Definition: hpm_bootheader.h:25