teensy_loader extract config before updating

jeff0778

Member
Hi,
I'm currently using the teensy_loader_cli as a method to deploy updates to devices (teensy 3.5)

However, i have a situation where some devices are on different versions and have different config files on them. Rather than resetting the device to defaults i would like to implement a method to smothly migrate them and maintain the configuration. The config is just a few structs saved to the eeprom.

i'd like to:
a) attach the usb
b) extract config structs
c) upload the new firmware
d) reset to defaults
e) download the config file

Is somthing like this posible using the teensy_loader_cli ???


Regards
 
More details needed.
Seems there are some number of historical variations of the code - perhaps each with evolving settings stored in EEPROM?
EEPROM is not erased on the upload - but if the understanding of various locations has evolved as versions changed then it would be best to have a signature or way of recognizing the prior version and use of the EEPROM and make any needed updates or changes based on that to fit with the current code's expectations.

This could be done in setup() on entry verify that the EEPROM layout present is proper for the code to follow and proceed. If that is not the case, then the appropriate steps would need to be taken so that stored information is correct for the code to follow.
 
Thanks, yes the issue im having is that the data mapping on the EEPROM changes and therfore just reading the EEPROM data in as raw can mean a missmatch.

I have looked at a number of ways to do this within the code, such as signitures etc, but this will ultimatly just keep growing and i'll eventually run out of ram, over the multiple itterations.

So my thoughts were to modify the teensy_loader_cli to first request some data on the USB (a few structs for example) The PC then stores those struts in a file on the laptop. Runs the firmware update to the teensy, then when its rebooted, the laptop can then send the structs back down the USB.

Regards
 
Teensy loader doesn't have access to that like a custom sketch would.

Would take writing a sketch to upload to spit out the values in some fashion for manipulation, then perhaps another intermediate sketch to take in the changes - again not a feature of the loader.

Rather a custom sketch could run once - perform the evaluation and updates in place - then be replaced by the new code with EEPROM properly configured.

Given a T_3.5 it could export the data to an SD card for PC manipulation and then have the data formatted for setting - again two intermediate sketches.
 
Thanks, unfortuanlty i don't have access to the SD card.

so im not specifically needing the teensy loader itself to do this. Im considering if its possible to modify the CLI aspect of the teensy loader so it would be e.g. press 'A' to copy the config, press 'B' to upload firmware, press 'C' to load config.
So A & B would just run a serial.write() / read type function to transfer the config data.
I'd appreaciate that i'd need to write some handler on both ends to cope with option A & B

Cheers
 
so im not specifically needing the teensy loader itself to do this. Im considering if its possible to modify the CLI aspect of the teensy loader so it would be e.g. press 'A' to copy the config, press 'B' to upload firmware, press 'C' to load config. So A & B would just run a serial.write() / read type function to transfer the config data. I'd appreaciate that i'd need to write some handler on both ends to cope with option A & B

The Teensy Loader CLI does not have the ability to read (or request) data from EEPROM. As @defragster has said, you either need to build the capability into your application (sketch) to do "in-place" updates as a function of version, or else you need your sketch to communicate with a custom program on the host to save/restore the EEPROM contents before/after the firmware update. For example, your sketch would need to listen for commands on the USB serial port and send the EEPROM data on request. Your host program would receive the data and save it to a file on your PC. Then you would update firmware using Teensy Loader CLI, and then finally you would restart your custom host program to send the contents of the file back to the Teensy, which would write the data into EEPROM. And unfortunately this doesn't solve the problem of updating the devices you have running now.

There are libraries that support serial communication on Teensy, such as EasyTransfer and SerialTransfer (my preferred), but you would have to build the host program yourself. What is your host, and do you have experience with development tools for building host programs?
 
Hi,
The Teensy Loader CLI is just a c program with firmware upload functions and facilities. Im not sure why you don't think it can be modified? I've not asked to read directly from the EEPROM, im looking to read a struct that happens to be also saved to the EEPROM.

What i've been trying to ask is using the Teensy Loader CLI as the foundation of then adding more controls.

e.g. press 'A' to copy the config, press 'B' to upload firmware, press 'C' to load config
Cheers

Thanks for suggesting EasyTransfer.
I will take a look at forking the Teensy Loader CLI and add some EasyTransfer to give the user option A & C options and then run some of the Teensy Loader CLI functions if they select B

I have over 1,500 of these devices out in the feild and this is becoming a real issue for me managing the updates.
thanks
 
The Teensy Loader CLI is just a c program with firmware upload functions and facilities. Im not sure why you don't think it can be modified? I've not asked to read directly from the EEPROM, im looking to read a struct that happens to be also saved to the EEPROM. What i've been trying to ask is using the Teensy Loader CLI as the foundation of then adding more controls.

Thanks for suggesting EasyTransfer. I will take a look at forking the Teensy Loader CLI and add some EasyTransfer to give the user option A & C options and then run some of the Teensy Loader CLI functions if they select B I have over 1,500 of these devices out in the feild and this is becoming a real issue for me managing the updates.

I don't know a lot about the Teensy loader CLI, but AKAIK it communicates with the bootloader, and does not have the possibility to communicate with your sketch. Let us know what you find as you get into it.
 
Hi,
It only talks to the bootloader when an specific funtion within the teensy_loader_cli program is called, which asks the teensy to go into the bootloader..
 
It only talks to the bootloader when an specific funtion within the teensy_loader_cli program is called, which asks the teensy to go into the bootloader..

I see in the cli source code that there is a simple write function, and that's how the new firmware is sent to the Teensy, so you could use that to write new data to EEPROM, but I don't see any read capability, which is too bad. Yes, I think you're right that you could extend the cli to communicate with the sketch to read the EEPROM data before entering the bootloader.
 
Back
Top