Skip to content

corentinaltepe/InnovasubBSL430

Repository files navigation

InnovasubBSL430

C# Library for field firmware update of MSP430 based devices.

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, employing the excellent HidLibrary by mikeobrien.

All contributions are welcome!

In order to run a firmware update:

  1. Ensure the flash BSL of the MSP430 is running and the device is connected to the computer with a USB cable.
  2. 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
	}
}

About

C# Library for field firmware update of MSP430 based devices.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages