utility now detects devices connected in their normal operating mode and sends command to make them jump into bootloader mode
This commit is contained in:
@@ -69,8 +69,18 @@
|
|||||||
#define DEFAULT_VID 0x04D8
|
#define DEFAULT_VID 0x04D8
|
||||||
#define DEFAULT_PID 0x003C
|
#define DEFAULT_PID 0x003C
|
||||||
|
|
||||||
|
// the command to make the device jump into bootloader mode
|
||||||
|
#define COMMAND_JUMP_BOOTLOADER 0xBB
|
||||||
|
|
||||||
|
struct USBDevIds
|
||||||
|
{
|
||||||
|
unsigned short vendor_id;
|
||||||
|
unsigned short product_id;
|
||||||
|
} NormalModeDevIds[2] =
|
||||||
|
{
|
||||||
|
{0x1209, 0x0600}, // from pid.codes
|
||||||
|
{0x04D8, 0xECEE} // from microchip sublicense
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//Surely the micro doesn't have a programmable memory region greater than 268 Megabytes...
|
//Surely the micro doesn't have a programmable memory region greater than 268 Megabytes...
|
||||||
@@ -367,6 +377,50 @@ void MainWindow::Connection(void)
|
|||||||
emit SetProgressBar(0);
|
emit SetProgressBar(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if a device is found in normal non-bootloader mode
|
||||||
|
hid_device_info *hidDevs = hid_enumerate(0, 0);
|
||||||
|
hid_device_info *d = hidDevs;
|
||||||
|
while (d)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0;i<sizeof(NormalModeDevIds)/sizeof(USBDevIds);i++)
|
||||||
|
{
|
||||||
|
USBDevIds ids = NormalModeDevIds[i];
|
||||||
|
if (d->vendor_id == ids.vendor_id &&
|
||||||
|
d->product_id == ids.product_id)
|
||||||
|
{
|
||||||
|
// a device was found, prompt user that it will need to be reset into bootloader mode
|
||||||
|
QMessageBox msgbox(QMessageBox::Information,
|
||||||
|
"Device detected in non-FW update mode",
|
||||||
|
"A device was detected in normal operating mode. Press OK to reset the device into firmware update mode and proceed.",
|
||||||
|
QMessageBox::Ok,
|
||||||
|
this,
|
||||||
|
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||||
|
msgbox.setWindowModality(Qt::ApplicationModal);
|
||||||
|
msgbox.exec();
|
||||||
|
|
||||||
|
// the user has closed the message box - send the bootloader entry command to the device
|
||||||
|
hid_device *dev = hid_open_path(d->path);
|
||||||
|
if (dev == NULL)
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, "Error", "Failed to open the HID device");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unsigned char hidOutData[2] = {0, COMMAND_JUMP_BOOTLOADER};
|
||||||
|
int bytesWritten = hid_write(dev, &hidOutData[0], sizeof(hidOutData));
|
||||||
|
if (bytesWritten == -1)
|
||||||
|
{
|
||||||
|
QString errMsg = QString("Failed to send mode switch command to the device:\n\n%1").arg(hid_error(dev));
|
||||||
|
QMessageBox::critical(this, "Error", errMsg);
|
||||||
|
}
|
||||||
|
hid_close(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d = d->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
hid_free_enumeration(hidDevs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setBootloadEnabled(bool enable)
|
void MainWindow::setBootloadEnabled(bool enable)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="resources.qrc">
|
<iconset resource="resources.qrc">
|
||||||
<normaloff>:/MainWindow/img/Microchip_logo.Ico</normaloff>:/MainWindow/img/Microchip_logo.Ico</iconset>
|
<normaloff>:/MainWindow/img/amx_logo.ico</normaloff>:/MainWindow/img/amx_logo.ico</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QVBoxLayout" name="_2">
|
<layout class="QVBoxLayout" name="_2">
|
||||||
@@ -517,14 +517,6 @@ QGroupBox::title {
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="formAdvancedButtons" native="true">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Segoe UI</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnResetDevice">
|
<widget class="QPushButton" name="btnResetDevice">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
@@ -547,31 +539,6 @@ QGroupBox::title {
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="btnResetDeviceFWUpdateMode">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Segoe UI</family>
|
|
||||||
<pointsize>10</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Reset Device into FW Update Mode</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|||||||
BIN
qt5_src/Bootloader/img/amx_logo.ico
Normal file
BIN
qt5_src/Bootloader/img/amx_logo.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
@@ -34,30 +34,12 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
hid_device *dev = hid_open(0x1209, 0x0600, NULL);
|
|
||||||
if (dev == NULL)
|
|
||||||
{
|
|
||||||
qCritical("failed to open device");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char data[2] = { 0, 0xBB };
|
|
||||||
|
|
||||||
int written = hid_write(dev, &data[0], sizeof(data));
|
|
||||||
qWarning("Wrote %d bytes", written);
|
|
||||||
qWarning("%s", QString::fromWCharArray(hid_error(dev)).toStdString().c_str());
|
|
||||||
|
|
||||||
hid_close(dev);
|
|
||||||
//hid_exit();
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////
|
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QCoreApplication::setOrganizationName("JOJCorp");
|
QCoreApplication::setOrganizationName("JOJCorp");
|
||||||
QCoreApplication::setOrganizationDomain("source.jojcorp.com");
|
QCoreApplication::setOrganizationDomain("source.jojcorp.com");
|
||||||
QCoreApplication::setApplicationName("Dancepad Interface FW Flash Tool");
|
QCoreApplication::setApplicationName("BIA MicroDDR FW Flash Tool");
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|||||||
@@ -10,5 +10,6 @@
|
|||||||
<file>img/Reset.png</file>
|
<file>img/Reset.png</file>
|
||||||
<file>img/help.png</file>
|
<file>img/help.png</file>
|
||||||
<file>img/Microchip_logo.Ico</file>
|
<file>img/Microchip_logo.Ico</file>
|
||||||
|
<file>img/amx_logo.ico</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
Reference in New Issue
Block a user