diff --git a/boards/teensy40.json b/boards/teensy40.json new file mode 100644 index 0000000..05da1ee --- /dev/null +++ b/boards/teensy40.json @@ -0,0 +1,31 @@ +{ + "build": { + "core": "teensy4", + "cpu": "cortex-m7", + "extra_flags": "-D__IMXRT1062__ -DTEENSY40", + "f_cpu": "600000000", + "ldscript": "imxrt1062.ld", + "mcu": "imxrt1062" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "MIMXRT1062xxxxA" + }, + "frameworks": [ + "arduino" + ], + "name": "Teensy 4.0", + "upload": { + "maximum_ram_size": 1048576, + "maximum_size": 2031616, + "protocol": "teensy-gui", + "protocols": [ + "teensy-gui", + "jlink" + ] + }, + "url": "https://www.pjrc.com/store/teensy40.html", + "vendor": "Teensy" +} diff --git a/builder/frameworks/arduino.py b/builder/frameworks/arduino.py index 44fe6fd..b2acf1a 100644 --- a/builder/frameworks/arduino.py +++ b/builder/frameworks/arduino.py @@ -33,6 +33,8 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoteensy") FRAMEWORK_VERSION = platform.get_package_version("framework-arduinoteensy") +BUILD_CORE = env.BoardConfig().get("build.core") + assert isdir(FRAMEWORK_DIR) BUILTIN_USB_FLAGS = ( @@ -61,6 +63,11 @@ if not set(env.get("CPPDEFINES", [])) & set(BUILTIN_USB_FLAGS): env.Append(CPPDEFINES=["USB_SERIAL"]) +env.Replace( + SIZEPROGREGEXP=r"^(?:\.text|\.text\.progmem|\.text\.itcm|\.data)\s+([0-9]+).*", + SIZEDATAREGEXP=r"^(?:\.usbdescriptortable|\.dmabuffers|\.usbbuffers|\.data|\.bss|\.bss\.dma|\.noinit|\.text\.itcm)\s+([0-9]+).*" +) + env.Append( CPPDEFINES=[ ("ARDUINO", 10805), @@ -68,7 +75,7 @@ ], CPPPATH=[ - join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core")) + join(FRAMEWORK_DIR, "cores", BUILD_CORE) ], LIBSOURCE_DIRS=[ @@ -76,7 +83,7 @@ ] ) -if "BOARD" in env and env.BoardConfig().get("build.core") == "teensy": +if "BOARD" in env and BUILD_CORE == "teensy": env.Append( ASFLAGS=["-x", "assembler-with-cpp"], @@ -91,7 +98,8 @@ CXXFLAGS=[ "-fno-exceptions", "-felide-constructors", - "-std=gnu++11" + "-std=gnu++11", + "-fpermissive" ], CPPDEFINES=[ @@ -107,7 +115,7 @@ LIBS=["m"] ) -elif "BOARD" in env and env.BoardConfig().get("build.core") == "teensy3": +elif "BOARD" in env and BUILD_CORE in ("teensy3", "teensy4"): env.Replace( AR="arm-none-eabi-gcc-ar", RANLIB="$AR" @@ -131,7 +139,8 @@ "-felide-constructors", "-fno-rtti", "-std=gnu++14", - "-Wno-error=narrowing" + "-Wno-error=narrowing", + "-fpermissive" ], CPPDEFINES=[ @@ -152,16 +161,20 @@ LIBS=["m", "stdc++"] ) - if env.BoardConfig().id_ in ("teensy35", "teensy36"): + if env.BoardConfig().id_ in ("teensy35", "teensy36", "teensy40"): + fpv_version = "4-sp" + if env.BoardConfig().id_ == "teensy40": + fpv_version = "5" + env.Append( CCFLAGS=[ "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16" + "-mfpu=fpv%s-d16" % fpv_version ], LINKFLAGS=[ "-mfloat-abi=hard", - "-mfpu=fpv4-sp-d16" + "-mfpu=fpv%s-d16" % fpv_version ] ) @@ -254,13 +267,15 @@ math_lib = math_lib % "M4lf" elif board in ("teensy30", "teensy31"): math_lib = math_lib % "M4l" + elif board == "teensy40": + math_lib = math_lib % "M7lfsp" else: math_lib = math_lib % "M0l" env.Prepend(LIBS=[math_lib]) # Teensy 2.x Core -if env.BoardConfig().get("build.core") == "teensy": +if BUILD_CORE == "teensy": env.Append(CPPPATH=[join(FRAMEWORK_DIR, "cores")]) # search relative includes in teensy directories @@ -281,7 +296,7 @@ with open(file_path, "w", encoding="latin-1") as fp: fp.write(content) else: - env.Prepend(LIBPATH=[join(FRAMEWORK_DIR, "cores", "teensy3")]) + env.Prepend(LIBPATH=[join(FRAMEWORK_DIR, "cores", BUILD_CORE)]) # # Target: Build Core Library @@ -303,7 +318,7 @@ libs.append(env.BuildLibrary( join("$BUILD_DIR", "FrameworkArduino"), - join(FRAMEWORK_DIR, "cores", env.BoardConfig().get("build.core")) + join(FRAMEWORK_DIR, "cores", BUILD_CORE) )) env.Prepend(LIBS=libs) diff --git a/builder/main.py b/builder/main.py index 1b5a026..e328f52 100644 --- a/builder/main.py +++ b/builder/main.py @@ -88,7 +88,7 @@ if not env.get("PIOFRAMEWORK"): env.SConscript("frameworks/_bare_avr.py") -elif "BOARD" in env and board_config.get("build.core") == "teensy3": +elif "BOARD" in env and board_config.get("build.core") in ("teensy3", "teensy4"): env.Replace( AR="arm-none-eabi-ar", AS="arm-none-eabi-as", @@ -138,6 +138,7 @@ target_elf = None if "nobuild" in COMMAND_LINE_TARGETS: + target_elf = join("$BUILD_DIR", "${PROGNAME}.elf") target_firm = join("$BUILD_DIR", "${PROGNAME}.hex") else: target_elf = env.BuildProgram() diff --git a/examples/arduino-blink/platformio.ini b/examples/arduino-blink/platformio.ini index 252b3bc..8e1f8db 100644 --- a/examples/arduino-blink/platformio.ini +++ b/examples/arduino-blink/platformio.ini @@ -41,3 +41,8 @@ board = teensy35 platform = teensy framework = arduino board = teensy36 + +[env:teensy40] +platform = teensy +framework = arduino +board = teensy40 diff --git a/examples/arduino-internal-libs/platformio.ini b/examples/arduino-internal-libs/platformio.ini index de4ce55..13e5a6c 100644 --- a/examples/arduino-internal-libs/platformio.ini +++ b/examples/arduino-internal-libs/platformio.ini @@ -41,3 +41,8 @@ board = teensy35 platform = teensy framework = arduino board = teensy36 + +[env:teensy40] +platform = teensy +framework = arduino +board = teensy40 diff --git a/platform.json b/platform.json index 2211c26..1bf00de 100644 --- a/platform.json +++ b/platform.json @@ -12,7 +12,7 @@ "type": "git", "url": "https://github.com/platformio/platform-teensy.git" }, - "version": "4.3.0", + "version": "4.4.0", "packageRepositories": [ "https://dl.bintray.com/platformio/dl-packages/manifest.json", "http://dl.platformio.org/packages/manifest.json" @@ -41,12 +41,12 @@ "framework-arduinoteensy": { "type": "framework", "optional": true, - "version": "~1.145.0" + "version": "~1.147.0" }, "framework-mbed": { "type": "framework", "optional": true, - "version": "~5.51203.190509" + "version": "~5.51203.0" }, "tool-teensy": { "type": "uploader",