FlasherX OTA update to a Teensy3.5 on Serial1 fails in the presence of a 'live' USB connection

paynterf

Well-known member
I have small autonomous robot that has a Pi5 for vision-based navigation and a Teensy 3.5 for motor & sensor management. I have a SSH wireless local network connection to the Pi5 for telemetry, testing, and for OTA updates to the Teensy firmware. I have a Visual Studio/Visual Micro setup that uses 'board.txt' to SCP a HEX file to the Pi5, and the Pi5 script runs a background loop that monitors the HEX file for 'newness'. When a new HEX file is detected, the Pi5 sends a trigger letter ('U') to the teensy on Serial1 which gets consumed by a monitoring function 'CheckForUserInput()'. This triggers a call to FXUtil.cpp's 'update_firmware()' function which prompts the Pi5 to send the hex lines via Serial1. This all works fine as long as there is no 'live' cable connection to the Teensy's hardware USB port.

However, if there *is* a USB cable connected, the HEX file lines sent to the Teens via Serial1 get consumed by 'CheckForUserInput()' instead of FXUtil.cpp's 'update_firmware()'. Because 'CheckForUserInput()' also controls the robots motors, some of the HEX file lines appear as motion commands, causing my poor robot to do something close to a 'St Vitus dance.

This isn't normally a problem, as the whole idea of OTA is to NOT require a USB connection. I only noticed this because I'm using a 6' long USB cable to do wired updates to speed up debug testing iterations, and decided to verify that I could still do OTA updates - without first disconnecting the USB cable - oops!

If anyone is interested in delving into this, my Teensy code is published on Github here, and Joe Pasquariello's FlasherX library is here
 
Your function CheckForUserInput() processes whatever characters arrive on either Serial or Serial1 as user input. You just need to decide where your input is coming from so that you interpret it correctly. If you look at the original FlasherX code, you'll see functions that take Stream* argument. They read from Serial or Serial1, Serial2, etc. depending on that argument.
 
Back
Top