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 #ifndef __HW_DEVICE_H__
31 #define __HW_DEVICE_H__
32 
33 #include "hw_memmap.h"
34 #include "hw_platform.h"
35 
36 //*****************************************************************************
37 //
38 // Address, offset and size definitions
39 //
40 //*****************************************************************************
41 
42 // --- ROM definitions ---
43 /// Size of the call stack used in ROM, in number of bytes
44 #define BOOT_CSTACK_SIZE                        (1024-sizeof(fcfg_appTrims_t))
45 
46 // --- FLASH definitions ---
47 /// Size of a 1T flash sector, in number of bytes
48 #define FLASH_1T_SECTOR_SIZE                    2048
49 /// Flash word width in number of bits
50 #define FLASH_DATAWIDTH_BITS                    128
51 /// Size of a 2T flash sector, in number of bytes
52 #define FLASH_2T_SECTOR_SIZE                    (FLASH_1T_SECTOR_SIZE/2)
53 /// Size of a MAIN flash sector, in number of bytes
54 #define FLASH_MAIN_SECTOR_SIZE                  FLASH_1T_SECTOR_SIZE
55 
56 // --- Factory Configuration (FCFG) definitions ---
57 /// Size of generalTrims section in FCFG, in number of 32-bit words
58 #define FCFG_GENERALTRIMS_SIZE                  ((FLASH_2T_SECTOR_SIZE / 4) - 104)
59 
60 // --- Customer Configuration (CCFG) definitions ---
61 /*! Macro for default CCFG configuration. All fields can be overwritten by
62  *  setting the field to another value further down in the struct definition
63  *  within a C file.
64  */
65 #define CCFG_DEFAULT_VALUES \
66     .bootCfg = { \
67         .pBldrVtor = XCFG_BC_PBLDR_UNDEF, \
68         .bldrParam = { 0x00000000 }, \
69         .pAppVtor = CCFG_BC_PAPP_NONE, \
70         .crc32 = 0x0BAD0BAD \
71     }, \
72     .hwOpts[0] = 0xFFFFFFFF, \
73     .hwOpts[1] = 0xFFFFFFFF, \
74     .permissions = { \
75         .allowReturnToFactory   = CCFG_PERMISSION_ALLOW, \
76         .allowFakeStby          = CCFG_PERMISSION_ALLOW, \
77         .allowToolsClientMode   = CCFG_PERMISSION_ALLOW, \
78         .allowChipErase         = CCFG_PERMISSION_ALLOW, \
79         .allowFlashProgram      = CCFG_PERMISSION_ALLOW, \
80         .allowFlashVerify       = CCFG_PERMISSION_ALLOW, \
81         .allowEnergyTrace       = CCFG_PERMISSION_ALLOW, \
82         .allowDebugPort         = CCFG_PERMISSION_ALLOW, \
83     }, \
84     .misc = { \
85         .saciTimeoutOverride = 0 \
86     }, \
87     .flashProt = { \
88         .writeEraseProt = { \
89             .mainSectors0_31   = 0xFFFFFFFF, \
90             .mainSectors32_255 = 0xFFFFFFFF, \
91             .auxSectors        = 0xFFFFFFFF, \
92         }, \
93         .res = 0xFFFFFFFF, \
94         .chipEraseRetain = { \
95             .mainSectors0_31   = 0, \
96             .mainSectors32_255 = 0, \
97         } \
98     }, \
99     .hwInitCopyList = { CPYLST_EOL }, \
100     .crc32 = 0x0BAD0BAD, \
101     .userRecord.crc32 = 0x0BAD0BAD, \
102     .debugCfg = { \
103         .authorization = CCFG_DBGAUTH_DBGOPEN, \
104         .allowBldr = CCFG_DBGBLDR_ALLOW, \
105         .pwdId = {1, 1, 2, 3, 5, 8, 13, 21 }, \
106         .pwdHash = { /* SHA256 of "Open Sesame!" */ \
107             0x6D, 0xD7, 0xE4, 0x36, 0xEB, 0xF4, 0x31, 0xDF, \
108             0x95, 0xAE, 0x15, 0xEE, 0x03, 0xBA, 0x8E, 0xE4, \
109             0xC4, 0xC6, 0x3F, 0xD8, 0x45, 0x3F, 0x67, 0x5E, \
110             0x74, 0xD7, 0xC2, 0x01, 0x2C, 0x90, 0x58, 0xE5, \
111         }, \
112         .crc32 = 0x0BAD0BAD, \
113     }
114 #endif // __HW_DEVICE_H__
115