Skip to content

Commit c81350a

Browse files
committed
M467: Refine config to support HyperRAM
This uses memory bank information to describe HyperRAM.
1 parent 58c5e6b commit c81350a

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
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/targets.json5

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7963,6 +7963,23 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
79637963
"hbi-mfp-reg-msk-list": "0xFFFFFF00, 0xFFFFFFFF, 0xFFFF0000, 0xFFFFFFFF",
79647964
"hbi-mfp-reg-val-list": "0x10101000, 0x10101010, 0x10100000, 0x10101010"
79657965
},
7966+
"memory_banks": {
7967+
"HYPERRAM1": {
7968+
"access": {
7969+
"execute": false,
7970+
"non_secure": false,
7971+
"non_secure_callable": false,
7972+
"peripheral": false,
7973+
"read": true,
7974+
"secure": false,
7975+
"write": true
7976+
},
7977+
"default": true,
7978+
"size": 0x800000,
7979+
"start": 0x80000000,
7980+
"startup": false
7981+
}
7982+
},
79667983
"image_url": "https://os.mbed.com/media/cache/platforms/NuMaker-IoT-M467_V1.1_F.png.250x250_q85.png"
79677984
},
79687985
"MCU_M480": {

0 commit comments

Comments
 (0)