Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
flash_layout.h
1
/*
2
* Copyright (c) 2018-2021 Arm Limited. All rights reserved.
3
* Copyright (c) 2020 Nordic Semiconductor ASA. All rights reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
/* This file has been modified for use in the Contiki-NG operating system. */
19
20
#ifndef __FLASH_LAYOUT_H__
21
#define __FLASH_LAYOUT_H__
22
23
/* Flash layout on NRF5340 Application MCU with BL2:
24
*
25
* 0x0000_0000 BL2 - MCUBoot (64 KB)
26
* 0x0001_0000 Primary image area (448 KB):
27
* 0x0001_0000 Secure image primary (256 KB)
28
* 0x0005_0000 Non-secure image primary (192 KB)
29
* 0x0008_0000 Secondary image area (448 KB):
30
* 0x0008_0000 Secure image secondary (256 KB)
31
* 0x000c_0000 Non-secure image secondary (192 KB)
32
* 0x000f_0000 Protected Storage Area (16 KB)
33
* 0x000f_4000 Internal Trusted Storage Area (8 KB)
34
* 0x000f_6000 NV counters area (4 KB)
35
* 0x000f_7000 Unused
36
*
37
* Flash layout on NRF5340 Application MCU without BL2:
38
*
39
* 0x0000_0000 Primary image area (960 KB):
40
* 0x0000_0000 Secure image primary (480 KB)
41
* 0x0007_8000 Non-secure image primary (480 KB)
42
* 0x000f_0000 Protected Storage Area (16 KB)
43
* 0x000f_4000 Internal Trusted Storage Area (8 KB)
44
* 0x000f_6000 NV counters area (4 KB)
45
* 0x000f_7000 Unused
46
*/
47
48
/* This header file is included from linker scatter file as well, where only a
49
* limited C constructs are allowed. Therefore it is not possible to include
50
* here the platform_base_address.h to access flash related defines. To resolve
51
* this some of the values are redefined here with different names, these are
52
* marked with comment.
53
*/
54
55
/* Size of a Secure and of a Non-secure image */
56
#ifdef PSA_API_TEST_IPC
57
/* Firmware Framework test suites */
58
#define FLASH_S_PARTITION_SIZE (0x48000)
/* S partition: 288 kB*/
59
#define FLASH_NS_PARTITION_SIZE (0x28000)
/* NS partition: 160 kB*/
60
#else
61
#define FLASH_S_PARTITION_SIZE (0x40000)
/* S partition: 256 kB*/
62
#define FLASH_NS_PARTITION_SIZE (0x30000)
/* NS partition: 192 kB*/
63
#endif
64
65
#define FLASH_MAX_PARTITION_SIZE ((FLASH_S_PARTITION_SIZE > \
66
FLASH_NS_PARTITION_SIZE) ? \
67
FLASH_S_PARTITION_SIZE : \
68
FLASH_NS_PARTITION_SIZE)
69
70
/* Sector size of the embedded flash hardware (erase/program) */
71
#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000)
/* 4 KB. Flash memory program/erase operations have a page granularity. */
72
73
/* FLASH size */
74
#define FLASH_TOTAL_SIZE (0x100000)
/* 1024 kB. */
75
76
/* Flash layout info for BL2 bootloader */
77
#define FLASH_BASE_ADDRESS (0x00000000)
78
79
80
/* Offset and size definitions of the flash partitions that are handled by the
81
* bootloader. The image swapping is done between IMAGE_PRIMARY and
82
* IMAGE_SECONDARY, SCRATCH is used as a temporary storage during image
83
* swapping.
84
*/
85
#define FLASH_AREA_BL2_OFFSET (0x0)
86
#define FLASH_AREA_BL2_SIZE (0x10000)
/* 64 KB */
87
88
#if !defined(MCUBOOT_IMAGE_NUMBER) || (MCUBOOT_IMAGE_NUMBER == 1)
89
/* Secure + Non-secure image primary slot */
90
#define FLASH_AREA_0_ID (1)
91
#define FLASH_AREA_0_OFFSET (FLASH_AREA_BL2_OFFSET + FLASH_AREA_BL2_SIZE)
92
#define FLASH_AREA_0_SIZE (FLASH_S_PARTITION_SIZE + \
93
FLASH_NS_PARTITION_SIZE)
94
/* Secure + Non-secure secondary slot */
95
#define FLASH_AREA_2_ID (FLASH_AREA_0_ID + 1)
96
#define FLASH_AREA_2_OFFSET (FLASH_AREA_0_OFFSET + FLASH_AREA_0_SIZE)
97
#define FLASH_AREA_2_SIZE (FLASH_S_PARTITION_SIZE + \
98
FLASH_NS_PARTITION_SIZE)
99
/* Not used, only the Non-swapping firmware upgrade operation
100
* is supported on NRF5340 Application MCU.
101
*/
102
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_2_ID + 1)
103
#define FLASH_AREA_SCRATCH_OFFSET (FLASH_AREA_2_OFFSET + FLASH_AREA_2_SIZE)
104
#define FLASH_AREA_SCRATCH_SIZE (0)
105
/* Maximum number of image sectors supported by the bootloader. */
106
#define MCUBOOT_MAX_IMG_SECTORS ((FLASH_S_PARTITION_SIZE + \
107
FLASH_NS_PARTITION_SIZE) / \
108
FLASH_AREA_IMAGE_SECTOR_SIZE)
109
#elif (MCUBOOT_IMAGE_NUMBER == 2)
110
/* Secure image primary slot */
111
#define FLASH_AREA_0_ID (1)
112
#define FLASH_AREA_0_OFFSET (FLASH_AREA_BL2_OFFSET + FLASH_AREA_BL2_SIZE)
113
#define FLASH_AREA_0_SIZE (FLASH_S_PARTITION_SIZE)
114
/* Non-secure image primary slot */
115
#define FLASH_AREA_1_ID (FLASH_AREA_0_ID + 1)
116
#define FLASH_AREA_1_OFFSET (FLASH_AREA_0_OFFSET + FLASH_AREA_0_SIZE)
117
#define FLASH_AREA_1_SIZE (FLASH_NS_PARTITION_SIZE)
118
/* Secure image secondary slot */
119
#define FLASH_AREA_2_ID (FLASH_AREA_1_ID + 1)
120
#define FLASH_AREA_2_OFFSET (FLASH_AREA_1_OFFSET + FLASH_AREA_1_SIZE)
121
#define FLASH_AREA_2_SIZE (FLASH_S_PARTITION_SIZE)
122
/* Non-secure image secondary slot */
123
#define FLASH_AREA_3_ID (FLASH_AREA_2_ID + 1)
124
#define FLASH_AREA_3_OFFSET (FLASH_AREA_2_OFFSET + FLASH_AREA_2_SIZE)
125
#define FLASH_AREA_3_SIZE (FLASH_NS_PARTITION_SIZE)
126
/* Not used, only the Non-swapping firmware upgrade operation
127
* is supported on NRF5340 Application MCU.
128
*/
129
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_3_ID + 1)
130
#define FLASH_AREA_SCRATCH_OFFSET (FLASH_AREA_3_OFFSET + FLASH_AREA_3_SIZE)
131
#define FLASH_AREA_SCRATCH_SIZE (0)
132
/* Maximum number of image sectors supported by the bootloader. */
133
#define MCUBOOT_MAX_IMG_SECTORS (FLASH_MAX_PARTITION_SIZE / \
134
FLASH_AREA_IMAGE_SECTOR_SIZE)
135
#else
/* MCUBOOT_IMAGE_NUMBER > 2 */
136
#error "Only MCUBOOT_IMAGE_NUMBER 1 and 2 are supported!"
137
#endif
/* MCUBOOT_IMAGE_NUMBER */
138
139
/* Not used, only the Non-swapping firmware upgrade operation
140
* is supported on nRF5340. The maximum number of status entries
141
* supported by the bootloader.
142
*/
143
#define MCUBOOT_STATUS_MAX_ENTRIES (0)
144
145
146
#define FLASH_PS_AREA_OFFSET (FLASH_AREA_SCRATCH_OFFSET + \
147
FLASH_AREA_SCRATCH_SIZE)
148
#define FLASH_PS_AREA_SIZE (0x4000)
/* 16 KB */
149
150
/* Internal Trusted Storage (ITS) Service definitions */
151
#define FLASH_ITS_AREA_OFFSET (FLASH_PS_AREA_OFFSET + \
152
FLASH_PS_AREA_SIZE)
153
#define FLASH_ITS_AREA_SIZE (0x2000)
/* 8 KB */
154
155
/* NV Counters definitions */
156
#define FLASH_NV_COUNTERS_AREA_OFFSET (FLASH_ITS_AREA_OFFSET + \
157
FLASH_ITS_AREA_SIZE)
158
#define FLASH_NV_COUNTERS_AREA_SIZE (FLASH_AREA_IMAGE_SECTOR_SIZE)
159
160
/* PSA MMIO Area definitions */
161
#define FLASH_MMIO_AREA_OFFSET (FLASH_NV_COUNTERS_AREA_OFFSET + \
162
FLASH_NV_COUNTERS_AREA_SIZE)
163
#define FLASH_MMIO_AREA_SIZE (FLASH_AREA_IMAGE_SECTOR_SIZE)
164
165
/* Offset and size definition in flash area used by assemble.py */
166
#define SECURE_IMAGE_OFFSET (0x0)
167
#define SECURE_IMAGE_MAX_SIZE FLASH_S_PARTITION_SIZE
168
169
#define NON_SECURE_IMAGE_OFFSET (SECURE_IMAGE_OFFSET + \
170
SECURE_IMAGE_MAX_SIZE)
171
#define NON_SECURE_IMAGE_MAX_SIZE FLASH_NS_PARTITION_SIZE
172
173
/* Flash device name used by BL2
174
* Name is defined in flash driver file: Driver_Flash.c
175
*/
176
#define FLASH_DEV_NAME Driver_FLASH0
177
#define TFM_HAL_FLASH_PROGRAM_UNIT (0x4)
178
179
/* Protected Storage (PS) Service definitions
180
* Note: Further documentation of these definitions can be found in the
181
* TF-M PS Integration Guide.
182
*/
183
#define TFM_HAL_PS_FLASH_DRIVER Driver_FLASH0
184
185
/* In this target the CMSIS driver requires only the offset from the base
186
* address instead of the full memory address.
187
*/
188
/* Base address of dedicated flash area for PS */
189
#define TFM_HAL_PS_FLASH_AREA_ADDR FLASH_PS_AREA_OFFSET
190
/* Size of dedicated flash area for PS */
191
#define TFM_HAL_PS_FLASH_AREA_SIZE FLASH_PS_AREA_SIZE
192
#define PS_RAM_FS_SIZE TFM_HAL_PS_FLASH_AREA_SIZE
193
/* Number of physical erase sectors per logical FS block */
194
#define TFM_HAL_PS_SECTORS_PER_BLOCK (1)
195
/* Smallest flash programmable unit in bytes */
196
#define TFM_HAL_PS_PROGRAM_UNIT (0x4)
197
198
/* Internal Trusted Storage (ITS) Service definitions
199
* Note: Further documentation of these definitions can be found in the
200
* TF-M ITS Integration Guide. The ITS should be in the internal flash, but is
201
* allocated in the external flash just for development platforms that don't
202
* have internal flash available.
203
*/
204
#define TFM_HAL_ITS_FLASH_DRIVER Driver_FLASH0
205
206
/* In this target the CMSIS driver requires only the offset from the base
207
* address instead of the full memory address.
208
*/
209
/* Base address of dedicated flash area for ITS */
210
#define TFM_HAL_ITS_FLASH_AREA_ADDR FLASH_ITS_AREA_OFFSET
211
/* Size of dedicated flash area for ITS */
212
#define TFM_HAL_ITS_FLASH_AREA_SIZE FLASH_ITS_AREA_SIZE
213
#define ITS_RAM_FS_SIZE TFM_HAL_ITS_FLASH_AREA_SIZE
214
/* Number of physical erase sectors per logical FS block */
215
#define TFM_HAL_ITS_SECTORS_PER_BLOCK (1)
216
/* Smallest flash programmable unit in bytes */
217
#define TFM_HAL_ITS_PROGRAM_UNIT (0x4)
218
219
/* NV Counters definitions */
220
#define TFM_NV_COUNTERS_AREA_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
221
#define TFM_NV_COUNTERS_AREA_SIZE (0x18)
/* 24 Bytes */
222
#define TFM_NV_COUNTERS_SECTOR_ADDR FLASH_NV_COUNTERS_AREA_OFFSET
223
#define TFM_NV_COUNTERS_SECTOR_SIZE FLASH_AREA_IMAGE_SECTOR_SIZE
224
225
/* Use Flash memory to store Code data */
226
#define FLASH_BASE_ADDRESS (0x00000000)
227
#define S_ROM_ALIAS_BASE FLASH_BASE_ADDRESS
228
#define NS_ROM_ALIAS_BASE FLASH_BASE_ADDRESS
229
230
/* Use SRAM memory to store RW data */
231
#define SRAM_BASE_ADDRESS (0x20000000)
232
#define S_RAM_ALIAS_BASE SRAM_BASE_ADDRESS
233
#define NS_RAM_ALIAS_BASE SRAM_BASE_ADDRESS
234
235
#define TOTAL_ROM_SIZE FLASH_TOTAL_SIZE
236
#define TOTAL_RAM_SIZE (0x00080000)
/* 512 kB */
237
238
#endif
/* __FLASH_LAYOUT_H__ */
arch
cpu
nrf
nrf5340
partition
flash_layout.h
Generated on
for Contiki-NG by
1.17.0