Infineon MOTIX™ MCU TLE988x/9x Device Family SDK
bootrom.h
Go to the documentation of this file.
1 /*
2  ***********************************************************************************************************************
3  *
4  * Copyright (c) Infineon Technologies AG
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
8  * following conditions are met:
9  *
10  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
11  * disclaimer.
12  *
13  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
14  * following disclaimer in the documentation and/or other materials provided with the distribution.
15  *
16  * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  **********************************************************************************************************************/
43 /*******************************************************************************
44 ** Author(s) Identity **
45 ********************************************************************************
46 ** Initials Name **
47 ** ---------------------------------------------------------------------------**
48 ** DM Daniel Mysliwitz **
49 ** BG Blandine Guillot **
50 ** JO Julia Ott **
51 ** PS Patrik Schwarz **
52 *******************************************************************************/
53 
54 /*******************************************************************************
55 ** Revision Control History **
56 ********************************************************************************
57 ** V0.1.0: 2020-08-14, JO: Initial version **
58 ** V0.1.1: 2020-11-12, JO: EP-590: Added end of group for doxygen **
59 ** V0.1.2: 2020-11-27, BG: EP-610: Corrected MISRA 2012 errors **
60 ** V0.1.3: 2020-11-27, JO: EP-624: Removed internal APIs **
61 ** V0.1.4: 2021-02-10, JO: EP-696: Changed from anonymous to named typedefs **
62 ** to prevent MISRA warning **
63 ** V0.2.0: 2021-04-23, JO: EP-696: Added artifacts for AB design step **
64 ** V0.2.1: 2021-07-12, BG: EP-829: Added API documentation **
65 ** V0.2.2: 2021-07-30, BG: EP-877: Corrected MISRA 2012 errors **
66 ** V0.2.3: 2021-11-12, JO: EP-937: Updated copyright and branding **
67 ** V0.3.0: 2021-11-30, BG: EP-875: Added artifacts for AK design step **
68 ** Removed error codes for AA and AB design steps **
69 ** V0.3.1: 2022-06-23, JO: EP-1150: Removed ARMCC V6.18 warnings **
70 ** V0.3.2: 2023-03-23, JO: EP-1427: Corrected doxygen inconsistency **
71 ** V0.3.3: 2023-04-04, PS: EP-1141: Correct MISRA warnings **
72 *******************************************************************************/
73 
74 #ifndef _BOOTROM_H
75 #define _BOOTROM_H
76 
77 /*******************************************************************************
78 ** Includes **
79 *******************************************************************************/
80 
81 #include "types.h"
82 #include "RTE_Components.h"
83 
84 /*******************************************************************************
85 ** Entry points into the BootROM **
86 *******************************************************************************/
87 
88 #define addr_user_nvm_isr_handler (0xc1u)
89 #define addr_user_cid_get (0xc5u)
90 #define addr_user_ram_mbist (0xc9u)
91 #define addr_user_nvm_udata_temp_protect_clear (0xd1u)
92 #define addr_user_nvm_ucode_temp_protect_clear (0xd5u)
93 #define addr_user_nvm_udata_temp_protect_set (0xd9u)
94 #define addr_user_nvm_ucode_temp_protect_set (0xddu)
95 #define addr_user_nvm_temp_protect_get (0xe1u)
96 #define addr_user_nvm_ecc_addr_get (0xe5u)
97 #define addr_user_nvm_ecc_check (0xe9u)
98 #define addr_user_nvm_100tp_read (0xedu)
99 #define addr_user_nvm_100tp_write (0xf1u)
100 #define addr_user_nvm_100tp_erase (0xf5u)
101 #define addr_user_nvm_config_get (0xf9u)
102 #define addr_user_nvm_page_erase (0xfdu)
103 #define addr_user_nvm_sector_erase (0x101u)
104 #define addr_user_nvm_page_write (0x105u)
105 #define addr_user_nvm_mapram_init (0x109u)
106 #define addr_user_nvm_mapram_recover (0x10du)
107 #define addr_user_nvm_service_algorithm (0x111u)
108 #define addr_user_crypto_aes_cmac_generate_start (0x115u)
109 #define addr_user_crypto_aes_cmac_generate_update (0x119u)
110 #define addr_user_crypto_aes_cmac_generate_finish (0x11du)
111 #define addr_user_crypto_aes_cmac_verify_start (0x121u)
112 #define addr_user_crypto_aes_cmac_verify_update (0x125u)
113 #define addr_user_crypto_aes_cmac_verify_finish (0x129u)
114 #define addr_user_crypto_aes_start (0x12du)
115 #define addr_user_crypto_aes_update (0x131u)
116 #define addr_user_crypto_aes_finish (0x135u)
117 #define addr_user_crypto_key_write (0x139u)
118 #define addr_user_crypto_key_erase (0x13du)
119 #define addr_user_crypto_key_verify (0x141u)
120 #define addr_user_nvm_reg_write (0x145u)
121 #define addr_user_nvm_reg_read (0x149u)
122 #define addr_user_secure_download_start (0x14du)
123 #define addr_user_secure_download_update (0x151u)
124 #define addr_user_secure_download_finish (0x155u)
125 #define addr_user_cache_operation (0x159u)
126 #define addr_user_ubsl_size_restore (0x15du)
127 #define addr_user_nvm_perm_protect_set (0x161u)
128 #define addr_user_nvm_ubsl_temp_protect_clear (0x201u)
129 #define addr_user_nvm_ubsl_temp_protect_set (0x205u)
130 #define addr_user_secure_dualboot (0x209u)
131 
132 /*******************************************************************************
133 ** Global Constant Declarations **
134 *******************************************************************************/
135 
137 #define USER_KEY_SIZE_128 (0x10u)
138 
140 #define USER_KEY_SIZE_256 (0x20u)
141 
143 #define USER_KEY_SIZE_MAX (USER_KEY_SIZE_256)
144 
146 #define USER_KEY_PARAM_SIZE (0x40u)
147 
149 #define USER_CMAC_SIGNATURE_SIZE (0x10u)
150 
152 #define USER_KEY_WRITE_BUFFER_SIZE (0x30u)
153 
155 #define USER_KEY_MAX_ID (12u)
156 
158 #define USER_KEY_MIN_ID (1u)
159 
161 #define IFX_KEY_ID (0u)
162 
163 /*******************************************************************************
164 ** Global Type Declarations **
165 *******************************************************************************/
166 
167 typedef struct user_100tp_read_t
168 {
169  uint32_t offset;
170  uint8_t *data;
171  uint16_t nbyte;
173 
174 typedef struct user_100tp_write_t
175 {
176  uint32_t offset;
177  uint8_t *data;
178  uint8_t nbyte;
179  uint8_t counter;
181 
183 typedef struct user_key_t
184 {
186  uint16_t version;
187  uint8_t length;
188  uint8_t protection;
190 
191 typedef enum user_crypto_fid_t
192 {
198 
199 typedef struct user_crypto_inp_buf_t
200 {
201  uint8_t *buffer;
202  uint32_t length;
204 
205 typedef struct user_crypto_out_buf_t
206 {
207  uint8_t *buffer;
208  uint32_t *length;
210 
211 typedef struct user_crypto_io_buf_t
212 {
216 
217 typedef struct user_crypto_cmac_t
218 {
222 
223 typedef struct user_crypto_cbc_t
224 {
225  void *iv;
226  uint32_t iv_length;
228 
229 
231 {
233  uint16_t target_key_id;
234  uint16_t encrypt_key_id;
236 
237 
238 typedef struct user_key_write_t
239 {
243 
245 {
246  uint16_t target_key_id;
247  uint16_t version;
249 
250 
251 typedef struct user_key_erase_t
252 {
256 
257 typedef struct user_nvm_page_write_t
258 {
259  uint8_t *data;
260  uint32_t nbyte;
261  uint32_t options;
263 
264 typedef enum user_cache_op_t
265 {
273  CACHE_OP_DIS = 7
275 
277 typedef enum user_nvm_segment_t
278 {
284 
285 /*******************************************************************************
286 ** Global Macro Declarations **
287 *******************************************************************************/
288 
289 /*******************************************************************************
290 ** Global Function Declarations **
291 *******************************************************************************/
292 
303 #define user_cid_get ( (int32_t(*)(uint32_t *)) addr_user_cid_get )
304 
320 #define user_ram_mbist ( (int32_t(*)(uint32_t, uint32_t)) addr_user_ram_mbist )
321 
334 #define user_nvm_udata_temp_protect_clear ( (int32_t(*)(uint32_t)) addr_user_nvm_udata_temp_protect_clear )
335 
348 #define user_nvm_ucode_temp_protect_clear ( (int32_t(*)(uint32_t)) addr_user_nvm_ucode_temp_protect_clear )
349 
362 #define user_nvm_udata_temp_protect_set ( (int32_t(*)(uint32_t)) addr_user_nvm_udata_temp_protect_set )
363 
376 #define user_nvm_ucode_temp_protect_set ( (int32_t(*)(uint32_t)) addr_user_nvm_ucode_temp_protect_set )
377 
387 #define user_nvm_temp_protect_get ( (uint32_t(*)(user_nvm_segment_t)) addr_user_nvm_temp_protect_get )
388 
407 #define user_nvm_perm_protect_set ( (int32_t(*)(uint32_t)) addr_user_nvm_perm_protect_set )
408 
431 #define user_nvm_ecc_addr_get ( (int32_t(*)(uint32_t, uint32_t *)) addr_user_nvm_ecc_addr_get )
432 
451 #define user_nvm_ecc_check ( (int32_t(*)(uint32_t)) addr_user_nvm_ecc_check )
452 
471 #define user_nvm_100tp_read ( (int32_t(*)(uint32_t, user_100tp_read_t *)) addr_user_nvm_100tp_read )
472 
497 #define user_nvm_100tp_write ( (int32_t(*)(uint32_t, user_100tp_write_t *)) addr_user_nvm_100tp_write )
498 
517 #define user_nvm_100tp_erase ( (int32_t(*)(uint32_t)) addr_user_nvm_100tp_erase )
518 
531 #define user_nvm_config_get ( (int32_t(*)(uint32_t *, uint32_t *, uint32_t *)) addr_user_nvm_config_get )
532 
559 #define user_nvm_page_erase ( (int32_t(*)(uint32_t, uint32_t)) addr_user_nvm_page_erase )
560 
586 #define user_nvm_sector_erase ( (int32_t(*)(uint32_t, uint32_t)) addr_user_nvm_sector_erase )
587 
624 #define user_nvm_page_write ( (int32_t(*)(uint32_t, user_nvm_page_write_t *)) addr_user_nvm_page_write )
625 #define user_nvm_write user_nvm_page_write
626 
641 #define user_nvm_mapram_init ( (int32_t(*)(uint32_t)) addr_user_nvm_mapram_init )
642 
660 #define user_nvm_mapram_recover ( (int32_t(*)(uint32_t)) addr_user_nvm_mapram_recover )
661 
676 #define user_nvm_service_algorithm ( (int32_t(*)(uint32_t)) addr_user_nvm_service_algorithm )
677 
692 #define user_nvm_reg_write ( (int32_t(*)(uint32_t, uint32_t )) addr_user_nvm_reg_write )
693 
709 #define user_nvm_reg_read ( (int32_t(*)(uint32_t, uint32_t *)) addr_user_nvm_reg_read )
710 
736 #define user_secure_download_start ( (int32_t(*)(uint8_t, uint8_t, uint8_t *)) addr_user_secure_download_start )
737 
762 #define user_secure_download_update ( (int32_t(*)(uint32_t, uint8_t *)) addr_user_secure_download_update )
763 
779 #define user_secure_download_finish ( (int32_t(*)(void)) addr_user_secure_download_finish )
780 
791 #define user_cache_operation ( (int32_t(*)(user_cache_op_t, uint32_t)) addr_user_cache_operation )
792 
799 #define user_ubsl_size_restore ( (void(*)(void)) addr_user_ubsl_size_restore )
800 
818 #define user_crypto_aes_cmac_generate_start ( (int32_t(*)(uint32_t)) addr_user_crypto_aes_cmac_generate_start )
819 
839 #define user_crypto_aes_cmac_generate_update ( (int32_t(*)(user_crypto_inp_buf_t *)) addr_user_crypto_aes_cmac_generate_update)
840 
860 #define user_crypto_aes_cmac_generate_finish ( (int32_t(*)(user_crypto_io_buf_t *, bool)) addr_user_crypto_aes_cmac_generate_finish)
861 
879 #define user_crypto_aes_cmac_verify_start ( (int32_t(*)(uint32_t)) addr_user_crypto_aes_cmac_verify_start )
880 
900 #define user_crypto_aes_cmac_verify_update ( (int32_t(*)(user_crypto_inp_buf_t *)) addr_user_crypto_aes_cmac_verify_update )
901 
921 #define user_crypto_aes_cmac_verify_finish ( (int32_t(*)(user_crypto_cmac_t *)) addr_user_crypto_aes_cmac_verify_finish )
922 
943 #define user_crypto_aes_start ( (int32_t(*)(user_crypto_fid_t, uint32_t, user_crypto_cbc_t *)) addr_user_crypto_aes_start )
944 
965 #define user_crypto_aes_update ( (int32_t(*)(user_crypto_io_buf_t *)) addr_user_crypto_aes_update )
966 
986 #define user_crypto_aes_finish ( (int32_t(*)(user_crypto_io_buf_t *)) addr_user_crypto_aes_finish )
987 
1012 #define user_crypto_key_write ( (int32_t(*)(user_key_write_t *)) addr_user_crypto_key_write )
1013 
1037 #define user_crypto_key_erase ( (int32_t(*)(user_key_erase_t *)) addr_user_crypto_key_erase )
1038 
1060 #define user_crypto_key_verify ( (int32_t(*)(uint8_t, bool)) addr_user_crypto_key_verify )
1061 
1062 /* User API extension, callable from UBSL segment only */
1075 #define user_nvm_ubsl_temp_protect_clear ( (int32_t(*)(uint32_t)) addr_user_nvm_ubsl_temp_protect_clear )
1076 
1089 #define user_nvm_ubsl_temp_protect_set ( (int32_t(*)(uint32_t)) addr_user_nvm_ubsl_temp_protect_set )
1090 
1105 #define user_secure_dualboot ( (int32_t(*)(uint32_t)) addr_user_secure_dualboot )
1106 
1107 /*******************************************************************************
1108 ** Global Inline Function Definitions **
1109 *******************************************************************************/
1110 
1113 #endif /* _BOOTROM_H */
struct user_100tp_write_t user_100tp_write_t
struct user_crypto_io_buf_t user_crypto_io_buf_t
struct user_crypto_out_buf_t user_crypto_out_buf_t
user_cache_op_t
Definition: bootrom.h:265
struct user_crypto_inp_buf_t user_crypto_inp_buf_t
struct user_crypto_cmac_t user_crypto_cmac_t
#define USER_CMAC_SIGNATURE_SIZE
cmac signature size 16 bytes
Definition: bootrom.h:149
struct user_key_write_params_t user_key_write_params_t
struct user_key_t user_key_t
Key data structure aligned with CFS page (ignored reserved bytes)
#define USER_KEY_SIZE_MAX
Maximum length for a key value to read/store.
Definition: bootrom.h:143
struct user_key_write_t user_key_write_t
struct user_key_erase_t user_key_erase_t
struct user_crypto_cbc_t user_crypto_cbc_t
user_crypto_fid_t
Definition: bootrom.h:192
struct user_100tp_read_t user_100tp_read_t
struct user_nvm_page_write_t user_nvm_page_write_t
#define USER_KEY_PARAM_SIZE
encrypted key parameter size 64 bytes
Definition: bootrom.h:146
struct user_key_erase_params_t user_key_erase_params_t
user_nvm_segment_t
Definition: bootrom.h:278
@ CACHE_OP_BU
Cache block unlock operation.
Definition: bootrom.h:271
@ CACHE_OP_AC
Cache all clean operation.
Definition: bootrom.h:266
@ CACHE_OP_BT
Cache block touch operation.
Definition: bootrom.h:269
@ CACHE_OP_SC
Cache set clean operation.
Definition: bootrom.h:267
@ CACHE_OP_BL
Cache block lock operation.
Definition: bootrom.h:270
@ CACHE_OP_BC
Cache block clean operation.
Definition: bootrom.h:268
@ CACHE_OP_DIS
Cache disable operation.
Definition: bootrom.h:273
@ CACHE_OP_EN
Cache enable operation.
Definition: bootrom.h:272
@ CRYPTO_ECB_DECRYPT
Definition: bootrom.h:194
@ CRYPTO_CBC_DECRYPT
Definition: bootrom.h:196
@ CRYPTO_CBC_ENCRYPT
Definition: bootrom.h:195
@ CRYPTO_ECB_ENCRYPT
Definition: bootrom.h:193
@ NVM_PASSWORD_SEGMENT_DATA
NVM password for customer data mapped segment (NVM FLASH0).
Definition: bootrom.h:281
@ NVM_PASSWORD_SEGMENT_BOOT
NVM password for customer segment, used for customer bootloader (NVM FLASH0).
Definition: bootrom.h:279
@ NVM_PASSWORD_SEGMENT_CODE
NVM password for customer code segment, which is not used by the customer bootloader (NVM FLASH1).
Definition: bootrom.h:280
@ NVM_PASSWORD_SEGMENT_TOTAL
Can be ignored and should not be used.
Definition: bootrom.h:282
Definition: bootrom.h:168
uint32_t offset
Byte offset inside the selected page address, where to start reading. Maximum is 127 bytes.
Definition: bootrom.h:169
uint16_t nbyte
Amount of data bytes to read. If nbyte is zero, there is no read operation done and an error code is ...
Definition: bootrom.h:171
uint8_t * data
Data pointer where to write data into. Pointer plus valid count must be within valid RAM range or an ...
Definition: bootrom.h:170
Definition: bootrom.h:175
uint8_t counter
Counter value to update internal 100TP counter (only updates if value is greater than current,...
Definition: bootrom.h:179
uint8_t nbyte
Amount of data bytes to write. If nbyte is zero, there is no write operation done and an error code i...
Definition: bootrom.h:178
uint32_t offset
Byte offset inside the selected page address, where to start writing. Maximum is 123 bytes.
Definition: bootrom.h:176
uint8_t * data
Data pointer where to read the data to write. Pointer plus valid count must be within valid RAM range...
Definition: bootrom.h:177
Definition: bootrom.h:224
uint32_t iv_length
Definition: bootrom.h:226
void * iv
Definition: bootrom.h:225
Definition: bootrom.h:218
user_crypto_inp_buf_t mac
CMAC generate output buffer.
Definition: bootrom.h:220
user_crypto_inp_buf_t inp
CMAC generate input buffer.
Definition: bootrom.h:219
Definition: bootrom.h:200
uint8_t * buffer
Crypto algorithm input buffer address.
Definition: bootrom.h:201
uint32_t length
Crypto algorithm input buffer length.
Definition: bootrom.h:202
Definition: bootrom.h:212
user_crypto_out_buf_t out
Crypto algorithm output buffer.
Definition: bootrom.h:214
user_crypto_inp_buf_t inp
Crypto algorithm input buffer.
Definition: bootrom.h:213
Definition: bootrom.h:206
uint8_t * buffer
Crypto algorithm output buffer address.
Definition: bootrom.h:207
uint32_t * length
Crypto algorithm output buffer length.
Definition: bootrom.h:208
Definition: bootrom.h:245
uint16_t target_key_id
Key slot ID for parameter decryption.
Definition: bootrom.h:246
uint16_t version
New key version number.
Definition: bootrom.h:247
Definition: bootrom.h:252
uint8_t signature[USER_CMAC_SIGNATURE_SIZE]
CMAC signature.
Definition: bootrom.h:254
user_key_erase_params_t params
Input parameters (signature checked).
Definition: bootrom.h:253
Key data structure aligned with CFS page (ignored reserved bytes)
Definition: bootrom.h:184
uint8_t key[USER_KEY_SIZE_MAX]
Key value
Definition: bootrom.h:185
uint8_t protection
Key protection
Definition: bootrom.h:188
uint8_t length
Key size in bytes [16|32].
Definition: bootrom.h:187
uint16_t version
New key version number
Definition: bootrom.h:186
Definition: bootrom.h:231
uint8_t encrypted_key_buf[USER_KEY_PARAM_SIZE]
Encrypted buffer with new key parameters.
Definition: bootrom.h:232
uint16_t target_key_id
Key slot ID for parameter decryption.
Definition: bootrom.h:233
uint16_t encrypt_key_id
Key slot ID used for the new key parameters.
Definition: bootrom.h:234
Definition: bootrom.h:239
uint8_t signature[USER_CMAC_SIGNATURE_SIZE]
New key CMAC signature.
Definition: bootrom.h:241
user_key_write_params_t params
Input parameters (signature checked).
Definition: bootrom.h:240
Definition: bootrom.h:258
uint32_t options
NVM programming options (for example NVM_OPTIONS_CORR_ACT or NVM_OPTIONS_NO_FAILPAGE_ERASE).
Definition: bootrom.h:261
uint32_t nbyte
Amount of bytes to program. Range from 1-128 bytes.
Definition: bootrom.h:260
uint8_t * data
Pointer to the data where to read the programming data. Pointer must be within valid RAM range or an ...
Definition: bootrom.h:259
General type declarations.