bootloaderShared.h
Go to the documentation of this file.
1 #ifndef __BOOTLOADER_SHARED_H__
2 #define __BOOTLOADER_SHARED_H__
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 
7 #include <stdint.h>
8 
9 // uINS-3 flash layout - uINS Flash Memory Map
10 /*
11  page size: 512 (0x200)
12  block size: 8192 (0x2000)
13  flash base address: 0x00400000
14  flash size: 0x00100000
15 
16  use offset flash address
17  ------------------------------------------------------------
18  -------------------- 0x00000000 (0x00400000)
19  | bootloader (15872 bytes + 512 bootloader header bytes)
20  -------------------- 0x00004000 (0x00404000)
21  | application (966656 bytes) - application + bootloader = 983040 bytes
22  -------------------- 0x000F0000 (0x004F0000)
23  | 40K: unclaimed (40960 bytes)
24  -------------------- 0x000FA000 (0x004FA000)
25  | 8K : config mirror (8192 bytes)
26  -------------------- 0x000FC000 (0x004FC000)
27  | 8K : calibration (8192 bytes)
28  -------------------- 0x000FE000 (0x00FE0000)
29  | 8K : config (user page 0, user page 1, flash config, internal config, 8192 bytes)
30  | Note: Last 4 bytes of flash is the migration marker, currently 0x01010101)
31  -------------------- 0x00100000 (0x00500000)
32 */
33 
34 // #define CONF_UART_BAUDRATE_LEGACY 2000000
35 #define CONF_UART_BAUDRATE 921600
36 #define CONF_UART_BAUDRATE_RS232 230400
37 #define CONF_UART_BAUDRATE_SLOW 115200
38 
39 // total size of all flash memory
40 #ifndef BOOTLOADER_FLASH_TOTAL_SIZE
41 #define BOOTLOADER_FLASH_TOTAL_SIZE ((uint32_t)1048576)
42 #endif
43 
44 // start address of bootloader in flash memory
45 #ifndef BOOTLOADER_FLASH_START_ADDRESS
46 #define BOOTLOADER_FLASH_START_ADDRESS ((uint32_t)0x00400000)
47 #endif
48 
49 // total space allocated to bootloader in flash memory
50 #ifndef BOOTLOADER_FLASH_BOOTLOADER_SIZE
51 #define BOOTLOADER_FLASH_BOOTLOADER_SIZE ((uint32_t)16384) // 16K
52 #endif
53 
54 // size of the user application in flash memory
55 #ifndef BOOTLOADER_FLASH_USER_APPLICATION_SIZE
56 #define BOOTLOADER_FLASH_USER_APPLICATION_SIZE ((uint32_t)966656) // 966656 = EC000, 1MB flash - 16K bootloader - 64K footer
57 #endif
58 
59 // note: the default is accurate for user flash memory, but sectors are smaller in the bootloader and start of application space
60 #ifndef BOOTLOADER_FLASH_SECTOR_SIZE
61 #define BOOTLOADER_FLASH_SECTOR_SIZE ((uint32_t)131072) // 128 KB
62 #endif
63 
64 // size of flash page
65 #ifndef BOOTLOADER_FLASH_PAGE_SIZE
66 #define BOOTLOADER_FLASH_PAGE_SIZE ((uint32_t)512)
67 #endif
68 
69 // size of flash block
70 #ifndef BOOTLOADER_FLASH_BLOCK_SIZE
71 #define BOOTLOADER_FLASH_BLOCK_SIZE ((uint32_t)8192) // 8K
72 #endif
73 
74 // size of the bootloader header
75 #ifndef BOOTLOADER_FLASH_BOOTLOADER_HEADER_SIZE
76 #define BOOTLOADER_FLASH_BOOTLOADER_HEADER_SIZE BOOTLOADER_FLASH_PAGE_SIZE
77 #endif
78 
79 // offset of bootloader header in flash memory
80 #ifndef BOOTLOADER_FLASH_BOOTLOADER_HEADER_ADDRESS
81 #define BOOTLOADER_FLASH_BOOTLOADER_HEADER_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + BOOTLOADER_FLASH_BOOTLOADER_SIZE - BOOTLOADER_FLASH_BOOTLOADER_HEADER_SIZE)
82 #endif
83 
84 // start offset in flash of config mirror data
85 #ifndef BOOTLOADER_FLASH_CONFIG_MIRROR_BASE_ADDRESS
86 #define BOOTLOADER_FLASH_CONFIG_MIRROR_BASE_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + 0x000FA000)
87 #endif
88 
89 // start offset in flash of calibration data
90 #ifndef BOOTLOADER_FLASH_CALIB_BASE_ADDRESS
91 #define BOOTLOADER_FLASH_CALIB_BASE_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + 0x000FC000)
92 #endif
93 
94 // start offset in flash of config data
95 #ifndef BOOTLOADER_FLASH_CONFIG_BASE_ADDRESS
96 #define BOOTLOADER_FLASH_CONFIG_BASE_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + 0x000FE000)
97 #endif
98 
99 // start of user application in flash memory
100 #ifndef BOOTLOADER_FLASH_USER_APPLICATION_START_ADDRESS
101 #define BOOTLOADER_FLASH_USER_APPLICATION_START_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + BOOTLOADER_FLASH_BOOTLOADER_SIZE)
102 #endif
103 
104 // start of user data in flash memory
105 #ifndef BOOTLOADER_FLASH_USER_DATA_START_ADDRESS
106 #define BOOTLOADER_FLASH_USER_DATA_START_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + BOOTLOADER_FLASH_BOOTLOADER_SIZE + BOOTLOADER_FLASH_USER_APPLICATION_SIZE)
107 #endif
108 
109 // size of config in flash memory
110 #ifndef BOOTLOADER_FLASH_USER_DATA_SIZE
111 #define BOOTLOADER_FLASH_USER_DATA_SIZE (BOOTLOADER_FLASH_TOTAL_SIZE - BOOTLOADER_FLASH_USER_APPLICATION_SIZE - BOOTLOADER_FLASH_BOOTLOADER_SIZE)
112 #endif
113 
114 // end address of user data in flash (exclusive)
115 #ifndef BOOTLOADER_FLASH_USER_DATA_END_ADDRESS
116 #define BOOTLOADER_FLASH_USER_DATA_END_ADDRESS (BOOTLOADER_FLASH_USER_DATA_START_ADDRESS + BOOTLOADER_FLASH_USER_DATA_SIZE)
117 #endif
118 
119 // the last address in flash, EXCLUSIVE!!! - subtract 1 to get the last valid byte to read or write to
120 #define BOOTLOADER_FLASH_END_ADDRESS (BOOTLOADER_FLASH_START_ADDRESS + BOOTLOADER_FLASH_TOTAL_SIZE)
121 
122 // start seed of bootloader hash
123 #define BOOTLOADER_HASH_CODE_START_VALUE ((uint32_t)435258227)
124 
125 // jump signature to stay in bootloader - DO NOT MODIFY!
126 #define BOOTLOADER_JUMP_SIGNATURE_STAY_IN_BOOTLOADER "__StayInBootLoader12345__"
127 
128 // jump signature to stay in user application - DO NOT MODIFY!
129 #define BOOTLOADER_JUMP_SIGNATURE_STAY_IN_USER_APPLICATION "__StayInUserApplication__"
130 
131 // jump signature size
132 #define BOOTLOADER_JUMP_SIGNATURE_SIZE ((uint32_t)32)
133 
134 // signature size
135 #define BOOTLOADER_SIGNATURE_SIZE ((uint32_t)16)
136 
137 // bootloader signature must be found within this number of bytes, or the bootload fails
138 #define BOOTLOADER_SIGNATURE_REQUIRED_WITHIN_BYTE_COUNT ((uint32_t)16384)
139 
140 // signature found marker - this is the only valid value to indicate that the signature was found in the firmware
141 #define BOOTLOADER_SIGNATURE_FOUND_MARKER ((uint32_t)1)
142 
143 // the size of each logical page size in the bootloader - 64K, this does not match the flash page size and is based on the fact that bootloader logic uses 16 bit unsigned int for page offsets
144 #define BOOTLOADER_LOGICAL_PAGE_SIZE ((uint32_t)65536)
145 
146 // bootloader sets all bytes in header to this value on deploy
147 #define BOOTLOADER_HEADER_INITIAL_FILL_BYTE ((uint8_t)0xFE)
148 
149 // bootloader sets all bytes in header to this value on deploy
150 #define BOOTLOADER_HEADER_INITIAL_FILL_UINT_32 ((uint32_t)0xFEFEFEFE)
151 
152 // Serial port selection key
153 #define PORT_SEL_KEY_SYS_GPBR_3 0x09ea4f06
154 #define PORT_SEL_KEY_SYS_GPBR_4 0x13d6007e
155 #define PORT_SEL_KEY_SYS_GPBR_5 0x93f035fe
156 #define PORT_SEL_KEY_SYS_GPBR_6 0xd096ae0f
157 
158 #define PORT_SEL_SER0 0
159 #define PORT_SEL_SER1 1
160 #define PORT_SEL_USB 2
161 
162 typedef union
163 {
164  struct
165  {
166  char jumpSignature[BOOTLOADER_JUMP_SIGNATURE_SIZE]; // indicates whether to stay in bootloader or user application
167  uint32_t signatureFound; // was a signature found, must be exactly BOOTLOADER_SIGNATURE_FOUND_MARKER to be true, no other value is true
168  uint32_t hashCode; // hash code for user application
169  char version[4]; // bootloader version
170  } data;
171  uint8_t bytes[BOOTLOADER_FLASH_BOOTLOADER_HEADER_SIZE]; // any additional bytes are reserved space
173 
174 // calculate bootloader hash code over a set of data - hashCode should be BOOTLOADER_HASH_CODE_START_VALUE if just starting, otherwise previous value if continuing
175 uint32_t calculateBootloaderHashCode(uint32_t hashCode, const uint32_t* start, const uint32_t* end);
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 #endif // __BOOTLOADER_SHARED_H__
not_this_one end(...)
uint32_t calculateBootloaderHashCode(uint32_t hashCode, const uint32_t *start, const uint32_t *end)
#define BOOTLOADER_JUMP_SIGNATURE_SIZE
USBInterfaceDescriptor data
#define BOOTLOADER_FLASH_BOOTLOADER_HEADER_SIZE


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:08