CC23x0R5DriverLibrary
hw_ccfg.h
Go to the documentation of this file.
1 /******************************************************************************
2 * Copyright (c) 2021-2023 Texas Instruments Incorporated. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * 1) Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 *
10 * 2) Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * 3) Neither the name of the copyright holder nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 ******************************************************************************
30 * \file hw_ccfg.h
31 *
32 * \brief Customer Configuration (CCFG) header file.
33 ******************************************************************************/
34 
35 #ifndef __HW_CCFG_H__
36 #define __HW_CCFG_H__
37 
38 #include <stdint.h>
39 #include "hw_device.h"
40 
45 typedef const struct {
46 
47  // Bootloader/application configuration
48  struct { // [0]: length 16B
49  // Pointer to user bootloader vector table
50  void* pBldrVtor;
51  #define CCFG_BC_PBLDR_USE_FCFG ((void*)0xFFFFFFF0)
52  #define XCFG_BC_PBLDR_FORBID ((void*)0xFFFFFFFC)
53  #define XCFG_BC_PBLDR_UNDEF ((void*)0xFFFFFFFF)
54  #define CCFG_BC_PBLDR_VALID(x) ((x) < CCFG_BC_PBLDR_USE_FCFG)
55  // Parameter passed to bootloader
56  union {
57  uint32_t val32;
58  #define CCFG_BC_BLDRCFG_UNDEF 0xFFFFFFFF
59  // Serial ROM bootloader parameters (also used in FCFG.h)
60  struct serialRomBldrParam_struct {
61  uint32_t bldrEnabled : 1;
62  #define XCFG_BC_BLDR_DIS 0
63  #define XCFG_BC_BLDR_EN 1
64  uint32_t pinTriggerEnabled : 1;
65  #define XCFG_BC_PINTRIG_DIS 0
66  #define XCFG_BC_PINTRIG_EN 1
67  uint32_t pinTriggerLevel : 1;
68  #define XCFG_BC_PINTRIG_LEVEL_LO 0
69  #define XCFG_BC_PINTRIG_LEVEL_HI 1
70  uint32_t res0 : 13;
71  uint32_t pinTriggerDio : 6;
72  uint32_t res1 : 2;
73  uint32_t serialIoCfgIndex : 3;
74  #define XCFG_BC_IOCFGIND_DEFAULT 0
75  uint32_t res2 : 5;
76  } serialRomBldrParamStruct;
77  } bldrParam;
78  // Pointer to application VTOR table
79  void* pAppVtor;
80  #define CCFG_BC_PAPP_NONE ((void*)0xFFFFFFFF)
81  uint32_t crc32;
82  } bootCfg;
83 
84 
85  // Paperspin options [16]: length 8 B
86  // Defines peripheral/feature availability and accessible memory. Allows
87  // customer to target a paperspin device features on a superset device
88  // AND-combined with FCFG.hwOpts.
89  uint32_t hwOpts[2];
90 
91 
92  // Device permissions [24]: length 4 B
93  // This is maximally-restrictive combined with similar field in FCFG
94  struct {
95  #define CCFG_PERMISSION_ALLOW 0xA
96  #define CCFG_PERMISSION_FORBID 0x0
97  // (all other value other than ALLOW are interpreted as FORBID)
98  uint32_t allowReturnToFactory : 4;
99  uint32_t allowFakeStby : 4;
100  uint32_t allowToolsClientMode : 4;
101  uint32_t allowChipErase : 4;
102  uint32_t allowFlashProgram : 4;
103  uint32_t allowFlashVerify : 4;
104  uint32_t allowEnergyTrace : 4;
105  uint32_t allowDebugPort : 4;
106  } permissions;
107 
108 
109  // Miscellaneous fields [28]: length 4B
110  struct {
111  // SACI timeout is infinite when 0, else (2^saciTimeoutExp)*64 ms
112  // Fcfg timeout applied instead if CCfg.saciTimeoutOverride==0
113  uint32_t saciTimeoutExp : 3;
114  #define XCFG_MISC_SACITOEXP_8SEC 7
115  #define XCFG_MISC_SACITOEXP_1SEC 4
116  #define XCFG_MISC_SACITOEXP_INFINITE 0
117  uint32_t saciTimeoutOverride : 1;
118  uint32_t res0 : 28;
119  } misc;
120 
121 
122  // Flash protection [32]: length 32 B
123  // This is maximally-restrictive combined with similar field in FCFG
124  struct {
125  struct {
126  // Sticky-0 bits written to VIMS.WEPRA (sectors 0-31, 1/bit)
127  uint32_t mainSectors0_31;
128  union {
129  // Sticky-0 bits written to VIMS.WEPRB(0) (sectors 32-255, 8/bit)
131  // Dummy symbol to allow code to remain the same across devices
133  };
134  // Sticky-0 bit written to VIMS.WEPRAUX
135  union {
136  uint32_t auxSectors;
137  struct {
138  uint32_t ccfgSector : 1;
139  uint32_t fcfgSector : 1;
140  uint32_t engrSector : 1;
141  uint32_t res1 : 29;
142  };
143  };
144  } writeEraseProt;
145  uint32_t res;
146  struct {
147  // Set bits (sectors 0-31, 1/bit) define what a chip erase command can optionally retain
148  uint32_t mainSectors0_31;
149  union {
150  // Set bits (sectors 32-255, 8/bit) define what a chip erase command can optionally retain
151  uint32_t mainSectors32_255;
152  // Dummy field to allow code to remain same across devices
153  uint32_t mainSectors256_511;
154  };
155  } chipEraseRetain;
156  // Reserved for future flash increases
157  uint32_t res0[2];
158  } flashProt;
159 
160 
161  // Optional HW initialization copy-list [64]: length x B
162  // Copy list applied before user application is entered. May be used by customer/SYSCFG to
163  // initialize hardware right before application is entered.
164  // Also used to pad out CCFG to correct size
165  uint32_t hwInitCopyList[(FLASH_1T_SECTOR_SIZE / 4) - 61];
166  // Simple macros to assist in initializing copy lists
167  // NOTE: Addresses to CPYLIST_CPY must fulfill ((a&0x0FF00003)==0).
168  // The memory map ensures this for SRAM and peripherals.
169  // There is no check as ELF only supports {symbol + const offset}
170  #define CPYLST_EOL 0
171  #define CPYLST_NOP 0x10000000
172  #define CPYLST_WAIT(x) ( 0x10000000 + (((x)<<2)&0x000FFFFC) )
173  #define CPYLST_CPY(a, n) ( ((uint32_t)(a)) + (((n)<<20)&0x0FF00000) )
174  #define CPYLST_CPYFULLADDR(a) (((uint32_t)(a)) + 1)
175  #define CPYLST_JUMP(a) (((uint32_t)(a)) + 2)
176  #define CPYLST_CALL(a) (((uint32_t)(a)) + 3)
177 
178 
179  // CRC across hwOpts through hwInitCopyList
180  // [End-180]: length 4B
181  uint32_t crc32;
182 
183 
184  // User record (programmable also through separate SACI command), no dependencies in boot code
185  // User record size is fixed at 128 B. Last word assumed to be CRC over first 124 B (optional)
186  #define CCFG_USER_RECORD_SIZE 128
187  union { // [End-176]: length 128B
188  // Generic 32b record layout
189  uint32_t val32[(CCFG_USER_RECORD_SIZE/4)];
190  // Generic 8b record layout
191  uint8_t val8[CCFG_USER_RECORD_SIZE];
192  // CRC field in last word
193  struct {
194  uint32_t res0[CCFG_USER_RECORD_SIZE/4-1];
195  uint32_t crc32;
196  };
197  } userRecord;
198 
199  // Debug configuration and password
200  struct { // [End-48]: length 48B
201  // Debug authorization requirements
202  uint8_t authorization;
203  #define CCFG_DBGAUTH_REQPWD 0xA5
204  #define CCFG_DBGAUTH_DBGOPEN 0x5A
205  #define CCFG_DBGAUTH_DBGFORBID 0x00
206  // (and any other value)
207  // Allow debugging of bootloader
208  uint8_t allowBldr;
209  #define CCFG_DBGBLDR_ALLOW 0xA5
210  #define CCFG_DBGBLDR_FORBID 0x00
211  // (and any other value)
212  uint8_t res0[2];
213  // 64b password ID value (may be used to calculate or look up debug password)
214  uint8_t pwdId[8];
215  // SHA256 hash of debug password
216  uint8_t pwdHash[32];
217  // CRC32 of previous fields in debugCfg
218  uint32_t crc32;
219  } debugCfg;
220 
221 } ccfg_t;
222 
223 
225 typedef struct serialRomBldrParam_struct serialRomBldrParam_t;
226 
227 
234 extern const ccfg_t ccfg;
235 
236 #endif // __HW_CCFG_H__
void * pBldrVtor
Definition: hw_ccfg.h:50
uint32_t mainSectors0_31
Definition: hw_ccfg.h:127
struct serialRomBldrParam_struct serialRomBldrParam_t
Definition: hw_ccfg.h:225
void * pAppVtor
Definition: hw_ccfg.h:79
uint32_t mainSectors256_511
Definition: hw_ccfg.h:132
uint32_t res
Definition: hw_ccfg.h:145
uint32_t crc32
Definition: hw_ccfg.h:81
#define FLASH_1T_SECTOR_SIZE
Size of a 1T flash sector, in number of bytes.
Definition: hw_device.h:48
uint32_t val32
Definition: hw_ccfg.h:57
uint8_t authorization
Definition: hw_ccfg.h:202
const ccfg_t ccfg
Extern declaration of the CCFG struct. This extern declaration can be used to access CCFG fields from...
Definition: hw_ccfg.h:45
#define CCFG_USER_RECORD_SIZE
Definition: hw_ccfg.h:186
uint8_t allowBldr
Definition: hw_ccfg.h:208
uint32_t mainSectors32_255
Definition: hw_ccfg.h:130
uint32_t auxSectors
Definition: hw_ccfg.h:136