From da9b8f3dee11a4af3b057bff2a86a242a60a8ea2 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Mon, 22 May 2017 10:16:08 -0500 Subject: [PATCH 1/3] Move duplicated NRF52 + MCU_NRF51822 files into NRF52 --- .../TARGET_NRF5/{ => TARGET_NRF52_COMMON}/analogin_api.c | 0 .../TARGET_NRF5/{ => TARGET_NRF52_COMMON}/pwmout_api.c | 0 targets/targets.json | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) rename targets/TARGET_NORDIC/TARGET_NRF5/{ => TARGET_NRF52_COMMON}/analogin_api.c (100%) rename targets/TARGET_NORDIC/TARGET_NRF5/{ => TARGET_NRF52_COMMON}/pwmout_api.c (100%) diff --git a/targets/TARGET_NORDIC/TARGET_NRF5/analogin_api.c b/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_NRF52_COMMON/analogin_api.c similarity index 100% rename from targets/TARGET_NORDIC/TARGET_NRF5/analogin_api.c rename to targets/TARGET_NORDIC/TARGET_NRF5/TARGET_NRF52_COMMON/analogin_api.c diff --git a/targets/TARGET_NORDIC/TARGET_NRF5/pwmout_api.c b/targets/TARGET_NORDIC/TARGET_NRF5/TARGET_NRF52_COMMON/pwmout_api.c similarity index 100% rename from targets/TARGET_NORDIC/TARGET_NRF5/pwmout_api.c rename to targets/TARGET_NORDIC/TARGET_NRF5/TARGET_NRF52_COMMON/pwmout_api.c diff --git a/targets/targets.json b/targets/targets.json index 200b3dc0d4..4916e55eaf 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -2628,7 +2628,7 @@ "inherits": ["Target"], "core": "Cortex-M4F", "macros": ["NRF52", "TARGET_NRF52832", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S132", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""], - "extra_labels": ["NORDIC", "MCU_NRF52", "MCU_NRF52832", "NRF5", "SDK11"], + "extra_labels": ["NORDIC", "MCU_NRF52", "MCU_NRF52832", "NRF5", "SDK11", "NRF52_COMMON"], "OUTPUT_EXT": "hex", "is_disk_virtual": true, "supported_toolchains": ["GCC_ARM", "ARM", "IAR"], @@ -2708,7 +2708,7 @@ "inherits": ["Target"], "core": "Cortex-M4F", "macros": ["TARGET_NRF52840", "BLE_STACK_SUPPORT_REQD", "SOFTDEVICE_PRESENT", "S140", "NRF_SD_BLE_API_VERSION=5", "NRF52840_XXAA", "NRF_DFU_SETTINGS_VERSION=1", "NRF_SD_BLE_API_VERSION=5", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""], - "extra_labels": ["NORDIC", "MCU_NRF52840", "NRF5", "SDK13"], + "extra_labels": ["NORDIC", "MCU_NRF52840", "NRF5", "SDK13", "NRF52_COMMON"], "OUTPUT_EXT": "hex", "is_disk_virtual": true, "supported_toolchains": ["GCC_ARM", "ARM", "IAR"], From deaabf312339106c461099cdc2041b2d3b2100c3 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Tue, 23 May 2017 14:04:05 +0100 Subject: [PATCH 2/3] uvision exporter: Escape double quote in flags. Without this fix macro defined as -DFOO="BAR" won't be correctly handled by uvision. --- tools/export/uvision/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/export/uvision/__init__.py b/tools/export/uvision/__init__.py index 154a56ca04..0c8e35b12c 100644 --- a/tools/export/uvision/__init__.py +++ b/tools/export/uvision/__init__.py @@ -166,7 +166,7 @@ class Uvision(Exporter): # Flag is invalid if set in template # Optimizations are also set in the template invalid_flag = lambda x: x in template or re.match("-O(\d|time)", x) - flags['c_flags'] = [flag for flag in c_flags if not invalid_flag(flag)] + flags['c_flags'] = [flag.replace('"','\\"') for flag in c_flags if not invalid_flag(flag)] flags['c_flags'] = " ".join(flags['c_flags']) return flags From 897667deaa51bbf4b316ce2d40d51b29193728d8 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Tue, 23 May 2017 14:08:24 +0100 Subject: [PATCH 3/3] makefile exporter: Escape double quote in toolchain flags. Without this fix macro defined as -DFOO="BAR" won't be correctly interpreted by the compiler. --- tools/export/makefile/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/export/makefile/__init__.py b/tools/export/makefile/__init__.py index c76bac7e1f..913a585ed2 100644 --- a/tools/export/makefile/__init__.py +++ b/tools/export/makefile/__init__.py @@ -111,7 +111,7 @@ class Makefile(Exporter): for key in ['include_paths', 'library_paths', 'hex_files', 'to_be_compiled']: ctx[key] = sorted(ctx[key]) - ctx.update(self.flags) + ctx.update(self.format_flags()) for templatefile in \ ['makefile/%s_%s.tmpl' % (self.TEMPLATE, @@ -128,6 +128,17 @@ class Makefile(Exporter): else: raise NotSupportedException("This make tool is in development") + def format_flags(self): + """Format toolchain flags for Makefile""" + flags = {} + for k, v in self.flags.iteritems(): + if k in ['asm_flags', 'c_flags', 'cxx_flags']: + flags[k] = map(lambda x: x.replace('"', '\\"'), v) + else: + flags[k] = v + + return flags + @staticmethod def build(project_name, log_name="build_log.txt", cleanup=True): """ Build Make project """