Smart Remote 3 nRF52 v1.2
nrf_dfu_types.h
1 /*$$$LICENCE_NORDIC_STANDARD<2016>$$$*/
9 #ifndef NRF_DFU_TYPES_H__
10 #define NRF_DFU_TYPES_H__
11 
12 #include "nrf.h"
13 #include "nrf_mbr.h"
14 #include "app_util_platform.h"
15 
16 #ifdef SOFTDEVICE_PRESENT
17 #include "nrf_sdm.h"
18 #include "ble_gap.h"
19 #endif
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #if defined(SOFTDEVICE_PRESENT)
26 
29 #define SOFTDEVICE_REGION_START MBR_SIZE
30 
31 
32 #ifndef CODE_REGION_1_START
33 #define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE)
34 #endif
35 
36 
37 #else
38 
39 #ifndef CODE_REGION_1_START
40 #define CODE_REGION_1_START MBR_SIZE
41 #endif
42 
43 #endif
44 
45 
46 #define INIT_COMMAND_MAX_SIZE 256
52 #if defined(NRF51)
53  #define CODE_PAGE_SIZE (PAGE_SIZE_IN_WORDS * sizeof(uint32_t))
54 #elif defined(NRF52) || defined(NRF52840_XXAA) || defined(NRF52810_XXAA)
55  #define CODE_PAGE_SIZE (MBR_PAGE_SIZE_IN_WORDS * sizeof(uint32_t))
56 #else
57  #error "Architecture not set."
58 #endif
59 
60 
62 #if defined( NRF51 )
63  #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE * 4)
64 #elif defined( NRF52_SERIES ) || defined ( __SDK_DOXYGEN__ )
65  #define DATA_OBJECT_MAX_SIZE (CODE_PAGE_SIZE)
66 #else
67  #error "Architecture not set."
68 #endif
69 
73 #if defined ( NRF51 )
74  #define BOOTLOADER_SETTINGS_ADDRESS (0x0003FC00UL)
75 #elif defined( NRF52832_XXAA )
76  #define BOOTLOADER_SETTINGS_ADDRESS (0x0007F000UL)
77 #elif defined( NRF52810_XXAA )
78  #define BOOTLOADER_SETTINGS_ADDRESS (0x0002F000UL)
79 #elif defined( NRF52840_XXAA )
80  #define BOOTLOADER_SETTINGS_ADDRESS (0x000FF000UL)
81 #else
82  #error "No valid target set for BOOTLOADER_SETTINGS_ADDRESS."
83 #endif
84 
85 
86 #if !defined(NRF_DFU_UPDATABLE_APPLICATION_ONLY) || (NRF_DFU_UPDATABLE_APPLICATION_ONLY == 0)
87 #if defined(NRF52832_XXAA) || defined(NRF52810_XXAA)
88 
95 #define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18)
96 #endif
97 
98 
102 #if defined(NRF52840_XXAA_ENGA)
103 #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x000FE000UL)
104 #elif defined( NRF52810_XXAA )
105 #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0002E000UL)
106 #else
107 #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x0007E000UL)
108 #endif
109 
110 
111 #if defined(NRF52840_XXAA)
112 
120 #define NRF_UICR_MBR_PARAMS_PAGE_ADDRESS (NRF_UICR_BASE + 0x18)
121 
122 
126 #define NRF_MBR_PARAMS_PAGE_ADDRESS (0x000FE000UL)
127 
128 #endif
129 #endif /* !defined(NRF_DFU_UPDATABLE_APPLICATION_ONLY) || (NRF_DFU_UPDATABLE_APPLICATION_ONLY == 0) */
130 
131 
134 #ifndef DFU_APP_DATA_RESERVED
135 #define DFU_APP_DATA_RESERVED CODE_PAGE_SIZE * 3
136 #endif
137 
138 
141 #define DFU_REGION_TOTAL_SIZE ((* (uint32_t *)NRF_UICR_BOOTLOADER_START_ADDRESS) - CODE_REGION_1_START)
142 
143 #ifdef SOFTDEVICE_PRESENT
144 
146 #define SOFTDEVICE_REGION_START MBR_SIZE
147 
148 
156 #ifndef CODE_REGION_1_START
157 #define CODE_REGION_1_START SD_SIZE_GET(MBR_SIZE)
158 #endif
159 #else
160 #ifndef CODE_REGION_1_START
161 #define CODE_REGION_1_START MBR_SIZE
162 #endif
163 #endif
164 
165 #define NRF_DFU_CURRENT_BANK_0 0x00
166 #define NRF_DFU_CURRENT_BANK_1 0x01
167 
168 #define NRF_DFU_BANK_LAYOUT_DUAL 0x00
169 #define NRF_DFU_BANK_LAYOUT_SINGLE 0x01
170 
171 
178 #define NRF_DFU_BANK_INVALID 0x00
179 #define NRF_DFU_BANK_VALID_APP 0x01
180 #define NRF_DFU_BANK_VALID_SD 0xA5
181 #define NRF_DFU_BANK_VALID_BL 0xAA
182 #define NRF_DFU_BANK_VALID_SD_BL 0xAC
186 #pragma pack(4)
187 typedef struct
188 {
189  uint32_t image_size;
190  uint32_t image_crc;
191  uint32_t bank_code;
193 
202 typedef struct
203 {
204  uint32_t command_size;
205  uint32_t command_offset;
206  uint32_t command_crc;
208  uint32_t data_object_size;
210  union
211  {
212  struct
213  {
218  };
219  struct
220  {
221  uint32_t sd_start_address;
222  };
223  };
226 
227 #define SYSTEM_SERVICE_ATT_SIZE 8
230 typedef struct
231 {
232  ble_gap_id_key_t ble_id;
233  ble_gap_enc_key_t enc_key;
234  uint8_t sys_serv_attr[SYSTEM_SERVICE_ATT_SIZE];
236 
238 typedef struct
239 {
240  uint8_t name[20];
241  uint32_t len;
243 
245 typedef struct
246 {
247  uint32_t crc;
249  ble_gap_addr_t ble_addr;
253 
255 typedef struct
256 {
257  uint32_t crc;
260  /* Bootloader private settings. Included in calculated CRC. */
261 
262  uint32_t settings_version;
263  uint32_t app_version;
266  uint32_t bank_layout;
267  uint32_t bank_current;
272  uint32_t write_offset;
273  uint32_t sd_size;
280  /* Below fields are not included in calculated CRC and are not part of the settings layout. */
281 
282  uint8_t init_command[INIT_COMMAND_MAX_SIZE];
286 
287 
288 #ifdef SOFTDEVICE_PRESENT
289 
290 
291 #endif // SYSTEM_SERVICE_ATT_SIZE
292 
293 
294 #pragma pack() // revert pack settings
295 
296 
297 #ifdef __cplusplus
298 }
299 #endif
300 
301 #endif // NRF_DFU_TYPES_H__
302 

Documentation feedback | Developer Zone | Subscribe | Updated