Skip to content

Commit 7b1deb6

Browse files
authored
Teensyduino 1.55 Compatibility (#24)
* Teensyduino 1.55 Compatibility * Update CI software versions * Update Teensyduino version in README (1.55) * Update TeensyLoader removal script The postbuild hook is now "postbuild.1" instead of "postbuild.3". This switches to regex (0-9) to avoid this issue for the future, and will now throw a runtime error if the build hook is not successfully found and removed by the script.
1 parent c6eecd2 commit 7b1deb6

File tree

5 files changed

+45
-27
lines changed

5 files changed

+45
-27
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ name: build
33
on: [push, pull_request, workflow_dispatch]
44

55
env:
6-
IDE_VERSION: 1.8.15
7-
TEENSY_VERSION: 154
6+
IDE_VERSION: 1.8.16
7+
TEENSY_VERSION: 155
88
IDE_LOCATION: /usr/local/share/arduino
99

1010
jobs:
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
#!/usr/bin/python
22

33
import sys
4+
import re
45

5-
filepath = sys.argv[1]
6-
lines = []
6+
filepath = sys.argv[1] # path of the file to parse
7+
lines = [] # list of lines from the file
8+
removed = False # flag for if the line was removed from the file
79

810
with open(filepath, 'r') as f:
911
lines = f.readlines()
1012

1113
with open(filepath, 'w') as f:
14+
# matching "postbuild" hooks of any number which call the "teensy_post_compile" application
15+
pattern = re.compile("recipe\.hooks\.postbuild\.[0-9]\.pattern=\"{compiler\.path}teensy_post_compile\"")
1216
for line in lines:
13-
if not line.startswith("recipe.hooks.postbuild.3.pattern=\"{compiler.path}teensy_post_compile\""): # remove post-compile trigger
17+
if not pattern.match(line):
1418
f.write(line)
1519
else:
1620
print("Removing line '{}'".format(line.strip('\n')))
21+
removed = True
22+
23+
if not removed:
24+
raise RuntimeError("Did not find a matching line to remove in \"{}\"".format(filepath))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This is meant to be used in conjunction with the [ArduinoXInput library](https:/
66

77
## Installation
88

9-
You must have both [Arduino](https://www.arduino.cc/en/main/software) and [Teensyduino](https://www.pjrc.com/teensy/td_download.html) installed before proceeding. Double-check that your installed Teensyduino version matches the files provided in this repository. This repository is currently using version [**1.54**](https://www.pjrc.com/teensy/td_154). If you don't know your Teensyduino version, compile a blank sketch with a Teensy board selected and the Teensy Loader will open. In the Teensy Loader window select `Help -> About` and it will tell you the version number. If your version does not match you will have to reinstall or update the Teensyduino software.
9+
You must have both [Arduino](https://www.arduino.cc/en/main/software) and [Teensyduino](https://www.pjrc.com/teensy/td_download.html) installed before proceeding. Double-check that your installed Teensyduino version matches the files provided in this repository. This repository is currently using version [**1.55**](https://www.pjrc.com/teensy/td_155). If you don't know your Teensyduino version, compile a blank sketch with a Teensy board selected and the Teensy Loader will open. In the Teensy Loader window select `Help -> About` and it will tell you the version number. If your version does not match you will have to reinstall or update the Teensyduino software.
1010

1111
Navigate to your Arduino installation directory and open up the 'hardware' folder. It is recommended that you make a backup of this folder before proceeding in case something goes wrong or if you want to revert the installation.
1212

teensy/avr/boards.txt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ menu.opt=Optimize
44
menu.keys=Keyboard Layout
55

66

7+
# TODO: consider whether these compiler warnings are worthwhile
8+
# -Wno-error=unused-function
9+
# -Wno-error=unused-but-set-variable
10+
# -Wno-error=unused-variable
11+
# -Wno-unused-parameter
12+
# -Wno-unused-but-set-parameter
13+
# -Wno-sign-compare
14+
15+
716
teensy41.name=Teensy 4.1
817
#teensy41.upload.maximum_size=8126464
918
teensy41.build.board=TEENSY41
@@ -26,7 +35,7 @@ teensy41.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
2635
teensy41.build.flags.dep=-MMD
2736
teensy41.build.flags.optimize=-Os
2837
teensy41.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
29-
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=154
38+
teensy41.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=155
3039
teensy41.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
3140
teensy41.build.flags.c=
3241
teensy41.build.flags.S=-x assembler-with-cpp
@@ -226,7 +235,7 @@ teensyMM.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
226235
teensyMM.build.flags.dep=-MMD
227236
teensyMM.build.flags.optimize=-Os
228237
teensyMM.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
229-
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=154
238+
teensyMM.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=155
230239
teensyMM.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
231240
teensyMM.build.flags.c=
232241
teensyMM.build.flags.S=-x assembler-with-cpp
@@ -426,7 +435,7 @@ teensy40.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
426435
teensy40.build.flags.dep=-MMD
427436
teensy40.build.flags.optimize=-Os
428437
teensy40.build.flags.cpu=-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16
429-
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=154
438+
teensy40.build.flags.defs=-D__IMXRT1062__ -DTEENSYDUINO=155
430439
teensy40.build.flags.cpp=-std=gnu++14 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing
431440
teensy40.build.flags.c=
432441
teensy40.build.flags.S=-x assembler-with-cpp
@@ -622,7 +631,7 @@ teensy36.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
622631
teensy36.build.flags.dep=-MMD
623632
teensy36.build.flags.optimize=-Os
624633
teensy36.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
625-
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=154
634+
teensy36.build.flags.defs=-D__MK66FX1M0__ -DTEENSYDUINO=155
626635
teensy36.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
627636
teensy36.build.flags.c=
628637
teensy36.build.flags.S=-x assembler-with-cpp
@@ -834,7 +843,7 @@ teensy35.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
834843
teensy35.build.flags.dep=-MMD
835844
teensy35.build.flags.optimize=-Os
836845
teensy35.build.flags.cpu=-mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
837-
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=154
846+
teensy35.build.flags.defs=-D__MK64FX512__ -DTEENSYDUINO=155
838847
teensy35.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
839848
teensy35.build.flags.c=
840849
teensy35.build.flags.S=-x assembler-with-cpp
@@ -1036,7 +1045,7 @@ teensy31.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
10361045
teensy31.build.flags.dep=-MMD
10371046
teensy31.build.flags.optimize=-Os
10381047
teensy31.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
1039-
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=154
1048+
teensy31.build.flags.defs=-D__MK20DX256__ -DTEENSYDUINO=155
10401049
teensy31.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
10411050
teensy31.build.flags.c=
10421051
teensy31.build.flags.S=-x assembler-with-cpp
@@ -1249,7 +1258,7 @@ teensy30.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdl
12491258
teensy30.build.flags.dep=-MMD
12501259
teensy30.build.flags.optimize=-Os
12511260
teensy30.build.flags.cpu=-mthumb -mcpu=cortex-m4 -fsingle-precision-constant
1252-
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=154
1261+
teensy30.build.flags.defs=-D__MK20DX128__ -DTEENSYDUINO=155
12531262
teensy30.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
12541263
teensy30.build.flags.c=
12551264
teensy30.build.flags.S=-x assembler-with-cpp
@@ -1408,7 +1417,7 @@ teensyLC.build.command.size=arm-none-eabi-size
14081417
teensyLC.build.flags.common=-g -Wall -ffunction-sections -fdata-sections -nostdlib -mno-unaligned-access
14091418
teensyLC.build.flags.dep=-MMD
14101419
teensyLC.build.flags.cpu=-mthumb -mcpu=cortex-m0plus -fsingle-precision-constant
1411-
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=154
1420+
teensyLC.build.flags.defs=-D__MKL26Z64__ -DTEENSYDUINO=155
14121421
teensyLC.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++14 -Wno-error=narrowing -fno-rtti
14131422
teensyLC.build.flags.c=
14141423
teensyLC.build.flags.S=-x assembler-with-cpp
@@ -1566,7 +1575,7 @@ teensypp2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
15661575
teensypp2.build.flags.dep=-MMD
15671576
teensypp2.build.flags.optimize=-Os
15681577
teensypp2.build.flags.cpu=-mmcu=at90usb1286
1569-
teensypp2.build.flags.defs=-DTEENSYDUINO=154 -DARDUINO_ARCH_AVR
1578+
teensypp2.build.flags.defs=-DTEENSYDUINO=155 -DARDUINO_ARCH_AVR
15701579
teensypp2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
15711580
teensypp2.build.flags.c=
15721581
teensypp2.build.flags.S=-x assembler-with-cpp
@@ -1683,7 +1692,7 @@ teensy2.build.flags.common=-g -Wall -ffunction-sections -fdata-sections
16831692
teensy2.build.flags.dep=-MMD
16841693
teensy2.build.flags.optimize=-Os
16851694
teensy2.build.flags.cpu=-mmcu=atmega32u4
1686-
teensy2.build.flags.defs=-DTEENSYDUINO=154 -DARDUINO_ARCH_AVR
1695+
teensy2.build.flags.defs=-DTEENSYDUINO=155 -DARDUINO_ARCH_AVR
16871696
teensy2.build.flags.cpp=-fno-exceptions -fpermissive -felide-constructors -std=gnu++11
16881697
teensy2.build.flags.c=
16891698
teensy2.build.flags.S=-x assembler-with-cpp

teensy/avr/cores/teensy3/usb_serial.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,18 @@ class usb_serial_class : public Stream
7676
public:
7777
constexpr usb_serial_class() {}
7878
void begin(long) {
79-
//uint32_t millis_begin = systick_millis_count;
80-
//disabled for now - causes more trouble than it solves?
81-
//while (!(*this)) {
82-
// wait up to 2.5 seconds for Arduino Serial Monitor
83-
// Yes, this is a long time, but some Windows systems open
84-
// the port very slowly. This wait allows programs for
85-
// Arduino Uno to "just work" (without forcing a reboot when
86-
// the port is opened), and when no PC is connected the user's
87-
// sketch still gets to run normally after this wait time.
88-
//if ((uint32_t)(systick_millis_count - millis_begin) > 2500) break;
89-
//}
79+
uint32_t millis_begin = systick_millis_count;
80+
while (!(*this)) {
81+
uint32_t elapsed = systick_millis_count - millis_begin;
82+
if (usb_configuration) {
83+
// Wait up to 2 seconds for Arduino Serial Monitor
84+
if (elapsed > 2000) break;
85+
} else {
86+
// But wait only 3/4 second if there is no sign the
87+
// USB host has begun the USB enumeration process.
88+
if (elapsed > 750) break;
89+
}
90+
}
9091
}
9192
void end() { /* TODO: flush output and shut down USB port */ };
9293
virtual int available() { return usb_serial_available(); }

0 commit comments

Comments
 (0)