Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 14 of 14

Thread: OTA Sketch Updates for Teensy

  1. #1
    Junior Member
    Join Date
    Feb 2016
    Posts
    7

    OTA Sketch Updates for Teensy

    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

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,928
    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.

  3. #3
    Senior Member brtaylor's Avatar
    Join Date
    Mar 2016
    Location
    Portland, OR
    Posts
    650
    Honestly, the best approach might be to get a Raspberry Pi and have the Raspberry Pi program the Teensy.

  4. #4
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    859
    You can use the flasher.cpp code here. Lots of checking and AFIAK, it has never bricked a teensy. At some point I should update it to work with teensy 4.

    https://gitlab.com/our-sci/reflectance-spec-firmware

  5. #5
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    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

  6. #6
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    859
    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.

  7. #7
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    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

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    198
    Could you use a cheap ESP based board to get the "Over Air" bit then send it to Teensy with serial?

  9. #9
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    859
    Yes, that is a good approach.

  10. #10
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    Quote Originally Posted by BriComp View Post
    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

  11. #11
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    What about using something like an HC-05 BT module for the 'RF bit'?

  12. #12
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    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

  13. #13
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    701
    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/g...i-smart-router
    https://openwrt.org/toh/gl.inet/gl.inet_gl-mt300n_v2

    Alas, none of this is as simple as it could be.

  14. #14
    Senior Member
    Join Date
    Jun 2017
    Posts
    153
    Quote Originally Posted by pictographer View Post

    Alas, none of this is as simple as it could be.
    That may well be the understatement of the decade

    Frank

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •