-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Corentin Altepe edited this page May 31, 2016
·
10 revisions
InnovasubBSL430 is a C# library for field firmware update on MSP430 devices via USB. It is NOT a C# wrapper for TI's C++ BSL430 library. It is rather written from zero, using the excellent HidLibrary by mikeobrien.
All contributions are welcome!
In order to run a firmware update:
- Ensure the flash BSL of the MSP430 is running and the device is connected to the computer with a USB cable.
- Run the following code:
// Considering BSL already enumerated - attempt connection
FirmwareUpdater firmwareUpdater = new FirmwareUpdater(File.ReadAllText("pathToFile.txt"), true);
The code will poll in background for a USB device corresponding to the BSL (vid:0x2047; pid:0x0200) and then automatically initiate the firmware update. "pathToFile.txt" must contain the hex code generated by Code Composer Studio.
If you need to integrate InnovasubBSL430 in your UI, you're advised to use a background worker:
private void FirmwareWorker_DoWork(object sender, DoWorkEventArgs e)
{
// Considering BSL already enumerated - attempt connection
FirmwareUpdater firmwareUpdater = new FirmwareUpdater(File.ReadAllText("pathToFile.txt"), false);
// Leave some time for the connection to establish
Thread.Sleep(1000);
if (firmwareUpdater.Connected)
{
// Start updating
firmwareUpdater.startFirmwareUpdate();
// Wait for update to complete (or canceled)
while (firmwareUpdater.Status == FirmwareUpdater.CONNECTED ||
firmwareUpdater.Status == FirmwareUpdater.SENDINGDATA)
{
// Report the progress to the UI
firmwareWorker.ReportProgress((int)(firmwareUpdater.Percentage * 100.0));
Thread.Sleep(1000);
}
// End of update - Handle errors if any
if(firmwareUpdater.Status == FirmwareUpdater.COMPLETE)
{
// Firmware update has worked properly
}
else if (firmwareUpdater.Status == FirmwareUpdater.CANCELED)
{
// Update was canceled
}
else
{
// Other issues
}
}
else
{
// Device not connected
}
}
Developed by Corentin Altepe - Visit my website: www.corentinaltepe.com