OTA Sketch Updates for Teensy

Status
Not open for further replies.

BobM

Member
I have been using a Teesny 3.2 for the past 18 months to drive a string of 850 WS20812B LED's around the perimeter of my backyard deck using the FastLED program and the Arduino IDE. The programs run various light colors and patterns based on the season and holiday and turn on/off based on time taken from a RTC I have connected to the Teensy.

I'm getting tired of bringing the Teensy in the house and connecting it to my PC to upload a new sketch so I'd like to look at OTA updates.

Can you point me to a 'simple' & reliable method or tutorial showing how to connect an ESP8622 or ESP32 to the Teensy to enable OTA Sketch updates? Or is there a better way to do OTA updates with a Teensy?

Thanks
 
There isn't a published supported way to update a Teensy beyond direct USB.

Some others have made/found ways - but it takes looking to discover them and then the risk they will brick your Teensy in the process.
 
Honestly, the best approach might be to get a Raspberry Pi and have the Raspberry Pi program the Teensy.
 
Jonr,

Can you expand on this project a bit? I looked at your flasher.cpp and it seems pretty reasonable, but a little more detail on the RF link portion of this would be nice, if you have the time.

TIA,

Frank
 
It probably isn't clear that it's more of a library that allows flashing teensy firmware. Unless you use the serial port, getting the data to the teensy has to be addressed with other code.
 
jonr,

Thanks for the reply. Its very frustrating to have such a nice line of MCU's with the Teensy 3.x & now the 4.x, but still have no good way of updating firmware OTA. I have seen some posts talking about the use of RPI's, and another talking about the 'flasher4' library, and now your post describing what appears to be a complete solution for the T3, but a bit light on details ;-). I was able to see some of the Teensy schematic by importing it into my DipTrace app, and I see where you are connecting something to the D+ & D- USB lines - is that how you are getting firmware into the Teensy? If so, can you describe the RF link portion of your project?

Alternatively, can you point me to an overall description of the project anywhere?

TIA,

Frank
 
Could you use a cheap ESP based board to get the "Over Air" bit then send it to Teensy with serial?
 
Could you use a cheap ESP based board to get the "Over Air" bit then send it to Teensy with serial?

That sounds great, but I'm not sure how that would work in detail. Is it sufficient to simply connect to the D+/D- pins on the USB connector so the Teensy thinks it is connected to a USB port, or is something like jonr's 'flasher.cpp' still required as part of any Teensy program using this technique?

Frank
 
I'm making some baby steps toward integrating an ESP32-based WiFi module with a Teensy setup for OTA programming. Using this tutorial, I have been able to pass text back and forth between two PuTTY terminals - one connected to the wireless port, and another connected to Rx0/Tx0.

However, I'm unsure of what the next step would be - do I then connect the Rx0/Tx0 lines to the Teensy's USB-D+/D- lines, or what?

TIA,

Frank
 
I've updated a Teensy with a Raspberry Pi Zero W. If you need the Pi desktop environment to install Arduino and configure things, the Zero is so slow, it's barely usable. Once you struggle through that, though, the teensy_loader_cli command works and will update your Teensys. The Raspberry Pi 4 looks like it would be a much better choice than the Zero because it has a faster processor and more RAM, but I haven't tried it myself.

I prefer using a pocket router running OpenWrt Linux. It's not difficult any more to compile the teensy_loader_cli application, though OpenWrt has a bit more of a learning curve than the Raspbian desktop. A GL-iNet GL-MT300N-V2 Mango Mini Router has a regular USB A port. You can power it from a USB battery.

For my cove lights and sunlight monitor, I pair an OpenWrt router with a Teensy plugged into the USB port of the router. The router talks to the Teensy by USB Serial. The Teensy drives the lights or sensors. I can connect to the routers over WiFi. The routers are configured in station mode. They each have one or more web servers, one for configuring the router itself, and the other for the application, e.g. controlling the lights. Sometimes getting USB Serial to work reliably can be a bit of a challenge. You have to install the right drivers and utilities for /dev/ttyACMn and stty, etc.

The Mango can reprogram the Teensy without the need to press the Teensy's program button. I use this script

Code:
#!/bin/sh
usbreset 16c0:0487
sleep 2
teensy_loader_cli --mcu=TEENSYLC -v -s /root/reboot2.hex&
sleep 1
echo "reboot" > /dev/ttyACM0
exit 0

The Teensy runs a sketch that reads commands using Serial.read() and calls _reboot_Teensyduino_() when it sees the string "reboot". Don't forget to change
the parameters to teensy_loader_cli for your stuff.

I haven't figured out why the call to usbreset is needed or a better alternative to the sleep commands.

https://store.gl-inet.com/products/gl-mt300n-v2-mini-smart-router
https://openwrt.org/toh/gl.inet/gl.inet_gl-mt300n_v2

Alas, none of this is as simple as it could be.
 
Status
Not open for further replies.
Back
Top