take the teensyload_cli source code and build your own SW, CLI or GUI as you wish
If what you want to do is load firmware without access to the USB port, have a look at this thread. I tried it about a year ago and was able to install an update via a hardware serial port. I only tested the process "manually", i.e. using a terminal emulator to send the specified commands and then to send the file containing the new firmware. I never got around to automating it. The basic idea is that your application must fit in less than half of flash space, so the other half is available to install an update. If you use that thread as your starting point and switch to that thread for discussion, there probably will be others who have gone further than I did.
Joe
https://forum.pjrc.com/threads/29607-Over-the-air-updates
var Board = PJRC_Board.Teensy_31;
var FlashImage = SharpUploader.GetEmptyFlashImage(Board);
SharpHexParser.ParseStream(File.OpenText("firmware.hex"), FlashImage);
USB_Device Teensy = Watcher.ConnectedDevices.FirstOrDefault();
SharpUploader.StartHalfKay(Teensy.Serialnumber);
int result = SharpUploader.Upload(FlashImage, Board, Teensy.Serialnumber, reboot: true);
At least for windows you can have a look here https://github.com/luni64/TeensySharp The purpose of the library is to provide firmware download capability for user applications. You can of course use it to program a fancy stand alone FW uploader as well.
Usage is quite simple. Basically you create an empty firmware image for your board and parse a Hex file into it:
Code:var Board = PJRC_Board.Teensy_31; var FlashImage = SharpUploader.GetEmptyFlashImage(Board); SharpHexParser.ParseStream(File.OpenText("firmware.hex"), FlashImage);
Then you start the Bootloader (HalfKay) on the Teensy and download the prepared image by calling
Code:USB_Device Teensy = Watcher.ConnectedDevices.FirstOrDefault(); SharpUploader.StartHalfKay(Teensy.Serialnumber); int result = SharpUploader.Upload(FlashImage, Board, Teensy.Serialnumber, reboot: true);
A complete example can be found in the linked repository
This looks VERY VERY promising. Thank you so much. I'll see what I can do.
using Microsoft.Win32;
using System.Windows;
using TeensySharp;
using System.IO;
namespace WpfDownload
{
public partial class MainWindow : Window
{
TeensyWatcher watcher;
public MainWindow()
{
InitializeComponent();
watcher = new TeensyWatcher();
// fill board list with connected boards
foreach (var teensy in watcher.ConnectedDevices)
{
cbTeensy.Items.Add(teensy);
}
cbTeensy.SelectedIndex = 0;
watcher.ConnectionChanged += OnBoardPlugged; // event handler
}
// Handle life hot plugging of boards -------------------------------------------------
private void OnBoardPlugged(object sender, ConnectionChangedEventArgs e)
{
var board = e.changedDevice;
if (e.changeType == TeensyWatcher.ChangeType.add)
{
Dispatcher.Invoke(() => // we can not access GUI thread directly from event handler, use dispatcher instead
{
cbTeensy.Items.Add(board);
cbTeensy.SelectedItem = board;
});
}
else if (e.changeType == TeensyWatcher.ChangeType.remove)
{
Dispatcher.Invoke(() => // we can not access GUI tread directly from event handler, use dispatcher instead
{
cbTeensy.Items.Remove(board);
cbTeensy.SelectedIndex = 0;
});
}
}
private void Browse_Click(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog();
if (dlg.ShowDialog() == true)
{
tbFirmware.Text = dlg.FileName;
}
}
private void Download_Click(object sender, RoutedEventArgs e)
{
if (!File.Exists(tbFirmware.Text))
{
MessageBox.Show("Firmware file not found!");
return;
}
var board = cbTeensy.SelectedItem as USB_Device;
var image = SharpUploader.GetEmptyFlashImage(board.Board);
using (var stream = File.OpenText(tbFirmware.Text))
{
SharpHexParser.ParseStream(stream, image);
}
var fwType = SharpHexParser.IdentifyModel(image);
if (fwType != board.Board)
{
MessageBox.Show("Firmware not compatible with Board");
return;
}
SharpUploader.StartHalfKay(board.Serialnumber);
int result = SharpUploader.Upload(image, board.Board, board.Serialnumber);
if (result != 0)
{
MessageBox.Show("Error uploading board");
}
}
}
}