Skip to content

Commit c827166

Browse files
committed
Nuvoton: Migrate to new style memory bank information
Change memory bank symbols: 1. MBED_APP_START/SIZE -> MBED_CONFIGURED_ROM_BANK_IROM1_START/SIZE 2. MBED_RAM_APP_START/SIZE -> MBED_CONFIGURED_RAM_BANK_IRAM1_START/SIZE 3. APPLICATION_ADDR/SIZE -> MBED_CONFIGURED_ROM_BANK_IROM1_START/SIZE 4. APPLICATION_RAM_ADDR/SIZE -> MBED_CONFIGURED_RAM_BANK_IRAM1_START/SIZE 5. -> MBED_CONFIGURED_RAM_BANK_XRAM1_START/SIZE NOTE: Specific to NUC472 6. NU_HYPERRAM_START/SIZE -> MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START/SIZE NOTE: Specific to M467
1 parent 67a1942 commit c827166

File tree

23 files changed

+293
-734
lines changed

23 files changed

+293
-734
lines changed

targets/TARGET_NUVOTON/TARGET_M2354/device/TOOLCHAIN_GCC_ARM/M2354.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE;
3434

3535
MEMORY
3636
{
37-
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400
38-
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
39-
RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE
37+
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400
38+
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x400
39+
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
4040
}
4141

4242
/**

targets/TARGET_NUVOTON/TARGET_M2354/device/partition_M2354_mem.h

Lines changed: 25 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -19,113 +19,37 @@
1919
#ifndef __PARTITION_M2354_MEM_H__
2020
#define __PARTITION_M2354_MEM_H__
2121

22-
/* About partition_M2354_mem.h/partition_M2354_mem.icf.h
23-
*
24-
* 1. partition_M2354_mem.h is created for centralizing memory partition configuration. It will be
25-
* included by C/C++ files and linker files (except IAR linker file).
26-
* 2. IAR linker doesn't support preprocessor, so partition_M2354_mem.icf.h, duplicate of partition_M2354_mem.h
27-
* is created for IAR linker file.
28-
* 3. To continue above, we name partition_M2354_mem.icf.h instead of partition_M2354_mem.icf because:
29-
* (1) Mbed OS build tool may mis-regard partition_M2354_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_M2354_mem.icf.h instead because *.h files are always present in these builds
33-
* (already there or via copy).
34-
*/
35-
3622
#include "nu_tfm_import_define.h"
3723
#include NU_TFM_S_REGION_DEFS_H_PATH
3824
#include "nu_tfm_import_undefine.h"
3925

40-
/* Resolve MBED_ROM_START and friends
26+
/* Resolve MBED_ROM_BANK_IROM1_START and friends
4127
*
42-
* TF-M exported region_defs.h essentially resolves MBED_ROM_START and friends.
43-
* target.mbed_rom_start and friends get unnecessary.
28+
* TF-M exported region_defs.h essentially resolves MBED_ROM_BANK_IROM1_START and friends.
4429
*/
45-
/* Resolve non-secure ROM start */
46-
#undef MBED_ROM_START
47-
#define MBED_ROM_START NS_CODE_START
48-
49-
/* Resolve non-secure ROM size */
50-
#undef MBED_ROM_SIZE
51-
#define MBED_ROM_SIZE NS_CODE_SIZE
52-
53-
/* Resolve non-secure RAM start */
54-
#undef MBED_RAM_START
55-
#define MBED_RAM_START NS_DATA_START
56-
57-
/* Resolve non-secure RAM size */
58-
#undef MBED_RAM_SIZE
59-
#define MBED_RAM_SIZE NS_DATA_SIZE
60-
61-
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
62-
* MBED_APP_xxx macros to linker files even though they mean the same thing.
63-
* Because this file is to include by both C/C++ files and linker files, we add
64-
* these macros according to the others for consistency when they are missing
65-
* in compile or link stage. */
66-
67-
#ifndef APPLICATION_ADDR
68-
#ifdef MBED_APP_START
69-
#define APPLICATION_ADDR MBED_APP_START
70-
#else
71-
#define APPLICATION_ADDR MBED_ROM_START
72-
#endif
73-
#endif
74-
75-
#ifndef APPLICATION_SIZE
76-
#ifdef MBED_APP_SIZE
77-
#define APPLICATION_SIZE MBED_APP_SIZE
78-
#else
79-
#define APPLICATION_SIZE MBED_ROM_SIZE
80-
#endif
81-
#endif
82-
83-
#ifndef APPLICATION_RAM_ADDR
84-
#ifdef MBED_RAM_APP_START
85-
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
86-
#else
87-
#define APPLICATION_RAM_ADDR MBED_RAM_START
88-
#endif
89-
#endif
90-
91-
#ifndef APPLICATION_RAM_SIZE
92-
#ifdef MBED_RAM_APP_SIZE
93-
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
94-
#else
95-
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
96-
#endif
97-
#endif
98-
99-
#ifndef MBED_APP_START
100-
#define MBED_APP_START APPLICATION_ADDR
101-
#endif
102-
103-
#ifndef MBED_APP_SIZE
104-
#define MBED_APP_SIZE APPLICATION_SIZE
105-
#endif
106-
107-
#ifndef MBED_RAM_APP_START
108-
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
109-
#endif
110-
111-
#ifndef MBED_RAM_APP_SIZE
112-
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
113-
#endif
114-
115-
#if (APPLICATION_ADDR != MBED_APP_START)
116-
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
117-
#endif
118-
119-
#if (APPLICATION_SIZE != MBED_APP_SIZE)
120-
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
121-
#endif
122-
123-
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
124-
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
125-
#endif
12630

127-
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
128-
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
129-
#endif
31+
/* Physical IROM1 start/size */
32+
#undef MBED_ROM_BANK_IROM1_START
33+
#define MBED_ROM_BANK_IROM1_START NS_CODE_START
34+
#undef MBED_ROM_BANK_IROM1_SIZE
35+
#define MBED_ROM_BANK_IROM1_SIZE NS_CODE_SIZE
36+
37+
/* Physical IRAM1 start/size */
38+
#undef MBED_RAM_BANK_IRAM1_START
39+
#define MBED_RAM_BANK_IRAM1_START NS_DATA_START
40+
#undef MBED_RAM_BANK_IRAM1_SIZE
41+
#define MBED_RAM_BANK_IRAM1_SIZE NS_DATA_SIZE
42+
43+
/* Configured IROM1 start/size */
44+
#undef MBED_CONFIGURED_ROM_BANK_IROM1_START
45+
#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START
46+
#undef MBED_CONFIGURED_ROM_BANK_IROM1_SIZE
47+
#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE
48+
49+
/* Configured IRAM1 start/size */
50+
#undef MBED_CONFIGURED_RAM_BANK_IRAM1_START
51+
#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START
52+
#undef MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
53+
#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE
13054

13155
#endif /* __PARTITION_M2354_MEM_H__ */

targets/TARGET_NUVOTON/TARGET_M251/device/M251_mem.h

Lines changed: 22 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -19,115 +19,42 @@
1919
#ifndef __M251_MEM_H__
2020
#define __M251_MEM_H__
2121

22-
/* About M251_mem.h/M251_mem.icf.h
23-
*
24-
* 1. M251_mem.h is created for centralizing memory configuration. It will be included by C/C++ files
25-
* and linker files (except IAR linker file).
26-
* 2. IAR linker doesn't support preprocessor, so M251_mem.icf.h, duplicate of M251_mem.h
27-
* is created for IAR linker file.
28-
* 3. To continue above, we name M251_mem.icf.h instead of M251_mem.icf because:
29-
* (1) Mbed OS build tool may mis-regard M251_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 M251_mem.icf.h instead because *.h files are always present in these builds
33-
* (already there or via copy).
34-
*/
35-
3622
/* Default memory specification
3723
*
3824
* Flash size: 256KiB
3925
* SRAM size: 32KiB
4026
*/
4127

42-
/* Resolve ROM start */
43-
#ifndef MBED_ROM_START
44-
#define MBED_ROM_START (0x0)
45-
#endif
46-
47-
/* Resolve ROM size */
48-
#ifndef MBED_ROM_SIZE
49-
#define MBED_ROM_SIZE (0x40000)
50-
#endif
51-
52-
/* Resolve RAM start */
53-
#ifndef MBED_RAM_START
54-
#define MBED_RAM_START (0x20000000)
55-
#endif
56-
57-
/* Resolve RAM size */
58-
#ifndef MBED_RAM_SIZE
59-
#define MBED_RAM_SIZE (0x8000)
60-
#endif
61-
62-
63-
/* Mbed build tool passes just APPLICATION_xxx macros to C/C++ files and just
64-
* MBED_APP_xxx macros to linker files even though they mean the same thing.
65-
* Because this file is to include by both C/C++ files and linker files, we add
66-
* these macros according to the others for consistency when they are missing
67-
* in compile or link stage. */
68-
69-
#ifndef APPLICATION_ADDR
70-
#ifdef MBED_APP_START
71-
#define APPLICATION_ADDR MBED_APP_START
72-
#else
73-
#define APPLICATION_ADDR MBED_ROM_START
74-
#endif
28+
/* Physical IROM1 start/size */
29+
#if !defined(MBED_ROM_BANK_IROM1_START)
30+
#define MBED_ROM_BANK_IROM1_START 0x0
7531
#endif
32+
#if !defined(MBED_ROM_BANK_IROM1_SIZE)
33+
#define MBED_ROM_BANK_IROM1_SIZE 0x40000
34+
#endif
7635

77-
#ifndef APPLICATION_SIZE
78-
#ifdef MBED_APP_SIZE
79-
#define APPLICATION_SIZE MBED_APP_SIZE
80-
#else
81-
#define APPLICATION_SIZE MBED_ROM_SIZE
36+
/* Physical IRAM1 start/size */
37+
#if !defined(MBED_RAM_BANK_IRAM1_START)
38+
#define MBED_RAM_BANK_IRAM1_START 0x20000000
8239
#endif
40+
#if !defined(MBED_RAM_BANK_IRAM1_SIZE)
41+
#define MBED_RAM_BANK_IRAM1_SIZE 0x8000
8342
#endif
8443

85-
#ifndef APPLICATION_RAM_ADDR
86-
#ifdef MBED_RAM_APP_START
87-
#define APPLICATION_RAM_ADDR MBED_RAM_APP_START
88-
#else
89-
#define APPLICATION_RAM_ADDR MBED_RAM_START
90-
#endif
44+
/* Configured IROM1 start/size */
45+
#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_START)
46+
#define MBED_CONFIGURED_ROM_BANK_IROM1_START MBED_ROM_BANK_IROM1_START
9147
#endif
48+
#if !defined(MBED_CONFIGURED_ROM_BANK_IROM1_SIZE)
49+
#define MBED_CONFIGURED_ROM_BANK_IROM1_SIZE MBED_ROM_BANK_IROM1_SIZE
50+
#endif
9251

93-
#ifndef APPLICATION_RAM_SIZE
94-
#ifdef MBED_RAM_APP_SIZE
95-
#define APPLICATION_RAM_SIZE MBED_RAM_APP_SIZE
96-
#else
97-
#define APPLICATION_RAM_SIZE MBED_RAM_SIZE
98-
#endif
52+
/* Configured IRAM1 start/size */
53+
#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_START)
54+
#define MBED_CONFIGURED_RAM_BANK_IRAM1_START MBED_RAM_BANK_IRAM1_START
9955
#endif
100-
101-
#ifndef MBED_APP_START
102-
#define MBED_APP_START APPLICATION_ADDR
103-
#endif
104-
105-
#ifndef MBED_APP_SIZE
106-
#define MBED_APP_SIZE APPLICATION_SIZE
107-
#endif
108-
109-
#ifndef MBED_RAM_APP_START
110-
#define MBED_RAM_APP_START APPLICATION_RAM_ADDR
111-
#endif
112-
113-
#ifndef MBED_RAM_APP_SIZE
114-
#define MBED_RAM_APP_SIZE APPLICATION_RAM_SIZE
115-
#endif
116-
117-
#if (APPLICATION_ADDR != MBED_APP_START)
118-
#error("APPLICATION_ADDR and MBED_APP_START are not the same!!!")
119-
#endif
120-
121-
#if (APPLICATION_SIZE != MBED_APP_SIZE)
122-
#error("APPLICATION_SIZE and MBED_APP_SIZE are not the same!!!")
123-
#endif
124-
125-
#if (APPLICATION_RAM_ADDR != MBED_RAM_APP_START)
126-
#error("APPLICATION_RAM_ADDR and MBED_RAM_APP_START are not the same!!!")
127-
#endif
128-
129-
#if (APPLICATION_RAM_SIZE != MBED_RAM_APP_SIZE)
130-
#error("APPLICATION_RAM_SIZE and MBED_RAM_APP_SIZE are not the same!!!")
56+
#if !defined(MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE)
57+
#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE
13158
#endif
13259

13360
#endif /* __M251_MEM_H__ */

targets/TARGET_NUVOTON/TARGET_M251/device/TOOLCHAIN_GCC_ARM/M251.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ StackSize = MBED_CONF_TARGET_BOOT_STACK_SIZE;
3232

3333
MEMORY
3434
{
35-
VECTORS (rx) : ORIGIN = MBED_APP_START, LENGTH = 0x00000400
36-
FLASH (rx) : ORIGIN = MBED_APP_START + 0x400, LENGTH = MBED_APP_SIZE - 0x400
37-
RAM_INTERN (rwx) : ORIGIN = MBED_RAM_APP_START, LENGTH = MBED_RAM_APP_SIZE
35+
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400
36+
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x400
37+
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
3838
}
3939

4040
/* Must match cmsis_nvic.h */

targets/TARGET_NUVOTON/TARGET_M251/flash_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ static const flash_algo_t flash_algo_config = {
9494

9595
/* Secure flash */
9696
static const sector_info_t sectors_info[] = {
97-
{MBED_ROM_START, 0x200}, // (start, sector size)
97+
{MBED_ROM_BANK_IROM1_START, 0x200}, // (start, sector size)
9898
};
9999

100100
/* Secure flash */
101101
static const flash_target_config_t flash_target_config = {
102102
.page_size = 4, // 4 bytes
103103
// Here page_size is program unit, which is different
104104
// than FMC definition.
105-
.flash_start = MBED_ROM_START,
106-
.flash_size = MBED_ROM_SIZE,
105+
.flash_start = MBED_ROM_BANK_IROM1_START,
106+
.flash_size = MBED_ROM_BANK_IROM1_SIZE,
107107
.sectors = sectors_info,
108108
.sector_info_count = sizeof(sectors_info) / sizeof(sector_info_t)
109109
};

0 commit comments

Comments
 (0)