Field Updates for Teensy 3.X

Davidelvig

Well-known member
I've seen lots of posts on possible ways to update a Teensy in the field, notably this one and some on OTA with BLE. They look like installed apps on a linux, Windows or Mac computer.

I think my needs are simple:

I have a product, soon in the field, that will have USB cable access to a web-connected PC or Mac in the customers hands. The customer is non-technical.

My products will have a PJRC Teensy in them for a long while. 3.2 now. I may see if I can use the LC.

I want the user to plug my product into USB (via the standard Teensy micro-USB socket), and launch my website in a browser, and choose "update the product" or something link that.

I'd like it to be as if I have their Teensy plugged into my Arduino environment and press "Upload".
I could arrange to have them push the program button on the Teensy (paper clip through the enclosure to the button?)

Does this solution exist here in the Forum? (I'm not yet finding it)

Thanks!
 
If you provide the hex file on your website, you can make a batch file with the teensy command line uploader, that way a user just has to double click the batch file and it will upload
 
Right. With this approach, I'd need to:
- have an installed app on Windows and/or Mac build from here - and installed sometime after the customer purchases my product (or a copied app and a batch file)
- have the user copy a HEX file from my website to a particular location on the PC
- Connect the product via USB, then click on an icon for the installed app above and run it

I suppose I could eliminate the HEX file copy by having the installed app get it from the web.

Is this the easiest way?
Is there any way to do updates of a Teensy in the field that does not involve an native app on Mac and Windows?
 
I'm resigned to have an installed loader app (or file-copied loader app) on the customers' PCs/Macs - an app created from Teensy_loader_cli.c, I expect.
I'm looking for an easy workflow for the end user, such as:
1) visit my website, and "download the latest software version". That would copy what's needed to the Downloads directory on their PC/Mac
2) then they double click on the downloaded thing, and a HEX file is copied to their USB-attached Teensy (my device).

I'm having trouble putting this together based on forum posts, and this Github site, and this Teensy Loader Application page and this Command Line version page on pjrc.com

My aim:
a) deliver updated HEX files to non-technical end-users via a link on a web page
b) have a simple process where they can flash their Teensy-based device (my device) with the new code.
and... not show them a technical-looking user interface

I expect many are doing just this.
Where can I find the recipe?

Dave
 
The command line version should contain everything you need and I'd say it is a perfect "receipe" to write your own loader.
 
While Frank is right of course (and I also used the commandline version and the TyTools code to find out how it is done), it is quite low level and might be difficult to transfer if one is used to more modern ways to program GUIs.

Here https://github.com/luni64/TeensySharp is a dotNet / c# library which can be used to integrate firmware uploading directly in your user application (or to do a dedicated uploader) with a couple of code lines. Basically it works like this:

First obtain an empty flash image and parse a hex file into it:
Code:
var FlashImage = SharpUploader.GetEmptyFlashImage(Board);
SharpHexParser.ParseStream(File.OpenText("firmware.hex"), FlashImage);

To upload you first get hold of one of the connected Teensies (here I simply grab the first I find). Then you start the bootloader on that board and upload the image.

Code:
USB_Device Teensy = Watcher.ConnectedDevices.FirstOrDefault();
SharpUploader.StartHalfKay(Teensy.Serialnumber);
int result = SharpUploader.Upload(FlashImage, Board, Teensy.Serialnumber, reboot: true);

Minus the usual boiler plate code this is all you need to do. There also is a worked out wpf Downloader example (ugly GUI but it shows how to do it).

Since you wrote that you want to handle PC/Mac you probably don't use dotNet. Nevertheless, the high level code of the library might be easier to transfer to whichever language you use.


Edit: It would also be simple to download the hex file directly from your server so the customer doesn't need that extra step with downloading strange files from the web.
 
Last edited:
Field Updates with teensy_loader_cli

Thanks for your suggestions @luni
As we also discussed, I've tried to use the standard teensy_loader_cli again

I've got the teensy_loader_cli working on the Mac with the following running in Terminal:
Code:
./teensy_loader_cli -mmcu=mk20dx256 -w -v TPT_V11.ino.hex

It results in this output... and I need to press the reset button as the output pauses at "(hint: press the reset button)"
Code:
Teensy Loader, Command Line, Version 2.1
Read "TPT_V11.ino.hex": 87164 bytes, 33.3% usage
Waiting for Teensy device...
 (hint: press the reset button)
Found HalfKay Bootloader
Read "TPT_V11.ino.hex": 87164 bytes, 33.3% usage
Programming......................................................................................
Booting

I'd like to avoid the Reset button press.
I've read a number of posts here suggesting that's possible.
I'm not finding the magic incantation.
Is there a way?

  • Mac OSX 10.14.6
  • Arduino 1.8.12
  • Teensyduino 1.5.1
  • Teensy 3.2, already flashed with my SERIAL+MIDI app.

I have also renamed the MIDI device in my sketch with a MIDI_Name.c tab, with contents as follows:
Code:
// To give your USB MIDI device a unique name, this code must be placed into a .c file (its own tab).  It can not be in a .cpp file or your main sketch (the .ino file).
#include "usb_names.h"

// Edit these lines to create your own name.  The length must match the number of characters in your custom name.
#define MIDI_NAME   {'D','i','g','i','B','r','a','s','s',' ','M','I','D','I'}
#define MIDI_NAME_LEN  14

// Do not change this part.  This exact format is required by USB.
struct usb_string_descriptor_struct usb_string_product_name = {
    2 + MIDI_NAME_LEN * 2,
    3,
    MIDI_NAME
};
Thanks
 
Is there someone who I could hire to construct a Teensy-3.2-related field update process?
I'd like to leverage the skills of someone who's done this before.
The user will be a novice PC or Mac (or Chromebook, I suppose) user, updating a USB-connected, Teensy-3.2 product, typically with me on the other end of the phone, or on a Zoom screen-share.
I can make access to the Teensy Reset button if needed.
This will not be the last update process, but will be used for the first 100 customers or so for occasional updates.

I look forward to your contact, here or at David.Elvig@gmail.com
Thanks!
 
Back
Top