mirror of https://github.com/EspoTek/Labrador.git
Manual firmware recovery in the GUI
This commit is contained in:
parent
9f9e4e48c6
commit
44703c1b35
|
@ -69,6 +69,7 @@ public:
|
|||
void setBufferPtr(bufferControl *newPtr);
|
||||
void saveState(int *_out_deviceMode, double *_out_scopeGain, double *_out_currentPsuVoltage, int *_out_digitalPinState);
|
||||
virtual void usbSendControl(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length, unsigned char *LDATA) = 0;
|
||||
virtual void manualFirmwareRecovery(void) = 0;
|
||||
protected:
|
||||
//State Vars
|
||||
unsigned char fGenTriple=0;
|
||||
|
|
|
@ -1724,3 +1724,14 @@ void MainWindow::checkForI2C(int value){
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFirmware_Recovery_triggered()
|
||||
{
|
||||
qDebug() << "on_actionFirmware_Recovery_triggered";
|
||||
ui->controller_iso->driver->manualFirmwareRecovery();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionShow_Debug_Console_triggered()
|
||||
{
|
||||
enableLabradorDebugging();
|
||||
}
|
||||
|
|
|
@ -158,6 +158,10 @@ private slots:
|
|||
void serialEmergencyDisable(int channel);
|
||||
|
||||
void checkForI2C(int value);
|
||||
void on_actionFirmware_Recovery_triggered();
|
||||
|
||||
void on_actionShow_Debug_Console_triggered();
|
||||
|
||||
private:
|
||||
//Generic Vars
|
||||
Ui::MainWindow *ui;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/****************************************************************************
|
||||
** Resource object code
|
||||
**
|
||||
** Created by: The Resource Compiler for Qt version 5.7.1
|
||||
** Created by: The Resource Compiler for Qt version 5.5.1
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
static const unsigned char qt_resource_data[] = {
|
||||
// C:/Users/Esposch/Documents/Git/labrador/Desktop_Interface/buffer_0.bmp
|
||||
// /home/esposch/Git/Labrador/Desktop_Interface/buffer_0.bmp
|
||||
0x0,0x0,0x0,0x8d,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x0,0x45,0xc1,0xb0,0x45,
|
||||
|
@ -19,7 +19,7 @@ static const unsigned char qt_resource_data[] = {
|
|||
0xab,0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,
|
||||
0x8f,0xd5,0xc7,0xea,0x63,0xf5,0xb1,0xfa,0x58,0x7d,0xac,0x3e,0x56,0x1f,0xab,0x8f,
|
||||
0xd5,0xc7,0xea,0x63,0x73,0xf6,0xf9,0x2,0xf4,0x4,0x42,0xe7,
|
||||
// C:/Users/Esposch/Documents/Git/labrador/Desktop_Interface/buffer_2.bmp
|
||||
// /home/esposch/Git/Labrador/Desktop_Interface/buffer_2.bmp
|
||||
0x0,0x0,0x0,0x7b,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0x31,0xd,0x80,0x30,0x14,0x45,0xd1,0xe2,0x82,
|
||||
|
@ -30,7 +30,7 @@ static const unsigned char qt_resource_data[] = {
|
|||
0x3e,0x99,0xf1,0xe1,0xc3,0x87,0xf,0x9f,0xcc,0xf8,0xf0,0xe1,0xc3,0x87,0x4f,0x66,
|
||||
0x7c,0xf8,0xf0,0xe1,0xc3,0x27,0x33,0x3e,0x7c,0xf8,0xf0,0xe1,0x93,0x19,0x1f,0x3e,
|
||||
0x7c,0xf8,0xf0,0x19,0x7b,0x1,0x6d,0x5a,0xf,0xce,
|
||||
// C:/Users/Esposch/Documents/Git/labrador/Desktop_Interface/buffer_1.bmp
|
||||
// /home/esposch/Git/Labrador/Desktop_Interface/buffer_1.bmp
|
||||
0x0,0x0,0x0,0x97,
|
||||
0x0,
|
||||
0x0,0x28,0xb6,0x78,0x9c,0xed,0xd0,0xb1,0xd,0xc2,0x30,0x10,0x40,0xd1,0xb0,0x5,
|
||||
|
|
|
@ -1327,7 +1327,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1440</width>
|
||||
<height>31</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
@ -1428,8 +1428,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>183</width>
|
||||
<height>151</height>
|
||||
<width>178</width>
|
||||
<height>115</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
|
@ -1564,12 +1564,20 @@
|
|||
<addaction name="actionSingle_ep_msync"/>
|
||||
<addaction name="actionSingle_ep_async"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionFirmware_Recovery"/>
|
||||
<addaction name="actionShow_Debug_Console"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuOscilloscope_2"/>
|
||||
<addaction name="menuMultimeter_2"/>
|
||||
<addaction name="menuBus_Sniffer"/>
|
||||
<addaction name="menuPower_Supply"/>
|
||||
<addaction name="menuConnection_Type"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<action name="actionGainAuto">
|
||||
<property name="checkable">
|
||||
|
@ -2211,6 +2219,16 @@
|
|||
<string>CH2</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFirmware_Recovery">
|
||||
<property name="text">
|
||||
<string>Firmware Recovery</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_Debug_Console">
|
||||
<property name="text">
|
||||
<string>Show Debug Console</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "unixusbdriver.h"
|
||||
#include "platformspecific.h"
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
|
||||
unixUsbDriver::unixUsbDriver(QWidget *parent) : genericUsbDriver(parent)
|
||||
{
|
||||
|
@ -377,3 +378,98 @@ int unixUsbDriver::flashFirmware(void){
|
|||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void unixUsbDriver::manualFirmwareRecovery(void){
|
||||
#ifndef PLATFORM_ANDROID
|
||||
//Get location of firmware file
|
||||
char fname[128];
|
||||
sprintf(fname, "/firmware/labrafirm_%04x_%02x.hex", EXPECTED_FIRMWARE_VERSION, DEFINED_EXPECTED_VARIANT);
|
||||
|
||||
QString dirString = QCoreApplication::applicationDirPath();
|
||||
dirString.append(fname);
|
||||
QByteArray array = dirString.toLocal8Bit();
|
||||
char* buffer = array.data();
|
||||
|
||||
//Vars
|
||||
QMessageBox manualFirmwareMessages;
|
||||
int messageBoxReturn;
|
||||
|
||||
|
||||
char leaveBootloaderCommand[256];
|
||||
sprintf(leaveBootloaderCommand, "dfu-programmer atxmega32a4u launch");
|
||||
int exit_code;
|
||||
char eraseCommand[256];
|
||||
sprintf(eraseCommand, "dfu-programmer atxmega32a4u erase --force");
|
||||
char flashCommand[256];
|
||||
sprintf(flashCommand, "dfu-programmer atxmega32a4u flash %s", buffer);
|
||||
|
||||
|
||||
|
||||
|
||||
//Intro
|
||||
manualFirmwareMessages.setText("Welcome to the firmware recovery wizard.\nThis tool will attempt various steps to troubleshoot a board with connection issues.\n\nPress OK to continue.");
|
||||
manualFirmwareMessages.exec();
|
||||
|
||||
|
||||
//Hello, this is IT, can you try turning it off and on again?
|
||||
manualFirmwareMessages.setText("Before continuing, please disconnect and reconnect your Labrador board, then wait 10 seconds.\n\nAlso ensure that there are no other instances of the Labrador software running on this machine.");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setStandardButtons(QMessageBox::Yes|QMessageBox::No);
|
||||
manualFirmwareMessages.setText("Did that fix things?");
|
||||
messageBoxReturn = manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setStandardButtons(QMessageBox::Ok);
|
||||
if(messageBoxReturn == 16384){ //"Yes" is 16384, no is 65536
|
||||
manualFirmwareMessages.setText("Awesome! Have fun!");
|
||||
messageBoxReturn = manualFirmwareMessages.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
//Real troubleshooting begins here.....
|
||||
|
||||
//USB Problems.
|
||||
if(connected){
|
||||
manualFirmwareMessages.setText("It seems like your board is already connected and configured correctly.\n\nIf your board is not functioning correctly, this indicates that there is an issue with the USB driver.\n\nLet's go through some manual troubleshooting steps.");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setText("There are two main possibilities:\n\n - Your USB Controller does not support Isochronous mode at USB 2.0 FS\n - Another device is competing with Labrador for bandwidth.");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setText("If Labrador is connected to a USB 2.0 port, unplug it and connect it to a USB3 port.\n\nIf it's in a USB3 port, try connecting it to a USB 2.0 port.\n\nIf you have other USB devices, such as a keyboard and mouse, ensure they're connected to a port of a different type than Labrador (e.g., if your mouse and keyboard are in USB 2.0 ports, try putting Labrador in a USB 3.0 port).\n\nIf you're not sure which is which, USB3 ports are usually blue on the inside.");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setText("If you have a spare USB hub, connect Labrador (and only Labrador) to the hub.\n\nThis will usually result in a huge reduction in bandwidth required to communicate with Labrador, since a Hi-Speed hub reads from Labrador at 12MHz, but transmits upstream to the host at 480MHz.\n\n(If the host is connected to Labrador directly, it is slowed down to 12MHz!) ");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setText("If it's still not working, please disconnect all USB devices from your machine, then one by one, insert Labrador into each USB port on your machine until it starts working.");
|
||||
manualFirmwareMessages.exec();
|
||||
manualFirmwareMessages.setText("If that doesn't fix it, please open an issue on github.com/espotek/labrador, or contact me at admin@espotek.com.");
|
||||
manualFirmwareMessages.exec();
|
||||
return;
|
||||
} else {
|
||||
exit_code = dfuprog_virtual_cmd(leaveBootloaderCommand);
|
||||
manualFirmwareMessages.setText("No Labrador board could be detected.\n\nIt's possible that you're stuck in booloader mode.\n\nI've attempted to launch the firmware manually.");
|
||||
manualFirmwareMessages.exec();
|
||||
if(exit_code){
|
||||
manualFirmwareMessages.setText("Command failed. This usually means that no device is detected.\n\nPlease Ensure that the cable you're using can carry data (for example, by using it to transfer data to your phone).\n\nSome cables are for charging only, and not physically contain data lines.\n\nAlso note that the red light on the Labrador board is a power indicator for the PSU output pins.\nIt will turn on even if no data lines are present.");
|
||||
manualFirmwareMessages.exec();
|
||||
return;
|
||||
}
|
||||
//Firmware launch failed, but bootloader preset
|
||||
if(!connected){
|
||||
exit_code = dfuprog_virtual_cmd(eraseCommand);
|
||||
exit_code += dfuprog_virtual_cmd(flashCommand);
|
||||
manualFirmwareMessages.setText("The bootloader is present, but firmware launch failed. I've attempted to reprogram it.");
|
||||
manualFirmwareMessages.exec();
|
||||
|
||||
if(!exit_code){ //Reprogramming was successful, but board is still in bootloader mode.
|
||||
exit_code = dfuprog_virtual_cmd(leaveBootloaderCommand);
|
||||
manualFirmwareMessages.setText("Reprogramming was successful! Attempting to launch the board.\n\nIf it does not start working immediately, please wait 10 seconds and then reconnect the board.");
|
||||
manualFirmwareMessages.exec();
|
||||
} else { //Programming failed.
|
||||
manualFirmwareMessages.setText("Automatic Reprogramming failed.\n\nPlease contact me at admin@espotek.com for further support.");
|
||||
manualFirmwareMessages.exec();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
~unixUsbDriver();
|
||||
void usbSendControl(uint8_t RequestType, uint8_t Request, uint16_t Value, uint16_t Index, uint16_t Length, unsigned char *LDATA);
|
||||
char *isoRead(unsigned int *newLength);
|
||||
void manualFirmwareRecovery(void);
|
||||
protected:
|
||||
//USB Vars
|
||||
libusb_context *ctx = NULL;
|
||||
|
|
Loading…
Reference in New Issue