mirror of https://github.com/ARMmbed/mbed-os.git
PSOC6: refactor M0 image merging, enable export to makefile
Rename the existing PSoC-specific m0_core_img key in targets.json as a more generic hex_filename key. Update makefile exporter to select the subset of resources.hex_files matching the hex_filename value. Without this fix, multiple prebuilt CM0+ hex files are found in the target resources and erroneously passed to the srec_cat tool. The fix is generic so other targets that need post-build hex merging can use this key to pass the correct image to srecord tool. The fix also removes sub_target key: instead, rely hex_filename json key to detect if the hex image merging needs to be done. The sub_target is not used in mbed-os codebase for anything else. It is possible to override the hex file name in mbed_app.json: { "target_overrides": { "*": { "target.hex_filename": "my_custom_m0_image.hex" } }pull/9466/head
parent
5b0daadd18
commit
a48ee113ea
|
@ -7837,12 +7837,11 @@
|
||||||
},
|
},
|
||||||
"FUTURE_SEQUANA": {
|
"FUTURE_SEQUANA": {
|
||||||
"inherits": ["MCU_PSOC6_M4"],
|
"inherits": ["MCU_PSOC6_M4"],
|
||||||
"sub_target": "FUTURE_SEQUANA_M0",
|
|
||||||
"supported_form_factors": ["ARDUINO"],
|
"supported_form_factors": ["ARDUINO"],
|
||||||
"extra_labels_add": ["CY8C63XX", "CORDIO"],
|
"extra_labels_add": ["CY8C63XX", "CORDIO"],
|
||||||
"macros_add": ["CY8C6347BZI_BLD53"],
|
"macros_add": ["CY8C6347BZI_BLD53"],
|
||||||
"detect_code": ["6000"],
|
"detect_code": ["6000"],
|
||||||
"m0_core_img": "psoc63_m0_default_1.02.hex",
|
"hex_filename": "psoc63_m0_default_1.02.hex",
|
||||||
"post_binary_hook": {
|
"post_binary_hook": {
|
||||||
"function": "PSOC6Code.complete"
|
"function": "PSOC6Code.complete"
|
||||||
},
|
},
|
||||||
|
@ -7892,12 +7891,11 @@
|
||||||
},
|
},
|
||||||
"FUTURE_SEQUANA_PSA": {
|
"FUTURE_SEQUANA_PSA": {
|
||||||
"inherits": ["NSPE_Target", "FUTURE_SEQUANA"],
|
"inherits": ["NSPE_Target", "FUTURE_SEQUANA"],
|
||||||
"sub_target": "FUTURE_SEQUANA_M0_PSA",
|
|
||||||
"extra_labels_add": ["PSA"],
|
"extra_labels_add": ["PSA"],
|
||||||
"extra_labels_remove": ["CORDIO"],
|
"extra_labels_remove": ["CORDIO"],
|
||||||
"components_add": ["SPM_MAILBOX"],
|
"components_add": ["SPM_MAILBOX"],
|
||||||
"macros_add": ["PSOC6_DYNSRM_DISABLE=1", "MBEDTLS_PSA_CRYPTO_C"],
|
"macros_add": ["PSOC6_DYNSRM_DISABLE=1", "MBEDTLS_PSA_CRYPTO_C"],
|
||||||
"m0_core_img": "psa_release_1.0.hex",
|
"hex_filename": "psa_release_1.0.hex",
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"secure-rom-start": "0x10000000",
|
"secure-rom-start": "0x10000000",
|
||||||
"secure-rom-size": "0x80000",
|
"secure-rom-size": "0x80000",
|
||||||
|
|
|
@ -54,7 +54,8 @@ class Makefile(Exporter):
|
||||||
"MCU_NRF51Code.binary_hook",
|
"MCU_NRF51Code.binary_hook",
|
||||||
"TEENSY3_1Code.binary_hook",
|
"TEENSY3_1Code.binary_hook",
|
||||||
"LPCTargetCode.lpc_patch",
|
"LPCTargetCode.lpc_patch",
|
||||||
"LPC4088Code.binary_hook"
|
"LPC4088Code.binary_hook",
|
||||||
|
"PSOC6Code.complete"
|
||||||
])
|
])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -83,6 +84,11 @@ class Makefile(Exporter):
|
||||||
sys_libs = [self.prepare_sys_lib(lib) for lib
|
sys_libs = [self.prepare_sys_lib(lib) for lib
|
||||||
in self.toolchain.sys_libs]
|
in self.toolchain.sys_libs]
|
||||||
|
|
||||||
|
hex_files = self.resources.hex_files
|
||||||
|
if hasattr(self.toolchain.target, 'hex_filename'):
|
||||||
|
hex_filename = self.toolchain.target.hex_filename
|
||||||
|
hex_files = list(f for f in hex_files if basename(f) == hex_filename)
|
||||||
|
|
||||||
ctx = {
|
ctx = {
|
||||||
'name': self.project_name,
|
'name': self.project_name,
|
||||||
'to_be_compiled': to_be_compiled,
|
'to_be_compiled': to_be_compiled,
|
||||||
|
@ -92,7 +98,7 @@ class Makefile(Exporter):
|
||||||
'linker_script': self.resources.linker_script,
|
'linker_script': self.resources.linker_script,
|
||||||
'libraries': libraries,
|
'libraries': libraries,
|
||||||
'ld_sys_libs': sys_libs,
|
'ld_sys_libs': sys_libs,
|
||||||
'hex_files': self.resources.hex_files,
|
'hex_files': hex_files,
|
||||||
'vpath': (["../../.."]
|
'vpath': (["../../.."]
|
||||||
if (basename(dirname(dirname(self.export_dir)))
|
if (basename(dirname(dirname(self.export_dir)))
|
||||||
== "projectfiles")
|
== "projectfiles")
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2017-2018 Future Electronics
|
# Copyright (c) 2017-2018 Future Electronics
|
||||||
|
# Copyright (c) 2018-2019 Cypress Semiconductor Corporation
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -114,18 +115,18 @@ def complete_func(message_func, elf0, hexf0, hexf1=None, dest=None):
|
||||||
ihex.write_hex_file(dest if dest else hexf0, write_start_addr=False, byte_count=64)
|
ihex.write_hex_file(dest if dest else hexf0, write_start_addr=False, byte_count=64)
|
||||||
|
|
||||||
# Find Cortex M0 image.
|
# Find Cortex M0 image.
|
||||||
def find_cm0_image(toolchain, resources, elf, hexf):
|
def find_cm0_image(toolchain, resources, elf, hexf, hex_filename):
|
||||||
# Locate user-specified image
|
# Locate user-specified image
|
||||||
from tools.resources import FileType
|
from tools.resources import FileType
|
||||||
hex_files = resources.get_file_paths(FileType.HEX)
|
hex_files = resources.get_file_paths(FileType.HEX)
|
||||||
m0hexf = next((f for f in hex_files if os.path.basename(f) == toolchain.target.m0_core_img), None)
|
m0hexf = next((f for f in hex_files if os.path.basename(f) == hex_filename), None)
|
||||||
if toolchain.target.name.endswith('_PSA'):
|
if toolchain.target.name.endswith('_PSA'):
|
||||||
m0hexf = next((f for f in hex_files if os.path.basename(f) == os.path.basename(hexf)), m0hexf)
|
m0hexf = next((f for f in hex_files if os.path.basename(f) == os.path.basename(hexf)), m0hexf)
|
||||||
|
|
||||||
if m0hexf:
|
if m0hexf:
|
||||||
toolchain.notify.debug("M0 core image file found: %s." % os.path.basename(m0hexf))
|
toolchain.notify.debug("M0 core image file found: %s." % os.path.basename(m0hexf))
|
||||||
else:
|
else:
|
||||||
toolchain.notify.debug("M0 core hex image file %s not found. Aborting." % toolchain.target.m0_core_img)
|
toolchain.notify.debug("M0 core hex image file %s not found. Aborting." % hex_filename)
|
||||||
raise ConfigException("Required M0 core hex image not found.")
|
raise ConfigException("Required M0 core hex image not found.")
|
||||||
|
|
||||||
return m0hexf
|
return m0hexf
|
||||||
|
|
|
@ -583,10 +583,11 @@ class PSOC6Code:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def complete(t_self, resources, elf, binf):
|
def complete(t_self, resources, elf, binf):
|
||||||
from tools.targets.PSOC6 import complete as psoc6_complete
|
from tools.targets.PSOC6 import complete as psoc6_complete
|
||||||
if hasattr(t_self.target, "sub_target"):
|
if hasattr(t_self.target, "hex_filename"):
|
||||||
|
hex_filename = t_self.target.hex_filename
|
||||||
# Completing main image involves merging M0 image.
|
# Completing main image involves merging M0 image.
|
||||||
from tools.targets.PSOC6 import find_cm0_image
|
from tools.targets.PSOC6 import find_cm0_image
|
||||||
m0hexf = find_cm0_image(t_self, resources, elf, binf)
|
m0hexf = find_cm0_image(t_self, resources, elf, binf, hex_filename)
|
||||||
psoc6_complete(t_self, elf, binf, m0hexf)
|
psoc6_complete(t_self, elf, binf, m0hexf)
|
||||||
else:
|
else:
|
||||||
psoc6_complete(t_self, elf, binf)
|
psoc6_complete(t_self, elf, binf)
|
||||||
|
|
Loading…
Reference in New Issue