|
19 | 19 | #ifndef __PARTITION_M2351_MEM_H__
|
20 | 20 | #define __PARTITION_M2351_MEM_H__
|
21 | 21 |
|
22 |
| -/* About partition_M2351_mem.h/partition_M2351_mem.icf |
| 22 | +/* About partition_M2351_mem.h/partition_M2351_mem.icf.h |
23 | 23 | *
|
24 | 24 | * 1. partition_M2351_mem.h is created for centralizing memory partition configuration. It will be
|
25 | 25 | * included by C/C++ files and linker files (except IAR linker file).
|
26 |
| - * 2. IAR linker doesn't support preprocessor, so partition_M2351_mem.icf, duplicate of partition_M2351_mem.h |
| 26 | + * 2. IAR linker doesn't support preprocessor, so partition_M2351_mem.icf.h, duplicate of partition_M2351_mem.h |
27 | 27 | * is created for IAR linker file.
|
| 28 | + * 3. To continue above, we name partition_M2351_mem.icf.h instead of partition_M2351_mem.icf because: |
| 29 | + * (1) Mbed OS build tool may mis-regard partition_M2351_mem.icf as the main linker configuration file. |
| 30 | + * (2) *.icf files may not be present in search directories for "include" directive. Per observation, |
| 31 | + * the search directories are inconsistent among normal example build and test code build. To address |
| 32 | + * it, we name partition_M2351_mem.icf.h instead because *.h files are always present in these builds |
| 33 | + * (already there or via copy). |
28 | 34 | */
|
29 | 35 |
|
30 | 36 | /* Default flash/SRAM partition
|
|
39 | 45 | */
|
40 | 46 | #if defined(DOMAIN_NS) && DOMAIN_NS
|
41 | 47 |
|
42 |
| -/* Default non-secure ROM layout */ |
| 48 | +/* Resolve non-secure ROM start */ |
43 | 49 | #ifndef MBED_ROM_START
|
44 | 50 | #define MBED_ROM_START (0x10040000)
|
45 | 51 | #endif
|
| 52 | +/* Resolve non-secure ROM size */ |
46 | 53 | #ifndef MBED_ROM_SIZE
|
47 | 54 | #define MBED_ROM_SIZE (0x40000)
|
48 | 55 | #endif
|
49 |
| -/* Default non-secure RAM layout */ |
| 56 | +/* Resolve non-secure RAM start */ |
50 | 57 | #ifndef MBED_RAM_START
|
51 | 58 | #define MBED_RAM_START (0x30008000)
|
52 | 59 | #endif
|
| 60 | +/* Resolve non-secure RAM size */ |
53 | 61 | #ifndef MBED_RAM_SIZE
|
54 | 62 | #define MBED_RAM_SIZE (0x10000)
|
55 | 63 | #endif
|
56 | 64 |
|
57 | 65 | #else
|
58 | 66 |
|
59 |
| -/* Default secure ROM layout */ |
| 67 | +/* Resolve secure ROM start */ |
60 | 68 | #ifndef MBED_ROM_START
|
61 | 69 | #define MBED_ROM_START (0x0)
|
62 | 70 | #endif
|
| 71 | +/* Resolve secure ROM size */ |
63 | 72 | #ifndef MBED_ROM_SIZE
|
64 | 73 | #define MBED_ROM_SIZE (0x40000)
|
65 | 74 | #endif
|
66 |
| -/* Default secure RAM layout */ |
| 75 | +/* Resolve secure RAM start */ |
67 | 76 | #ifndef MBED_RAM_START
|
68 | 77 | #define MBED_RAM_START (0x20000000)
|
69 | 78 | #endif
|
| 79 | +/* Resolve secure RAM size */ |
70 | 80 | #ifndef MBED_RAM_SIZE
|
71 | 81 | #define MBED_RAM_SIZE (0x8000)
|
72 | 82 | #endif
|
|
108 | 118 |
|
109 | 119 | #endif
|
110 | 120 |
|
| 121 | +/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just |
| 122 | + * MBED_APP_xxx macros to linker files even though they mean the same thing. |
| 123 | + * Because this file is to include by both C/C++ files and linker files, we add |
| 124 | + * these macros according to the others for consistency when they are missing |
| 125 | + * in compile or link stage. */ |
| 126 | + |
| 127 | +#ifndef APPLICATION_ADDR |
| 128 | +#ifdef MBED_APP_START |
| 129 | +#define APPLICATION_ADDR MBED_APP_START |
| 130 | +#else |
| 131 | +#define APPLICATION_ADDR MBED_ROM_START |
| 132 | +#endif |
| 133 | +#endif |
| 134 | + |
| 135 | +#ifndef APPLICATION_SIZE |
| 136 | +#ifdef MBED_APP_SIZE |
| 137 | +#define APPLICATION_SIZE MBED_APP_SIZE |
| 138 | +#else |
| 139 | +#define APPLICATION_SIZE MBED_ROM_SIZE |
| 140 | +#endif |
| 141 | +#endif |
| 142 | + |
| 143 | +#ifndef APPLICATION_RAM_ADDR |
| 144 | +#ifdef MBED_RAM_APP_START |
| 145 | +#define APPLICATION_RAM_ADDR MBED_RAM_APP_START |
| 146 | +#else |
| 147 | +#define APPLICATION_RAM_ADDR MBED_RAM_START |
| 148 | +#endif |
| 149 | +#endif |
| 150 | + |
| 151 | +#ifndef APPLICATION_RAM_SIZE |
| 152 | +#ifdef MBED_RAM_APP_SIZE |
| 153 | +#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE |
| 154 | +#else |
| 155 | +#define APPLICATION_RAM_SIZE MBED_RAM_SIZE |
| 156 | +#endif |
| 157 | +#endif |
| 158 | + |
| 159 | +#ifndef MBED_APP_START |
| 160 | +#define MBED_APP_START APPLICATION_ADDR |
| 161 | +#endif |
| 162 | + |
| 163 | +#ifndef MBED_APP_SIZE |
| 164 | +#define MBED_APP_SIZE APPLICATION_SIZE |
| 165 | +#endif |
| 166 | + |
| 167 | +#ifndef MBED_RAM_APP_START |
| 168 | +#define MBED_RAM_APP_START APPLICATION_RAM_ADDR |
| 169 | +#endif |
| 170 | + |
| 171 | +#ifndef MBED_RAM_APP_SIZE |
| 172 | +#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE |
| 173 | +#endif |
| 174 | + |
| 175 | +#if (APPLICATION_ADDR != MBED_APP_START) |
| 176 | +#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!") |
| 177 | +#endif |
| 178 | + |
| 179 | +#if (APPLICATION_SIZE != MBED_APP_SIZE) |
| 180 | +#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!") |
| 181 | +#endif |
| 182 | + |
| 183 | +#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START) |
| 184 | +#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!") |
| 185 | +#endif |
| 186 | + |
| 187 | +#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE) |
| 188 | +#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!") |
| 189 | +#endif |
| 190 | + |
| 191 | +/* Determine NSC area |
| 192 | + * |
| 193 | + * Requirements for NSC area: |
| 194 | + * 1. Requested by SAU, NSC area must start at 32 byte-aligned boundary. |
| 195 | + * 2. By IDAU, 0~0x4000 is secure. NSC can only locate in 0x4000~0x10000000. |
| 196 | + * 3. Greentea flash IAP uses last 2 sectors for its test. Avoid this range. |
| 197 | + * 4. Greentea NVSTORE uses last 2 sectors or 4 KiB x 2 for its test. Avoid this range. |
| 198 | + * 5. KVStore uses last a few KiB. Avoid this range. |
| 199 | + * 6. Due to TFM build process, TFM and its tests must generate the same cmse_lib.o. |
| 200 | + * To this end, TZ NSC location must fix at a well-known location and cannot place |
| 201 | + * arbitrarily. |
| 202 | + * |
| 203 | + * Configurable for NSC area: |
| 204 | + * We cannot configure NSC location via configuration parameter because the generated |
| 205 | + * configuration macros are just passed to C/C++ files but not to linker files. So |
| 206 | + * we can only hardcode NSC location here as constants (to be included by linker file). |
| 207 | + * |
| 208 | + * Locate NSC area at end of secure flash: |
| 209 | + * We decide to locate NSC area at end of secure flash. To avoid this area |
| 210 | + * accidentally erased by flash IAP operation, flash IAP must configure to exclude |
| 211 | + * this area. |
| 212 | + */ |
| 213 | +/* TZ NSC area defaults to from secure ROM end */ |
| 214 | +#define NU_TZ_NSC_START (NU_ROM_START_S + NU_ROM_SIZE_S - NU_TZ_NSC_SIZE) |
| 215 | +/* TZ NSC area defaults to 4KiB. */ |
| 216 | +#define NU_TZ_NSC_SIZE 0x1000 |
| 217 | + |
| 218 | +/* Configuration of flash IAP area */ |
| 219 | +#define NU_FLASHIAP_SECURE_START NU_ROM_START_S |
| 220 | +/* Exclude NSC area to avoid accidentally erased */ |
| 221 | +#define NU_FLASHIAP_SECURE_SIZE (NU_ROM_SIZE_S - NU_TZ_NSC_SIZE) |
| 222 | +#define NU_FLASHIAP_NONSECURE_START NU_ROM_START_NS |
| 223 | +#define NU_FLASHIAP_NONSECURE_SIZE NU_ROM_SIZE_NS |
| 224 | + |
111 | 225 | #endif /* __PARTITION_M2351_MEM_H__ */
|
0 commit comments