Skip to content

Commit

Permalink
M467: Refine config to support HyperRAM
Browse files Browse the repository at this point in the history
This uses memory bank information to describe HyperRAM.
  • Loading branch information
ccli8 committed Feb 12, 2025
1 parent 631b9d7 commit f91a452
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 18 deletions.
19 changes: 5 additions & 14 deletions targets/TARGET_NUVOTON/TARGET_M460/device/M460_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,11 @@
#define MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE MBED_RAM_BANK_IRAM1_SIZE
#endif

/* Physical HYPERRAM1 start/size */
#if !defined(MBED_RAM_BANK_HYPERRAM1_START)
#define MBED_RAM_BANK_HYPERRAM1_START 0x80000000
#endif
#if !defined(MBED_RAM_BANK_HYPERRAM1_SIZE)
#define MBED_RAM_BANK_HYPERRAM1_SIZE 0x800000
#endif

/* Configured HYPERRAM1 start/size */
#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START)
#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START MBED_RAM_BANK_HYPERRAM1_START
#endif
#if !defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE)
#define MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE MBED_RAM_BANK_HYPERRAM1_SIZE
#if defined(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START) && \
(MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE != 0x0)
#define NU_HAVE_HYPERRAM1 1
#else
#define NU_HAVE_HYPERRAM1 0
#endif

#endif /* __M460_MEM_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ MEMORY
VECTORS (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START, LENGTH = 0x00000400
FLASH (rx) : ORIGIN = MBED_CONFIGURED_ROM_BANK_IROM1_START + 0x400, LENGTH = MBED_CONFIGURED_ROM_BANK_IROM1_SIZE - 0x00000400
RAM_INTERN (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_IRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_IRAM1_SIZE
#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
HYPERRAM (rwx) : ORIGIN = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_START, LENGTH = MBED_CONFIGURED_RAM_BANK_HYPERRAM1_SIZE
#endif
}

/**
Expand Down Expand Up @@ -93,6 +95,7 @@ SECTIONS
LONG (ADDR(.data))
LONG (SIZEOF(.data))

#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
/* .text.nu.hyperram located at HyperRAM */
LONG (LOADADDR(.text.nu.hyperram))
LONG (ADDR(.text.nu.hyperram))
Expand All @@ -102,6 +105,7 @@ SECTIONS
LONG (LOADADDR(.data.nu.hyperram))
LONG (ADDR(.data.nu.hyperram))
LONG (SIZEOF(.data.nu.hyperram))
#endif

__copy_table_end__ = .;
} > FLASH
Expand All @@ -114,13 +118,16 @@ SECTIONS
LONG (ADDR(.bss))
LONG (SIZEOF(.bss))

#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
/* .bss.nu.hyperram located at HyperRAM */
LONG (ADDR(.bss.nu.hyperram))
LONG (SIZEOF(.bss.nu.hyperram))
#endif

__zero_table_end__ = .;
} > FLASH

#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
/* First match used, so place in front of .text */
.text.nu.hyperram :
{
Expand All @@ -130,6 +137,7 @@ SECTIONS
Image$$NU_HYPERRAM$$RO$$Base = ADDR(.text.nu.hyperram);
Image$$NU_HYPERRAM$$RO$$Limit = ADDR(.text.nu.hyperram) + SIZEOF(.text.nu.hyperram);
Image$$NU_HYPERRAM$$RO$$Length = SIZEOF(.text.nu.hyperram);
#endif

.text :
{
Expand Down Expand Up @@ -208,6 +216,7 @@ SECTIONS
__CRASH_DATA_RAM_END__ = .; /* Define a global symbol at data end */
} > RAM_INTERN

#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
/* First match used, so place in front of .data */
.data.nu.hyperram :
{
Expand All @@ -217,6 +226,7 @@ SECTIONS
Image$$NU_HYPERRAM$$RW$$Base = ADDR(.data.nu.hyperram);
Image$$NU_HYPERRAM$$RW$$Limit = ADDR(.data.nu.hyperram) + SIZEOF(.data.nu.hyperram);
Image$$NU_HYPERRAM$$RW$$Length = SIZEOF(.data.nu.hyperram);
#endif

.data :
{
Expand Down Expand Up @@ -266,6 +276,7 @@ SECTIONS
__uninitialized_end = .;
} > RAM_INTERN

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

.bss (NOLOAD):
{
Expand Down
8 changes: 4 additions & 4 deletions targets/TARGET_NUVOTON/TARGET_M460/device/system_M460.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*****************************************************************************/

#include "NuMicro.h"

#include "M460_mem.h"

/*----------------------------------------------------------------------------
DEFINES
Expand Down Expand Up @@ -93,7 +93,7 @@ void SystemInit (void)
/* Lock protected registers */
SYS_LockReg();

#if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE
#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE
/* Initialize HBI for HyperRAM */
void nu_hbi_init(void);
nu_hbi_init();
Expand Down Expand Up @@ -138,7 +138,7 @@ int32_t nu_hyperram_used(void)
return NU_HYPERRAM_USED;
}

#if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE
#if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE

/* Simple array size macro without type check */
#define _NU_ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
Expand Down Expand Up @@ -187,4 +187,4 @@ void nu_hbi_init(void)
SYS_LockReg();
}

#endif /* #if defined(MBED_CONF_TARGET_HBI_ENABLE) && MBED_CONF_TARGET_HBI_ENABLE */
#endif /* #if NU_HAVE_HYPERRAM1 && MBED_CONF_TARGET_HBI_ENABLE */
17 changes: 17 additions & 0 deletions targets/targets.json5
Original file line number Diff line number Diff line change
Expand Up @@ -7963,6 +7963,23 @@ mode is recommended for target MCUs with small amounts of flash and RAM.",
"hbi-mfp-reg-msk-list": "0xFFFFFF00, 0xFFFFFFFF, 0xFFFF0000, 0xFFFFFFFF",
"hbi-mfp-reg-val-list": "0x10101000, 0x10101010, 0x10100000, 0x10101010"
},
"memory_banks": {
"HYPERRAM1": {
"access": {
"execute": false,
"non_secure": false,
"non_secure_callable": false,
"peripheral": false,
"read": true,
"secure": false,
"write": true
},
"default": true,
"size": 0x800000,
"start": 0x80000000,
"startup": false
}
},
"image_url": "https://os.mbed.com/media/cache/platforms/NuMaker-IoT-M467_V1.1_F.png.250x250_q85.png"
},
"MCU_M480": {
Expand Down

0 comments on commit f91a452

Please sign in to comment.