-
-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teensy support? #700
Comments
Hello @SebCanet , It seems that teensy doesn't follow the right 3rd party install. It hacks the arduino folder by adding teensy board directly in the arduino root folder The most straightforward way is probably to ask to PJRC to provide an URL that publishes the teensy platform instead of an executable file. You agree, it is not related to arduino-cli ;-) |
Hi @SebCanet, @jmchiappa, The Arduino CLI do not support Teensy at the moment, there are 2 reasons:
Thanks for the heads up! |
Hi, Many thanks. |
Hi Guys, Was there any progress on this? Cheers Andy |
hi @AndrewCapon |
Hi @ubidefeo Thanks very much for the info, I will keep an eye out. Have a nice day. Andy |
Any update? |
hi @Beefy-Swain You can probably hack your way into supporting Teensy for your own needs but I'd wait for something that is well thought of by Paul Stoffregen in order to make sure his User Experience is preserved. A bit more patience might be required, just know that we're not sleeping on this one :) |
I have made a small workaround for teensy based boards. https://github.com/gannaramu/Teensy-Github-Action. It does not use the arduino-cli, but hope it helps someone. |
@ubidefeo - Is any info or specification published regarding your plans for Pluggable Monitor? As I'm sure you're already aware, Teensyduino adds patches to the Java IDE to implement a pluggable monitor using stdio/stdout/stderr, using only very simple status messages on stderr. I seem to recall a conversation in 2019 about plans to use localhost networking and maybe RPC? Is that still your plan? If you have any sort of preliminary spec, I would really like to begin migrating Teensyduino to use that approach on the Java IDE, so I am ready to fully support arduino-cli and the Pro IDE when you add pluggable monitor. |
I should also mention, serial monitor performance is critically important for Teensy 4.x. Here is a simple USB Serial.print() speed test. Very easy to run this on any board, just copy into Arduino, upload, and open the serial monitor to watch the result. https://github.com/PaulStoffregen/USB-Serial-Print-Speed-Test/blob/master/usb_serial_print_speed.ino I ran this yesterday on Portenta. It prints just over 10000 lines/sec. Teensy 4.0 can print ~700000 lines/sec to Linux desktop systems, and about 500000 - 600000 to Windows. Very efficient serial monitor code is needed to keep the IDE from crashing with sustained incoming data at that speed. I rewrote the serial monitor's internal data storage, and even then Java struggles to keep up with this speed. If you are still in the process of choosing the pluggable monitor approach, I hope we can work together as it evolves. |
thank you for taking the time to reach out. I have recently found out that the current monitor we're using in the Pro IDE is dropping packets (which is better than crashing the host app) so that will need some serious rework. We're more than interested in having Teensy support, as you know, and I think the work done on the CLI over the past few months has been laying the foundation to make this work, we just need a bit more time. Unfortunately we only have 2 developers on CLI, but development has been moving forward pretty steadily. Let's reconnect in a week, I'll ask Cristian to email you. |
@ubidefeo - Do you have any Teensy boards for testing? If not, please email me directly and I will arrange to send you some. I'll pre-load that USB speed test on them so you can just plug it in and open the serial port. Even if all features are implemented, long-term the Pro IDE needs to be able to handle incoming serial data at high speed, so please let me send you some hardware you can use for performance tests. |
@paulrnash If you can send us that USB speed test code (or binary we can upload with Also today I was chatting with @facchinm and he pointed me at some serial handling code that already needs patching. I really look forward to the team being back from the holiday so we can keep hammering 🔨 🔨 🔨 |
Here's the speed test code. https://github.com/PaulStoffregen/USB-Serial-Print-Speed-Test/blob/master/usb_serial_print_speed.ino And here's a copy right in this message! It's just a very simple sketch. Just copy into the IDE and upload to any board. uint32_t count, prior_count;
uint32_t prior_msec;
uint32_t count_per_second;
// Uncomment this for boards where "SerialUSB" needed for native port
//#define Serial SerialUSB
void setup() {
Serial.begin(1000000); // edit for highest baud your board can use
while (!Serial) ;
count = 10000000; // starting with 8 digits gives consistent chars/line
prior_count = count;
count_per_second = 0;
prior_msec = millis();
}
void loop() {
Serial.print("count=");
Serial.print(count);
Serial.print(", lines/sec=");
Serial.println(count_per_second);
count = count + 1;
uint32_t msec = millis();
if (msec - prior_msec > 1000) {
// when 1 second as elapsed, update the lines/sec count
prior_msec = prior_msec + 1000;
count_per_second = count - prior_count;
prior_count = count;
}
} |
straight forward Hope to have an update for you soon. |
Hahaha - all native USB boards have plenty of black magic lurking deep underneath Serial.print() |
Any update on this? |
@kofoednielsen we are currently working on the Pluggable Discovery, that will make it possible to add support for Teensy and lots of other features. Just releasing this new feature won't make it magically work though, the Teensy platform will need to be updated to support this new feature and that's up to @PaulStoffregen. |
I'm planning to work with the new Pluggable Discovery in a few weeks. Currently working on support for hardware decryption in flash memory, which is turning out to be a lot more work than originally anticipated (easy to do poorly, tough to make actually secure & also simple to use). Hoping to wrap it up soon. Teensy already implements an earlier version of Pluggable Discovery, so I'm not expecting trouble with Pluggable Discovery. But Pluggable Discovery alone isn't enough for Teensy to be fully supported by future Arduino software. Teensy will also need Pluggable Monitor, which Teensyduino implements today by a large set of Java patches. Also on my to-do list is a proof of concept pluggable monitor conforming to the draft spec Cristian recently wrote. |
For the records, implementation (arduino-cli side) is going on here #1333 🔨 |
Hi there, I notice that #1333 is merged now, and the Pluggable Monitor RFC appears to have been merged to (unsure of implementation) - is there a good spec or the like available for folks to add a Teensy plugin? |
@catkins here is the pluggable discovery-related documentation: |
It has been 3 months and I can't find any good updates about Teensy support with Arduino CLI / 2.0 IDE. It looks like Pluggable Discovery and Pluggable Monitor have been added but I have not seen much from Paul on whether PJRC is working on it yet. Are there any updates? |
@Michael2MacDonald - Sorry, I've been really distracted by USB MTP recently, and also managing business problems from chip shortages. I don't have any update for you, other than I'm alive (no covid yet, fully vax+boost) and I am working on a lot of stuff, where this is on a long list of higher priority tasks to be worked on "soon". |
Thanks for the update! |
I've been able to get cli-based compilation and upload to Teensy devices with the following on Ubuntu. Change as needed for your use case (e.g. I imagine most people won't want to save things to /tmp): Setup: # Set up ability to compile code for Teensy controller
# Downloads Arduino and patches it with teensy support
# https://www.pjrc.com/teensy/td_download.html
curl -sSL https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz > /tmp/arduino-1.8.19-linux64.tar.xz && \
curl -sSL https://www.pjrc.com/teensy/td_156/TeensyduinoInstall.linux64 > /tmp/TeensyduinoInstall.linux64 && \
curl -sSL https://www.pjrc.com/teensy/00-teensy.rules > /tmp/00-teensy.rules && \
mkdir -p /etc/udev/rules.d && \
mv /tmp/00-teensy.rules /etc/udev/rules.d && \
tar -C /tmp -xf /tmp/arduino-1.8.19-linux64.tar.xz && \
mv /tmp/arduino-1.8.19 /tmp/arduino && \
chmod 755 /tmp/TeensyduinoInstall.linux64 && \
/tmp/TeensyduinoInstall.linux64 --dir=/tmp/arduino
# Note: also copy your custom arduino libraries to ~/Arduino/libraries/
# More info at https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc Usage in python (with two Teensys connected to my computer, both using the same code): import sys
import serial # from pyserial
import serial.tools.list_ports
def get_serial_devices():
if sys.platform == "linux" or sys.platform == "linux2":
device_string = "ttyACM"
else:
# Windows, Mac etc
raise Exception(f"Unsupported platform detected: {sys.platform}")
all_devices = serial.tools.list_ports.comports()
all_devices = [(d.device.replace("cu", "tty"), d.manufacturer) for d in all_devices]
all_devices = list(set(all_devices))
serial_devices = [d for d in all_devices if device_string in d[0]]
return serial_devices
serial_devices = get_serial_devices()
teensys = [
port
for (port, manufacturer) in serial_devices
if manufacturer == "Teensyduino"
]
for idx, port in enumerate(teensys):
DEVICE, SPEED, USBTYPE, INO_PATH = "teensy41", "600", "serial", "/path/to/your.ino"
os.system(f'/tmp/arduino/arduino --verify --port {port} --board "teensy:avr:{DEVICE}:usb={USBTYPE},speed={SPEED},opt=o2std,keys=en-us" {INO_PATH}')
if idx != len(teensys) - 1:
# Added a 500ms timeout as it seemed to have issues without any sleep between flashes
# Could be more scientific on what the length of this delay should be
time.sleep(0.5) Usage in bash (not tested) # get ports in bash, from https://unix.stackexchange.com/a/668691:
vidpid_to_devs(){
find $(grep -l "PRODUCT=$(printf "%x/%x" "0x${1%:*}" "0x${1#*:}")" \
/sys/bus/usb/devices/[0-9]*:*/uevent | sed 's,uevent$,,') \
/dev/null -name dev -o -name dev_id |
sed 's,[^/]*$,uevent,' |
xargs sed -n -e s,DEVNAME=,/dev/,p -e s,INTERFACE=,,p
}
# "16c0:0483" is for teensy 4.1, find whatever [vendor]:[product] yours is by running lsusb
vidpid_to_devs 16c0:0483 \
| xargs -I %s -- sh -c '\
echo "Attempting to program Teensy at %s" \
&& /tmp/arduino/arduino --verify --port %s --board "teensy:avr:{DEVICE}:usb={USBTYPE},speed={SPEED},opt=o2std,keys=en-us" {INO_PATH}
&& sleep 0.5 \
&& echo "Finished with Teensy at %s"' Basically, using the arduino cli instead of arduino-cli 😛 I do get the following issue when using this though (message seems to come from the
Update, I've gotten uploading to a specific teensy semi-working with a fork of teensy_loader_cli. Weird thing is it seems to work exactly every other time, so I have to run it twice. # install teensy_loader_cli
apt-get install -y libusb-dev && \
git clone -b serial_number --single-branch --depth 1 https://github.com/raphaelrk/teensy_loader_cli.git /tmp/teensy_loader_cli && \
cd /tmp/teensy_loader_cli/ && \
make
# get teensy serial numbers
apt-get install usbutils
lsusb -d 16c0:0483 -v 2>/dev/null \
| grep iSerial \
| awk '{print $3}'
# run it once, doesn't work
# .hex comes from running arduino's cli above with `--pref build.path=/tmp/embedded_build`
root@ubuntu:/tmp/teensy_loader_cli# ./teensy_loader_cli --mcu=TEENSY41 -w -v -s --serial-number=12345678 /tmp/embedded_build/main.ino.hex
Teensy Loader, Command Line, Version 2.2
Read "/tmp/embedded_build/main.ino.hex": 128000 bytes, 1.6% usage
Soft reboot performed
Waiting for Teensy device...
(hint: press the reset button)
Found HalfKay Bootloader
Read "/tmp/embedded_build/main.ino.hex": 128000 bytes, 1.6% usage
Programming...error writing to Teensy
# run it again, works
root@ubuntu:/tmp/teensy_loader_cli# ./teensy_loader_cli --mcu=TEENSY41 -w -v -s --serial-number=12345678 /tmp/embedded_build/main.ino.hex
Teensy Loader, Command Line, Version 2.2
Read "/tmp/embedded_build/main.ino.hex": 128000 bytes, 1.6% usage
Found HalfKay Bootloader
Programming..........................................................................................................................
Booting Update, above error no longer happens. I changed all calls to teensy_write in teensy_loader_cli.c to have a timeout of 1 which fixed it. So everything seems to work now 🎉 |
I'm been working on this recently. Here is an early and very experimental first try. So far only tested in Arduino 1.8.19 portable. Tools are only built for Linux x86_64 so far. https://www.pjrc.com/teensy/td_156/package_teensy_index.json Unresolved problems. 1: Upload recipe causes GUI-based Teensy Loader to actually perform the upload. That's probably not going to make command-line-only Arduino CLI users happy. I can't find any predefined property to inform my tools whether to run a GUI-based or "headless" upload process is appropriate. @cmaglie - Any suggestion how I should handle this? Is there any way my upload command can detect whether the upload request came from an IDE or CLI? 2: Boards Manager in Arduino 1.8.19 does not start the Pluggable Discovery process my platform.txt file specifies. A full restart of the Arduino 1.8.19 IDE is needed after installing the package. Also, my discovery utility is older than the Pluggable Discovery spec and speaks the JSON dialect of the Java IDE... still needs to be updated for the new spec. 3: I don't understand how to use discoveryDependencies in my package index JSON, or whether I even need to do so. Currently I have my discovery tool inside a tools package installed by toolsDependencies. If I create a discoveryDependencies section, it is supposed to reference a download from my "tools" section? Or do I need to add something else to the JSON? I seem to be missing some piece of the documentation about how the JSON is supposed to look. 4: Serial Monitor isn't working yet. My serial monitor stuff was created before the Pluggable Serial Monitor spec, and still needs to be converted from stdin/stdout to localhost socket. 5: Teensy has its own size utility. The regex-based size isn't enough for the complicated memory on Teensy 4.x. Currently I'm running it by one of the hooks and it has to print to stderr which appears in alarming red. Still need to try using advanced size feature. |
More progress. Looks like discoveryDependencies just references stuff in the tools section (which wasn't clear to me from the documentation and so far I could not find any other platforms using this feature to serve as any example). Still need to update Teensy's discovery tool for the new JSON format and require state machine. But I'm stuck on monitorDependencies. Looks like it might be issue #1564. |
More progress, got Pluggable Discovery working on Linux. Had to redesign my old discovery code from the 1.8.x IDE, which ignores stdin and just operates in sync mode. With stdin parsing for the required commands, the "board list" command is finally working.
|
Hi @PaulStoffregen, great to see progress on this one! here some random answers:
Unfortunately no (at least nothing comes to my mind right now). Maybe we can set an environment variable to check like
this must be fixed in the Arduino IDE 1.8.x. I've never encountered this bug (because we never had a pluggable discovery platform before...).
yes, I see that you successfully updated it, so I consider this part solved
You're correct they must be part of the
Yes, that one is a big chunk of work, let me know if I can help in some way. https://arduino.github.io/arduino-cli/0.20/platform-specification/#pluggable-discovery
If you can link me your |
Would it really make sense to not set that value when running from gRPC? It would indeed allow distinguishing IDE from commandline usage, but I would be otherwise surprised by this. If somehow the discovery wants to know the arduino-cli version, (e.g. to work around a bug in the discovery protocol implementation maybe), then it would not be able to use this variable in gRPC mode. TBH I haven't looked much at how the gRPC stuff works, but just from reading this comment I have serious doubts about this approach. @PaulStoffregen, going one step back here, if there is a headless upload available, why not always use that one? That is consistent with most if not all other platforms. What is the gain of using a GUI for upload here? |
The intended user experience for Teensy is to show uploading in a GUI. The GUI also gives users troubleshooting and diagnostic info, and offers additional features which have been a well established practice for Teensy over the last 12 years.
User experience matters greatly. |
Would using a headless uploader be able to provide a roughly equivalent user experience by outputting the troubleshooting & diagnostic information to STDOUT, which would then show up in the console in Arduino IDE? |
@cmaglie - Any chance to get that environment variable into a nightly build? I've got Pluggable Discovery and Pluggable Monitor working on Linux x86_64. Today I'm going to work on converting Teensy 4 sizer to JSON and updating the Java patches. So the last major issue should be adding a headless upload mode, rather than always running the GUI as Teensy has always done. |
The cli version is already passed in the
Let me draft something in a new PR, so we can move the discussion there. |
Good news! If you've been following this issue and patiently waiting for me to finally publish a first experimental version, now it has finally come. Well, at least for Linux x86_64. If you install and try this, please share any Teensy-specific feedback on the forum thread. Let's only add more messages on Arduino's issue tracking if problems turn up that might be relevant to actual arduino-cli issues. |
Quick update for everyone watching this issue & waiting for better Arduino CLI support. Package version 1.56.1 is now available, with support for Windows, MacOS and Linux x86_64. Details here: Pluggable Discovery and Pluggable Monitor are fully implemented on all 3 platforms. Uploading is still done by launching a GUI program, but support for headless mode is planned for future versions. See the forum post for more detail. |
I have managed to run and test a build in Github Actions my using |
In case anyone is wondering, I've been really distracted by semiconductor shortage and production issues for the last several weeks. In that time, Arduino did implement the version metadata needed to distinguish GUI versus headless. But IDE 2.0-rc5 still is not using pluggable monitor. The main issue blocking Teensy support is this: In normal times I would probably publish a 1.56.2 package to make use of the version info, and then another 1.56.3 package when the new IDE starts supporting pluggable monitor. Still might do that, but right now focusing on the business side (we ran out of Teensy 4.1 last week - more being made now) and probably going to wait until IDE 2.0-rc6 adds pluggable monitor support to use both features. |
@PaulStoffregen - looks like RC6 was released yesterday or the day before, but it so far I have not seen anything that went into |
Don't see anything I can do, other than wait patiently for Arduino to implement pluggable monitor. |
Looks like pluggable monitor just landed! arduino/arduino-ide#982 |
@prutschman - Yup, and it's working pretty well with the 1.56.1 package. Or at least the snapshot yesterday was. Haven't run it since (instead worked on a Wire library slave mode high frequency noise sensitivity issue today). If you want to give 1.56.1 a try, this is the preliminary package index to add with File > Preferences (or add to arduino-cli.yaml for Arduino CLI). https://www.pjrc.com/teensy/td_156/package_teensy_index.json Some documentation and extra info can be found here: https://forum.pjrc.com/threads/53548-Arduino-CLI-Alpha-Release-Teensy-Support On msg 178 of that thread, you can find a solution for using Teensy with both Arduino IDE 1.8.19 and Arduino IDE 2.0-rc. We're in the early days of beta testing Teensyduino 1.57. As always, latest beta can be found on the forum announcements. Next beta (coming in a week or two) will include that 1.8.19 workaround, and (probably) a new package index to use the latest beta on 2.0 nightly builds, and (maybe) some updates to fix minor issues, plus of course the many new Teensy-specific features of 1.57. But right now, if you want to use Teensy on the latest Arduino 2.0 nightly builds, the old 1.56.1 package file works fine. It's had pluggable monitor all this time. Now you can really use it with the new IDE. |
Closing as resolved by the completion of support for pluggable discovery and pluggable monitor. |
Hi,
I don't know if it's the right place to ask it, but is there any support for Teensy board?
I did not find any information for this kind of board.
Many thanks.
The text was updated successfully, but these errors were encountered: