From ca206d85117dca0a1a61b42ca632a2e814553052 Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 25 Jan 2021 12:15:26 +0200 Subject: [PATCH 1/8] Declare optional package versions --- platform.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 98d8a64..6039724 100644 --- a/platform.json +++ b/platform.json @@ -35,7 +35,8 @@ "type": "toolchain", "optional": false, "owner": "platformio", - "version": "~1.50400.0" + "version": "~1.50400.0", + "optionalVersions": [">=1.60301.0,<1.80000.0"] }, "toolchain-gccarmnoneeabi": { "type": "toolchain", From 97fc2ea46491646ebcfd835d77c6e9f963582892 Mon Sep 17 00:00:00 2001 From: valeros Date: Thu, 28 Jan 2021 17:39:59 +0200 Subject: [PATCH 2/8] Run CI only on Python 3 --- .github/workflows/examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index a01f5ce..fa97d17 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -8,7 +8,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-16.04, windows-latest, macos-latest] - python-version: [2.7, 3.7] + python-version: [3.7] example: - "examples/arduino-blink" - "examples/arduino-hid-usb-mouse" From 9260c195571da89b27dac4b78173585fd8bb0b4e Mon Sep 17 00:00:00 2001 From: valeros Date: Tue, 2 Feb 2021 12:45:34 +0200 Subject: [PATCH 3/8] Allow overriding debug adapter speed using "debug_speed" option --- builder/main.py | 2 +- platform.py | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/builder/main.py b/builder/main.py index 4e063cb..0786666 100644 --- a/builder/main.py +++ b/builder/main.py @@ -188,7 +188,7 @@ def _jlink_cmd_script(env, source): UPLOADER="JLink.exe" if system() == "Windows" else "JLinkExe", UPLOADERFLAGS=[ "-device", board_config.get("debug", {}).get("jlink_device"), - "-speed", "4000", + "-speed", env.GetProjectOption("debug_speed", "4000"), "-if", ("jtag" if upload_protocol == "jlink-jtag" else "swd"), "-autoconnect", "1", "-NoGui", "1" diff --git a/platform.py b/platform.py index a08bd28..d4eaa05 100644 --- a/platform.py +++ b/platform.py @@ -12,7 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platform import system +import copy +import platform from platformio.managers.platform import PlatformBase @@ -30,7 +31,7 @@ def configure_default_packages(self, variables, targets): if "mbed" in variables.get("pioframework", []): self.packages["toolchain-gccarmnoneeabi"][ - 'version'] = ">=1.60301.0,<1.80000.0" + "version"] = ">=1.60301.0,<1.80000.0" # configure J-LINK tool jlink_conds = [ @@ -66,12 +67,12 @@ def _add_default_debug_tools(self, board): upload_protocols = board.manifest.get("upload", {}).get( "protocols", []) if "tools" not in debug: - debug['tools'] = {} + debug["tools"] = {} - if "jlink" in upload_protocols and "jlink" not in debug['tools']: + if "jlink" in upload_protocols and "jlink" not in debug["tools"]: assert debug.get("jlink_device"), ( "Missed J-Link Device ID for %s" % board.id) - debug['tools']['jlink'] = { + debug["tools"]["jlink"] = { "server": { "package": "tool-jlink", "arguments": [ @@ -82,10 +83,22 @@ def _add_default_debug_tools(self, board): "-port", "2331" ], "executable": ("JLinkGDBServerCL.exe" - if system() == "Windows" else + if platform.system() == "Windows" else "JLinkGDBServer") } } - board.manifest['debug'] = debug + board.manifest["debug"] = debug return board + + def configure_debug_options(self, initial_debug_options, ide_data): + debug_options = copy.deepcopy(initial_debug_options) + server_executable = debug_options["server"]["executable"].lower() + adapter_speed = initial_debug_options.get("speed") + if adapter_speed: + if "jlink" in server_executable: + debug_options["server"]["arguments"].extend( + ["-speed", adapter_speed] + ) + + return debug_options From 127c8a717e71e7cbd843329c99aaad3d5f923695 Mon Sep 17 00:00:00 2001 From: valeros Date: Thu, 11 Feb 2021 11:37:35 +0200 Subject: [PATCH 4/8] Add teensy-cli to the list of supported protocols for Teensy 4.0/4.1 Resolve platformio/platformio-docs#175 --- boards/teensy40.json | 1 + boards/teensy41.json | 1 + 2 files changed, 2 insertions(+) diff --git a/boards/teensy40.json b/boards/teensy40.json index 39e350d..e0f034b 100644 --- a/boards/teensy40.json +++ b/boards/teensy40.json @@ -24,6 +24,7 @@ "maximum_size": 2031616, "protocol": "teensy-gui", "protocols": [ + "teensy-cli", "teensy-gui", "jlink" ] diff --git a/boards/teensy41.json b/boards/teensy41.json index aebe1ce..f403c8a 100644 --- a/boards/teensy41.json +++ b/boards/teensy41.json @@ -24,6 +24,7 @@ "maximum_size": 8126464, "protocol": "teensy-gui", "protocols": [ + "teensy-cli", "teensy-gui", "jlink" ] From faf7988e77dc89482df0f7596de1b8d61f34f8ab Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 12 Jul 2021 15:06:54 +0300 Subject: [PATCH 5/8] Add an explicit dependency on the checkprogsize target for the final binary --- builder/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/builder/main.py b/builder/main.py index 0786666..af85f7d 100644 --- a/builder/main.py +++ b/builder/main.py @@ -143,6 +143,7 @@ else: target_elf = env.BuildProgram() target_firm = env.ElfToHex(join("$BUILD_DIR", "${PROGNAME}"), target_elf) + env.Depends(target_firm, "checkprogsize") AlwaysBuild(env.Alias("nobuild", target_firm)) target_buildprog = env.Alias("buildprog", target_firm, target_firm) From 6319aab241ad9a526de55c013934595aa89299dd Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 12 Jul 2021 15:11:19 +0300 Subject: [PATCH 6/8] Update Teensyduino to v1.54 // Resolve #74 --- boards/teensymm.json | 34 ++++++++++++++++ builder/frameworks/arduino.py | 40 ++++++++++++++----- examples/arduino-internal-libs/platformio.ini | 5 +++ platform.json | 2 +- 4 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 boards/teensymm.json diff --git a/boards/teensymm.json b/boards/teensymm.json new file mode 100644 index 0000000..3106531 --- /dev/null +++ b/boards/teensymm.json @@ -0,0 +1,34 @@ +{ + "build": { + "arduino": { + "ldscript": "imxrt1062_mm.ld" + }, + "core": "teensy4", + "cpu": "cortex-m7", + "extra_flags": "-D__IMXRT1062__ -DARDUINO_TEENSY_MICROMOD", + "f_cpu": "600000000", + "mcu": "imxrt1062" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "MIMXRT1062xxxxA" + }, + "frameworks": [ + "arduino" + ], + "name": "SparkFun MicroMod Teensy", + "upload": { + "maximum_ram_size": 524288, + "maximum_size": 8126464, + "protocol": "teensy-gui", + "protocols": [ + "teensy-cli", + "teensy-gui", + "jlink" + ] + }, + "url": "https://www.sparkfun.com/products/16402", + "vendor": "SparkFun" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 1920817..40a7965 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -66,7 +66,7 @@ env.Append(CPPDEFINES=["USB_SERIAL"]) env.Replace( - SIZEPROGREGEXP=r"^(?:\.text|\.text\.progmem|\.text\.itcm|\.data)\s+([0-9]+).*", + SIZEPROGREGEXP=r"^(?:\.text|\.text\.progmem|\.text\.itcm|\.data|\.text\.csf)\s+([0-9]+).*", SIZEDATAREGEXP=r"^(?:\.usbdescriptortable|\.dmabuffers|\.usbbuffers|\.data|\.bss|\.noinit|\.text\.itcm|\.text\.itcm\.padding)\s+([0-9]+).*" ) @@ -157,8 +157,7 @@ "-Wl,--gc-sections,--relax", "-mthumb", "-mcpu=%s" % env.BoardConfig().get("build.cpu"), - "-Wl,--defsym=__rtc_localtime=$UNIX_TIME", - "-fsingle-precision-constant" + "-Wl,--defsym=__rtc_localtime=$UNIX_TIME" ], LIBS=["m", "stdc++"] @@ -167,10 +166,17 @@ if not env.BoardConfig().get("build.ldscript", ""): env.Replace(LDSCRIPT_PATH=env.BoardConfig().get("build.arduino.ldscript", "")) - if env.BoardConfig().id_ in ("teensy35", "teensy36", "teensy40", "teensy41"): + if env.BoardConfig().id_ in ( + "teensy35", + "teensy36", + "teensy40", + "teensy41", + "teensymm", + ): fpv_version = "4-sp" - if env.BoardConfig().id_.startswith("teensy4"): + if env.BoardConfig().id_.startswith(("teensy4", "teensymm")): fpv_version = "5" + env.Append(CXXFLAGS=["-fno-threadsafe-statics"]) env.Append( CCFLAGS=[ @@ -262,24 +268,38 @@ LINKFLAGS=["-O2"] ) -env.Append( - ASFLAGS=env.get("CCFLAGS", [])[:] -) -if "cortex-m" in env.BoardConfig().get("build.cpu", ""): +cpu = env.BoardConfig().get("build.cpu", "") +if "cortex-m" in cpu: board = env.subst("$BOARD") math_lib = "arm_cortex%s_math" if board in ("teensy35", "teensy36"): math_lib = math_lib % "M4lf" elif board in ("teensy30", "teensy31"): math_lib = math_lib % "M4l" - elif board.startswith("teensy4"): + elif board.startswith(("teensy4", "teensymm")): math_lib = math_lib % "M7lfsp" else: math_lib = math_lib % "M0l" env.Prepend(LIBS=[math_lib]) + if cpu.startswith(("cortex-m4", "cortex-m0")): + env.Append( + CCFLAGS=[ + "-mno-unaligned-access", + "-fsingle-precision-constant" + ], + + LINKFLAGS=[ + "-fsingle-precision-constant" + ] + ) + +env.Append( + ASFLAGS=env.get("CCFLAGS", [])[:] +) + # Teensy 2.x Core if BUILD_CORE == "teensy": env.Append(CPPPATH=[join(FRAMEWORK_DIR, "cores")]) diff --git a/examples/arduino-internal-libs/platformio.ini b/examples/arduino-internal-libs/platformio.ini index 5f6989c..ed29e4b 100644 --- a/examples/arduino-internal-libs/platformio.ini +++ b/examples/arduino-internal-libs/platformio.ini @@ -51,3 +51,8 @@ board = teensy40 platform = teensy framework = arduino board = teensy41 + +[env:teensymm] +platform = teensy +framework = arduino +board = teensymm diff --git a/platform.json b/platform.json index 6039724..868a8f6 100644 --- a/platform.json +++ b/platform.json @@ -48,7 +48,7 @@ "type": "framework", "optional": true, "owner": "platformio", - "version": "~1.153.0" + "version": "~1.154.0" }, "framework-mbed": { "type": "framework", From 267f6ad6161021e223e93bbbc876a2370bf292ff Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 26 Jul 2021 16:50:03 +0300 Subject: [PATCH 7/8] Better handling of custom debug options --- platform.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform.py b/platform.py index d4eaa05..a3d2866 100644 --- a/platform.py +++ b/platform.py @@ -93,9 +93,10 @@ def _add_default_debug_tools(self, board): def configure_debug_options(self, initial_debug_options, ide_data): debug_options = copy.deepcopy(initial_debug_options) - server_executable = debug_options["server"]["executable"].lower() adapter_speed = initial_debug_options.get("speed") if adapter_speed: + server_options = debug_options.get("server") or {} + server_executable = server_options.get("executable", "").lower() if "jlink" in server_executable: debug_options["server"]["arguments"].extend( ["-speed", adapter_speed] From b1290f7fbd69ee34eb8a1886d81d16c794715979 Mon Sep 17 00:00:00 2001 From: valeros Date: Mon, 26 Jul 2021 19:48:33 +0300 Subject: [PATCH 8/8] Bump version to 4.13.0 --- platform.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform.json b/platform.json index 868a8f6..7961e91 100644 --- a/platform.json +++ b/platform.json @@ -19,7 +19,7 @@ "type": "git", "url": "https://github.com/platformio/platform-teensy.git" }, - "version": "4.12.0", + "version": "4.13.0", "frameworks": { "arduino": { "package": "framework-arduinoteensy",