Skip to content

Commit 0553c11

Browse files
authored
Nuvoton: Refine external RAM config (#436)
* NUC472: Fix no XRAM build failure This fixes linker script is missing on no XRAM build. * NUC472: Refine config to support EBI RAM This refines config to support EBI RAM: 1. Use memory bank information to describe EBI RAM 2. Drop target labels NU_XRAM_SUPPORTED/NU_XRAM_UNSUPPORTED and add target config "target.ebi-enable" to enable EBI RAM * M467: Refine config to support HyperRAM This uses memory bank information to describe HyperRAM.
1 parent ed468ce commit 0553c11

File tree

9 files changed

+104
-283
lines changed

9 files changed

+104
-283
lines changed

targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,17 @@
5757
#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE
5858
#endif
5959

60-
/* Physical HYPERRAM1 start/size */
61-
#if !defined(MBED_RAM_BANK_HYPERRAM1_START)
62-
#define MBED_RAM_BANK_HYPERRAM1_START 0x80000000
63-
#endif
64-
#if !defined(MBED_RAM_BANK_HYPERRAM1_SIZE)
65-
#define MBED_RAM_BANK_HYPERRAM1_SIZE 0x800000
60+
#if defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START) && \
61+
(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE != 0x0)
62+
#define NU_HAVE_HYPERRAM1 1
63+
#else
64+
#define NU_HAVE_HYPERRAM1 0
6665
#endif
6766

68-
/* Configured HYPERRAM1 start/size */
69-
#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START)
70-
#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START MBED_RAM_BANK_HYPERRAM1_START
71-
#endif
72-
#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE)
73-
#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE MBED_RAM_BANK_HYPERRAM1_SIZE
67+
#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
68+
#define NU_ENABLE_HYPERRAM1 1
69+
#else
70+
#define NU_ENABLE_HYPERRAM1 0
7471
#endif
7572

7673
#endif /* __M460_MEM_H__ */

targets/TARGET_NUVOTON/TARGET_M460/device/TOOLCHAIN_GCC_ARM/M467.ld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ MEMORY
3838
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400
3939
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400
4040
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
41+
#if NU_ENABLE_HYPERRAM1
4142
HYPERRAM (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE
43+
#endif
4244
}
4345

4446
/**
@@ -93,6 +95,7 @@ SECTIONS
9395
LONG (ADDR(.data))
9496
LONG (SIZEOF(.data))
9597

98+
#if NU_ENABLE_HYPERRAM1
9699
/* .text.nu.hyperram located at HyperRAM */
97100
LONG (LOADADDR(.text.nu.hyperram))
98101
LONG (ADDR(.text.nu.hyperram))
@@ -102,6 +105,7 @@ SECTIONS
102105
LONG (LOADADDR(.data.nu.hyperram))
103106
LONG (ADDR(.data.nu.hyperram))
104107
LONG (SIZEOF(.data.nu.hyperram))
108+
#endif
105109

106110
__copy_table_end__ = .;
107111
} > FLASH
@@ -114,13 +118,16 @@ SECTIONS
114118
LONG (ADDR(.bss))
115119
LONG (SIZEOF(.bss))
116120

121+
#if NU_ENABLE_HYPERRAM1
117122
/* .bss.nu.hyperram located at HyperRAM */
118123
LONG (ADDR(.bss.nu.hyperram))
119124
LONG (SIZEOF(.bss.nu.hyperram))
125+
#endif
120126

121127
__zero_table_end__ = .;
122128
} > FLASH
123129

130+
#if NU_ENABLE_HYPERRAM1
124131
/* First match used, so place in front of .text */
125132
.text.nu.hyperram :
126133
{
@@ -130,6 +137,7 @@ SECTIONS
130137
Image$$NU_HYPERRAM$$RO$$Base = ADDR(.text.nu.hyperram);
131138
Image$$NU_HYPERRAM$$RO$$Limit = ADDR(.text.nu.hyperram) + SIZEOF(.text.nu.hyperram);
132139
Image$$NU_HYPERRAM$$RO$$Length = SIZEOF(.text.nu.hyperram);
140+
#endif
133141

134142
.text :
135143
{
@@ -208,6 +216,7 @@ SECTIONS
208216
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
209217
} > RAM_INTERN
210218

219+
#if NU_ENABLE_HYPERRAM1
211220
/* First match used, so place in front of .data */
212221
.data.nu.hyperram :
213222
{
@@ -217,6 +226,7 @@ SECTIONS
217226
Image$$NU_HYPERRAM$$RW$$Base = ADDR(.data.nu.hyperram);
218227
Image$$NU_HYPERRAM$$RW$$Limit = ADDR(.data.nu.hyperram) + SIZEOF(.data.nu.hyperram);
219228
Image$$NU_HYPERRAM$$RW$$Length = SIZEOF(.data.nu.hyperram);
229+
#endif
220230

221231
.data :
222232
{
@@ -266,6 +276,7 @@ SECTIONS
266276
__uninitialized_end = .;
267277
} > RAM_INTERN
268278

279+
#if NU_ENABLE_HYPERRAM1
269280
/* First match used, so place in front of .bss */
270281
/* If a variable defined with __attribute__((section())) keyword the
271282
* variable is treated like an initialized variable. To not waste memory
@@ -279,6 +290,7 @@ SECTIONS
279290
Image$$NU_HYPERRAM$$ZI$$Base = ADDR(.bss.nu.hyperram);
280291
Image$$NU_HYPERRAM$$ZI$$Limit = ADDR(.bss.nu.hyperram) + SIZEOF(.bss.nu.hyperram);
281292
Image$$NU_HYPERRAM$$ZI$$Length = SIZEOF(.bss.nu.hyperram);
293+
#endif
282294

283295
.bss (NOLOAD):
284296
{

targets/TARGET_NUVOTON/TARGET_M460/device/system_M460.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*****************************************************************************/
99

1010
#include "NuMicro.h"
11-
11+
#include "M460_mem.h"
1212

1313
/*----------------------------------------------------------------------------
1414
DEFINES
@@ -93,7 +93,7 @@ void SystemInit (void)
9393
/* Lock protected registers */
9494
SYS_LockReg();
9595

96-
#if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE
96+
#if MBED_CONF_TARGET_HBI_ENABLE
9797
/* Initialize HBI for HyperRAM */
9898
void nu_hbi_init(void);
9999
nu_hbi_init();
@@ -138,7 +138,7 @@ int32_t nu_hyperram_used(void)
138138
return NU_HYPERRAM_USED;
139139
}
140140

141-
#if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE
141+
#if MBED_CONF_TARGET_HBI_ENABLE
142142

143143
/* Simple array size macro without type check */
144144
#define _NU_ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
@@ -187,4 +187,4 @@ void nu_hbi_init(void)
187187
SYS_LockReg();
188188
}
189189

190-
#endif /* #if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE */
190+
#endif /* #if MBED_CONF_TARGET_HBI_ENABLE */

targets/TARGET_NUVOTON/TARGET_NUC472/CMakeLists.txt

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,9 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
5-
if("NU_XRAM_SUPPORTED" IN_LIST MBED_TARGET_LABELS)
6-
set(LINKER_FILE_NU_XRAM_SUPPORTED device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_SUPPORTED/NUC472.ld)
7-
elseif("NU_XRAM_UNSUPPORTED" IN_LIST MBED_TARGET_LABELS)
8-
set(LINKER_FILE_NU_XRAM_UNSUPPORTED device/TOOLCHAIN_GCC_ARM/TARGET_NU_XRAM_UNSUPPORTED/NUC472.ld)
9-
endif()
10-
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
11-
if("NU_XRAM_SUPPORTED" IN_LIST MBED_TARGET_LABELS)
12-
set(LINKER_FILE_NU_XRAM_SUPPORTED device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_SUPPORTED/NUC472.sct)
13-
elseif("NU_XRAM_UNSUPPORTED" IN_LIST MBED_TARGET_LABELS)
14-
set(LINKER_FILE_NU_XRAM_UNSUPPORTED device/TOOLCHAIN_ARM_STD/TARGET_NU_XRAM_UNSUPPORTED/NUC472.sct)
15-
endif()
5+
set(LINKER_FILE device/TOOLCHAIN_GCC_ARM/NUC472.ld)
166
endif()
177

18-
add_library(mbed-nu-xram-supported INTERFACE)
19-
mbed_set_linker_script(mbed-nu-xram-supported ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE_NU_XRAM_SUPPORTED})
20-
21-
add_library(mbed-nu-xram-unsupported INTERFACE)
22-
mbed_set_linker_script(mbed-nu-xram-unsupported ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE_NU_XRAM_UNSUPPORTED})
23-
24-
25-
268
add_library(mbed-nuc472 INTERFACE)
279

2810
target_sources(mbed-nuc472
@@ -90,8 +72,10 @@ target_include_directories(mbed-nuc472
9072
device/StdDriver
9173
)
9274

93-
target_link_libraries(mbed-nuc472 INTERFACE mbed-nuvoton)
75+
target_link_libraries(mbed-nuc472 INTERFACE mbed-nuvoton mbed-flash-cmsis-algo)
76+
77+
mbed_set_linker_script(mbed-nuc472 ${CMAKE_CURRENT_SOURCE_DIR}/${LINKER_FILE})
9478

9579
add_library(mbed-numaker-pfm-nuc472 INTERFACE)
9680

97-
target_link_libraries(mbed-numaker-pfm-nuc472 INTERFACE mbed-nuc472 mbed-nu-xram-supported mbed-flash-cmsis-algo)
81+
target_link_libraries(mbed-numaker-pfm-nuc472 INTERFACE mbed-nuc472)

targets/TARGET_NUVOTON/TARGET_NUC472/device/NUC472_mem.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,17 @@
5757
#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE
5858
#endif
5959

60-
/* Physical XRAM1 start/size */
61-
#if !defined(MBED_RAM_BANK_XRAM1_START)
62-
#define MBED_RAM_BANK_XRAM1_START 0x60000000
63-
#endif
64-
#if !defined(MBED_RAM_BANK_XRAM1_SIZE)
65-
#define MBED_RAM_BANK_XRAM1_SIZE 0x100000
60+
#if defined(MBED_CONFIGURED_RAM_BANK_EBIRAM1_START) && \
61+
(MBED_CONFIGURED_RAM_BANK_EBIRAM1_SIZE != 0x0)
62+
#define NU_HAVE_EBIRAM1 1
63+
#else
64+
#define NU_HAVE_EBIRAM1 0
6665
#endif
6766

68-
/* Configured XRAM1 start/size */
69-
#if !defined(MBED_CONFIGURED_RAM_BANK_XRAM1_START)
70-
#define MBED_CONFIGURED_RAM_BANK_XRAM1_START MBED_RAM_BANK_XRAM1_START
71-
#endif
72-
#if !defined(MBED_CONFIGURED_RAM_BANK_XRAM1_SIZE)
73-
#define MBED_CONFIGURED_RAM_BANK_XRAM1_SIZE MBED_RAM_BANK_XRAM1_SIZE
67+
#if NU_HAVE_EBIRAM1 && MBED_CONF_TARGET_EBI_ENABLE
68+
#define NU_ENABLE_EBIRAM1 1
69+
#else
70+
#define NU_ENABLE_EBIRAM1 0
7471
#endif
7572

7673
#endif /* __NUC472_MEM_H__ */
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Nuvoton NUC472 GCC linker script file
33
*/
44

5-
#include "../../NUC472_mem.h"
5+
#include "../NUC472_mem.h"
66

77
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
88
# if defined(MBED_BOOT_STACK_SIZE)
@@ -21,6 +21,9 @@ MEMORY
2121
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400
2222
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400
2323
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
24+
#if NU_ENABLE_EBIRAM1
25+
RAM_EXTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_EBIRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_EBIRAM1_SIZE
26+
#endif
2427
}
2528

2629
/**
@@ -66,7 +69,6 @@ SECTIONS
6669
} > VECTORS
6770

6871

69-
7072
.text :
7173
{
7274

@@ -200,8 +202,12 @@ SECTIONS
200202
*lwip_*.o(COMMON)
201203
*mesh_system.o(.bss*)
202204
__bss_extern_end__ = .;
205+
#if NU_ENABLE_EBIRAM1
206+
} > RAM_EXTERN
207+
#else
203208
} > RAM_INTERN
204-
209+
#endif
210+
205211
.bss (NOLOAD):
206212
{
207213
__bss_start__ = .;
@@ -210,6 +216,16 @@ SECTIONS
210216
__bss_end__ = .;
211217
} > RAM_INTERN
212218

219+
#if NU_ENABLE_EBIRAM1
220+
.heap (NOLOAD):
221+
{
222+
__end__ = .;
223+
end = __end__;
224+
*(.heap*);
225+
. += (ORIGIN(RAM_EXTERN) + LENGTH(RAM_EXTERN) - .);
226+
__HeapLimit = .;
227+
} > RAM_EXTERN
228+
#else
213229
.heap (NOLOAD):
214230
{
215231
__end__ = .;
@@ -218,6 +234,7 @@ SECTIONS
218234
. += (ORIGIN(RAM_INTERN) + LENGTH(RAM_INTERN) - .);
219235
__HeapLimit = .;
220236
} > RAM_INTERN
237+
#endif
221238
PROVIDE(__heap_size = SIZEOF(.heap));
222239
PROVIDE(__mbed_sbrk_start = ADDR(.heap));
223240
PROVIDE(__mbed_krbs_start = ADDR(.heap) + SIZEOF(.heap));

0 commit comments

Comments
 (0)