Merge pull request #9480 from deepikabhavnani/core_arch_v8m

Refactor core optional parameters (FPU + DSP + Security extensions)
pull/9021/head
Cruz Monrreal 2019-01-31 10:22:09 -06:00 committed by GitHub
commit c9e00cf781
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 93 deletions

View File

@ -52,8 +52,8 @@ CORE_LABELS = {
"Cortex-M33-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
"Cortex-M33F": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
"Cortex-M33F-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
"Cortex-M33FD": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
"Cortex-M33FD-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"]
"Cortex-M33FE": ["M33", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"],
"Cortex-M33FE-NS": ["M33", "M33_NS", "CORTEX_M", "LIKE_CORTEX_M33", "CORTEX"]
}
CORE_ARCH = {
@ -73,8 +73,8 @@ CORE_ARCH = {
"Cortex-M33F": 8,
"Cortex-M33-NS": 8,
"Cortex-M33F-NS": 8,
"Cortex-M33FD": 8,
"Cortex-M33FD-NS": 8,
"Cortex-M33FE": 8,
"Cortex-M33FE-NS": 8,
}
################################################################################

View File

@ -78,8 +78,8 @@ class mbedToolchain:
"Cortex-M33": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
"Cortex-M33F-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
"Cortex-M33F": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM"],
"Cortex-M33FD-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
"Cortex-M33FD": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
"Cortex-M33FE-NS": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "DOMAIN_NS=1", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
"Cortex-M33FE": ["__CORTEX_M33", "ARM_MATH_ARMV8MML", "__FPU_PRESENT=1U", "__CMSIS_RTOS", "__MBED_CMSIS_RTOS_CM", "__DSP_PRESENT=1U"],
}
MBED_CONFIG_FILE_NAME="mbed_config.h"

View File

@ -25,6 +25,7 @@ from tempfile import mkstemp
from shutil import rmtree
from distutils.version import LooseVersion
from tools.targets import CORE_ARCH
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool
from tools.utils import mkdir, NotSupportedException, run_cmd
@ -363,7 +364,7 @@ class ARMC6(ARM_STD):
SUPPORTED_CORES = ["Cortex-M0", "Cortex-M0+", "Cortex-M3", "Cortex-M4",
"Cortex-M4F", "Cortex-M7", "Cortex-M7F", "Cortex-M7FD",
"Cortex-M23", "Cortex-M23-NS", "Cortex-M33", "Cortex-M33F",
"Cortex-M33-NS", "Cortex-M33F-NS", "Cortex-M33FD-NS", "Cortex-M33FD",
"Cortex-M33-NS", "Cortex-M33F-NS", "Cortex-M33FE-NS", "Cortex-M33FE",
"Cortex-A9"]
ARMCC_RANGE = (LooseVersion("6.10"), LooseVersion("7.0"))
@ -380,76 +381,67 @@ class ARMC6(ARM_STD):
if not set(("ARM", "ARMC6")).intersection(set(target.supported_toolchains)):
raise NotSupportedException("ARM/ARMC6 compiler support is required for ARMC6 build")
if target.core.lower().endswith("fd"):
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-2])
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-2])
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-2]
elif target.core.lower().endswith("fd-ns"):
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-5])
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-5])
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-5]
elif target.core.lower().endswith("f"):
self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-1])
self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-1])
self.SHEBANG += " -mcpu=%s" % target.core.lower()[:-1]
elif target.core.startswith("Cortex-M33"):
self.flags['common'].append("-mcpu=cortex-m33+nodsp")
self.flags['common'].append("-mfpu=none")
self.flags['ld'].append("--cpu=Cortex-M33.no_dsp.no_fp")
elif not target.core.startswith("Cortex-M23"):
self.flags['common'].append("-mcpu=%s" % target.core.lower())
self.flags['ld'].append("--cpu=%s" % target.core.lower())
self.SHEBANG += " -mcpu=%s" % target.core.lower()
core = target.core
if CORE_ARCH[target.core] == 8:
if (not target.core.endswith("-NS")) and kwargs.get('build_dir', False):
# Create Secure library
build_dir = kwargs['build_dir']
secure_file = join(build_dir, "cmse_lib.o")
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
if target.core == "Cortex-M4F":
# Add linking time preprocessor macro DOMAIN_NS
if target.core.endswith("-NS"):
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
self.flags["ld"].append(define_string)
core = target.core[:-3]
else:
# Add secure build flag
self.flags['cxx'].append("-mcmse")
self.flags['c'].append("-mcmse")
cpu = {
"Cortex-M0+": "cortex-m0plus",
"Cortex-M4F": "cortex-m4",
"Cortex-M7F": "cortex-m7",
"Cortex-M7FD": "cortex-m7",
"Cortex-M33": "cortex-m33+no_dsp+no_fp",
"Cortex-M33F": "cortex-m33+no_dsp",
"Cortex-M33FE": "cortex-m33"}.get(core, core)
cpu = cpu.lower()
self.flags['common'].append("-mcpu=%s" % cpu)
self.SHEBANG += " -mcpu=%s" % cpu
# FPU handling
if core == "Cortex-M4F":
self.flags['common'].append("-mfpu=fpv4-sp-d16")
self.flags['common'].append("-mfloat-abi=hard")
elif target.core == "Cortex-M7F":
self.flags['ld'].append("--cpu=cortex-m4")
elif core == "Cortex-M7F":
self.flags['common'].append("-mfpu=fpv5-sp-d16")
self.flags['common'].append("-mfloat-abi=hard")
elif target.core == "Cortex-M7FD":
self.flags['ld'].append("--cpu=cortex-m7.fp.sp")
elif core == "Cortex-M7FD":
self.flags['common'].append("-mfpu=fpv5-d16")
self.flags['common'].append("-mfloat-abi=hard")
elif target.core.startswith("Cortex-M23"):
self.flags['common'].append("-march=armv8-m.base")
elif target.core.startswith("Cortex-M33F"):
self.flags['ld'].append("--cpu=cortex-m7")
elif core == "Cortex-M33F":
self.flags['common'].append("-mfpu=fpv5-sp-d16")
self.flags['common'].append("-mfloat-abi=hard")
if ((target.core.startswith("Cortex-M23") or
target.core.startswith("Cortex-M33")) and
not target.core.endswith("-NS")):
self.flags['cxx'].append("-mcmse")
self.flags['c'].append("-mcmse")
# Create Secure library
if ((target.core.startswith("Cortex-M23") or
target.core.startswith("Cortex-M33")) and
not target.core.endswith("-NS") and
kwargs.get('build_dir', False)):
build_dir = kwargs['build_dir']
secure_file = join(build_dir, "cmse_lib.o")
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
# Add linking time preprocessor macro DOMAIN_NS
if ((target.core.startswith("Cortex-M23") or
target.core.startswith("Cortex-M33")) and
target.core.endswith("-NS")):
define_string = self.make_ld_define("DOMAIN_NS", "0x1")
self.flags["ld"].append(define_string)
self.flags['ld'].append("--cpu=cortex-m33.no_dsp")
elif core == "Cortex-M33":
self.flags['ld'].append("--cpu=cortex-m33.no_dsp.no_fp")
else:
self.flags['ld'].append("--cpu=%s" % cpu)
asm_cpu = {
"Cortex-M0+": "Cortex-M0",
"Cortex-M4F": "Cortex-M4.fp",
"Cortex-M7F": "Cortex-M7.fp.sp",
"Cortex-M7FD": "Cortex-M7.fp.dp",
"Cortex-M23-NS": "Cortex-M23",
"Cortex-M33": "Cortex-M33.no_dsp.no_fp",
"Cortex-M33-NS": "Cortex-M33.no_dsp.no_fp",
"Cortex-M33F": "Cortex-M33.no_dsp",
"Cortex-M33F-NS": "Cortex-M33.no_dsp",
"Cortex-M33FD": "Cortex-M33",
"Cortex-M33FD-NS": "Cortex-M33"}.get(target.core, target.core)
"Cortex-M33FE": "Cortex-M33"}.get(core, core)
self.flags['asm'].append("--cpu=%s" % asm_cpu)

View File

@ -20,6 +20,7 @@ from os import getenv
from distutils.spawn import find_executable
from distutils.version import LooseVersion
from tools.targets import CORE_ARCH
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
from tools.hooks import hook_tool
from tools.utils import run_cmd, NotSupportedException
@ -52,37 +53,46 @@ class GCC(mbedToolchain):
self.flags["common"].append("-DMBED_RTOS_SINGLE_THREAD")
self.flags["ld"].append("--specs=nano.specs")
if target.core == "Cortex-M0+":
self.cpu = ["-mcpu=cortex-m0plus"]
elif target.core.startswith("Cortex-M4"):
self.cpu = ["-mcpu=cortex-m4"]
elif target.core.startswith("Cortex-M7"):
self.cpu = ["-mcpu=cortex-m7"]
elif target.core.startswith("Cortex-M23"):
self.cpu = ["-mcpu=cortex-m23"]
elif target.core.startswith("Cortex-M33FD"):
self.cpu = ["-mcpu=cortex-m33"]
elif target.core.startswith("Cortex-M33F"):
self.cpu = ["-mcpu=cortex-m33+nodsp"]
elif target.core.startswith("Cortex-M33"):
core = target.core
if CORE_ARCH[target.core] == 8:
# Add linking time preprocessor macro DOMAIN_NS
if target.core.endswith("-NS"):
self.flags["ld"].append("-DDOMAIN_NS=1")
core = target.core[:-3]
else:
self.cpu.append("-mcmse")
self.flags["ld"].extend([
"-Wl,--cmse-implib",
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
])
cpu = {
"Cortex-M0+": "cortex-m0plus",
"Cortex-M4F": "cortex-m4",
"Cortex-M7F": "cortex-m7",
"Cortex-M7FD": "cortex-m7",
"Cortex-M33F": "cortex-m33+no_dsp",
"Cortex-M33FE": "cortex-m33"}.get(core, core)
if core == "Cortex-M33":
self.cpu = ["-march=armv8-m.main"]
else:
self.cpu = ["-mcpu={}".format(target.core.lower())]
self.cpu = ["-mcpu={}".format(cpu.lower())]
if target.core.startswith("Cortex-M"):
self.cpu.append("-mthumb")
# FPU handling, M7 possibly to have double FPU
if target.core == "Cortex-M4F":
if core == "Cortex-M4F":
self.cpu.append("-mfpu=fpv4-sp-d16")
self.cpu.append("-mfloat-abi=softfp")
elif target.core == "Cortex-M7F":
elif core == "Cortex-M7F":
self.cpu.append("-mfpu=fpv5-sp-d16")
self.cpu.append("-mfloat-abi=softfp")
elif target.core == "Cortex-M7FD":
elif core == "Cortex-M7FD":
self.cpu.append("-mfpu=fpv5-d16")
self.cpu.append("-mfloat-abi=softfp")
elif target.core.startswith("Cortex-M33F"):
elif core.startswith("Cortex-M33F"):
self.cpu.append("-mfpu=fpv5-sp-d16")
self.cpu.append("-mfloat-abi=softfp")
@ -94,21 +104,6 @@ class GCC(mbedToolchain):
self.cpu.append("-mfloat-abi=hard")
self.cpu.append("-mno-unaligned-access")
if ((target.core.startswith("Cortex-M23") or
target.core.startswith("Cortex-M33")) and
not target.core.endswith("-NS")):
self.cpu.append("-mcmse")
self.flags["ld"].extend([
"-Wl,--cmse-implib",
"-Wl,--out-implib=%s" % join(build_dir, "cmse_lib.o")
])
# Add linking time preprocessor macro DOMAIN_NS
if ((target.core.startswith("Cortex-M23") or
target.core.startswith("Cortex-M33")) and
target.core.endswith("-NS")):
self.flags["ld"].append("-DDOMAIN_NS=1")
self.flags["common"] += self.cpu
main_cc = join(tool_path, "arm-none-eabi-gcc")