From d919905c96dba355fd03355f322760b076268efc Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 14 Apr 2021 03:10:25 +0200 Subject: [PATCH] all: clean up Cortex-M target files In this commit I've moved all core-specific flags to files for that specific core. This is a bit of a cleanup (less duplicated JSON) but should also help in the future when core-specific changes are made, such as core specific build tags or when the FPU finally gets supported in TinyGo. Some notable specific changes: - I've removed floating point flags from the Teensy 3.6 target. The reason is that the FPU is not yet supported in TinyGo (in goroutine stack switching for example) and floating point numbers would only be supported by C files, not Go files (because the LLVM FPU feature flags aren't used). This would create an ABI mismatch across CGo. - I've added the "cpu":"cortex-m7" to the cortex-m7.json file to match the configuration for the Teensy 4.0. This implies a change to the nucleo-f722ze (because now it has its CPU field set). Somehow that reduces the code size, so it looks like a good change. I don't believe any of these changes should have any practical consequences. One issue I've found is in the Cortex-M33 target: it uses armv7m, which is incorrect: it should be armv8m. But the chip is backwards compatible so this should mostly work. Switching to armv8m led to a compilation failure because PRIMASK isn't defined, this may be an actual bug. --- targets/atsamd21e18a.json | 6 +----- targets/atsamd21g18a.json | 6 +----- targets/bluepill.json | 6 +----- targets/cortex-m-qemu.json | 6 +----- targets/cortex-m0plus.json | 7 +++++++ targets/cortex-m3.json | 7 +++++++ targets/cortex-m7.json | 5 ++++- targets/nrf51.json | 4 +--- targets/nucleo-f103rb.json | 6 +----- targets/stm32l0x2.json | 6 +----- targets/teensy36.json | 9 +-------- targets/teensy40.json | 8 +------- 12 files changed, 27 insertions(+), 49 deletions(-) create mode 100644 targets/cortex-m0plus.json create mode 100644 targets/cortex-m3.json diff --git a/targets/atsamd21e18a.json b/targets/atsamd21e18a.json index 3b35a7b7..0fcf5067 100644 --- a/targets/atsamd21e18a.json +++ b/targets/atsamd21e18a.json @@ -1,10 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv6m-none-eabi", + "inherits": ["cortex-m0plus"], "build-tags": ["atsamd21e18a", "atsamd21e18", "atsamd21", "sam"], - "cflags": [ - "--target=armv6m-none-eabi" - ], "linkerscript": "targets/atsamd21.ld", "extra-files": [ "src/device/sam/atsamd21e18a.s" diff --git a/targets/atsamd21g18a.json b/targets/atsamd21g18a.json index f9b8a540..956afba5 100644 --- a/targets/atsamd21g18a.json +++ b/targets/atsamd21g18a.json @@ -1,10 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv6m-none-eabi", + "inherits": ["cortex-m0plus"], "build-tags": ["atsamd21g18a", "atsamd21g18", "atsamd21", "sam"], - "cflags": [ - "--target=armv6m-none-eabi" - ], "linkerscript": "targets/atsamd21.ld", "extra-files": [ "src/device/sam/atsamd21g18a.s" diff --git a/targets/bluepill.json b/targets/bluepill.json index 1bd029a3..9f1e4b00 100644 --- a/targets/bluepill.json +++ b/targets/bluepill.json @@ -1,10 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv7m-none-eabi", + "inherits": ["cortex-m3"], "build-tags": ["bluepill", "stm32f103", "stm32f1", "stm32"], - "cflags": [ - "--target=armv7m-none-eabi" - ], "linkerscript": "targets/stm32.ld", "extra-files": [ "src/device/stm32/stm32f103.s" diff --git a/targets/cortex-m-qemu.json b/targets/cortex-m-qemu.json index 6d384c74..1d1cfc89 100644 --- a/targets/cortex-m-qemu.json +++ b/targets/cortex-m-qemu.json @@ -1,10 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv7m-none-eabi", + "inherits": ["cortex-m3"], "build-tags": ["qemu", "lm3s6965"], - "cflags": [ - "--target=armv7m-none-eabi" - ], "linkerscript": "targets/lm3s6965.ld", "extra-files": [ "targets/cortex-m-qemu.s" diff --git a/targets/cortex-m0plus.json b/targets/cortex-m0plus.json new file mode 100644 index 00000000..f86945b8 --- /dev/null +++ b/targets/cortex-m0plus.json @@ -0,0 +1,7 @@ +{ + "inherits": ["cortex-m"], + "llvm-target": "armv6m-none-eabi", + "cflags": [ + "--target=armv6m-none-eabi" + ] +} diff --git a/targets/cortex-m3.json b/targets/cortex-m3.json new file mode 100644 index 00000000..68ecb7fc --- /dev/null +++ b/targets/cortex-m3.json @@ -0,0 +1,7 @@ +{ + "inherits": ["cortex-m"], + "llvm-target": "armv7m-none-eabi", + "cflags": [ + "--target=armv7m-none-eabi" + ] +} diff --git a/targets/cortex-m7.json b/targets/cortex-m7.json index dcaa4257..f63490eb 100644 --- a/targets/cortex-m7.json +++ b/targets/cortex-m7.json @@ -1,7 +1,10 @@ { "inherits": ["cortex-m"], "llvm-target": "armv7em-none-eabi", + "cpu": "cortex-m7", "cflags": [ - "--target=armv7em-none-eabi" + "--target=armv7em-none-eabi", + "-mcpu=cortex-m7", + "-mfloat-abi=soft" ] } diff --git a/targets/nrf51.json b/targets/nrf51.json index 2327d39f..714e2c55 100644 --- a/targets/nrf51.json +++ b/targets/nrf51.json @@ -1,9 +1,7 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv6m-none-eabi", + "inherits": ["cortex-m0"], "build-tags": ["nrf51822", "nrf51", "nrf"], "cflags": [ - "--target=armv6m-none-eabi", "-DNRF51", "-I{root}/lib/CMSIS/CMSIS/Include", "-I{root}/lib/nrfx/mdk" diff --git a/targets/nucleo-f103rb.json b/targets/nucleo-f103rb.json index 10c9b2a6..1c12af84 100644 --- a/targets/nucleo-f103rb.json +++ b/targets/nucleo-f103rb.json @@ -1,10 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv7m-none-eabi", + "inherits": ["cortex-m3"], "build-tags": ["nucleof103rb", "stm32f103", "stm32f1","stm32"], - "cflags": [ - "--target=armv7m-none-eabi" - ], "linkerscript": "targets/stm32f103rb.ld", "extra-files": [ "src/device/stm32/stm32f103.s" diff --git a/targets/stm32l0x2.json b/targets/stm32l0x2.json index 78389f37..13b42cc5 100644 --- a/targets/stm32l0x2.json +++ b/targets/stm32l0x2.json @@ -1,16 +1,12 @@ { "inherits": [ - "cortex-m" + "cortex-m0plus" ], - "llvm-target": "armv6m-none-eabi", "build-tags": [ "stm32l0", "stm32l0x2", "stm32" ], - "cflags": [ - "--target=armv6m-none-eabi" - ], "extra-files": [ "src/device/stm32/stm32l0x2.s" ] diff --git a/targets/teensy36.json b/targets/teensy36.json index de9e6dc0..c341511e 100644 --- a/targets/teensy36.json +++ b/targets/teensy36.json @@ -1,13 +1,6 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv7em-none-eabi", - "cpu": "cortex-m4", + "inherits": ["cortex-m4"], "build-tags": ["teensy36", "teensy", "mk66f18", "nxp"], - "cflags": [ - "--target=armv7em-none-eabi", - "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16" - ], "linkerscript": "targets/nxpmk66f18.ld", "extra-files": [ "src/device/nxp/mk66f18.s", diff --git a/targets/teensy40.json b/targets/teensy40.json index 0ecb0353..d08b8d1d 100644 --- a/targets/teensy40.json +++ b/targets/teensy40.json @@ -1,14 +1,8 @@ { - "inherits": ["cortex-m"], - "llvm-target": "armv7em-none-eabi", - "cpu": "cortex-m7", + "inherits": ["cortex-m7"], "build-tags": ["teensy40", "teensy", "mimxrt1062", "nxp"], "automatic-stack-size": false, "default-stack-size": 4096, - "cflags": [ - "--target=armv7em-none-eabi", - "-mfloat-abi=soft" - ], "linkerscript": "targets/mimxrt1062-teensy40.ld", "extra-files": [ "src/device/nxp/mimxrt1062.s",