aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-01-01 17:28:19 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-01-01 17:28:19 +0200
commit25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9 (patch)
tree600a6623f866d48a522406b4d93e5f213d290c61 /Software/Visual_Studio
parent9a3114908dd0a4f61fc959ef0f352b2b6255a652 (diff)
downloadTango-25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9.tar.gz
Tango-25f5e6ddef7ef2fa0a747305847eeb4ceee5a2c9.zip
Added tango firmware update lib.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/AssemblyInfo.cpp38
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.cpp292
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.h189
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUError.h27
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.cpp15
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.h31
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUMode.h13
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.cpp132
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.h33
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.cpp12
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h88
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressMode.h16
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ReadMe.txt38
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.cpp5
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.h7
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Tango.FirmwareUpdateLib.vcxproj186
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Twine.FirmwareUpdate.vcxproj.filters88
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/TwineDFUExtras.h39
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.icobin0 -> 41395 bytes
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.rcbin0 -> 2558 bytes
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfu.h321
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.cpp299
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.h78
-rw-r--r--Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/resource.h3
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/ReadMe.txt29
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/dfuprog.cpp1113
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcproj374
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj220
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj.filters33
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.cpp299
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.h78
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/stdafx.cpp8
-rw-r--r--Software/Visual_Studio/Firmware/dfuprog/stdafx.h15
-rw-r--r--Software/Visual_Studio/Tango.sln51
-rw-r--r--Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml11
-rw-r--r--Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs61
-rw-r--r--Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj6
37 files changed, 4219 insertions, 29 deletions
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/AssemblyInfo.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/AssemblyInfo.cpp
new file mode 100644
index 000000000..d56b68087
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/AssemblyInfo.cpp
@@ -0,0 +1,38 @@
+#include "stdafx.h"
+
+using namespace System;
+using namespace System::Reflection;
+using namespace System::Runtime::CompilerServices;
+using namespace System::Runtime::InteropServices;
+using namespace System::Security::Permissions;
+
+//
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly:AssemblyTitleAttribute(L"TwineFirmwareUpdateLib")];
+[assembly:AssemblyDescriptionAttribute(L"")];
+[assembly:AssemblyConfigurationAttribute(L"")];
+[assembly:AssemblyCompanyAttribute(L"")];
+[assembly:AssemblyProductAttribute(L"TwineFirmwareUpdateLib")];
+[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2017")];
+[assembly:AssemblyTrademarkAttribute(L"")];
+[assembly:AssemblyCultureAttribute(L"")];
+
+//
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the value or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+
+[assembly:AssemblyVersionAttribute("1.0.*")];
+
+[assembly:ComVisible(false)];
+
+[assembly:CLSCompliantAttribute(true)]; \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.cpp
new file mode 100644
index 000000000..a2a29397f
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.cpp
@@ -0,0 +1,292 @@
+#include "stdafx.h"
+#include "stdio.h";
+#include "DFUDevice.h"
+#include "DFUError.h"
+#include "DFUException.h"
+#include "ProgressForm.h"
+#include "TwineDFUExtras.h"
+
+using namespace System::Runtime::InteropServices;
+using namespace System::IO;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ DFUDevice::DFUDevice()
+ {
+ TwineExtras = gcnew TwineDFUExtras();
+ }
+
+ DFUDevice::DFUDevice(tLMDFUDeviceInfo *deviceInfo, tLMDFUHandle deviceHandle)
+ {
+ devInfo = deviceInfo;
+ devHandle = deviceHandle;
+ TwineExtras = gcnew TwineDFUExtras();
+ }
+
+ DFUDevice::~DFUDevice()
+ {
+ try {
+ if (!_isDisposed)
+ {
+ _LMDFUDeviceClose(devHandle, FALSE); //Reset device? FALSE.
+ _isDisposed = true;
+ }
+ }
+ catch (Exception^ e) {
+ //Do Nothing...
+ }
+ }
+
+ void DFUDevice::SwitchToDFUMode()
+ {
+ tLMDFUErr eRetcode = _LMDFUModeSwitch(devHandle);
+ _isDisposed = true;
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+
+ Mode = DFUMode::DFU;
+ }
+
+ void DFUDevice::ClearFlash()
+ {
+ tLMDFUErr eRetcode = _LMDFUErase(devHandle, 0, 0, true, NULL);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+ }
+
+ void DFUDevice::Reset()
+ {
+ tLMDFUErr eRetcode = _LMDFUDeviceClose(devHandle, TRUE); //Reset device? TRUE.
+ _isDisposed = true;
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+ }
+
+ void DFUDevice::Upload(array<byte>^ bytes, ProgressCallbackDelegate^ callback)
+ {
+ tLMDFUParams *psDFU;
+ tLMDFUParams sDFU;
+ tLMDFUErr eRetcode;
+
+ // If it supports the Tiva DFU protocol, read back
+ // some important parameters.
+ if (SupportsTivaExtensions)
+ {
+ // Read flash size parameters from the device.
+ eRetcode = _LMDFUParamsGet(devHandle, &sDFU);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+
+ psDFU = &sDFU;
+ }
+ else
+ {
+ // The device doesn't support the Tiva
+ // protocol so set the DFU parameter structure
+ // pointer to NULL.
+ psDFU = (tLMDFUParams *)0;
+ }
+
+ //Create an unmanaged array of from the bytes.
+ pin_ptr<System::Byte> p = &bytes[0];
+ unsigned char* pby = p;
+ unsigned char* pcFileBuf = reinterpret_cast<unsigned char*>(pby);
+
+ //Create notification form.
+ IntPtr formHandle = IntPtr::Zero;
+
+ if (callback != nullptr)
+ {
+ ProgressForm^ f = gcnew ProgressForm(callback, true);
+ formHandle = f->Handle; // forces the form Control to be created.
+ }
+
+ //Upload the image and verify!
+ eRetcode = _LMDFUDownloadBin(devHandle, pcFileBuf, (unsigned long)bytes->Length,
+ AppStartAddress, TRUE, formHandle != IntPtr::Zero ? (HWND)formHandle.ToPointer() : NULL);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+ }
+
+ void DFUDevice::UploadTwineExtras(TwineDFUExtras^ extras, ProgressCallbackDelegate^ callback)
+ {
+ tLMDFUErr eRetcode;
+ MemoryStream^ ms = gcnew MemoryStream();
+ BinaryWriter^ writer = gcnew BinaryWriter(ms, System::Text::Encoding::ASCII);
+
+ //Write extension code.
+ writer->Write(EXTENSION_CODE);
+
+ //Write date time.
+ writer->Write(extras->UploadDateTime->Ticks);
+
+ //Write version.
+ writer->Write(extras->Version->Major);
+ writer->Write(extras->Version->Minor);
+ writer->Write(extras->Version->Build);
+ writer->Write(extras->Version->Revision);
+
+ //Write Comments.
+ String^ fixedString = extras->Comments->PadRight(EXTENSION_COMMENTS_LENGTH, ' ');
+ writer->Write(fixedString->ToCharArray());
+
+ //Write Image size.
+ writer->Write(extras->ImageLength);
+
+ array<byte>^ extraBytes = ms->ToArray();
+
+ delete writer;
+ delete ms;
+
+ pin_ptr<System::Byte> pt = &extraBytes[0];
+ unsigned char* pby2 = pt;
+ unsigned char* extraBuf = reinterpret_cast<unsigned char*>(pby2);
+
+ //Create notification form.
+ IntPtr formHandle = IntPtr::Zero;
+
+ if (callback != nullptr)
+ {
+ ProgressForm^ f = gcnew ProgressForm(callback, false);
+ formHandle = f->Handle; // forces the form Control to be created.
+ }
+
+ //Upload the extra info!
+ eRetcode = _LMDFUDownloadBin(devHandle, extraBuf, EXTENSION_LENGTH,
+ FlashTopAddress - FlashBlockSize, FALSE, formHandle != IntPtr::Zero ? (HWND)formHandle.ToPointer() : NULL);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+ }
+
+ void DFUDevice::Download(ProgressCallbackDelegate^ callback)
+ {
+ tLMDFUParams *psDFU;
+ tLMDFUParams sDFU;
+ tLMDFUErr eRetcode;
+ size_t iLen;
+ unsigned long g_ulLength = 0;
+
+ // If it supports the Tiva DFU protocol, read back
+ // some important parameters.
+ if (SupportsTivaExtensions)
+ {
+ // Read flash size parameters from the device.
+ eRetcode = _LMDFUParamsGet(devHandle, &sDFU);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+
+ psDFU = &sDFU;
+ }
+ else
+ {
+ // The device doesn't support the Tiva
+ // protocol so set the DFU parameter structure
+ // pointer to NULL.
+ psDFU = (tLMDFUParams *)0;
+ }
+
+ //Allocate image buffer.
+ lastDownloadBytes = (unsigned char *)malloc(ImageLength);
+
+ //Create notification form.
+ IntPtr formHandle = IntPtr::Zero;
+
+ if (callback != nullptr)
+ {
+ ProgressForm^ f = gcnew ProgressForm(callback, false);
+ formHandle = f->Handle; // forces the form Control to be created.
+ }
+
+ //Download image from device.
+ eRetcode = _LMDFUUpload(devHandle, lastDownloadBytes, AppStartAddress, ImageLength, TRUE, formHandle != IntPtr::Zero ? (HWND)formHandle.ToPointer() : NULL);
+
+ if (eRetcode != DFU_OK)
+ {
+ throw gcnew DFUException(eRetcode);
+ }
+ }
+
+ array<byte>^ DFUDevice::GetDownloadBytes()
+ {
+ //Create a managed array from the chars array.
+ IntPtr ptr(lastDownloadBytes);
+ array<Byte>^ bytes = gcnew array<Byte>(ImageLength);
+ Marshal::Copy(ptr, bytes, 0, ImageLength);
+ return bytes;
+ }
+
+ void DFUDevice::FetchTwineExtras()
+ {
+ tLMDFUErr eRetcode;
+
+ unsigned char *buffer;
+
+ //Allocate image buffer.
+ buffer = (unsigned char *)malloc(EXTENSION_LENGTH);
+
+ //Download extras from device.
+ eRetcode = _LMDFUUpload(devHandle, buffer, FlashTopAddress - FlashBlockSize, EXTENSION_LENGTH, TRUE, NULL);
+
+ if (eRetcode == DFU_OK)
+ {
+ //Create a managed array from the chars array.
+ IntPtr ptr(buffer);
+ array<Byte>^ bytes = gcnew array<Byte>(EXTENSION_LENGTH);
+ Marshal::Copy(ptr, bytes, 0, EXTENSION_LENGTH);
+
+ MemoryStream^ ms = gcnew MemoryStream(bytes);
+ BinaryReader^ reader = gcnew BinaryReader(ms, System::Text::Encoding::ASCII);
+
+ bool hasExtras = reader->ReadInt32() == EXTENSION_CODE;
+
+ if (hasExtras)
+ {
+ //Put has extras.
+ TwineExtras->HasExtras = true;
+
+ //Create DateTime from ticks.
+ TwineExtras->UploadDateTime = gcnew DateTime(reader->ReadInt64());
+
+ //Create version.
+ TwineExtras->Version = gcnew Version(reader->ReadInt32(), reader->ReadInt32(), reader->ReadInt32(), reader->ReadInt32());
+
+ //Read Comments.
+ TwineExtras->Comments = gcnew String(reader->ReadChars(EXTENSION_COMMENTS_LENGTH));
+ TwineExtras->Comments = TwineExtras->Comments->Trim();
+
+ //Read Image Length.
+ TwineExtras->ImageLength = reader->ReadInt32();
+
+ //Set Accurate Image Size
+ ImageLength = TwineExtras->ImageLength;
+ }
+
+ delete reader;
+ delete ms;
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.h
new file mode 100644
index 000000000..c5d954cb2
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUDevice.h
@@ -0,0 +1,189 @@
+#include "DFUMode.h"
+#include <stdio.h>
+#include "stdafx.h"
+#include <stdlib.h>
+#include <conio.h>
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+#include "ProgressMode.h"
+#include "TwineDFUExtras.h"
+
+#pragma once
+
+using namespace System;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib {
+
+ /// <summary>
+ /// Represents the upload operation progress callback delegate.
+ /// </summary>
+ /// <param name="progressMode">The progress mode.</param>
+ /// <param name="current">The current.</param>
+ /// <param name="total">The total.</param>
+ public delegate void ProgressCallbackDelegate(ProgressMode progressMode, int current, int total);
+
+ public ref class DFUDevice
+ {
+ private:
+ unsigned char *lastDownloadBytes;
+ tLMDFUDeviceInfo *devInfo;
+ tLMDFUHandle devHandle;
+ bool _isDisposed;
+
+ public:
+
+ /// <summary>
+ /// Vendor ID published in the device descriptor.
+ /// </summary>
+ property String^ VID;
+ /// <summary>
+ /// Product ID published in the device descriptor.
+ /// </summary>
+ property String^ PID;
+ /// <summary>
+ /// BCD device release number published in the device descriptor.
+ /// </summary>
+ property String^ DeviceName;
+ /// <summary>
+ /// The manufacturer name string published in the device.
+ /// </summary>
+ property String^ Manufacturer;
+ /// <summary>
+ /// The interface string published in the DFU interface descriptor.
+ /// </summary>
+ property String^ DFUInterface;
+ /// <summary>
+ /// The serial number string published in the device descriptor.
+ /// </summary>
+ property String^ SerialNumber;
+ /// <summary>
+ /// Maximum number of bytes that the device can accept per control-write transaction as published in the DFU functional descriptor.
+ /// </summary>
+ property int MaxTransfer;
+ /// <summary>
+ /// Determines the current DFU driver mode. (An update can only be applied while in DFU mode).
+ /// </summary>
+ property DFUMode Mode;
+ /// <summary>
+ /// Indicates that the device will detach and reattach automatically on receipt of the DFU_DETACH request whereas 'false' indicates that the host must issue a USB reset after the DFU_DETACH request.
+ /// </summary>
+ property bool WillDetach;
+ /// <summary>
+ /// Indicates that the device supports firmware download operations and: 'false' indicates that download is not supported.
+ /// </summary>
+ property bool ManifestTolerant;
+
+ property bool UploadCable;
+
+ property bool DownloadCable;
+ /// <summary>
+ ///Determines whether the DFU device supports the Tiva DFU binary protocol or false otherwise. (If not than AppStartAddress should be provided!).
+ /// </summary>
+ property bool SupportsTivaExtensions;
+ /// <summary>
+ /// The size of a flash block in bytes.
+ /// </summary>
+ property short FlashBlockSize;
+ /// <summary>
+ /// The number of blocks of flash in the device. Total flash size is NumFlashBlocks * FlashBlockSize.
+ /// </summary>
+ property short NumFlashBlocks;
+ /// <summary>
+ /// Address 1 byte above the highest location the boot loader can access.
+ /// </summary>
+ property long FlashTopAddress;
+ /// <summary>
+ /// Total flash size in bytes.
+ /// </summary>
+ property int FlashSize;
+ /// <summary>
+ /// Lowest address the boot loader can write or erase.
+ /// </summary>
+ property long AppStartAddress;
+
+ /// <summary>
+ /// Image Size.
+ /// </summary>
+ property long ImageLength;
+
+ /// <summary>
+ /// Optional Twine information which will be flashed to the top of the memory.
+ /// </summary>
+ property TwineDFUExtras^ TwineExtras;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DFUDevice"/> class.
+ /// </summary>
+ DFUDevice();
+
+ /// <summary>
+ /// Finalizes an instance of the <see cref="DFUDevice"/> class.
+ /// </summary>
+ ~DFUDevice();
+
+ /// <summary>
+ /// Switch the device to DFU upgrade mode.
+ /// </summary>
+ void SwitchToDFUMode();
+
+ /// <summary>
+ /// Clears the flash.
+ /// </summary>
+ void ClearFlash();
+
+ /// <summary>
+ /// Resets the device.
+ /// </summary>
+ void Reset();
+
+ /// <summary>
+ /// Uploads the specified image bytes to the firmware via the DFU class.
+ /// </summary>
+ /// <param name="bytes">The bytes.</param>
+ /// <param name="callback">The progress callback.</param>
+ void Upload(array<byte>^ bytes, ProgressCallbackDelegate^ callback);
+
+ /// <summary>
+ /// Uploads the specified twine extras to the top of the flash memory.
+ /// </summary>
+ /// <param name="extras">The extras.</param>
+ /// <param name="callback">The progress callback.</param>
+ void UploadTwineExtras(TwineDFUExtras^ extras, ProgressCallbackDelegate^ callback);
+
+ /// <summary>
+ /// Downloads the existing image bytes from the firmware via the DFU class.
+ /// </summary>
+ /// <param name="callback">The progress callback.</param>
+ /// <returns></returns>
+ void Download(ProgressCallbackDelegate^ callback);
+
+ /// <summary>
+ /// Gets the last download operation bytes.
+ /// </summary>
+ /// <returns></returns>
+ array<byte>^ GetDownloadBytes();
+
+ internal:
+
+ const int EXTENSION_LENGTH = 1024;
+ const int EXTENSION_CODE = 1357;
+ const int EXTENSION_COMMENTS_LENGTH = 992;
+
+ /// <summary>
+ /// Fetches the twine extras.
+ /// </summary>
+ void FetchTwineExtras();
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DFUDevice"/> class.
+ /// </summary>
+ /// <param name="deviceInfo">The device information.</param>
+ /// <param name="deviceHandle">The device handle.</param>
+ DFUDevice(tLMDFUDeviceInfo *deviceInfo, tLMDFUHandle deviceHandle);
+ };
+
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUError.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUError.h
new file mode 100644
index 000000000..2b0595829
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUError.h
@@ -0,0 +1,27 @@
+#pragma once
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib {
+
+ public enum class DFUError
+ {
+ DFU_ERR_VERIFY_FAIL = -14,
+ DFU_ERR_CANT_VERIFY = -13,
+ DFU_ERR_DNLOAD_FAIL = -12,
+ DFU_ERR_STALL = -11,
+ DFU_ERR_TIMEOUT = -10,
+ DFU_ERR_DISCONNECTED = -9,
+ DFU_ERR_INVALID_SIZE = -8,
+ DFU_ERR_INVALID_ADDR = -7,
+ DFU_ERR_INVALID_FORMAT = -6,
+ DFU_ERR_UNSUPPORTED = -5,
+ DFU_ERR_UNKNOWN = -4,
+ DFU_ERR_NOT_FOUND = -3,
+ DFU_ERR_MEMORY = -2,
+ DFU_ERR_HANDLE = -1,
+ DFU_OK = 0,
+ };
+
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.cpp
new file mode 100644
index 000000000..8c5eb9035
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.cpp
@@ -0,0 +1,15 @@
+#include "stdafx.h"
+#include "DFUException.h"
+
+using namespace System;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+
+ DFUException::DFUException()
+ {
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.h
new file mode 100644
index 000000000..e3c61c8e5
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUException.h
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include "stdafx.h"
+#include <stdlib.h>
+#include <conio.h>
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+#include "DFUError.h"
+
+#pragma once
+
+using namespace System;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib {
+
+ ref class DFUException :
+ public Exception
+ {
+ internal:
+ DFUException(tLMDFUErr error) : Exception(gcnew String(_LMDFUErrorStringGet(error))) { Error = static_cast<DFUError>(error); };
+ public:
+ property DFUError Error;
+ DFUException();
+ DFUException(DFUError error) : Exception(error.ToString()) { Error = error; };
+ DFUException(DFUError error, String^ message) : Exception(message) { Error = error; };
+ };
+ }
+}
+
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUMode.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUMode.h
new file mode 100644
index 000000000..66f3f7352
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/DFUMode.h
@@ -0,0 +1,13 @@
+#pragma once
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ public enum class DFUMode
+ {
+ RunTime,
+ DFU
+ };
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.cpp
new file mode 100644
index 000000000..556519e00
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.cpp
@@ -0,0 +1,132 @@
+#include "FirmwareUpdateManager.h"
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+#include "DFUMode.h"
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ void FirmwareUpdateManager::Initialize()
+ {
+
+ tLMDFUErr eRetcode = _LMDFUInit();
+
+ if (eRetcode != DFU_OK)
+ {
+ switch (eRetcode)
+ {
+ case DFU_ERR_NOT_FOUND:
+ throw gcnew InvalidOperationException(DFU_ERR_NOT_FOUND_ERROR);
+ break;
+ case DFU_ERR_INVALID_ADDR:
+ throw gcnew InvalidOperationException(DFU_ERR_INVALID_ADDR_ERROR);
+ break;
+ default:
+ throw gcnew InvalidOperationException(DFU_ERR_UNKNOWN_ERROR);
+ break;
+ }
+ }
+ }
+
+ List<DFUDevice^>^ FirmwareUpdateManager::GetAvailableDevices(bool fetchTwineExtras)
+ {
+ int iDevIndex = 0;
+ tLMDFUDeviceInfo devInfo;
+ tLMDFUHandle hHandle;
+ tLMDFUErr eRetcode;
+ unsigned short usStringLen;
+ char pcStringBuf[256];
+ bool g_bReset = false;
+
+ List<DFUDevice^>^ devices = gcnew List<DFUDevice^>();
+
+ do
+ {
+ eRetcode = _LMDFUDeviceOpen(iDevIndex, &devInfo, &hHandle);
+
+ if (eRetcode == DFU_OK)
+ {
+ tLMDFUDeviceInfo *psDevInfo = &devInfo;
+
+ DFUDevice^ device = gcnew DFUDevice(psDevInfo, hHandle);
+
+ device->VID = String::Format("0x{0}", psDevInfo->usVID);
+ device->PID = String::Format("0x{0}", psDevInfo->usPID);
+
+ //Device Name.
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle, psDevInfo->ucProductString,
+ pcStringBuf, &usStringLen);
+
+ device->DeviceName = eRetcode == DFU_OK ? gcnew String(pcStringBuf) : "Unknown";
+
+ //Manufacturer.
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle,
+ psDevInfo->ucManufacturerString,
+ pcStringBuf, &usStringLen);
+
+ device->Manufacturer = eRetcode == DFU_OK ? gcnew String(pcStringBuf) : "Unknown";
+
+ //DFU Interface.
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle,
+ psDevInfo->ucDFUInterfaceString,
+ pcStringBuf, &usStringLen);
+
+ device->DFUInterface = eRetcode == DFU_OK ? gcnew String(pcStringBuf) : "Unknown";
+
+ //Serial Number.
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle, psDevInfo->ucSerialString,
+ pcStringBuf, &usStringLen);
+ device->SerialNumber = eRetcode == DFU_OK ? gcnew String(pcStringBuf) : "Unknown";
+
+ //Max bytes transfer.
+ device->MaxTransfer = psDevInfo->usTransferSize;
+
+ //Current device mode.
+ device->Mode = psDevInfo->bDFUMode ? DFUMode::DFU : DFUMode::RunTime;
+
+ //Supports Tiva extensions. (Good for updates)
+ device->SupportsTivaExtensions = psDevInfo->bSupportsTivaExtensions;
+
+ //Attributes.
+ device->WillDetach = psDevInfo->ucDFUAttributes & DFU_ATTR_WILL_DETACH;
+ device->ManifestTolerant = psDevInfo->ucDFUAttributes & DFU_ATTR_MANIFEST_TOLERANT;
+ device->UploadCable = psDevInfo->ucDFUAttributes & DFU_ATTR_CAN_UPLOAD;
+ device->DownloadCable = psDevInfo->ucDFUAttributes & DFU_ATTR_CAN_DOWNLOAD;
+
+ //Read device flash parameters.
+ tLMDFUParams sDFU;
+ if (device->SupportsTivaExtensions)
+ {
+ eRetcode = _LMDFUParamsGet(hHandle, &sDFU);
+ if (eRetcode == DFU_OK)
+ {
+ device->AppStartAddress = sDFU.ulAppStartAddr;
+ device->FlashTopAddress = sDFU.ulFlashTop;
+ device->FlashBlockSize = sDFU.usFlashBlockSize;
+ device->NumFlashBlocks = sDFU.usNumFlashBlocks;
+ device->ImageLength = device->FlashTopAddress - device->AppStartAddress;
+ device->FlashSize = device->FlashBlockSize * device->NumFlashBlocks;
+
+ if (fetchTwineExtras)
+ {
+ device->FetchTwineExtras();
+ }
+ }
+ }
+
+ devices->Add(device);
+ }
+
+ iDevIndex++;
+
+ } while (eRetcode == DFU_OK);
+
+ return devices;
+ }
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.h
new file mode 100644
index 000000000..f176517c0
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/FirmwareUpdateManager.h
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include "stdafx.h"
+#include <stdlib.h>
+#include <conio.h>
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+#include "DFUDevice.h";
+
+#pragma once
+
+using namespace System;
+using namespace System::Collections;
+using namespace System::Collections::Generic;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+
+ public ref class FirmwareUpdateManager
+ {
+ //Initialization Errors
+ String^ DFU_ERR_NOT_FOUND_ERROR = "The driver for the USB Device Firmware Upgrade device cannot be found.\nBefore running this program, please connect the DFU device to this system\nand install the device driver when prompted by Windows. The device driver\ncan be found on the evaluation kit CD or can be found in the windows_drivers\ndirectory of your TivaWare installation.\n\n";
+ String^ DFU_ERR_INVALID_ADDR_ERROR = "The driver for the USB Device Firmware Upgrade device was found but appears\nto be a version which this program does not support. Please download and\ninstall the latest device driver and example applications from the TI\nweb site to ensure that you are using compatible versions. The drivers\ncan be found in the windows_drivers directory of your TivaWare\ninstallation and the applications can be found in package \"Windows-side\nexamples for USB kits\" which may be downloaded from the web site at\nhttp://www.ti.com/software_updates.\n\n";
+ String^ DFU_ERR_UNKNOWN_ERROR = "An error was reported while attempting to load the device driver for the \nUSB Device Firmware Upgrade device. If this error persists, please download\nand reinstall the latest device driver and example applications from the TI\nweb site. The drivers can be found in the windows_drivers directory of your\nTivaWare installation and the applications can be found in package\n\"Windows-side examples for USB kits\" which may be downloaded from\n";
+
+ public:
+ void Initialize();
+ List<DFUDevice^>^ GetAvailableDevices(bool fetchTwineExtras);
+ };
+ }
+} \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.cpp
new file mode 100644
index 000000000..25ac79e3a
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.cpp
@@ -0,0 +1,12 @@
+#include "stdafx.h"
+#include "ProgressForm.h"
+
+using namespace System::Windows::Forms;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h
new file mode 100644
index 000000000..4953b7b15
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressForm.h
@@ -0,0 +1,88 @@
+#include "DFUMode.h"
+#include <stdio.h>
+#include "stdafx.h"
+#include <stdlib.h>
+#include <conio.h>
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+#include "DFUDevice.h"
+#include "ProgressMode.h"
+
+#pragma once
+
+using namespace System::Windows::Forms;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ ref class ProgressForm :
+ public Form
+ {
+ private:
+ ProgressMode _mode;
+ int _currentTotal;
+ bool _verified;
+ bool _verifiable;
+ ProgressCallbackDelegate^ _callback;
+
+ void RaiseCallback(ProgressMode mode, int current, int total)
+ {
+ if (_callback != nullptr)
+ {
+ _callback(mode, current, total);
+ }
+ }
+ public:
+ ProgressForm(ProgressCallbackDelegate^ callback, bool verifiable)
+ {
+ _verifiable = verifiable;
+ _callback = callback;
+ };
+ protected: virtual void WndProc(System::Windows::Forms::Message% m) override
+ {
+ switch (m.Msg)
+ {
+ case WM_DFU_DOWNLOAD:
+ _verified = !_verifiable;
+ _mode = ProgressMode::Uploading;
+ _currentTotal = (int)m.WParam;
+ RaiseCallback(_mode, 0, _currentTotal);
+ break;
+ case WM_DFU_UPLOAD:
+ _verified = true;
+ _mode = ProgressMode::Downloading;
+ _currentTotal = (int)m.WParam;
+ RaiseCallback(_mode, 0, _currentTotal);
+ break;
+ case WM_DFU_VERIFY:
+ _verified = true;
+ _mode = ProgressMode::Verifying;
+ _currentTotal = (int)m.WParam;
+ RaiseCallback(_mode, 0, _currentTotal);
+ break;
+ case WM_DFU_COMPLETE:
+ if (_verified)
+ {
+ _mode = ProgressMode::Completed;
+ _currentTotal = (int)m.WParam;
+ RaiseCallback(_mode, 0, _currentTotal);
+ }
+ break;
+ case WM_DFU_ERROR:
+ _mode = ProgressMode::Error;
+ _currentTotal = (int)m.WParam;
+ RaiseCallback(_mode, 0, _currentTotal);
+ break;
+ case WM_DFU_PROGRESS:
+ RaiseCallback(_mode, (int)m.WParam, _currentTotal);
+ break;
+ }
+
+ Form::WndProc(m);
+ }
+ };
+ }
+}
+
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressMode.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressMode.h
new file mode 100644
index 000000000..1c4d189ba
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ProgressMode.h
@@ -0,0 +1,16 @@
+#pragma once
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ public enum class ProgressMode
+ {
+ Uploading,
+ Downloading,
+ Verifying,
+ Error,
+ Completed,
+ };
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ReadMe.txt b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ReadMe.txt
new file mode 100644
index 000000000..677f64d62
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/ReadMe.txt
@@ -0,0 +1,38 @@
+========================================================================
+ DYNAMIC LINK LIBRARY : Twine.FirmwareUpdateLib Project Overview
+========================================================================
+
+AppWizard has created this Twine.FirmwareUpdateLib DLL for you.
+
+This file contains a summary of what you will find in each of the files that
+make up your Twine.FirmwareUpdateLib application.
+
+Twine.FirmwareUpdateLib.vcxproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+Twine.FirmwareUpdateLib.vcxproj.filters
+ This is the filters file for VC++ projects generated using an Application Wizard.
+ It contains information about the association between the files in your project
+ and the filters. This association is used in the IDE to show grouping of files with
+ similar extensions under a specific node (for e.g. ".cpp" files are associated with the
+ "Source Files" filter).
+
+Twine.FirmwareUpdateLib.cpp
+ This is the main DLL source file.
+
+Twine.FirmwareUpdateLib.h
+ This file contains a class declaration.
+
+AssemblyInfo.cpp
+ Contains custom attributes for modifying assembly metadata.
+
+/////////////////////////////////////////////////////////////////////////////
+Other notes:
+
+AppWizard uses "TODO:" to indicate parts of the source code you
+should add to or customize.
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.cpp
new file mode 100644
index 000000000..d42872910
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.cpp
@@ -0,0 +1,5 @@
+// stdafx.cpp : source file that includes just the standard includes
+// Twine.FirmwareUpdateLib.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.h
new file mode 100644
index 000000000..3cc4c24ef
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Stdafx.h
@@ -0,0 +1,7 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#pragma once
+
+
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Tango.FirmwareUpdateLib.vcxproj b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Tango.FirmwareUpdateLib.vcxproj
new file mode 100644
index 000000000..b6c273214
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Tango.FirmwareUpdateLib.vcxproj
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}</ProjectGuid>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+ <Keyword>ManagedCProj</Keyword>
+ <RootNamespace>TwineFirmwareUpdate</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
+ <ProjectName>Tango.FirmwareUpdateLib</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CLRSupport>true</CLRSupport>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>$(SolutionDir)Build\Core\$(Configuration)</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(SolutionDir)Build\Core\$(Configuration)</OutDir>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <AdditionalIncludeDirectories>..\SideChains\UpdateFirmwareLib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies />
+ <AdditionalLibraryDirectories>D:\Development\TwinePrototype\Host\PcLab\SideChains\dfuprog\bin\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies />
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies />
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies />
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="DFUDevice.h" />
+ <ClInclude Include="DFUError.h" />
+ <ClInclude Include="DFUException.h" />
+ <ClInclude Include="DFUMode.h" />
+ <ClInclude Include="lmdfu.h" />
+ <ClInclude Include="lmdfuwrap.h" />
+ <ClInclude Include="ProgressForm.h" />
+ <ClInclude Include="ProgressMode.h" />
+ <ClInclude Include="resource.h" />
+ <ClInclude Include="Stdafx.h" />
+ <ClInclude Include="TwineDFUExtras.h" />
+ <ClInclude Include="FirmwareUpdateManager.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="AssemblyInfo.cpp" />
+ <ClCompile Include="DFUDevice.cpp" />
+ <ClCompile Include="DFUException.cpp" />
+ <ClCompile Include="lmdfuwrap.cpp" />
+ <ClCompile Include="ProgressForm.cpp" />
+ <ClCompile Include="Stdafx.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+ </ClCompile>
+ <ClCompile Include="FirmwareUpdateManager.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="app.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="app.ico" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\SideChains\UpdateFirmwareLib\UpdateFirmwareLib.vcxproj">
+ <Project>{cbf47870-840d-40fb-9d1a-61f4fe1b7c18}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Twine.FirmwareUpdate.vcxproj.filters b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Twine.FirmwareUpdate.vcxproj.filters
new file mode 100644
index 000000000..21f9becfa
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/Twine.FirmwareUpdate.vcxproj.filters
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Stdafx.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\SideChains\dfuprog\lmdfuwrap.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="DFUError.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="DFUDevice.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="Updater.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="DFUException.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="DFUMode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="ProgressForm.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="ProgressMode.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="TwineDFUExtras.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="AssemblyInfo.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Stdafx.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\SideChains\dfuprog\lmdfuwrap.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="DFUDevice.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="Updater.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="DFUException.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="ProgressForm.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="app.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="app.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/TwineDFUExtras.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/TwineDFUExtras.h
new file mode 100644
index 000000000..845e706d7
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/TwineDFUExtras.h
@@ -0,0 +1,39 @@
+#pragma once
+
+using namespace System;
+
+namespace Tango
+{
+ namespace FirmwareUpdateLib
+ {
+ /// <summary>
+ /// Represents an optional information which will be written to the top of the
+ /// flash memory and can be used to save important data about the current saved image.
+ /// </summary>
+ public ref class TwineDFUExtras
+ {
+ public:
+
+ /// <summary>
+ /// Determines whether the twine extras were found.
+ /// </summary>
+ property bool HasExtras;
+ /// <summary>
+ /// The date and time for the last upload operation on this device.
+ /// </summary>
+ property DateTime^ UploadDateTime;
+ /// <summary>
+ /// The version of the last uploaded image.
+ /// </summary>
+ property Version^ Version;
+ /// <summary>
+ /// Optional comments (Max 100 ASCII characters).
+ /// </summary>
+ property String^ Comments;
+ /// <summary>
+ /// The size of the last uploaded image.
+ /// </summary>
+ property int ImageLength;
+ };
+ }
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.ico b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.ico
new file mode 100644
index 000000000..789d7ccbb
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.ico
Binary files differ
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.rc b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.rc
new file mode 100644
index 000000000..eab43064f
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/app.rc
Binary files differ
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfu.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfu.h
new file mode 100644
index 000000000..c5a77a458
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfu.h
@@ -0,0 +1,321 @@
+//*****************************************************************************
+//
+// lmdfu.h : main header file for the USB Device Firmware Upgrade DLL
+//
+// Copyright (c) 2008-2015 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.2.111 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#ifdef __cplusplus
+
+#pragma once
+
+#endif
+
+#include "resource.h" // main symbols
+
+#ifdef __cplusplus
+//
+// Functions exported by this DLL.
+//
+extern "C" {
+#endif
+
+//****************************************************************************
+//
+// Error codes returned by various API functions.
+//
+//****************************************************************************
+typedef enum
+{
+ DFU_ERR_VERIFY_FAIL = -14,
+ DFU_ERR_CANT_VERIFY = -13,
+ DFU_ERR_DNLOAD_FAIL = -12,
+ DFU_ERR_STALL = -11,
+ DFU_ERR_TIMEOUT = -10,
+ DFU_ERR_DISCONNECTED = -9,
+ DFU_ERR_INVALID_SIZE = -8,
+ DFU_ERR_INVALID_ADDR = -7,
+ DFU_ERR_INVALID_FORMAT = -6,
+ DFU_ERR_UNSUPPORTED = -5,
+ DFU_ERR_UNKNOWN = -4,
+ DFU_ERR_NOT_FOUND = -3,
+ DFU_ERR_MEMORY = -2,
+ DFU_ERR_HANDLE = -1,
+ DFU_OK = 0,
+}
+tLMDFUErr;
+
+//*****************************************************************************
+//
+// The current error status of the DFU device. These values are reported to
+// the host in response to a USBD_DFU_REQUEST_GETSTATUS request and may be
+// queried by calling LMDFUGetStatus().
+//
+//*****************************************************************************
+typedef enum
+{
+ STATUS_OK = 0,
+ STATUS_ERR_TARGET,
+ STATUS_ERR_FILE,
+ STATUS_ERR_WRITE,
+ STATUS_ERR_ERASE,
+ STATUS_ERR_CHECK_ERASED,
+ STATUS_ERR_PROG,
+ STATUS_ERR_VERIFY,
+ STATUS_ERR_ADDRESS,
+ STATUS_ERR_NOTDONE,
+ STATUS_ERR_FIRMWARE,
+ STATUS_ERR_VENDOR,
+ STATUS_ERR_USBR,
+ STATUS_ERR_POR,
+ STATUS_ERR_UNKNOWN,
+ STATUS_ERR_STALLEDPKT
+}
+tDFUStatus;
+
+//*****************************************************************************
+//
+// The size of the pcPartNumber array in tLMDFUDeviceInfo. This field contains
+// a NULL terminated ASCII string containing the target part number in the
+// form "lm3sxxxx" where "xxxx" is the 4 character part number. In cases where
+// the part number can be represented using hexadecimal digits, it will also be
+// encoded into the ulPartNumber field (which is left in the structure for
+// backwards compatibility even though recent part numbers break the assumption
+// that the part number can be encoded using hex).
+//
+//*****************************************************************************
+#define NUM_PART_STRING_CHARS 10
+
+//****************************************************************************
+//
+// Device information as returned by LMDFUDeviceOpen().
+//
+//****************************************************************************
+typedef struct
+{
+ unsigned short usVID;
+ unsigned short usPID;
+ unsigned short usDevice;
+ unsigned short usDetachTimeOut;
+ unsigned short usTransferSize;
+ unsigned char ucDFUAttributes;
+ unsigned char ucManufacturerString;
+ unsigned char ucProductString;
+ unsigned char ucSerialString;
+ unsigned char ucDFUInterfaceString;
+ bool bSupportsTivaExtensions;
+ bool bDFUMode;
+ unsigned long ulPartNumber;
+ char cRevisionMajor;
+ char cRevisionMinor;
+ char pcPartNumber[NUM_PART_STRING_CHARS];
+}
+tLMDFUDeviceInfo;
+
+//****************************************************************************
+//
+// DFU parameter information returned by LMDFUParamsGet().
+//
+//****************************************************************************
+typedef struct
+{
+ unsigned short usFlashBlockSize; // The size of a flash block in bytes.
+ unsigned short usNumFlashBlocks; // The number of blocks of flash in the
+ // device. Total flash size is
+ // usNumFlashBlocks * usFlashBlockSize.
+ unsigned long ulFlashTop; // Address 1 byte above the highest
+ // location the boot loader can access.
+ unsigned long ulAppStartAddr; // Lowest address the boot loader can
+ // write or erase.
+}
+tLMDFUParams;
+
+//****************************************************************************
+//
+// A handle to a DFU device. This handle is returned from a call to
+// LMDFUDeviceOpen().
+//
+//****************************************************************************
+typedef void *tLMDFUHandle;
+
+//****************************************************************************
+//
+// Bit fields used in the ucDFUAttributes field of tLMDFUDeviceInfo.
+//
+//****************************************************************************
+#define DFU_ATTR_WILL_DETACH 0x08
+#define DFU_ATTR_MANIFEST_TOLERANT 0x04
+#define DFU_ATTR_CAN_UPLOAD 0x02
+#define DFU_ATTR_CAN_DOWNLOAD 0x01
+
+//****************************************************************************
+//
+// Windows Messages optionally sent during LMDFUDownload and LMDFUUpload.
+//
+//****************************************************************************
+
+// A download operation is about to begin. The WPARAM value provides the
+// number of transfers will be required to complete the operation.
+// WPARAM = transfer count, LPARAM = LMDFUHandle
+#define WM_DFU_DOWNLOAD (WM_USER + 0x200)
+
+// An upload operation is about to begin. The WPARAM value provides the
+// number of transfers will be required to complete the operation.
+// WPARAM = transfer count, LPARAM = LMDFUHandle
+#define WM_DFU_UPLOAD (WM_USER + 0x201)
+
+// A verification cycle is beginning following a download. The WPARAM value
+// provides the number of transfers that will be required to read back the
+// downloaded image to verify that it is correct.
+// WPARAM = transfer count, LPARAM = LMDFUHandle
+#define WM_DFU_VERIFY (WM_USER + 0x202)
+
+// An erase operation about to begin. The WPARAM value provides the number of
+// blocks that are to be erased.
+// WPARAM = transfer count, LPARAM = LMDFUHandle
+#define WM_DFU_ERASE (WM_USER + 0x203)
+
+// A download or upload operation has completed successfully
+// WPARAM = 0, LPARAM = LMDFUHandle
+#define WM_DFU_COMPLETE (WM_USER + 0x204)
+
+// An error was reported during the operation that was in progress. The
+// operation has been aborted.
+// WPARAM = 0, LPARAM = LMDFUHandle
+#define WM_DFU_ERROR (WM_USER + 0x205)
+
+// A download, upload, erase or verify operation is in progress. This message
+// provides information on the progress of the operation. The WPARAM parameter
+// increments on each message until it reaches the value passed in the
+// WM_DFU_ERASE, WM_DFU_DOWNLOAD, WM_DFU_UPLOAD or WM_DFU_VERIFY message sent
+// at the start of the operation.
+// WPARAM = transfers completed, LPARAM = LMDFUHandle
+#define WM_DFU_PROGRESS (WM_USER + 0x206)
+
+//****************************************************************************
+//
+// Exported function prototypes.
+//
+//****************************************************************************
+tLMDFUErr __stdcall LMDFUInit(void);
+tLMDFUErr __stdcall LMDFUDeviceOpen(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle);
+tLMDFUErr __stdcall LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset);
+tLMDFUErr __stdcall LMDFUDeviceStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall LMDFUParamsGet(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams);
+tLMDFUErr __stdcall LMDFUIsValidImage(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat);
+tLMDFUErr __stdcall LMDFUDownload(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen, bool bVerify,
+ bool bIgnoreIDs, HWND hwndNotify);
+tLMDFUErr __stdcall LMDFUDownloadBin(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify, HWND hwndNotify);
+tLMDFUErr __stdcall LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
+ unsigned long ulEraseLen, bool bVerify,
+ HWND hwndNotify);
+tLMDFUErr __stdcall LMDFUBlankCheck(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen);
+tLMDFUErr __stdcall LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen, bool bRaw,
+ HWND hwndNotify);
+tLMDFUErr __stdcall LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus);
+tLMDFUErr __stdcall LMDFUModeSwitch(tLMDFUHandle hHandle);
+char * __stdcall LMDFUErrorStringGet(tLMDFUErr eError);
+
+//****************************************************************************
+//
+// Typedefs for each of the exported functions. This helps if applications
+// want to link the DLL dynamically using LoadLibrary rather than linking
+// directly to the lib file.
+//
+//****************************************************************************
+typedef tLMDFUErr (__stdcall *tLMDFUInit)(void);
+typedef tLMDFUErr (__stdcall *tLMDFUDeviceOpen)(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle);
+typedef tLMDFUErr (__stdcall *tLMDFUDeviceClose)(tLMDFUHandle hHandle,
+ bool bReset);
+typedef tLMDFUErr (__stdcall *tLMDFUDeviceStringGet)(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen);
+typedef tLMDFUErr (__stdcall *tLMDFUDeviceASCIIStringGet)(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen);
+typedef tLMDFUErr (__stdcall *tLMDFUParamsGet)(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams);
+typedef tLMDFUErr (__stdcall *tLMDFUIsValidImage)(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat);
+typedef tLMDFUErr (__stdcall *tLMDFUDownload)(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool bVerify,
+ bool bIgnoreIDs,
+ HWND hwndNotify);
+typedef tLMDFUErr (__stdcall *tLMDFUDownloadBin)(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify,
+ HWND hwndNotify);
+typedef tLMDFUErr (__stdcall *tLMDFUErase)(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulEraseLen,
+ bool bVerify,
+ HWND hwndNotify);
+typedef tLMDFUErr (__stdcall *tLMDFUBlankCheck)(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen);
+typedef tLMDFUErr (__stdcall *tLMDFUUpload)(tLMDFUHandle hHandle,
+ unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen,
+ bool bRaw, HWND hwndNotify);
+typedef tLMDFUErr (__stdcall *tLMDFUStatusGet)(tLMDFUHandle hHandle,
+ tDFUStatus *pStatus);
+typedef char * (__stdcall *tLMDFUErrorStringGet)(tLMDFUErr eError);
+typedef tLMDFUErr (__stdcall *tLMDFUModeSwitch)(tLMDFUHandle hHandle);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.cpp b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.cpp
new file mode 100644
index 000000000..4dc047dc5
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.cpp
@@ -0,0 +1,299 @@
+//*****************************************************************************
+//
+// lmdfuwrap.cpp : A thin wrapper over the lmdfu.dll library allowing it to be
+// loaded dynamically rather than statically linking to its .lib
+// file.
+//
+// Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+
+//*****************************************************************************
+//
+// DLL module handle.
+//
+//*****************************************************************************
+HINSTANCE hLMUSB = (HINSTANCE)NULL;
+
+//*****************************************************************************
+//
+// Function pointers for each DLL entry point.
+//
+//*****************************************************************************
+tLMDFUInit pfnLMDFUInit = NULL;
+tLMDFUDeviceOpen pfnLMDFUDeviceOpen = NULL;
+tLMDFUDeviceClose pfnLMDFUDeviceClose = NULL;
+tLMDFUDeviceStringGet pfnLMDFUDeviceStringGet = NULL;
+tLMDFUDeviceASCIIStringGet pfnLMDFUDeviceASCIIStringGet = NULL;
+tLMDFUParamsGet pfnLMDFUParamsGet = NULL;
+tLMDFUIsValidImage pfnLMDFUIsValidImage = NULL;
+tLMDFUDownload pfnLMDFUDownload = NULL;
+tLMDFUDownloadBin pfnLMDFUDownloadBin = NULL;
+tLMDFUErase pfnLMDFUErase = NULL;
+tLMDFUBlankCheck pfnLMDFUBlankCheck = NULL;
+tLMDFUUpload pfnLMDFUUpload = NULL;
+tLMDFUStatusGet pfnLMDFUStatusGet = NULL;
+tLMDFUErrorStringGet pfnLMDFUErrorStringGet = NULL;
+tLMDFUModeSwitch pfnLMDFUModeSwitch = NULL;
+
+tLMDFUErr __stdcall _LMDFUInit(void)
+{
+ //
+ // Try to load the USB DLL.
+ //
+ hLMUSB = LoadLibrary(TEXT("lmdfu.dll"));
+
+ //
+ // Did we find it?
+ //
+ if(hLMUSB)
+ {
+ //
+ // Yes - query all the entry point addresses.
+ //
+ pfnLMDFUInit = (tLMDFUInit)GetProcAddress(hLMUSB, "LMDFUInit");
+ pfnLMDFUDeviceOpen = (tLMDFUDeviceOpen)GetProcAddress(hLMUSB, "LMDFUDeviceOpen");
+ pfnLMDFUDeviceClose = (tLMDFUDeviceClose)GetProcAddress(hLMUSB, "LMDFUDeviceClose");
+ pfnLMDFUDeviceStringGet = (tLMDFUDeviceStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceStringGet");
+ pfnLMDFUDeviceASCIIStringGet = (tLMDFUDeviceASCIIStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceASCIIStringGet");
+ pfnLMDFUParamsGet = (tLMDFUParamsGet)GetProcAddress(hLMUSB, "LMDFUParamsGet");
+ pfnLMDFUIsValidImage = (tLMDFUIsValidImage)GetProcAddress(hLMUSB, "LMDFUIsValidImage");
+ pfnLMDFUDownload = (tLMDFUDownload)GetProcAddress(hLMUSB, "LMDFUDownload");
+ pfnLMDFUDownloadBin = (tLMDFUDownloadBin)GetProcAddress(hLMUSB, "LMDFUDownloadBin");
+ pfnLMDFUErase = (tLMDFUErase)GetProcAddress(hLMUSB, "LMDFUErase");
+ pfnLMDFUBlankCheck = (tLMDFUBlankCheck)GetProcAddress(hLMUSB, "LMDFUBlankCheck");
+ pfnLMDFUUpload = (tLMDFUUpload)GetProcAddress(hLMUSB, "LMDFUUpload");
+ pfnLMDFUStatusGet = (tLMDFUStatusGet)GetProcAddress(hLMUSB, "LMDFUStatusGet");
+ pfnLMDFUErrorStringGet = (tLMDFUErrorStringGet)GetProcAddress(hLMUSB, "LMDFUErrorStringGet");
+ pfnLMDFUModeSwitch = (tLMDFUModeSwitch)GetProcAddress(hLMUSB, "LMDFUModeSwitch");
+
+ //
+ // Make sure we actually queried all the expected entry points.
+ //
+ if(!pfnLMDFUInit || !pfnLMDFUDeviceOpen || !pfnLMDFUDeviceClose ||
+ !pfnLMDFUDeviceStringGet || !pfnLMDFUDeviceASCIIStringGet ||
+ !pfnLMDFUParamsGet || !pfnLMDFUIsValidImage || !pfnLMDFUDownload ||
+ !pfnLMDFUDownloadBin || !pfnLMDFUErase || !pfnLMDFUBlankCheck ||
+ !pfnLMDFUUpload || !pfnLMDFUStatusGet || !pfnLMDFUErrorStringGet ||
+ !pfnLMDFUModeSwitch)
+ {
+ //
+ // We failed to query at least one entry point. Return
+ // DFU_ERR_INVALID_ADDR to signal to the caller that the driver
+ // is likely the wrong version.
+ //
+ return(DFU_ERR_INVALID_ADDR);
+ }
+ else
+ {
+ //
+ // We got all the expected function pointers so call the library
+ // init function and return it's response.
+ //
+ return(pfnLMDFUInit());
+ }
+ }
+ else
+ {
+ //
+ // The DLL could not be found. This tends to suggest that the driver
+ // is not installed. Return an appropriate error code to the caller
+ // so that they can provide helpful information to the user.
+ //
+ return(DFU_ERR_NOT_FOUND);
+ }
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceOpen(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle)
+{
+ if(pfnLMDFUDeviceOpen)
+ {
+ return(pfnLMDFUDeviceOpen(iDeviceIndex, psDevInfo, phHandle));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset)
+{
+ if(pfnLMDFUDeviceClose)
+ {
+ return(pfnLMDFUDeviceClose(hHandle, bReset));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen)
+{
+ if(pfnLMDFUDeviceStringGet)
+ {
+ return(pfnLMDFUDeviceStringGet(hHandle, ucStringIndex, usLanguageID,
+ pcString, pusStringLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen)
+{
+ if(pfnLMDFUDeviceASCIIStringGet)
+ {
+ return(pfnLMDFUDeviceASCIIStringGet(hHandle, ucStringIndex, pcString,
+ pusStringLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUParamsGet(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams)
+{
+ if(pfnLMDFUParamsGet)
+ {
+ return(pfnLMDFUParamsGet(hHandle, psParams));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUIsValidImage(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat)
+{
+ if(pfnLMDFUIsValidImage)
+ {
+ return(pfnLMDFUIsValidImage(hHandle, pcDFUImage, ulImageLen,
+ pbTivaFormat));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDownload(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen, bool bVerify,
+ bool bIgnoreIDs, HWND hwndNotify)
+{
+ if(pfnLMDFUDownload)
+ {
+ return(pfnLMDFUDownload(hHandle, pcDFUImage, ulImageLen, bVerify,
+ bIgnoreIDs, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDownloadBin(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify, HWND hwndNotify)
+{
+ if(pfnLMDFUDownloadBin)
+ {
+ return(pfnLMDFUDownloadBin(hHandle, pcBinaryImage, ulImageLen,
+ ulStartAddr, bVerify, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
+ unsigned long ulEraseLen, bool bVerify,
+ HWND hwndNotify)
+{
+ if(pfnLMDFUErase)
+ {
+ return(pfnLMDFUErase(hHandle, ulStartAddr, ulEraseLen, bVerify,
+ hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUBlankCheck(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen)
+{
+ if(pfnLMDFUBlankCheck)
+ {
+ return(pfnLMDFUBlankCheck(hHandle, ulStartAddr, ulLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen, bool bRaw,
+ HWND hwndNotify)
+{
+ if(pfnLMDFUUpload)
+ {
+ return(pfnLMDFUUpload(hHandle, pcBuffer, ulStartAddr, ulImageLen,
+ bRaw, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus)
+{
+ if(pfnLMDFUStatusGet)
+ {
+ return(pfnLMDFUStatusGet(hHandle, pStatus));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUModeSwitch(tLMDFUHandle hHandle)
+{
+ if(pfnLMDFUStatusGet)
+ {
+ return(pfnLMDFUModeSwitch(hHandle));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+char * __stdcall _LMDFUErrorStringGet(tLMDFUErr eError)
+{
+ if(pfnLMDFUErrorStringGet)
+ {
+ return(pfnLMDFUErrorStringGet(eError));
+ }
+
+ return("Driver not installed");
+}
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.h
new file mode 100644
index 000000000..808f836b2
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/lmdfuwrap.h
@@ -0,0 +1,78 @@
+//*****************************************************************************
+//
+// lmdfuwrap.h : A thin wrapper over the lmdfu.dll library allowing it to be
+// loaded dynamically rather than statically linking to its .lib
+// file.
+//
+// Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#ifndef __LMDFUWRAP_H__
+#define __LMDFUWRAP_H__
+
+//*****************************************************************************
+//
+// Wrapper function prototypes.
+//
+//*****************************************************************************
+tLMDFUErr __stdcall _LMDFUInit(void);
+tLMDFUErr __stdcall _LMDFUDeviceOpen(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle);
+tLMDFUErr __stdcall _LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset);
+tLMDFUErr __stdcall _LMDFUDeviceStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall _LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall _LMDFUParamsGet(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams);
+tLMDFUErr __stdcall _LMDFUIsValidImage(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat);
+tLMDFUErr __stdcall _LMDFUDownload(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen, bool bVerify,
+ bool bIgnoreIDs, HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUDownloadBin(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify, HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
+ unsigned long ulEraseLen, bool bVerify,
+ HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUBlankCheck(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen);
+tLMDFUErr __stdcall _LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen, bool bRaw,
+ HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus);
+tLMDFUErr __stdcall _LMDFUModeSwitch(tLMDFUHandle hHandle);
+char * __stdcall _LMDFUErrorStringGet(tLMDFUErr eError);
+
+#endif
diff --git a/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/resource.h b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/resource.h
new file mode 100644
index 000000000..d5ac7c42a
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/Tango.FirmwareUpdateLib/resource.h
@@ -0,0 +1,3 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by app.rc
diff --git a/Software/Visual_Studio/Firmware/dfuprog/ReadMe.txt b/Software/Visual_Studio/Firmware/dfuprog/ReadMe.txt
new file mode 100644
index 000000000..b72b1dfd8
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/ReadMe.txt
@@ -0,0 +1,29 @@
+========================================================================
+ USB Device Firmware Upgrade programming tool
+========================================================================
+
+This project contains a simple, Windows command line application which uses
+the LMDFU DLL to allow you to program binary images to a USB connected
+device running the Luminary Micro DFU boot loader.
+
+This file contains a summary of what you will find in each of the files that
+make up your dfuprog application.
+
+dfuprog.vcproj
+ This is the main project file for VC++ projects generated using an Application Wizard.
+ It contains information about the version of Visual C++ that generated the file, and
+ information about the platforms, configurations, and project features selected with the
+ Application Wizard.
+
+dfuprog.cpp
+ This is the main application source file.
+
+/////////////////////////////////////////////////////////////////////////////
+Other standard files:
+
+StdAfx.h, StdAfx.cpp
+ These files are used to build a precompiled header (PCH) file
+ named dfuprog.pch and a precompiled types file named StdAfx.obj.
+
+/////////////////////////////////////////////////////////////////////////////
+
diff --git a/Software/Visual_Studio/Firmware/dfuprog/dfuprog.cpp b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.cpp
new file mode 100644
index 000000000..62ad3abc3
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.cpp
@@ -0,0 +1,1113 @@
+//*****************************************************************************
+//
+// dfuprog.cpp : A simple command-line utility for programming a USB-connected
+// Tiva board running the USB DFU boot loader.
+//
+// Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <conio.h>
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+
+//*****************************************************************************
+//
+// Helpful macros for generating output depending upon verbose and quiet flags.
+//
+//*****************************************************************************
+#define VERBOSEPRINT(...) if(g_bVerbose) { printf(__VA_ARGS__); }
+#define QUIETPRINT(...) if(!g_bQuiet) { printf(__VA_ARGS__); }
+
+//*****************************************************************************
+//
+// Globals whose values are set or overridden via command line parameters.
+//
+//*****************************************************************************
+bool g_bVerbose = false;
+bool g_bQuiet = false;
+bool g_bOverwrite = false;
+bool g_bUpload = false;
+bool g_bClear = false;
+bool g_bBinary = false;
+bool g_bEnumOnly = false;
+bool g_bDisregardIDs = false;
+bool g_bSkipVerify = false;
+bool g_bWaitOnExit = false;
+bool g_bReset = false;
+bool g_bSwitchMode = false;
+char *g_pszFile = NULL;
+unsigned long g_ulAddress = 0;
+unsigned long g_ulAddressOverride = 0xFFFFFFFF;
+unsigned long g_ulLength = 0;
+int g_iDeviceIndex = 0;
+
+//*****************************************************************************
+//
+// Exit the application, optionally pausing for a key press first.
+//
+//*****************************************************************************
+void
+ExitApp(int iRetcode)
+{
+
+ //
+ // Has the caller asked us to pause before exiting?
+ //
+ if(g_bWaitOnExit)
+ {
+ printf("\nPress any key to exit...\n");
+ while (!_kbhit())
+ {
+ //
+ // Wait for a key press.
+ //
+ }
+ }
+
+ exit(iRetcode);
+}
+
+//*****************************************************************************
+//
+// Display the welcome banner when the program is started.
+//
+//*****************************************************************************
+void
+PrintWelcome(void)
+{
+ if(g_bQuiet)
+ {
+ return;
+ }
+
+ printf("\nUSB Device Firmware Upgrade Example\n");
+ printf("Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.\n\n");
+}
+
+//*****************************************************************************
+//
+// Show help on the application command line parameters.
+//
+//*****************************************************************************
+void
+ShowHelp(void)
+{
+ //
+ // Only print help if we are not in quiet mode.
+ //
+ if(g_bQuiet)
+ {
+ return;
+ }
+
+ printf("This application may be used to download images to a Texas Instruments\n");
+ printf("Tiva microcontroller running the USB Device Firmware Upgrade\n");
+ printf("boot loader. Additionally, the application can read back the\n");
+ printf("existing application image or a subsection of flash and store it\n");
+ printf("either as raw data or wrapped as a DFU-downloadable image.\n\n");
+ printf("Supported parameters are:\n\n");
+ printf("-e - Enumerate connected devices, show info then exit.\n");
+ printf("-m - Switch into DFU mode if device is currently in runtime mode.\n");
+ printf("-u - Upload an image from the board into the target DFU file.\n");
+ printf(" If absent, the file will be downloaded to the board.\n");
+ printf("-c Clear a block of flash. The address and size of the\n");
+ printf(" block are may be given using -a and -l. If these are\n");
+ printf(" absent, clears the entire writable area of flash. Trumps -u.\n");
+ printf("-f <file> - The file name for upload or download use.\n");
+ printf("-b - Upload binary rather than a DFU-formatted file. (used with -u)\n");
+ printf("-d - Disregard VID and PID in DFU image to be downloaded.\n");
+ printf("-s - Skip verification after a download operation.\n");
+ printf("-a <num> - Set the address the binary will be flashed to or read from.\n");
+ printf(" If absent, binary files are flashed the default application\n");
+ printf(" start address for the target. Ignored for DFU files.\n");
+ printf("-l <num> - Set the upload length (use with -u). If absent, the\n");
+ printf(" entire writable flash area is uploaded.\n");
+ printf("-i <num> - Sets the index of the USB DFU device to access if more\n");
+ printf(" than one is found. If absent, the first device found is used.\n");
+ printf("-x - Overwrite existing file without prompting. (used with -u)\n");
+ printf("-r - Reset the target on completion of operation.\n");
+ printf("-? or -h - Show this help.\n");
+ printf("-q - Quiet mode. Disable output to stdio.\n");
+ printf("-w - Wait for a key press before exiting.\n");
+ printf("-v - Enable verbose output\n\n");
+ printf("Examples:\n\n");
+ printf(" dfuprog -f program.bin -a 0x1800\n\n");
+ printf("Writes binary file program.bin to the device at address 0x1800\n\n");
+ printf(" dfuprog -i 1 -f program.dfu\n\n");
+ printf("Writes DFU-formatted file program.dfu to the second connected\n");
+ printf("device (index 1) at the address found in the DFU file prefix.\n\n");
+ printf(" dfuprog -u -f appimage.dfu\n\n");
+ printf("Reads the current board application image into DFU-formatted file\n");
+ printf("appimage.dfu\n\n");
+}
+
+//*****************************************************************************
+//
+// Parse the command line, extracting all parameters.
+//
+// Returns 0 on success. On failure, calls ExitApp(1).
+//
+//*****************************************************************************
+int
+ParseCommandLine(int argc, char *argv[])
+{
+ int iParm;
+ bool bShowHelp;
+ char *pcOptArg;
+
+ //
+ // By default, don't show the help screen.
+ //
+ bShowHelp = false;
+
+ //
+ // Walk through each of the parameters in the list, skipping the first one
+ // which is the executable name itself.
+ //
+ for(iParm = 1; iParm < argc; iParm++)
+ {
+ //
+ // Does this look like a valid switch?
+ //
+ if(!argv || ((argv[iParm][0] != '-') && (argv[iParm][0] != '/')) ||
+ (argv[iParm][1] == '\0'))
+ {
+ //
+ // We found something on the command line that didn't look like a
+ // switch so bomb out.
+ //
+ printf("Unrecognized or invalid argument: %s\n", argv[iParm]);
+ ExitApp(1);
+ }
+ else
+ {
+ //
+ // For convenience, get a pointer to the next argument since this
+ // is often a parameter for a given switch (and since this code was
+ // converted from a previous version which used getopt which is not
+ // available in the Windows SDK).
+ //
+ pcOptArg = ((iParm + 1) < argc) ? argv[iParm + 1] : NULL;
+ }
+
+ switch(argv[iParm][1])
+ {
+ case 'w':
+ g_bWaitOnExit = true;
+ break;
+
+ case 'c':
+ g_bClear = true;
+ break;
+
+ case 's':
+ g_bSkipVerify = true;
+ break;
+
+ case 'd':
+ g_bDisregardIDs = true;
+ break;
+
+ case 'e':
+ g_bEnumOnly = true;
+ break;
+
+ case 'u':
+ g_bUpload = true;
+ break;
+
+ case 'm':
+ g_bSwitchMode = true;
+ break;
+
+ case 'f':
+ g_pszFile = pcOptArg;
+ iParm++;
+ break;
+
+ case 'b':
+ g_bBinary = true;
+ break;
+
+ case 'a':
+ g_ulAddressOverride = (unsigned long)strtol(pcOptArg, NULL, 0);
+ iParm++;
+ break;
+
+ case 'l':
+ g_ulLength = (unsigned long)strtol(pcOptArg, NULL, 0);
+ iParm++;
+ break;
+
+ case 'i':
+ g_iDeviceIndex = (int)strtol(pcOptArg, NULL, 0);
+ iParm++;
+ break;
+
+ case 'r':
+ g_bReset = TRUE;
+ break;
+
+ case 'v':
+ g_bVerbose = TRUE;
+ break;
+
+ case 'q':
+ g_bQuiet = TRUE;
+ break;
+
+ case 'x':
+ g_bOverwrite = TRUE;
+ break;
+
+ case '?':
+ case 'h':
+ bShowHelp = TRUE;
+ break;
+
+ default:
+ printf("Unrecognized argument: %s\n", argv[iParm]);
+ ExitApp(1);
+ }
+ }
+
+ //
+ // Show the welcome banner unless we have been told to be quiet.
+ //
+ PrintWelcome();
+
+ //
+ // Show the help screen if requested.
+ //
+ if(bShowHelp)
+ {
+ ShowHelp();
+ ExitApp(0);
+ }
+
+ //
+ // Catch various invalid or pointless parameter cases.
+ //
+ if(g_bEnumOnly)
+ {
+ //
+ // The -e option causes pretty much all other command line options to
+ // be ignored so let the user know if they specified something that is
+ // not going to do anything.
+ //
+ if(g_iDeviceIndex || g_ulLength || g_ulAddress || g_bBinary ||
+ g_pszFile || g_bUpload || g_bClear || g_bSwitchMode)
+ {
+ //
+ // Tell the user what's going on but don't exit since this is not
+ // a fatal error condition.
+ //
+ QUIETPRINT("Some options ignored - irrelevant when used "
+ "with -e.\n");
+ }
+ }
+ else
+ {
+ if(!g_bClear && !g_bSwitchMode)
+ {
+ //
+ // We are performing a download or upload operation. In this case,
+ // we definitely need a file name.
+ //
+ if(!g_pszFile)
+ {
+ //
+ // No file name provided. If we haven't displayed it already,
+ // show command line help then display the error information.
+ //
+ ShowHelp();
+
+ QUIETPRINT("ERROR: No file name was specified. Please use -f "
+ "to provide one.\n");
+ ExitApp(1);
+ }
+ }
+ }
+
+ //
+ // Tell the caller that everything is OK.
+ //
+ return(0);
+}
+
+//*****************************************************************************
+//
+// Dump the information contained within the passed device information structure
+// to stdout assuming we are not in quiet mode.
+//
+//*****************************************************************************
+void
+DumpDeviceInformation(tLMDFUHandle hHandle, tLMDFUDeviceInfo *psDevInfo)
+{
+ char pcStringBuf[256];
+ unsigned short usStringLen;
+ tLMDFUErr eRetcode;
+
+ //
+ // Show the VID and PID for the device.
+ //
+ QUIETPRINT("VID: 0x%04x PID: 0x%04x\n", psDevInfo->usVID,
+ psDevInfo->usPID);
+
+ //
+ // Now query the string descriptors associated with the device and
+ // display these.
+ //
+ // We chicken out here and get an ASCII version of the strings
+ // in the default language (even though this may not be
+ // something that can be represented in ASCII). Handling the
+ // real UNICODE returned by LMDFUDeviceStringGet() is left as
+ // an exercise to the reader.
+ //
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle, psDevInfo->ucProductString,
+ pcStringBuf, &usStringLen);
+ QUIETPRINT("Device Name: %s\n",
+ (eRetcode == DFU_OK) ? pcStringBuf : "<<Unknown>>");
+
+
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle,
+ psDevInfo->ucManufacturerString,
+ pcStringBuf, &usStringLen);
+ QUIETPRINT("Manufacturer: %s\n",
+ (eRetcode == DFU_OK) ? pcStringBuf : "<<Unknown>>");
+
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle,
+ psDevInfo->ucDFUInterfaceString,
+ pcStringBuf, &usStringLen);
+ QUIETPRINT("DFU Interface: %s\n",
+ (eRetcode == DFU_OK) ? pcStringBuf : "<<Unknown>>");
+
+ usStringLen = sizeof(pcStringBuf);
+ eRetcode = _LMDFUDeviceASCIIStringGet(hHandle, psDevInfo->ucSerialString,
+ pcStringBuf, &usStringLen);
+ QUIETPRINT("Serial Num: %s\n",
+ (eRetcode == DFU_OK) ? pcStringBuf : "<<Unknown>>");
+
+ //
+ // Display other relevant information.
+ //
+ QUIETPRINT("Max Transfer: %d bytes\n", psDevInfo->usTransferSize);
+ QUIETPRINT("Mode: %s\n", psDevInfo->bDFUMode ? "DFU" : "Runtime");
+ if(psDevInfo->bDFUMode)
+ {
+ QUIETPRINT("TI Extensions: %s\n", psDevInfo->bSupportsTivaExtensions ?
+ "Supported" : "Not Supported");
+ if(psDevInfo->bSupportsTivaExtensions)
+ {
+ QUIETPRINT("Target: %s revision %c%c\n",
+ psDevInfo->pcPartNumber,
+ psDevInfo->cRevisionMajor + 'A',
+ psDevInfo->cRevisionMinor + '0');
+ }
+ }
+ QUIETPRINT("Attributes:\n");
+ QUIETPRINT(" Will Detach: %s\n",
+ ((psDevInfo->ucDFUAttributes & DFU_ATTR_WILL_DETACH) ?
+ "Yes" : "No"));
+ QUIETPRINT(" Manifest Tolerant: %s\n",
+ ((psDevInfo->ucDFUAttributes & DFU_ATTR_MANIFEST_TOLERANT) ?
+ "Yes" : "No"));
+ QUIETPRINT(" Upload Capable: %s\n",
+ ((psDevInfo->ucDFUAttributes & DFU_ATTR_CAN_UPLOAD) ? "Yes" : "No"));
+ QUIETPRINT(" Download Capable: %s\n",
+ ((psDevInfo->ucDFUAttributes & DFU_ATTR_CAN_DOWNLOAD) ? "Yes" : "No"));
+}
+
+//*****************************************************************************
+//
+// Upload an image from the device identified by the passed handle. The actual
+// section of flash to upload and the format to save the upload in is controlled
+// by command line parameters via global variables.
+//
+// Returns 0 on success or a positive error return code on failure.
+//
+//*****************************************************************************
+int
+UploadImage(tLMDFUHandle hHandle, tLMDFUParams *psDFU)
+{
+ FILE *fh;
+ tLMDFUErr eRetcode;
+ unsigned char *pcFileBuf;
+ size_t iLen;
+ int iRetcode;
+ int iResponse;
+ errno_t eErr;
+
+ QUIETPRINT("Uploading from device to %s...\n", g_pszFile);
+
+ //
+ // We only support upload on devices supporting the Tiva DFU
+ // protocol since, on other devices, we have no idea how large an
+ // uploaded image to expect.
+ //
+ if(!psDFU)
+ {
+ QUIETPRINT("Target device does not support Tiva protocol.\n");
+ return(40);
+ }
+
+ //
+ // Check if the address has a override value.
+ //
+ if(g_ulAddressOverride != 0xFFFFFFFF)
+ {
+ g_ulAddress = g_ulAddressOverride;
+ }
+ else if(g_ulAddress == 0)
+ {
+ //
+ // Where should we start uploading from? If the start address is not
+ // specified, assume the start of the writeable area. Upload from
+ // the application start address.
+ //
+ g_ulAddress = psDFU->ulAppStartAddr;
+ }
+
+ //
+ // How much data must we read? If the length is not specified, set the
+ // length to be the whole block between the start address and the top of
+ // the writable area.
+ //
+ if(g_ulLength == 0)
+ {
+ g_ulLength = psDFU->ulFlashTop - g_ulAddress;
+ }
+
+ //
+ // Now allocate a buffer large enough to hold the image. We need to add
+ // space for the 8 byte prefix and 16 byte suffix if we have been asked
+ // for a DFU-format image.
+ //
+ pcFileBuf = (unsigned char *)malloc(g_ulLength + (g_bBinary ? 0 : 24));
+ if(!pcFileBuf)
+ {
+ //
+ // We can't allocate the memory!
+ //
+ QUIETPRINT("Error allocating %d bytes of memory!\n",
+ g_ulLength + (g_bBinary ? 0 : 24));
+ return(41);
+ }
+
+ //
+ // Upload the data into our buffer.
+ //
+ eRetcode = _LMDFUUpload(hHandle, pcFileBuf, g_ulAddress,
+ (g_ulLength + (g_bBinary ? 0 : 24)), g_bBinary, NULL);
+
+ if(eRetcode == DFU_OK)
+ {
+ //
+ // We got the image successfully. Have we been given the go-ahead to
+ // overwrite the output file without a warning?
+ //
+ if(!g_bOverwrite)
+ {
+ eErr = fopen_s(&fh, g_pszFile, "rb");
+ if(eErr == 0)
+ {
+ //
+ // We don't need this handle any more so close the file.
+ //
+ fclose(fh);
+
+ //
+ // The file exists and we are in quiet mode so fail the
+ // operation since we can't prompt the user for permission to
+ // overwrite.
+ //
+ if(g_bQuiet)
+ {
+ free(pcFileBuf);
+ return(43);
+ }
+ else
+ {
+ //
+ // Prompt the user for permission to overwrite the output
+ // file.
+ //
+ printf("File %s exists. Overwrite? (Y/N): ", g_pszFile);
+ iResponse = getc(stdin);
+ if((iResponse != 'y') && (iResponse != 'Y'))
+ {
+ //
+ // The user didn't respond with 'y' or 'Y' so return an
+ // error and don't overwrite the file.
+ //
+ VERBOSEPRINT("User chose not to overwrite output.\n");
+ free(pcFileBuf);
+ return(44);
+ }
+ printf("Overwriting existing output file.\n");
+ }
+ }
+ }
+
+ //
+ // At this point it is fine for us to open the output file for writing.
+ //
+ eErr = fopen_s(&fh, g_pszFile, "wb");
+
+ if(eErr != 0)
+ {
+ QUIETPRINT("Error opening output file for writing.\n");
+ iRetcode = 45;
+ }
+ else
+ {
+ //
+ // Write the uploaded image to the file.
+ //
+ iLen = fwrite(pcFileBuf, 1, (g_ulLength + (g_bBinary ? 0 : 24)), fh);
+
+ //
+ // Did we write the expected amount of data?
+ //
+ if(iLen != (g_ulLength + (g_bBinary ? 0 : 24)))
+ {
+ //
+ // No - something went wrong.
+ //
+ QUIETPRINT("Error writing output. Write %d bytes, "
+ "expected %d.\n", iLen,
+ (g_ulLength + (g_bBinary ? 0 : 24)));
+ iRetcode = 46;
+ }
+ else
+ {
+ //
+ // Life is good. Set an appropriate exit code.
+ //
+ iRetcode = 0;
+ }
+
+ //
+ // Close the output file.
+ //
+ fclose(fh);
+ }
+ }
+ else
+ {
+ //
+ // There was an error attempting to upload the image from the device.
+ //
+ QUIETPRINT("Error uploading %d bytes from 0x%08x!\n",
+ g_ulLength + (g_bBinary ? 0 : 24), g_ulAddress);
+ iRetcode = 42;
+ }
+
+ //
+ // Free up our image buffer.
+ //
+ free(pcFileBuf);
+
+ return(iRetcode);
+}
+
+//*****************************************************************************
+//
+// Download an image to the the device identified by the passed handle. The
+// image to be downloaded and other parameters related to the operation are
+// controlled by command line parameters via global variables.
+//
+// Returns 0 on success or a positive error return code on failure.
+//
+//*****************************************************************************
+int
+DownloadImage(tLMDFUHandle hHandle, tLMDFUParams *psDFU)
+{
+ FILE *fh;
+ tLMDFUErr eRetcode;
+ unsigned char *pcFileBuf;
+ size_t iLen;
+ size_t iRead;
+ bool bTivaFormat;
+
+ QUIETPRINT("Downloading %s to device...\n", g_pszFile);
+
+ //
+ // Check if the address has a override value.
+ //
+ if(g_ulAddressOverride != 0xFFFFFFFF)
+ {
+ g_ulAddress = g_ulAddressOverride;
+ }
+
+ //
+ // Does the input file exist?
+ //
+ fopen_s(&fh, g_pszFile, "rb");
+ if(!fh)
+ {
+ QUIETPRINT("Unable to open file %s. Does it exist?\n", g_pszFile);
+ return(10);
+ }
+
+ //
+ // How big is the file?
+ //
+ fseek(fh, 0, SEEK_END);
+ iLen = ftell(fh);
+ fseek(fh, 0, SEEK_SET);
+
+ //
+ // Allocate a buffer large enough for the file.
+ //
+ pcFileBuf = (unsigned char *)malloc(iLen);
+ if(!pcFileBuf)
+ {
+ QUIETPRINT("Error allocating %d bytes of memory!\n", iLen);
+ fclose(fh);
+ return(11);
+ }
+
+ //
+ // Read the file into our buffer and check that it was correctly read.
+ //
+ iRead = fread(pcFileBuf, 1, iLen, fh);
+ fclose(fh);
+
+ if(iRead != iLen)
+ {
+ QUIETPRINT("Error reading input file!\n");
+ free(pcFileBuf);
+ return(12);
+ }
+
+ //
+ // Check to see whether this is a binary or a DFU-wrapped file.
+ //
+ eRetcode = _LMDFUIsValidImage(hHandle, pcFileBuf, (unsigned long)iLen, &bTivaFormat);
+
+ //
+ // Is the image for the target we are currently talking to?
+ //
+ if((eRetcode == DFU_ERR_UNSUPPORTED) && !g_bDisregardIDs)
+ {
+ QUIETPRINT("This image does not appear to be valid for the target "
+ "device.\nUse -d to disregard embedded IDs\n");
+ free(pcFileBuf);
+ return(14);
+ }
+
+ if(((eRetcode == DFU_OK) ||
+ ((eRetcode == DFU_ERR_UNSUPPORTED) && g_bDisregardIDs)) &&
+ bTivaFormat)
+ {
+ //
+ // This is a DFU formatted image and either it is intended for the
+ // target device or the user wants us to ignore the IDs in the file.
+ // Since it also contains a Tiva prefix, we can send it to the
+ // main download function.
+ //
+ VERBOSEPRINT("Image contains valid DFU suffix and Tiva prefix.\n");
+ VERBOSEPRINT("Downloading image to flash.... ");
+ eRetcode = _LMDFUDownload(hHandle, pcFileBuf, (unsigned long)iLen, g_bSkipVerify,
+ g_bDisregardIDs, NULL);
+ }
+ else
+ {
+ //
+ // This is not a DFU-formatted file so we download it as a binary. In
+ // this case, we need to pass the flash address passed by the user or,
+ // if this was not provided, the application start address that the
+ // device told us to use when we queried its capabilities earlier.
+ //
+
+ //
+ // Did the file contain a DFU suffix but no Tiva prefix? If so,
+ // we remove the DFU suffix since this doesn't get downloaded. The
+ // length of the suffix is in the 5th last byte.
+ //
+ if((eRetcode == DFU_OK) || (eRetcode == DFU_ERR_UNSUPPORTED))
+ {
+ iLen -= pcFileBuf[iLen - 5];
+ }
+
+ VERBOSEPRINT("Image is not fully DFU-wrapped. Downloading as binary\n");
+ VERBOSEPRINT("Downloading image to flash.... ");
+
+ eRetcode = _LMDFUDownloadBin(hHandle, pcFileBuf, (unsigned long)iLen,
+ g_ulAddress, g_bSkipVerify, NULL);
+ }
+
+ VERBOSEPRINT("Completed.\n");
+
+ //
+ // Free the file buffer memory.
+ //
+ free(pcFileBuf);
+
+ if(eRetcode != DFU_OK)
+ {
+ QUIETPRINT("Error %s (%d) reported during file download\n",
+ _LMDFUErrorStringGet(eRetcode), eRetcode);
+ return(13);
+ }
+ else
+ {
+ return(0);
+ }
+}
+
+//*****************************************************************************
+//
+// Erase a section of the writeable region of flash. If the "-a" parameter
+// was not specified or was specified with address 0, the entire writeable
+// region of the target device flash will be erased. If a non-zero address
+// is provided, the -l parameter must also specified to set the start address
+// and length of the region that will be erased. The start address and length
+// must both be integer multiples of 1024.
+//
+// Returns 0 on success or a positive error return code on failure.
+//
+//*****************************************************************************
+int
+ClearFlash(tLMDFUHandle hHandle, tLMDFUParams *psDFU)
+{
+ tLMDFUErr eRetcode;
+
+ if(g_ulAddress)
+ {
+ QUIETPRINT("Clearing %dKB flash block from address 0x%08x\n",
+ g_ulLength / 1024, g_ulAddress);
+ }
+ else
+ {
+ QUIETPRINT("Clearing entire writable region of flash.\n");
+ }
+
+ //
+ // Erase the required block and verify that the erase completed
+ // successfully.
+ //
+ eRetcode = _LMDFUErase(hHandle, g_ulAddress, g_ulLength, true, NULL);
+
+ if(eRetcode != DFU_OK)
+ {
+ QUIETPRINT("Error %s (%d) erasing flash!\n",
+ _LMDFUErrorStringGet(eRetcode), eRetcode);
+ return(20);
+ }
+ else
+ {
+ QUIETPRINT("Flash erased successfully.\n");
+ return(0);
+ }
+}
+
+//*****************************************************************************
+//
+// The main entry point of the DFU programmer example application.
+//
+//*****************************************************************************
+int
+main(int argc,char* argv[])
+{
+ tLMDFUDeviceInfo sDevInfo;
+ tLMDFUHandle hHandle;
+ tLMDFUErr eRetcode;
+ tLMDFUParams sDFU;
+ tLMDFUParams *psDFU;
+ int iExitCode;
+ int iDevIndex;
+ bool bCompleted;
+ bool bDeviceFound;
+
+ //
+ // Parse the command line parameters, print the welcome banner and
+ // tell the user about any errors they made.
+ //
+ ParseCommandLine(argc, argv);
+
+ //
+ // Initialize the DFU library.
+ //
+ eRetcode = _LMDFUInit();
+
+ //
+ // Could we load the DLL and query all its entry points successfully?
+ //
+ if(eRetcode != DFU_OK)
+ {
+ //
+ // Oops - something is wrong with the DFU DLL.
+ //
+ if(eRetcode == DFU_ERR_NOT_FOUND)
+ {
+ printf("The driver for the USB Device Firmware Upgrade device cannot be found.\n");
+ printf("Before running this program, please connect the DFU device to this system\n");
+ printf("and install the device driver when prompted by Windows. The device driver\n");
+ printf("can be found on the evaluation kit CD or can be found in the windows_drivers\n");
+ printf("directory of your TivaWare installation.\n\n");
+ iExitCode = 10;
+ }
+ else if(eRetcode == DFU_ERR_INVALID_ADDR)
+ {
+ printf("The driver for the USB Device Firmware Upgrade device was found but appears\n");
+ printf("to be a version which this program does not support. Please download and\n");
+ printf("install the latest device driver and example applications from the TI\n");
+ printf("web site to ensure that you are using compatible versions. The drivers\n");
+ printf("can be found in the windows_drivers directory of your TivaWare\n");
+ printf("installation and the applications can be found in package \"Windows-side\n");
+ printf("examples for USB kits\" which may be downloaded from the web site at\n");
+ printf("http://www.ti.com/software_updates.\n\n");
+ iExitCode = 11;
+ }
+ else
+ {
+ printf("An error was reported while attempting to load the device driver for the \n");
+ printf("USB Device Firmware Upgrade device. If this error persists, please download\n");
+ printf("and reinstall the latest device driver and example applications from the TI\n");
+ printf("web site. The drivers can be found in the windows_drivers directory of your\n");
+ printf("TivaWare installation and the applications can be found in package\n");
+ printf("\"Windows-side examples for USB kits\" which may be downloaded from\n");
+ printf("http://www.ti.com/software_updates.\n\n");
+ iExitCode = 12;
+ }
+
+ //
+ // Exit now with the appropriate error code.
+ //
+ ExitApp(iExitCode);
+ }
+
+ //
+ // Enumerate the available DFU devices until we find the one we have been
+ // asked to access.
+ //
+ QUIETPRINT("Scanning USB buses for supported DFU devices...\n\n");
+
+ iDevIndex = 0;
+ bCompleted = false;
+ iExitCode = 0;
+ bDeviceFound = false;
+
+ do
+ {
+ //
+ // Try to open a device.
+ //
+ eRetcode = _LMDFUDeviceOpen(iDevIndex, &sDevInfo, &hHandle);
+
+ //
+ // Were we successful?
+ //
+ if(eRetcode == DFU_OK)
+ {
+ //
+ // Yes - if we are enumerating, dump information on the device.
+ //
+ if(g_bEnumOnly)
+ {
+ QUIETPRINT("\n<<<< Device %d >>>>\n\n", iDevIndex);
+ DumpDeviceInformation(hHandle, &sDevInfo);
+ }
+ else
+ {
+ //
+ // Have we found the device we are looking for?
+ //
+ if(iDevIndex == g_iDeviceIndex)
+ {
+ //
+ // We have found the required device
+ //
+ bDeviceFound = true;
+
+ //
+ // Is the device currently in runtime mode?
+ //
+ if(sDevInfo.bDFUMode == FALSE)
+ {
+ //
+ // Have we been asked to switch it into DFU mode?
+ //
+ if(g_bSwitchMode)
+ {
+ QUIETPRINT("\n<<<< Device %d >>>>\n\n", iDevIndex);
+ DumpDeviceInformation(hHandle, &sDevInfo);
+ QUIETPRINT("Switching device into DFU mode.\n");
+
+ //
+ // Yes - switch the device into DFU mode.
+ //
+ eRetcode = _LMDFUModeSwitch(hHandle);
+
+ //
+ // Set an appropriate return code.
+ //
+ iExitCode = (eRetcode != DFU_OK) ? 0 : 100;
+
+ //
+ // Drop out of the loop.
+ //
+ break;
+ }
+ else
+ {
+ QUIETPRINT("Device is in runtime mode. Switch to "
+ "DFU mode using '-m' before\n"
+ "attempting any other operation\n");
+ }
+ }
+ else
+ {
+ //
+ // If we were asked to switch modes and the device is already in
+ // DFU mode, check that we were passed some other operation to
+ // perform.
+ //
+ if(g_bSwitchMode)
+ {
+ QUIETPRINT("Device is already in DFU mode. No "
+ "switch necessary.\n");
+ }
+
+ //
+ // If it supports the Tiva DFU protocol, read back
+ // some important parameters.
+ //
+ if(sDevInfo.bSupportsTivaExtensions)
+ {
+ //
+ // Read flash size parameters from the device.
+ //
+ eRetcode = _LMDFUParamsGet(hHandle, &sDFU);
+ if(eRetcode != DFU_OK)
+ {
+ QUIETPRINT("Error %s (%d) reading flash "
+ "parameters.\n",
+ _LMDFUErrorStringGet(eRetcode),
+ eRetcode);
+ }
+ psDFU = &sDFU;
+ }
+ else
+ {
+ //
+ // The device doesn't support the Tiva
+ // protocol so set the DFU parameter structure
+ // pointer to NULL.
+ //
+ psDFU = (tLMDFUParams *)0;
+ }
+
+ //
+ // No errors so far?
+ //
+ if(eRetcode == DFU_OK)
+ {
+ //
+ // Have we been asked to clear the flash?
+ //
+ if(g_bClear)
+ {
+ //
+ // Yes - clear the required area of flash.
+ //
+ iExitCode = ClearFlash(hHandle, psDFU);
+ }
+ //
+ // Yes - have we been asked to upload the current
+ // image to a file on the host?
+ //
+ else if(g_bUpload)
+ {
+ //
+ // Yes - go ahead and perform the upload.
+ //
+ iExitCode = UploadImage(hHandle, psDFU);
+ }
+ else
+ {
+ //
+ // No - download an image to the device if a
+ // filename has been provided.
+ //
+ if(g_pszFile)
+ {
+ iExitCode = DownloadImage(hHandle, psDFU);
+ }
+ }
+ }
+
+ //
+ // At this point, we've done whatever we have been asked
+ // to do so make sure we exit the loop next time we get
+ // to the end.
+ //
+ bCompleted = true;
+ }
+ }
+ }
+
+ //
+ // We are finished with this device for now.
+ //
+ eRetcode = _LMDFUDeviceClose(hHandle, g_bReset);
+
+ //
+ // Move on to look for another device.
+ //
+ iDevIndex++;
+ }
+ }
+ while((eRetcode == DFU_OK) && !bCompleted);
+
+ //
+ // Print a final summary of what we found if we are merely enumerating the
+ // devices.
+ //
+ if(g_bEnumOnly)
+ {
+ QUIETPRINT("\nFound %d device%s.\n", iDevIndex, (iDevIndex == 1) ? "" : "s");
+ }
+ else
+ {
+ //
+ // Did we find the device that the user wanted to talk to?
+ //
+ if(!bDeviceFound)
+ {
+ //
+ // No - we couldn't find the requested device.
+ //
+ QUIETPRINT("The requested device was not found on the bus.\n");
+ iExitCode = 1;
+ }
+ }
+
+ ExitApp(iExitCode);
+}
+
diff --git a/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcproj b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcproj
new file mode 100644
index 000000000..00c738bea
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcproj
@@ -0,0 +1,374 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="dfuprog"
+ ProjectGUID="{10860F0F-3C9A-41FD-AE0D-2F7482BFC3EC}"
+ RootNamespace="dfuprog"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../lmdfu"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseLibraryDependencyInputs="true"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="$(OutDir);..\Debug"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../lmdfu"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseLibraryDependencyInputs="true"
+ AdditionalDependencies="lmusbdll.lib"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="$(OutDir);..\lmusbdll\x64\Debug"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../lmdfu"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseLibraryDependencyInputs="true"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="$(OutDir);..\Release"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="../lmdfu"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ UseLibraryDependencyInputs="true"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="$(OutDir);..\x64\Release"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\dfuprog.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\lmdfuwrap.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\lmdfuwrap.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj
new file mode 100644
index 000000000..22723cf84
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj
@@ -0,0 +1,220 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{10860F0F-3C9A-41FD-AE0D-2F7482BFC3EC}</ProjectGuid>
+ <RootNamespace>dfuprog</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>15.0.26430.15</_ProjectFileVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <OutDir>$(ProjectDir)bin\Debug</OutDir>
+ <IntDir>$(Configuration)\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental>true</LinkIncremental>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <OutDir>$(SolutionDir)$(Configuration)\</OutDir>
+ <IntDir>$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(Platform)\$(Configuration)\</IntDir>
+ <LinkIncremental>false</LinkIncremental>
+ <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules />
+ <CodeAnalysisRuleAssemblies />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\UpdateFirmwareLib;..\UpdateFirmwareLib\bin\Debug;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ </ClCompile>
+ <ProjectReference>
+ <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <Link>
+ <AdditionalLibraryDirectories>$(OutDir);..\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention />
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>../lmdfu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ProjectReference>
+ <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <Link>
+ <AdditionalDependencies>lmusbdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(OutDir);..\lmusbdll\x64\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention />
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>../lmdfu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ProjectReference>
+ <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <Link>
+ <AdditionalLibraryDirectories>$(OutDir);..\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention />
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>../lmdfu;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <PrecompiledHeader />
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <ProjectReference>
+ <UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <Link>
+ <AdditionalLibraryDirectories>$(OutDir);..\x64\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Console</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <DataExecutionPrevention />
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="dfuprog.cpp" />
+ <ClCompile Include="lmdfuwrap.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="lmdfuwrap.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\UpdateFirmwareLib\UpdateFirmwareLib.vcxproj">
+ <Project>{cbf47870-840d-40fb-9d1a-61f4fe1b7c18}</Project>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj.filters b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj.filters
new file mode 100644
index 000000000..ad16a600c
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/dfuprog.vcxproj.filters
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="dfuprog.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="lmdfuwrap.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="lmdfuwrap.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.cpp b/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.cpp
new file mode 100644
index 000000000..4dc047dc5
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.cpp
@@ -0,0 +1,299 @@
+//*****************************************************************************
+//
+// lmdfuwrap.cpp : A thin wrapper over the lmdfu.dll library allowing it to be
+// loaded dynamically rather than statically linking to its .lib
+// file.
+//
+// Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#include <windows.h>
+#include "lmdfu.h"
+#include "lmdfuwrap.h"
+
+//*****************************************************************************
+//
+// DLL module handle.
+//
+//*****************************************************************************
+HINSTANCE hLMUSB = (HINSTANCE)NULL;
+
+//*****************************************************************************
+//
+// Function pointers for each DLL entry point.
+//
+//*****************************************************************************
+tLMDFUInit pfnLMDFUInit = NULL;
+tLMDFUDeviceOpen pfnLMDFUDeviceOpen = NULL;
+tLMDFUDeviceClose pfnLMDFUDeviceClose = NULL;
+tLMDFUDeviceStringGet pfnLMDFUDeviceStringGet = NULL;
+tLMDFUDeviceASCIIStringGet pfnLMDFUDeviceASCIIStringGet = NULL;
+tLMDFUParamsGet pfnLMDFUParamsGet = NULL;
+tLMDFUIsValidImage pfnLMDFUIsValidImage = NULL;
+tLMDFUDownload pfnLMDFUDownload = NULL;
+tLMDFUDownloadBin pfnLMDFUDownloadBin = NULL;
+tLMDFUErase pfnLMDFUErase = NULL;
+tLMDFUBlankCheck pfnLMDFUBlankCheck = NULL;
+tLMDFUUpload pfnLMDFUUpload = NULL;
+tLMDFUStatusGet pfnLMDFUStatusGet = NULL;
+tLMDFUErrorStringGet pfnLMDFUErrorStringGet = NULL;
+tLMDFUModeSwitch pfnLMDFUModeSwitch = NULL;
+
+tLMDFUErr __stdcall _LMDFUInit(void)
+{
+ //
+ // Try to load the USB DLL.
+ //
+ hLMUSB = LoadLibrary(TEXT("lmdfu.dll"));
+
+ //
+ // Did we find it?
+ //
+ if(hLMUSB)
+ {
+ //
+ // Yes - query all the entry point addresses.
+ //
+ pfnLMDFUInit = (tLMDFUInit)GetProcAddress(hLMUSB, "LMDFUInit");
+ pfnLMDFUDeviceOpen = (tLMDFUDeviceOpen)GetProcAddress(hLMUSB, "LMDFUDeviceOpen");
+ pfnLMDFUDeviceClose = (tLMDFUDeviceClose)GetProcAddress(hLMUSB, "LMDFUDeviceClose");
+ pfnLMDFUDeviceStringGet = (tLMDFUDeviceStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceStringGet");
+ pfnLMDFUDeviceASCIIStringGet = (tLMDFUDeviceASCIIStringGet)GetProcAddress(hLMUSB, "LMDFUDeviceASCIIStringGet");
+ pfnLMDFUParamsGet = (tLMDFUParamsGet)GetProcAddress(hLMUSB, "LMDFUParamsGet");
+ pfnLMDFUIsValidImage = (tLMDFUIsValidImage)GetProcAddress(hLMUSB, "LMDFUIsValidImage");
+ pfnLMDFUDownload = (tLMDFUDownload)GetProcAddress(hLMUSB, "LMDFUDownload");
+ pfnLMDFUDownloadBin = (tLMDFUDownloadBin)GetProcAddress(hLMUSB, "LMDFUDownloadBin");
+ pfnLMDFUErase = (tLMDFUErase)GetProcAddress(hLMUSB, "LMDFUErase");
+ pfnLMDFUBlankCheck = (tLMDFUBlankCheck)GetProcAddress(hLMUSB, "LMDFUBlankCheck");
+ pfnLMDFUUpload = (tLMDFUUpload)GetProcAddress(hLMUSB, "LMDFUUpload");
+ pfnLMDFUStatusGet = (tLMDFUStatusGet)GetProcAddress(hLMUSB, "LMDFUStatusGet");
+ pfnLMDFUErrorStringGet = (tLMDFUErrorStringGet)GetProcAddress(hLMUSB, "LMDFUErrorStringGet");
+ pfnLMDFUModeSwitch = (tLMDFUModeSwitch)GetProcAddress(hLMUSB, "LMDFUModeSwitch");
+
+ //
+ // Make sure we actually queried all the expected entry points.
+ //
+ if(!pfnLMDFUInit || !pfnLMDFUDeviceOpen || !pfnLMDFUDeviceClose ||
+ !pfnLMDFUDeviceStringGet || !pfnLMDFUDeviceASCIIStringGet ||
+ !pfnLMDFUParamsGet || !pfnLMDFUIsValidImage || !pfnLMDFUDownload ||
+ !pfnLMDFUDownloadBin || !pfnLMDFUErase || !pfnLMDFUBlankCheck ||
+ !pfnLMDFUUpload || !pfnLMDFUStatusGet || !pfnLMDFUErrorStringGet ||
+ !pfnLMDFUModeSwitch)
+ {
+ //
+ // We failed to query at least one entry point. Return
+ // DFU_ERR_INVALID_ADDR to signal to the caller that the driver
+ // is likely the wrong version.
+ //
+ return(DFU_ERR_INVALID_ADDR);
+ }
+ else
+ {
+ //
+ // We got all the expected function pointers so call the library
+ // init function and return it's response.
+ //
+ return(pfnLMDFUInit());
+ }
+ }
+ else
+ {
+ //
+ // The DLL could not be found. This tends to suggest that the driver
+ // is not installed. Return an appropriate error code to the caller
+ // so that they can provide helpful information to the user.
+ //
+ return(DFU_ERR_NOT_FOUND);
+ }
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceOpen(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle)
+{
+ if(pfnLMDFUDeviceOpen)
+ {
+ return(pfnLMDFUDeviceOpen(iDeviceIndex, psDevInfo, phHandle));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset)
+{
+ if(pfnLMDFUDeviceClose)
+ {
+ return(pfnLMDFUDeviceClose(hHandle, bReset));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen)
+{
+ if(pfnLMDFUDeviceStringGet)
+ {
+ return(pfnLMDFUDeviceStringGet(hHandle, ucStringIndex, usLanguageID,
+ pcString, pusStringLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen)
+{
+ if(pfnLMDFUDeviceASCIIStringGet)
+ {
+ return(pfnLMDFUDeviceASCIIStringGet(hHandle, ucStringIndex, pcString,
+ pusStringLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUParamsGet(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams)
+{
+ if(pfnLMDFUParamsGet)
+ {
+ return(pfnLMDFUParamsGet(hHandle, psParams));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUIsValidImage(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat)
+{
+ if(pfnLMDFUIsValidImage)
+ {
+ return(pfnLMDFUIsValidImage(hHandle, pcDFUImage, ulImageLen,
+ pbTivaFormat));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDownload(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen, bool bVerify,
+ bool bIgnoreIDs, HWND hwndNotify)
+{
+ if(pfnLMDFUDownload)
+ {
+ return(pfnLMDFUDownload(hHandle, pcDFUImage, ulImageLen, bVerify,
+ bIgnoreIDs, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUDownloadBin(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify, HWND hwndNotify)
+{
+ if(pfnLMDFUDownloadBin)
+ {
+ return(pfnLMDFUDownloadBin(hHandle, pcBinaryImage, ulImageLen,
+ ulStartAddr, bVerify, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
+ unsigned long ulEraseLen, bool bVerify,
+ HWND hwndNotify)
+{
+ if(pfnLMDFUErase)
+ {
+ return(pfnLMDFUErase(hHandle, ulStartAddr, ulEraseLen, bVerify,
+ hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUBlankCheck(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen)
+{
+ if(pfnLMDFUBlankCheck)
+ {
+ return(pfnLMDFUBlankCheck(hHandle, ulStartAddr, ulLen));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen, bool bRaw,
+ HWND hwndNotify)
+{
+ if(pfnLMDFUUpload)
+ {
+ return(pfnLMDFUUpload(hHandle, pcBuffer, ulStartAddr, ulImageLen,
+ bRaw, hwndNotify));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus)
+{
+ if(pfnLMDFUStatusGet)
+ {
+ return(pfnLMDFUStatusGet(hHandle, pStatus));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+tLMDFUErr __stdcall _LMDFUModeSwitch(tLMDFUHandle hHandle)
+{
+ if(pfnLMDFUStatusGet)
+ {
+ return(pfnLMDFUModeSwitch(hHandle));
+ }
+
+ return(DFU_ERR_HANDLE);
+}
+
+char * __stdcall _LMDFUErrorStringGet(tLMDFUErr eError)
+{
+ if(pfnLMDFUErrorStringGet)
+ {
+ return(pfnLMDFUErrorStringGet(eError));
+ }
+
+ return("Driver not installed");
+}
diff --git a/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.h b/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.h
new file mode 100644
index 000000000..808f836b2
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/lmdfuwrap.h
@@ -0,0 +1,78 @@
+//*****************************************************************************
+//
+// lmdfuwrap.h : A thin wrapper over the lmdfu.dll library allowing it to be
+// loaded dynamically rather than statically linking to its .lib
+// file.
+//
+// Copyright (c) 2009-2017 Texas Instruments Incorporated. All rights reserved.
+// Software License Agreement
+//
+// Texas Instruments (TI) is supplying this software for use solely and
+// exclusively on TI's microcontroller products. The software is owned by
+// TI and/or its suppliers, and is protected under applicable copyright
+// laws. You may not combine this software with "viral" open-source
+// software in order to form a larger program.
+//
+// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
+// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
+// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
+// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+// DAMAGES, FOR ANY REASON WHATSOEVER.
+//
+// This is part of revision 2.1.4.178 of the Tiva Firmware Development Package.
+//
+//*****************************************************************************
+
+#ifndef __LMDFUWRAP_H__
+#define __LMDFUWRAP_H__
+
+//*****************************************************************************
+//
+// Wrapper function prototypes.
+//
+//*****************************************************************************
+tLMDFUErr __stdcall _LMDFUInit(void);
+tLMDFUErr __stdcall _LMDFUDeviceOpen(int iDeviceIndex,
+ tLMDFUDeviceInfo *psDevInfo,
+ tLMDFUHandle *phHandle);
+tLMDFUErr __stdcall _LMDFUDeviceClose(tLMDFUHandle hHandle, bool bReset);
+tLMDFUErr __stdcall _LMDFUDeviceStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ unsigned short usLanguageID,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall _LMDFUDeviceASCIIStringGet(tLMDFUHandle hHandle,
+ unsigned char ucStringIndex,
+ char *pcString,
+ unsigned short *pusStringLen);
+tLMDFUErr __stdcall _LMDFUParamsGet(tLMDFUHandle hHandle,
+ tLMDFUParams *psParams);
+tLMDFUErr __stdcall _LMDFUIsValidImage(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen,
+ bool *pbTivaFormat);
+tLMDFUErr __stdcall _LMDFUDownload(tLMDFUHandle hHandle,
+ unsigned char *pcDFUImage,
+ unsigned long ulImageLen, bool bVerify,
+ bool bIgnoreIDs, HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUDownloadBin(tLMDFUHandle hHandle,
+ unsigned char *pcBinaryImage,
+ unsigned long ulImageLen,
+ unsigned long ulStartAddr,
+ bool bVerify, HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUErase(tLMDFUHandle hHandle, unsigned long ulStartAddr,
+ unsigned long ulEraseLen, bool bVerify,
+ HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUBlankCheck(tLMDFUHandle hHandle,
+ unsigned long ulStartAddr,
+ unsigned long ulLen);
+tLMDFUErr __stdcall _LMDFUUpload(tLMDFUHandle hHandle, unsigned char *pcBuffer,
+ unsigned long ulStartAddr,
+ unsigned long ulImageLen, bool bRaw,
+ HWND hwndNotify);
+tLMDFUErr __stdcall _LMDFUStatusGet(tLMDFUHandle hHandle, tDFUStatus *pStatus);
+tLMDFUErr __stdcall _LMDFUModeSwitch(tLMDFUHandle hHandle);
+char * __stdcall _LMDFUErrorStringGet(tLMDFUErr eError);
+
+#endif
diff --git a/Software/Visual_Studio/Firmware/dfuprog/stdafx.cpp b/Software/Visual_Studio/Firmware/dfuprog/stdafx.cpp
new file mode 100644
index 000000000..fae591523
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/stdafx.cpp
@@ -0,0 +1,8 @@
+// stdafx.cpp : source file that includes just the standard includes
+// dfuprog.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/Software/Visual_Studio/Firmware/dfuprog/stdafx.h b/Software/Visual_Studio/Firmware/dfuprog/stdafx.h
new file mode 100644
index 000000000..0d7ddfc06
--- /dev/null
+++ b/Software/Visual_Studio/Firmware/dfuprog/stdafx.h
@@ -0,0 +1,15 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#pragma once
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#include <stdio.h>
+#include <tchar.h>
+
+
diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln
index a7a6fb27d..c605b3ea9 100644
--- a/Software/Visual_Studio/Tango.sln
+++ b/Software/Visual_Studio/Tango.sln
@@ -248,6 +248,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Web", "Tango.Web\Tang
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Dispensers", "MachineStudio\Modules\MachineStudio.Dispensers\Tango.MachineStudio.Dispensers.csproj", "{F69DA3A8-F823-461E-87CF-A9275ABC0B15}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Firmware", "Firmware", "{AD8721D6-D728-4D58-A0D8-BE2E3FF7A9BC}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.FirmwareUpdateLib", "Firmware\Tango.FirmwareUpdateLib\Tango.FirmwareUpdateLib.vcxproj", "{DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
AppVeyor|Any CPU = AppVeyor|Any CPU
@@ -4451,6 +4455,40 @@ Global
{F69DA3A8-F823-461E-87CF-A9275ABC0B15}.Release|x64.Build.0 = Release|Any CPU
{F69DA3A8-F823-461E-87CF-A9275ABC0B15}.Release|x86.ActiveCfg = Release|Any CPU
{F69DA3A8-F823-461E-87CF-A9275ABC0B15}.Release|x86.Build.0 = Release|Any CPU
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|Any CPU.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|Any CPU.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|ARM.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|ARM.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|ARM64.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|ARM64.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|x64.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|x64.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|x86.ActiveCfg = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.AppVeyor|x86.Build.0 = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|ARM.ActiveCfg = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|ARM64.ActiveCfg = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|x64.ActiveCfg = Debug|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|x64.Build.0 = Debug|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|x86.ActiveCfg = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Debug|x86.Build.0 = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|Any CPU.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|Any CPU.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|ARM.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|ARM.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|ARM64.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|ARM64.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|x64.ActiveCfg = Debug|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|x64.Build.0 = Debug|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|x86.ActiveCfg = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.DefaultBuild|x86.Build.0 = Debug|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|Any CPU.ActiveCfg = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|ARM.ActiveCfg = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|ARM64.ActiveCfg = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|x64.ActiveCfg = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|x64.Build.0 = Release|x64
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|x86.ActiveCfg = Release|Win32
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -4528,14 +4566,15 @@ Global
{7E5E4BED-538C-4566-A005-DCC070AF8715} = {C81ED1A3-D18C-4D80-A8F5-061994A14A60}
{D2EE865B-B006-487A-9487-60A663636AC3} = {0048447D-1D94-4E60-9DAD-7349C777CB4E}
{F69DA3A8-F823-461E-87CF-A9275ABC0B15} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8}
+ {DB79FB33-CE7A-49CF-AA89-F697E5CDB0F6} = {AD8721D6-D728-4D58-A0D8-BE2E3FF7A9BC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
- BuildVersion_UseGlobalSettings = False
- BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs
- BuildVersion_StartDate = 2000/1/1
- BuildVersion_UpdateFileVersion = False
- BuildVersion_UpdateAssemblyVersion = True
- BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear
SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6}
+ BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear
+ BuildVersion_UpdateAssemblyVersion = True
+ BuildVersion_UpdateFileVersion = False
+ BuildVersion_StartDate = 2000/1/1
+ BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs
+ BuildVersion_UseGlobalSettings = False
EndGlobalSection
EndGlobal
diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml
index 1ab00e18f..8714e65c3 100644
--- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml
+++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml
@@ -14,11 +14,14 @@
xmlns:commonControls="clr-namespace:Tango.PPC.Common.Controls;assembly=Tango.PPC.Common"
xmlns:explorer="clr-namespace:Tango.Explorer;assembly=Tango.Explorer"
mc:Ignorable="d"
- Title="MainWindow" Height="1280" Width="800" DataContext="{Binding RelativeSource={RelativeSource Self}}">
+ Title="MainWindow" Height="346.703" Width="716.514" DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Grid>
-
- <touch:TouchDatePicker VerticalAlignment="Center" Height="40" HorizontalAlignment="Center" Width="300" SelectedDate="12/15/2018" />
- <!--<touch:TouchCalendar DisplayDateStart="12/10/2018" DisplayDateEnd="1/1/2019" SelectedDate="12/15/2018" HorizontalAlignment="Center" VerticalAlignment="Center" />-->
+ <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
+ <TextBlock HorizontalAlignment="Center" Margin="0 0 0 10" x:Name="txtStatus"></TextBlock>
+ <ProgressBar x:Name="prog" VerticalAlignment="Center" Height="15" Width="700"></ProgressBar>
+ <Button x:Name="btnStart" Click="btnStart_Click" HorizontalAlignment="Center" Padding="30 10" Margin="0 10 0 0">START</Button>
+ <Button x:Name="btnSwitch" Click="btnSwitch_Click" HorizontalAlignment="Center" Padding="30 10" Margin="0 10 0 0">SWITCH</Button>
+ </StackPanel>
</Grid>
</Window>
diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs
index 0b06438b1..0352bcb82 100644
--- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs
+++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs
@@ -1,7 +1,9 @@
-using System;
+using Microsoft.Win32;
+using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
+using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -21,6 +23,7 @@ using Tango.BL.Entities;
using Tango.Core;
using Tango.Core.Commands;
using Tango.DragAndDrop;
+using Tango.FirmwareUpdateLib;
using Tango.SharedUI;
namespace Tango.UITests
@@ -30,38 +33,60 @@ namespace Tango.UITests
/// </summary>
public partial class MainWindow : Window
{
+ private FirmwareUpdateManager _manager;
+ private DFUDevice _device;
+
public MainWindow()
{
-
- Start();
InitializeComponent();
+ this.ContentRendered += MainWindow_ContentRendered;
}
- private async void Start()
+ private void MainWindow_ContentRendered(object sender, EventArgs e)
{
- using (ObservablesContext db = ObservablesContext.CreateDefault())
+ Task.Factory.StartNew(() =>
{
- var machine = new MachineBuilder(db).Set(x => x.SerialNumber == "1111").WithConfiguration().WithOrganization().WithJobs().WithSpools().WithCats().Build();
- MachineVersion version = db.MachineVersions.First();
- await version.ApplyPrototypeMachine(machine, db);
+ _manager = new FirmwareUpdateManager();
+ _manager.Initialize();
- Machine m = version.CreatePrototypeMachine(db);
- }
+ _device = _manager.GetAvailableDevices(false).FirstOrDefault();
+
+ if (_device != null)
+ {
+ MessageBox.Show($"Detected device: '{_device.DeviceName}'.");
+ }
+ });
}
-
+ private void btnStart_Click(object sender, RoutedEventArgs e)
+ {
+ OpenFileDialog dlg = new OpenFileDialog();
+ if (dlg.ShowDialog().Value)
+ {
+ byte[] data = File.ReadAllBytes(dlg.FileName);
+ _device.Upload(data, OnProgress);
+ }
+ }
- public String CurrentPath
+ private void OnProgress(ProgressMode progressMode, int current, int total)
{
- get { return (String)GetValue(CurrentPathProperty); }
- set { SetValue(CurrentPathProperty, value); }
+ this.BeginInvoke(() =>
+ {
+ txtStatus.Text = progressMode.ToString();
+ prog.Maximum = total;
+ prog.Value = current;
+ });
}
- public static readonly DependencyProperty CurrentPathProperty =
- DependencyProperty.Register("CurrentPath", typeof(String), typeof(MainWindow), new PropertyMetadata(null));
- private void Button_Click(object sender, RoutedEventArgs e)
+ private void btnSwitch_Click(object sender, RoutedEventArgs e)
{
- CurrentPath = @"D:\PPC Explorer Test";
+ _device.SwitchToDFUMode();
+ _device = _manager.GetAvailableDevices(false).FirstOrDefault();
+
+ if (_device.Mode == DFUMode.DFU)
+ {
+ MessageBox.Show($"Switched to DFU mode: '{_device.DeviceName}'.");
+ }
}
}
}
diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj
index 909acedb6..4becfe554 100644
--- a/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj
+++ b/Software/Visual_Studio/Utilities/Tango.UITests/Tango.UITests.csproj
@@ -112,6 +112,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
+ <ProjectReference Include="..\..\Firmware\Tango.FirmwareUpdateLib\Tango.FirmwareUpdateLib.vcxproj">
+ <Project>{db79fb33-ce7a-49cf-aa89-f697e5cdb0f6}</Project>
+ <Name>Tango.FirmwareUpdateLib</Name>
+ </ProjectReference>
<ProjectReference Include="..\..\PPC\Tango.PPC.Common\Tango.PPC.Common.csproj">
<Project>{0be74eee-22cb-4dba-b896-793b9e1a3ac0}</Project>
<Name>Tango.PPC.Common</Name>
@@ -148,7 +152,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
+ <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file