From 1cfaed10e890634ce1920dfb48fb5db8856fe452 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Mon, 30 Oct 2017 11:01:12 -0500 Subject: [PATCH 1/7] Disable Arm Compiler 5 and Use Arm Compiler 6 by default --- tools/profiles/debug.json | 23 +---------------------- tools/profiles/develop.json | 21 +-------------------- tools/profiles/release.json | 21 +-------------------- tools/toolchains/__init__.py | 5 +---- tools/toolchains/arm.py | 3 ++- 5 files changed, 6 insertions(+), 67 deletions(-) diff --git a/tools/profiles/debug.json b/tools/profiles/debug.json index ad4fab345a7..6679db850af 100644 --- a/tools/profiles/debug.json +++ b/tools/profiles/debug.json @@ -15,7 +15,7 @@ "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", "-Wl,-n"] }, - "ARMC6": { + "ARM": { "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-g", "-O0", "-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions", "-DMULADDC_CANNOT_USE_R7", "-fdata-sections", @@ -26,27 +26,6 @@ "ld": ["--verbose", "--remove", "--legacyalign", "--no_strict_wchar_size", "--no_strict_enum_size"] }, - "ARM": { - "common": ["-c", "--gnu", "-Otime", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O0", "-g", "-DMBED_DEBUG", - "-DMBED_TRAP_ERRORS_ENABLED=1"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--show_full_path"] - }, - "uARM": { - "common": ["-c", "--gnu", "-Otime", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O0", "-D__MICROLIB", "-g", - "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DMBED_DEBUG", - "-DMBED_TRAP_ERRORS_ENABLED=1"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--library_type=microlib"] - }, "IAR": { "common": [ "--no_wrap_diagnostics", "-e", diff --git a/tools/profiles/develop.json b/tools/profiles/develop.json index 6142485a5fa..35f9e54620f 100644 --- a/tools/profiles/develop.json +++ b/tools/profiles/develop.json @@ -14,7 +14,7 @@ "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", "-Wl,-n"] }, - "ARMC6": { + "ARM": { "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Os", "-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions", "-DMULADDC_CANNOT_USE_R7", "-fdata-sections", @@ -24,25 +24,6 @@ "cxx": ["-fno-rtti", "-std=gnu++98"], "ld": ["--legacyalign", "--no_strict_wchar_size", "--no_strict_enum_size"] }, - "ARM": { - "common": ["-c", "--gnu", "-Otime", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O3"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--show_full_path"] - }, - "uARM": { - "common": ["-c", "--gnu", "-Otime", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O3", "-D__MICROLIB", - "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--library_type=microlib"] - }, "IAR": { "common": [ "--no_wrap_diagnostics", "-e", diff --git a/tools/profiles/release.json b/tools/profiles/release.json index eedbce067f6..0dc13b48680 100644 --- a/tools/profiles/release.json +++ b/tools/profiles/release.json @@ -14,7 +14,7 @@ "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", "-Wl,-n"] }, - "ARMC6": { + "ARM": { "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz", "-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions", "-DMULADDC_CANNOT_USE_R7", "-fdata-sections", @@ -24,25 +24,6 @@ "cxx": ["-fno-rtti", "-std=gnu++98"], "ld": ["--legacyalign", "--no_strict_wchar_size", "--no_strict_enum_size"] }, - "ARM": { - "common": ["-c", "--gnu", "-Ospace", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O3", "-DNDEBUG"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--show_full_path"] - }, - "uARM": { - "common": ["-c", "--gnu", "-Ospace", "--split_sections", - "--apcs=interwork", "--brief_diagnostics", "--restrict", - "--multibyte_chars", "-O3", "-D__MICROLIB", - "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DNDEBUG"], - "asm": [], - "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], - "cxx": ["--cpp", "--no_rtti", "--no_vla"], - "ld": ["--library_type=microlib"] - }, "IAR": { "common": [ "--no_wrap_diagnostics", "-e", diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 0df502303f0..dd66a875123 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -1572,7 +1572,6 @@ def report(self): TOOLCHAIN_PATHS = { 'ARM': ARM_PATH, - 'uARM': ARM_PATH, 'ARMC6': ARMC6_PATH, 'GCC_ARM': GCC_ARM_PATH, 'IAR': IAR_PATH @@ -1583,9 +1582,7 @@ def report(self): from tools.toolchains.iar import IAR TOOLCHAIN_CLASSES = { - 'ARM': ARM_STD, - 'uARM': ARM_MICRO, - 'ARMC6': ARMC6, + 'ARM': ARMC6, 'GCC_ARM': GCC_ARM, 'IAR': IAR } diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index 4cc46aa0c2b..6428c2d128f 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -296,7 +296,8 @@ class ARMC6(ARM_STD): "CortexM33-NS"] @staticmethod def check_executable(): - return mbedToolchain.generic_check_executable("ARMC6", "armclang", 1) + return(mbedToolchain.generic_check_executable("ARMC6", "armclang", 1) or + mbedToolchain.generic_check_executable("ARM", "armclang", 1)) def __init__(self, target, *args, **kwargs): mbedToolchain.__init__(self, target, *args, **kwargs) From 3f9330c7ea9e5e488878a3767e169e456a70f699 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 7 Nov 2017 13:27:09 -0600 Subject: [PATCH 2/7] Add ARMC6 support to REALTEK post-binary hook --- tools/targets/REALTEK_RTL8195AM.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/targets/REALTEK_RTL8195AM.py b/tools/targets/REALTEK_RTL8195AM.py index be991645aef..59180f46bd8 100644 --- a/tools/targets/REALTEK_RTL8195AM.py +++ b/tools/targets/REALTEK_RTL8195AM.py @@ -100,7 +100,7 @@ def find_symbol(toolchain, mapfile, symbol): HEX = '0x0{,8}(?P[0-9A-Fa-f]{8})' if toolchain == "GCC_ARM": SYM = re.compile(r'^\s+' + HEX + r'\s+' + symbol + '\r?$') - elif toolchain in ["ARM_STD", "ARM", "ARM_MICRO"]: + elif toolchain in ("ARM_STD", "ARM", "ARM_MICRO", "ARMC6"): SYM = re.compile(r'^\s+' + HEX + r'\s+0x[0-9A-Fa-f]{8}\s+Code.*\s+i\.' + symbol + r'\s+.*$') elif toolchain == "IAR": SYM = re.compile(r'^' + symbol + r'\s+' + HEX + '\s+.*$') @@ -155,7 +155,9 @@ def parse_load_segment_armcc(image_elf): (offset, addr, size) = (0, 0, 0) segment_list = [] in_segment = False - cmd = os.path.join(TOOLCHAIN_PATHS['ARM'], 'bin', 'fromelf') + cmd = os.path.join(TOOLCHAIN_PATHS['ARMC6'], 'fromelf') + if not os.path.exists(cmd): + cmd = os.path.join(TOOLCHAIN_PATHS['ARM'], 'bin', 'fromelf') cmd = '"' + cmd + '"' + ' --text -v --only=none ' + image_elf for line in subprocess.check_output(cmd, shell=True, universal_newlines=True).split("\n"): if line == "": @@ -227,7 +229,7 @@ def parse_load_segment_iar(image_elf): def parse_load_segment(toolchain, image_elf): if toolchain == "GCC_ARM": return parse_load_segment_gcc(image_elf) - elif toolchain in ["ARM_STD", "ARM", "ARM_MICRO"]: + elif toolchain in ("ARM_STD", "ARM", "ARM_MICRO", "ARMC6"): return parse_load_segment_armcc(image_elf) elif toolchain == "IAR": return parse_load_segment_iar(image_elf) From 9c68057dc651b9f9a0df4ecbf3b02e6392babd7e Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 7 Nov 2017 13:45:59 -0600 Subject: [PATCH 3/7] Explicitly instantiate vector base class --- platform/mbed_retarget.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/mbed_retarget.cpp b/platform/mbed_retarget.cpp index f77b3ce4fc3..66eac68a3c4 100644 --- a/platform/mbed_retarget.cpp +++ b/platform/mbed_retarget.cpp @@ -1091,3 +1091,8 @@ MBED_WEAK const ticker_info_t* lp_ticker_get_info() }; return &info; } + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#include +template class std::__1::__vector_base_common<1>; +#endif From 2c653ada38ab59576850a4c8563f3fbef4b22627 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 7 Nov 2017 13:55:34 -0600 Subject: [PATCH 4/7] Remove superfluous tests I'm going to explain why these tests are superfluous because I don't like removing tests. The asserts were all asserting something that does not need to be true: that the toolchain's `name` attribute matched it's key in the `TOOLCHIAN_CLASSES` dictionary. With that out of the way, the `test_instantiation` test did not assert anything, and is therefore not a test. --- tools/test/toolchains/api_test.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tools/test/toolchains/api_test.py b/tools/test/toolchains/api_test.py index d98b1cef1b2..fc14473b049 100644 --- a/tools/test/toolchains/api_test.py +++ b/tools/test/toolchains/api_test.py @@ -15,13 +15,6 @@ Resources, TOOLCHAIN_PATHS, mbedToolchain from tools.targets import TARGET_MAP -def test_instantiation(): - """Test that all exported toolchain may be instantiated""" - for name, tc_class in TOOLCHAIN_CLASSES.items(): - cls = tc_class(TARGET_MAP["K64F"]) - assert name == cls.name or\ - name == LEGACY_TOOLCHAIN_NAMES[cls.name] - ALPHABET = [char for char in printable if char not in [u'.', u'/']] @given(fixed_dictionaries({ @@ -115,10 +108,6 @@ def test_toolchain_profile_asm(profile, source_file): "Toolchain %s did not propagate arg %s" % (toolchain.name, parameter) - for name, Class in TOOLCHAIN_CLASSES.items(): - CLS = Class(TARGET_MAP["K64F"]) - assert name == CLS.name or name == LEGACY_TOOLCHAIN_NAMES[CLS.name] - @given(fixed_dictionaries({ 'common': lists(text()), 'c': lists(text()), @@ -152,10 +141,6 @@ def test_toolchain_profile_ld(profile, source_file): "Toolchain %s did not propagate arg %s" % (toolchain.name, parameter) - for name, Class in TOOLCHAIN_CLASSES.items(): - CLS = Class(TARGET_MAP["K64F"]) - assert name == CLS.name or name == LEGACY_TOOLCHAIN_NAMES[CLS.name] - @given(lists(text(alphabet=ALPHABET, min_size=1), min_size=1)) def test_detect_duplicates(filenames): From 727aada32a9761e67031c977dae2046d7069d1c9 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Thu, 9 Nov 2017 09:56:17 -0600 Subject: [PATCH 5/7] Workaround for NCS36510 deepsleep bug Arm compiler 6 optimized way too well, and adding 2 more nops did the trick --- targets/TARGET_ONSEMI/TARGET_NCS36510/sleep.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/sleep.c b/targets/TARGET_ONSEMI/TARGET_NCS36510/sleep.c index 31c9a5f720c..70998255004 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/sleep.c +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/sleep.c @@ -66,6 +66,8 @@ void fncs36510_deepsleep(void) __WFI(); __NOP(); __NOP(); + __NOP(); + __NOP(); /** Wait for the external 32MHz to be power-ed up & running * Re-power down the 32MHz internal osc From 146d0d9a583b69a23dd3e152928f19ce45488505 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Fri, 10 Nov 2017 11:30:15 -0600 Subject: [PATCH 6/7] Correct fpu passing for Armlink 6 --- tools/toolchains/arm.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index 6428c2d128f..01ce72f28ed 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -310,16 +310,12 @@ def __init__(self, target, *args, **kwargs): 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]) 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]) elif target.core.lower().endswith("ns"): self.flags['common'].append("-mcpu=%s" % target.core.lower()[:-3]) - self.flags['ld'].append("--cpu=%s" % target.core.lower()[:-3]) else: self.flags['common'].append("-mcpu=%s" % target.core.lower()) - self.flags['ld'].append("--cpu=%s" % target.core.lower()) if target.core == "Cortex-M4F": self.flags['common'].append("-mfpu=fpv4-sp-d16") @@ -347,6 +343,7 @@ def __init__(self, target, *args, **kwargs): "Cortex-M33-NS": "Cortex-M33" }.get(target.core, target.core) self.flags['asm'].append("--cpu=%s" % asm_cpu) + self.flags['ld'].append("--cpu=%s" % asm_cpu) self.cc = ([join(TOOLCHAIN_PATHS["ARMC6"], "armclang")] + self.flags['common'] + self.flags['c']) From 5839c1bf11d89c82f1cbfd51ee42bf9791f4722f Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Fri, 10 Nov 2017 11:30:48 -0600 Subject: [PATCH 7/7] Correct Arm Compiler 6 FPU present check --- cmsis/core_cm4.h | 2 +- cmsis/core_cm7.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmsis/core_cm4.h b/cmsis/core_cm4.h index bdaedcf9f31..9258e651540 100644 --- a/cmsis/core_cm4.h +++ b/cmsis/core_cm4.h @@ -84,7 +84,7 @@ #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP + #if defined (__ARM_FP) && (__ARM_FP >= 2) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else diff --git a/cmsis/core_cm7.h b/cmsis/core_cm7.h index fee3d0c977a..d4aa0f06e05 100644 --- a/cmsis/core_cm7.h +++ b/cmsis/core_cm7.h @@ -84,7 +84,7 @@ #endif #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) - #if defined __ARM_PCS_VFP + #if defined (__ARM_FP) && (__ARM_FP >= 2) #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) #define __FPU_USED 1U #else