Skip to content

Commit 22a4f41

Browse files
New version of memory bank information system
1 parent c1e3c86 commit 22a4f41

File tree

7 files changed

+102
-28
lines changed

7 files changed

+102
-28
lines changed

targets/cmsis_mcu_descriptions.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8178,8 +8178,8 @@
81788178
"write": false
81798179
},
81808180
"default": true,
8181-
"size": 1048576,
8182-
"start": 135266304,
8181+
"size": 0x200000,
8182+
"start": 0x08000000,
81838183
"startup": true
81848184
},
81858185
"RAM_D3": {

targets/targets.json5

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3690,10 +3690,13 @@
36903690
"ARDUINO_PORTENTA_H7_M7": {
36913691
"inherits": ["ARDUINO_PORTENTA_H7"],
36923692
"core": "Cortex-M7FD",
3693-
"mbed_rom_start": "0x08000000",
3694-
"mbed_rom_size" : "0x100000",
3695-
"mbed_ram_start": "0x24000000",
3696-
"mbed_ram_size" : "0x80000",
3693+
"memory_bank_config": {
3694+
// Select flash bank 1
3695+
"IROM1": {
3696+
"start": 0x08000000,
3697+
"size": 0x100000
3698+
}
3699+
},
36973700
"extra_labels_add": [
36983701
"STM32H747xI_CM7"
36993702
],
@@ -3704,10 +3707,13 @@
37043707
"ARDUINO_PORTENTA_H7_M4": {
37053708
"inherits": ["ARDUINO_PORTENTA_H7"],
37063709
"core": "Cortex-M4F",
3707-
"mbed_rom_start": "0x08100000",
3708-
"mbed_rom_size" : "0x100000",
3709-
"mbed_ram_start": "0x10000000",
3710-
"mbed_ram_size" : "0x48000",
3710+
"memory_bank_config": {
3711+
// Select flash bank 2
3712+
"IROM1": {
3713+
"start": 0x08100000,
3714+
"size": 0x100000
3715+
}
3716+
},
37113717
"extra_labels_add": [
37123718
"STM32H747xI_CM4"
37133719
],
@@ -5309,6 +5315,35 @@
53095315
"overrides": {
53105316
"network-default-interface-type": "ETHERNET"
53115317
},
5318+
"memory_banks": {
5319+
"SDRAM": {
5320+
"access": {
5321+
"execute": false,
5322+
"peripheral": false,
5323+
"read": true,
5324+
"secure": false,
5325+
"write": true
5326+
},
5327+
"default": false,
5328+
"size": 0x10000000, // 256MiB
5329+
"start": 0x80000000,
5330+
"startup": false
5331+
},
5332+
// MIMXRT1050 EVK uses hyperflash by default
5333+
"EXT_FLASH": {
5334+
"access": {
5335+
"execute": true,
5336+
"peripheral": false,
5337+
"read": true,
5338+
"secure": false,
5339+
"write": false
5340+
},
5341+
"default": true,
5342+
"size": 0x4000000, // 64MiB
5343+
"start": 0x60000000,
5344+
"startup": true
5345+
}
5346+
},
53125347
"bootloader_supported": true,
53135348
"device_name": "MIMXRT1052DVL6A",
53145349
"image_url": "https://www.nxp.com/assets/images/en/dev-board-image/IMX_RT1050-EVKB_TOP-LR.jpg"
@@ -5335,6 +5370,35 @@
53355370
"overrides": {
53365371
"network-default-interface-type": "ETHERNET"
53375372
},
5373+
"memory_banks": {
5374+
"SDRAM": {
5375+
"access": {
5376+
"execute": false,
5377+
"peripheral": false,
5378+
"read": true,
5379+
"secure": false,
5380+
"write": true
5381+
},
5382+
"default": false,
5383+
"size": 0x10000000, // 256MiB
5384+
"start": 0x80000000,
5385+
"startup": false
5386+
},
5387+
// MIMXRT1050 EVK uses QSPI flash by default
5388+
"EXT_FLASH": {
5389+
"access": {
5390+
"execute": true,
5391+
"peripheral": false,
5392+
"read": true,
5393+
"secure": false,
5394+
"write": false
5395+
},
5396+
"default": true,
5397+
"size": 0x800000, // 8MiB
5398+
"start": 0x60000000,
5399+
"startup": true
5400+
}
5401+
},
53385402
"device_name": "MIMXRT1062DVL6B",
53395403
"image_url": "https://www.nxp.com/assets/images/en/dev-board-image/X-MIMXRT1060-EVK-BOARD-BOTTOM.jpg"
53405404
},

tools/cmake/mbed_generate_configuration.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ if(MBED_NEED_TO_RECONFIGURE)
9797
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake)
9898

9999
set(MBEDTOOLS_CONFIGURE_COMMAND ${Python3_EXECUTABLE}
100-
-c "import mbed_tools.cli.main\; exit(mbed_tools.cli.main.cli())" # This is used instead of invoking mbed_tools as a script, because it might not be on the user's PATH.
100+
-m mbed_tools.cli.main
101101
-v # without -v, warnings (e.g. "you have tried to override a nonexistent parameter") do not get printed
102102
configure
103103
-t GCC_ARM # GCC_ARM is currently the only supported toolchain
@@ -120,7 +120,7 @@ if(MBED_NEED_TO_RECONFIGURE)
120120

121121
if((NOT MBEDTOOLS_CONFIGURE_RESULT EQUAL 0) OR (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mbed_config.cmake))
122122
string(JOIN " " MBEDTOOLS_COMMAND_SPC_SEP ${MBEDTOOLS_CONFIGURE_COMMAND})
123-
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was ${MBEDTOOLS_COMMAND_SPC_SEP}")
123+
message(FATAL_ERROR "mbedtools configure failed! Cannot build this project. Command was cd ${CMAKE_CURRENT_LIST_DIR}/../python && ${MBEDTOOLS_COMMAND_SPC_SEP}")
124124
endif()
125125

126126
endif()

tools/python/mbed_tools/build/_internal/templates/mbed_config.tmpl

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,14 @@ set(MBED_TARGET_DEFINITIONS{% for component in components %}
5757
{% for form_factor in supported_form_factors %}
5858
TARGET_FF_{{form_factor}}
5959
{%- endfor %}
60-
{% if mbed_rom_start is defined %}
61-
MBED_ROM_START={{ mbed_rom_start | to_hex }}
62-
{%- endif %}
63-
{% if mbed_rom_size is defined %}
64-
MBED_ROM_SIZE={{ mbed_rom_size | to_hex }}
65-
{%- endif %}
66-
{% if mbed_ram_start is defined %}
67-
MBED_RAM_START={{ mbed_ram_start | to_hex }}
68-
{%- endif %}
69-
{% if mbed_ram_size is defined %}
70-
MBED_RAM_SIZE={{ mbed_ram_size | to_hex }}
71-
{%- endif %}
7260
TARGET_LIKE_MBED
7361
__MBED__=1
7462
)
7563

7664
# config
7765
set(MBED_CONFIG_DEFINITIONS
66+
67+
# Config settings
7868
{% for setting in config %}
7969
{%- if setting.macro_name -%}
8070
{%- set setting_name = setting.macro_name -%}
@@ -90,7 +80,14 @@ set(MBED_CONFIG_DEFINITIONS
9080
"{{setting_name}}={{value}}"
9181
{% endif -%}
9282
{%- endfor -%}
83+
84+
# Macros from JSON
9385
{% for macro in macros %}
9486
"{{macro|replace("\"", "\\\"")}}"
9587
{%- endfor %}
88+
89+
# Memory bank macros
90+
{% for macro in memory_bank_macros | sort %}
91+
{{macro}}
92+
{%- endfor %}
9693
)

tools/python/mbed_tools/build/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
from mbed_tools.targets import get_target_by_name
1313
from mbed_tools.build._internal.cmake_file import render_mbed_config_cmake_template
1414
from mbed_tools.build._internal.config.assemble_build_config import Config, assemble_config
15+
from mbed_tools.build._internal.memory_banks import incorporate_memory_bank_data_from_cmsis, process_memory_banks
1516
from mbed_tools.build._internal.write_files import write_file
1617
from mbed_tools.build.exceptions import MbedBuildError
1718

1819
CMAKE_CONFIG_FILE = "mbed_config.cmake"
20+
MEMORY_BANKS_JSON_FILE = "memory_banks.json"
1921
MBEDIGNORE_FILE = ".mbedignore"
2022

2123

@@ -33,9 +35,11 @@ def generate_config(target_name: str, toolchain: str, program: MbedProgram) -> T
3335
"""
3436
targets_data = _load_raw_targets_data(program)
3537
target_build_attributes = get_target_by_name(target_name, targets_data)
38+
incorporate_memory_bank_data_from_cmsis(target_build_attributes, program)
3639
config = assemble_config(
3740
target_build_attributes, [program.root, program.mbed_os.root], program.files.app_config_file
3841
)
42+
process_memory_banks(config, program.files.cmake_build_dir / MEMORY_BANKS_JSON_FILE)
3943
cmake_file_contents = render_mbed_config_cmake_template(
4044
target_name=target_name, config=config, toolchain_name=toolchain,
4145
)

tools/python/mbed_tools/project/_internal/project_data.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
MBED_OS_REFERENCE_FILE_NAME = "mbed-os.lib"
2828
MBED_OS_DIR_NAME = "mbed-os"
2929
TARGETS_JSON_FILE_PATH = Path("targets", "targets.json5")
30+
CMSIS_MCU_DESCRIPTIONS_JSON_FILE_PATH = Path("targets", "cmsis_mcu_descriptions.json5")
3031
CUSTOM_TARGETS_JSON_FILE_NAME = "custom_targets.json"
3132
CUSTOM_TARGETS_JSON5_FILE_NAME = "custom_targets.json5"
3233

@@ -149,21 +150,29 @@ class MbedOS:
149150

150151
root: Path
151152
targets_json_file: Path
153+
cmsis_mcu_descriptions_json_file: Path
152154

153155
@classmethod
154156
def from_existing(cls, root_path: Path, check_root_path_exists: bool = True) -> "MbedOS":
155157
"""Create MbedOS from a directory containing an existing MbedOS installation."""
156158
targets_json_file = root_path / TARGETS_JSON_FILE_PATH
159+
cmsis_mcu_descriptions_json_file = root_path / CMSIS_MCU_DESCRIPTIONS_JSON_FILE_PATH
157160

158161
if check_root_path_exists and not root_path.exists():
159162
raise ValueError("The mbed-os directory does not exist.")
160163

161164
if root_path.exists() and not targets_json_file.exists():
162-
raise ValueError("This MbedOS copy does not contain a targets.json file.")
165+
raise ValueError(f"This MbedOS copy does not contain a {TARGETS_JSON_FILE_PATH} file.")
163166

164-
return cls(root=root_path, targets_json_file=targets_json_file)
167+
if root_path.exists() and not cmsis_mcu_descriptions_json_file.exists():
168+
raise ValueError(f"This MbedOS copy does not contain a "
169+
f"{CMSIS_MCU_DESCRIPTIONS_JSON_FILE_PATH.name} file.")
170+
171+
return cls(root=root_path, targets_json_file=targets_json_file,
172+
cmsis_mcu_descriptions_json_file=cmsis_mcu_descriptions_json_file)
165173

166174
@classmethod
167175
def from_new(cls, root_path: Path) -> "MbedOS":
168176
"""Create MbedOS from an empty or new directory."""
169-
return cls(root=root_path, targets_json_file=root_path / TARGETS_JSON_FILE_PATH)
177+
return cls(root=root_path, targets_json_file=root_path / TARGETS_JSON_FILE_PATH,
178+
cmsis_mcu_descriptions_json_file=root_path / CMSIS_MCU_DESCRIPTIONS_JSON_FILE_PATH)

tools/python/mbed_tools/targets/_internal/targets_json_parsers/overriding_attribute_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from mbed_tools.targets._internal.targets_json_parsers.accumulating_attribute_parser import ALL_ACCUMULATING_ATTRIBUTES
2626

27-
MERGING_ATTRIBUTES = ("config", "overrides")
27+
MERGING_ATTRIBUTES = ("config", "overrides", "memory_banks", "memory_overrides")
2828
NON_OVERRIDING_ATTRIBUTES = ALL_ACCUMULATING_ATTRIBUTES + ("public", "inherits")
2929

3030

0 commit comments

Comments
 (0)