From 1de46ae493520a84842a3cf2744146ce885643a2 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sun, 7 Sep 2014 23:01:20 +0200 Subject: [PATCH] OP-1476 - Clanup upload_tool and add Makefile target --- Makefile | 44 +- .../experimental/USB_UPLOAD_TOOL/SSP/port.cpp | 5 +- .../experimental/USB_UPLOAD_TOOL/SSP/qssp.cpp | 2 +- .../src/experimental/USB_UPLOAD_TOOL/main.cpp | 490 +++++++++--------- .../experimental/USB_UPLOAD_TOOL/op_dfu.cpp | 51 +- .../src/experimental/USB_UPLOAD_TOOL/op_dfu.h | 1 + 6 files changed, 333 insertions(+), 260 deletions(-) diff --git a/Makefile b/Makefile index 6716e1cc4..771c30ca5 100644 --- a/Makefile +++ b/Makefile @@ -439,7 +439,7 @@ sim_osx_%: uavobjects_flight ############################## .PHONY: all_ground -all_ground: openpilotgcs +all_ground: openpilotgcs uploader # Convenience target for the GCS .PHONY: gcs gcs_clean @@ -479,6 +479,40 @@ openpilotgcs_clean: @$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF))" $(V1) [ ! -d "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF)" +################################ +# +# Serial Uploader tool +# +################################ + +.NOTPARALLEL: +.PHONY: uploader +uploader: uploader_qmake uploader_make + +.PHONY: uploader_qmake +uploader_qmake: +ifeq ($(QMAKE_SKIP),) + $(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) + $(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) && \ + $(QMAKE) $(ROOT_DIR)/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/upload.pro -spec $(QT_SPEC) -r CONFIG+="$(GCS_BUILD_CONF) $(GCS_SILENT)" $(GCS_QMAKE_OPTS) \ + ) +else + @$(ECHO) "skipping qmake" +endif + +.PHONY: uploader_make +uploader_make: + $(V1) $(MKDIR) -p $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF) + $(V1) ( cd $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)/$(MAKE_DIR) && \ + $(MAKE) -w ; \ + ) + +.PHONY: uploader_clean +uploader_clean: + @$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/uploader_$(GCS_BUILD_CONF))" + $(V1) [ ! -d "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" ] || $(RM) -r "$(BUILD_DIR)/uploader_$(GCS_BUILD_CONF)" + + ################################ # # Android GCS related components @@ -972,6 +1006,14 @@ help: @$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)" @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" @$(ECHO) + @$(ECHO) " [UPLOADER TOOL]" + @$(ECHO) " uploader - Build the serial uploader tool (debug|release)" + @$(ECHO) " Skip qmake: QMAKE_SKIP=1" + @$(ECHO) " Example: make gcs QMAKE_SKIP=1" + @$(ECHO) " uploader_clean - Remove the serial uploader tool (debug|release)" + @$(ECHO) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))" + @$(ECHO) + @$(ECHO) @$(ECHO) " [AndroidGCS]" @$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application" @$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application" diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp index 89fa1d248..c0d39daf2 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/port.cpp @@ -61,8 +61,9 @@ port::portstatus port::status() int16_t port::pfSerialRead(void) { char c[1]; - sport->waitForBytesWritten(5); - if (sport->bytesAvailable() || sport->waitForReadyRead(1)) { + + sport->waitForBytesWritten(1); + if (sport->bytesAvailable() || sport->waitForReadyRead(0)) { sport->read(c, 1); if (debug) { if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) { diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/qssp.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/qssp.cpp index 2fa945016..66ce3588e 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/qssp.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/SSP/qssp.cpp @@ -282,7 +282,7 @@ uint16_t qssp::ssp_SendDataBlock(uint8_t *data, uint16_t length) * \note * */ -int16_t qssp:: ssp_SendData(const uint8_t *data, const uint16_t length) +int16_t qssp::ssp_SendData(const uint8_t *data, const uint16_t length) { int16_t value = SSP_TX_WAITING; diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp index 90b214138..36580e895 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/main.cpp @@ -3,259 +3,283 @@ #include "op_dfu.h" #include -#define PRIVATE false - +void showProgress(QString status); +void progressUpdated(int percent); +void usage(QTextStream *standardOutput); +QString label; int main(int argc, char *argv[]) { - ///SSP///////////////////////////////// - - - ///////////////////////////////////////////// QCoreApplication a(argc, argv); + QTextStream standardOutput(stdout); + int argumentCount = QCoreApplication::arguments().size(); + bool use_serial = false; + bool verify; + bool debug = false; + bool umodereset = false; + OP_DFU::Actions action; + QString file; + QString serialport; + QString description; + int device = -1; + QStringList args = QCoreApplication::arguments(); -// argc=4; -// argv[1]="-ls"; -// argv[2]="-t"; -// argv[3]="COM3"; - if (argc > 1 || !PRIVATE) { - bool use_serial = false; - bool verify; - bool debug = false; - bool umodereset = false; - OP_DFU::Actions action; - QString file; - QString serialport; - QString description; - int device = -1; - QStringList args; - for (int i = 0; i < argc; ++i) { - args << argv[i]; + if (args.contains("-debug")) { + debug = true; + } + if (args.contains("-ur")) { + umodereset = true; + } + standardOutput << "OpenPilot serial firmware uploader tool." << endl; + if (args.indexOf(PROGRAMFW) + 1 < args.length()) { + file = args[args.indexOf(PROGRAMFW) + 1]; + } + if (args.contains(DEVICE)) { + if (args.indexOf(DEVICE) + 1 < args.length()) { + device = (args[args.indexOf(DEVICE) + 1]).toInt(); } - if (args.contains("-debug")) { - debug = true; + } else { + device = 0; + } + + if (argumentCount == 0 || args.contains("-?") || !args.contains(USE_SERIAL)) { + usage(&standardOutput); + return -1; + } else if (args.contains(PROGRAMFW)) { + if (args.contains(VERIFY)) { + verify = true; + } else { + verify = false; } - if (args.contains("-ur")) { - umodereset = true; + if (args.contains(PROGRAMDESC)) { + if (args.indexOf(PROGRAMDESC) + 1 < args.length()) { + description = (args[args.indexOf(PROGRAMDESC) + 1]); + } } - if (args.contains("-?") || (!PRIVATE && argc == 1)) { - cout << "_________________________________________________________________________\n"; - cout << "| Commands |\n"; - cout << "| |\n"; - cout << "| -ls : lists available devices |\n"; - cout << "| -p : program hw (requires:-d - optionals:-v,-w) |\n"; - cout << "| -v : verify (requires:-d) |\n"; - cout << "| -dn : download firmware to file (requires:-d) |\n"; - // cout << "| -dd : download discription (requires:-d) |\n"; - cout << "| -d : (requires: -p) |\n"; - cout << "| -ca : compares byte by byte current firmware with file|\n"; - cout << "| -cc : compares CRC of current firmware with file |\n"; - cout << "| -s : requests status of device |\n"; - cout << "| -r : resets the device |\n"; - cout << "| -j : exits bootloader and jumps to user FW |\n"; - cout << "| -debug : prints debug information |\n"; - cout << "| -t : uses serial port(requires:-ur) |\n"; - cout << "| -ur : user mode reset* |\n"; - cout << "| |\n"; - cout << "| examples: |\n"; - cout << "| |\n"; - cout << "| program and verify device #0 |\n"; - cout << "| OPUploadTool -p c:/OpenPilot.bin -w \"OpenPilot Firmware\" -v -d 0 |\n"; - cout << "| |\n"; - cout << "| Perform a quick compare of FW in file with FW in device #1 |\n"; - cout << "| OPUploadTool -ch c:/OpenPilot2.bin -d 2 |\n"; - cout << "| |\n"; - cout << "| *requires valid user space firmwares already running |\n"; - cout << "|________________________________________________________________________|\n"; + action = OP_DFU::actionProgram; + } else if (args.contains(COMPARECRC) || args.contains(COMPAREALL)) { + int index; + if (args.contains(COMPARECRC)) { + index = args.indexOf(COMPARECRC); + action = OP_DFU::actionCompareCrc; + } else { + index = args.indexOf(COMPAREALL); + action = OP_DFU::actionCompareAll; + } + } else if (args.contains(DOWNLOAD)) { + int index; + index = args.indexOf(DOWNLOAD); + action = OP_DFU::actionDownload; + } else if (args.contains(STATUSREQUEST)) { + action = OP_DFU::actionStatusReq; + } else if (args.contains(RESET)) { + action = OP_DFU::actionReset; + } else if (args.contains(JUMP)) { + action = OP_DFU::actionJump; + } else if (args.contains(LISTDEVICES)) { + action = OP_DFU::actionListDevs; + } + if ((file.isEmpty() || device == -1) && action != OP_DFU::actionReset && action != OP_DFU::actionStatusReq && action != OP_DFU::actionListDevs && action != OP_DFU::actionJump) { + usage(&standardOutput); + return -1; + } + if (args.contains(USE_SERIAL)) { + if (args.indexOf(USE_SERIAL) + 1 < args.length()) { + serialport = (args[args.indexOf(USE_SERIAL) + 1]); + use_serial = true; + } + } + if (debug) { + qDebug() << "Action=" << (int)action << endl; + qDebug() << "File=" << file << endl; + qDebug() << "Device=" << device << endl; + qDebug() << "Action=" << action << endl; + qDebug() << "Desctription" << description << endl; + qDebug() << "Use Serial port" << use_serial << endl; + if (use_serial) { + qDebug() << "Port Name" << serialport << endl; + } + } + if (use_serial) { + if (args.contains(NO_COUNTDOWN)) {} else { + standardOutput << "Connect the board" << endl; + label = ""; + for (int i = 0; i < 6; i++) { + progressUpdated(i * 100 / 5); + QThread::msleep(500); + } + } + standardOutput << endl << "Connect the board NOW" << endl; + QThread::msleep(1000); + } + ///////////////////////////////////ACTIONS START/////////////////////////////////////////////////// + OP_DFU::DFUObject dfu(debug, use_serial, serialport); + + QObject::connect(&dfu, &OP_DFU::DFUObject::operationProgress, showProgress); + QObject::connect(&dfu, &OP_DFU::DFUObject::progressUpdated, progressUpdated); + + if (!dfu.ready()) { + return -1; + } + dfu.AbortOperation(); + if (!dfu.enterDFU(0)) { + standardOutput << "Could not enter DFU mode\n" << endl; + return -1; + } + if (debug) { + OP_DFU::Status ret = dfu.StatusRequest(); + qDebug() << dfu.StatusToString(ret); + } + if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) { + dfu.findDevices(); + if (action == OP_DFU::actionListDevs) { + standardOutput << "Found " << dfu.numberOfDevices << "\n" << endl; + for (int x = 0; x < dfu.numberOfDevices; ++x) { + standardOutput << "Device #" << x << "\n" << endl; + standardOutput << "Device ID=" << dfu.devices[x].ID << "\n" << endl; + standardOutput << "Device Readable=" << dfu.devices[x].Readable << "\n" << endl; + standardOutput << "Device Writable=" << dfu.devices[x].Writable << "\n" << endl; + standardOutput << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n" << endl; + standardOutput << "BL Version=" << dfu.devices[x].BL_Version << "\n" << endl; + standardOutput << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n" << endl; + standardOutput << "FW CRC=" << dfu.devices[x].FW_CRC << "\n"; + + int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc; + dfu.enterDFU(x); + standardOutput << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n" << endl; + standardOutput << "\n"; + } return 0; - } else if (args.contains(PROGRAMFW)) { - if (args.contains(VERIFY)) { - verify = true; - } else { - verify = false; - } - if (args.contains(PROGRAMDESC)) { - if (args.indexOf(PROGRAMDESC) + 1 < args.length()) { - description = (args[args.indexOf(PROGRAMDESC) + 1]); - } - } - action = OP_DFU::actionProgram; - if (args.contains(DEVICE)) { - if (args.indexOf(DEVICE) + 1 < args.length()) { - device = (args[args.indexOf(DEVICE) + 1]).toInt(); - } - if (args.indexOf(PROGRAMFW) + 1 < args.length()) { - file = args[args.indexOf(PROGRAMFW) + 1]; - } - } else { - cout << ("Device not specified\n"); - return -1; - } - } else if (args.contains(COMPARECRC) || args.contains(COMPAREALL)) { - int index; - if (args.contains(COMPARECRC)) { - index = args.indexOf(COMPARECRC); - action = OP_DFU::actionCompareCrc; - } else { - index = args.indexOf(COMPAREALL); - action = OP_DFU::actionCompareAll; - } - if (args.contains(DEVICE)) { - if (args.indexOf(DEVICE) + 1 < args.length()) { - device = (args[args.indexOf(DEVICE) + 1]).toInt(); - } - if (index + 1 < args.length()) { - file = args[index + 1]; - } - } else { - cout << "Device not specified"; - return -1; - } - } else if (args.contains(DOWNLOAD)) { - int index; - index = args.indexOf(DOWNLOAD); - action = OP_DFU::actionDownload; - - if (args.contains(DEVICE)) { - if (args.indexOf(DEVICE) + 1 < args.length()) { - device = (args[args.indexOf(DEVICE) + 1]).toInt(); - } - if (index + 1 < args.length()) { - file = args[index + 1]; - } - } else { - cout << "Device not specified"; - return -1; - } - } else if (args.contains(STATUSREQUEST)) { - action = OP_DFU::actionStatusReq; - } else if (args.contains(RESET)) { - action = OP_DFU::actionReset; - } else if (args.contains(JUMP)) { - action = OP_DFU::actionJump; - } else if (args.contains(LISTDEVICES)) { - action = OP_DFU::actionListDevs; } - if ((file.isEmpty() || device == -1) && action != OP_DFU::actionReset && action != OP_DFU::actionStatusReq && action != OP_DFU::actionListDevs && action != OP_DFU::actionJump) { - cout << "wrong parameters"; + if (device > dfu.numberOfDevices - 1) { + standardOutput << "Error:Invalid Device" << endl; return -1; } - if (args.contains(USE_SERIAL)) { - if (args.indexOf(USE_SERIAL) + 1 < args.length()) { - serialport = (args[args.indexOf(USE_SERIAL) + 1]); - use_serial = true; - } + if (dfu.numberOfDevices == 1) { + dfu.use_delay = false; } - if (debug) { - qDebug() << "Action=" << (int)action; - qDebug() << "File=" << file; - qDebug() << "Device=" << device; - qDebug() << "Action=" << action; - qDebug() << "Desctription" << description; - qDebug() << "Use Serial port" << use_serial; - if (use_serial) { - qDebug() << "Port Name" << serialport; - } - } - - ///////////////////////////////////ACTIONS START/////////////////////////////////////////////////// - OP_DFU::DFUObject dfu(debug, use_serial, serialport); - if (!dfu.ready()) { + if (!dfu.enterDFU(device)) { + standardOutput << "Error:Could not enter DFU mode\n" << endl; return -1; } - - dfu.AbortOperation(); - if (!dfu.enterDFU(0)) { - cout << "Could not enter DFU mode\n"; - return -1; - } - if (debug) { - OP_DFU::Status ret = dfu.StatusRequest(); - qDebug() << dfu.StatusToString(ret); - } - if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) { - dfu.findDevices(); - if (action == OP_DFU::actionListDevs) { - cout << "Found " << dfu.numberOfDevices << "\n"; - for (int x = 0; x < dfu.numberOfDevices; ++x) { - cout << "Device #" << x << "\n"; - cout << "Device ID=" << dfu.devices[x].ID << "\n"; - cout << "Device Readable=" << dfu.devices[x].Readable << "\n"; - cout << "Device Writable=" << dfu.devices[x].Writable << "\n"; - cout << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n"; - cout << "BL Version=" << dfu.devices[x].BL_Version << "\n"; - cout << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n"; - cout << "FW CRC=" << dfu.devices[x].FW_CRC << "\n"; - - int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc; - dfu.enterDFU(x); - cout << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n"; - cout << "\n"; - } - return 0; + if (action == OP_DFU::actionProgram) { + if (((OP_DFU::device)dfu.devices[device]).Writable == false) { + standardOutput << "ERROR device not Writable\n" << endl; + return false; } - if (device > dfu.numberOfDevices - 1) { - cout << "Error:Invalid Device"; + standardOutput << "Uploading..." << endl; + bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device); + if (!retstatus) { + standardOutput << "Upload failed with code:" << retstatus << endl; return -1; } - if (dfu.numberOfDevices == 1) { - dfu.use_delay = false; - } - if (!dfu.enterDFU(device)) { - cout << "Error:Could not enter DFU mode\n"; - return -1; - } - if (action == OP_DFU::actionProgram) { - if (((OP_DFU::device)dfu.devices[device]).Writable == false) { - cout << "ERROR device not Writable\n"; - return false; - } - - bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device); - if (!retstatus) { - cout << "Upload failed with code:" << retstatus; + if (!description.isEmpty()) { + retstatus = dfu.UploadDescription(description); + if (retstatus != OP_DFU::Last_operation_Success) { + standardOutput << "Upload failed with code:" << retstatus << endl; return -1; } - if (!description.isEmpty()) { - retstatus = dfu.UploadDescription(description); - if (retstatus != OP_DFU::Last_operation_Success) { - cout << "Upload failed with code:" << retstatus; - return -1; - } - } - cout << "Uploading Succeded!\n"; - } else if (action == OP_DFU::actionDownload) { - if (((OP_DFU::device)dfu.devices[device]).Readable == false) { - cout << "ERROR device not readable\n"; - return false; - } - qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode; - QByteArray fw; - dfu.DownloadFirmware(&fw, 0); - bool ret = dfu.SaveByteArrayToFile(file.toLatin1(), fw); - return ret; - } else if (action == OP_DFU::actionCompareCrc) { - dfu.CompareFirmware(file.toLatin1(), OP_DFU::crccompare, device); - return 1; - } else if (action == OP_DFU::actionCompareAll) { - if (((OP_DFU::device)dfu.devices[device]).Readable == false) { - cout << "ERROR device not readable\n"; - return false; - } - dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device); - return 1; } - } else if (action == OP_DFU::actionStatusReq) { - cout << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n"; - } else if (action == OP_DFU::actionReset) { - dfu.ResetDevice(); - } else if (action == OP_DFU::actionJump) { - dfu.JumpToApp(false, false); + while (!dfu.isFinished()) { + QThread::msleep(500); + } + standardOutput << "Uploading Succeded!\n" << endl; + } else if (action == OP_DFU::actionDownload) { + if (((OP_DFU::device)dfu.devices[device]).Readable == false) { + standardOutput << "ERROR device not readable\n" << endl; + return false; + } + qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode; + QByteArray fw; + dfu.DownloadFirmware(&fw, 0); + bool ret = dfu.SaveByteArrayToFile(file.toLatin1(), fw); + return ret; + } else if (action == OP_DFU::actionCompareCrc) { + dfu.CompareFirmware(file.toLatin1(), OP_DFU::crccompare, device); + return 1; + } else if (action == OP_DFU::actionCompareAll) { + if (((OP_DFU::device)dfu.devices[device]).Readable == false) { + standardOutput << "ERROR device not readable\n" << endl; + return false; + } + dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device); + return 1; } - while(!dfu.isFinished()){ - QThread::msleep(500); - } - return 0; + } else if (action == OP_DFU::actionStatusReq) { + standardOutput << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n" << endl; + } else if (action == OP_DFU::actionReset) { + dfu.ResetDevice(); + } else if (action == OP_DFU::actionJump) { + dfu.JumpToApp(false, false); } - return a.exec(); + return 0; + + // return a.exec(); +} + +void showProgress(QString status) +{ + QTextStream standardOutput(stdout); + + standardOutput << status << endl; + label = status; +} + +void progressUpdated(int percent) +{ + std::string bar; + + for (int i = 0; i < 50; i++) { + if (i < (percent / 2)) { + bar.replace(i, 1, "="); + } else if (i == (percent / 2)) { + bar.replace(i, 1, ">"); + } else { + bar.replace(i, 1, " "); + } + } + std::cout << "\r" << label.toLatin1().data() << "[" << bar << "] "; + std::cout.width(3); + std::cout << percent << "% " << std::flush; +} +void usage(QTextStream *standardOutput) +{ + *standardOutput << "_________________________________________________________________________\n"; + *standardOutput << "| Commands |\n"; + *standardOutput << "| |\n"; + *standardOutput << "| -ls : lists available devices |\n"; + *standardOutput << "| -p : program hw (requires:-d - optionals:-v,-w) |\n"; + *standardOutput << "| -v : verify (requires:-d) |\n"; + *standardOutput << "| -dn : download firmware to file |\n"; + // *standardOutput << "| -dd : download discription (requires:-d) |\n"; + *standardOutput << "| -d : target device number (default 0, first device) |\n"; + // *standardOutput << "| -w : (requires: -p) |\n"; + *standardOutput << "| -ca : compares byte by byte current firmware with file|\n"; + *standardOutput << "| -cc : compares CRC of current firmware with file |\n"; + *standardOutput << "| -s : requests status of device |\n"; + *standardOutput << "| -r : resets the device |\n"; + *standardOutput << "| -j : exits bootloader and jumps to user FW |\n"; + *standardOutput << "| -debug : prints debug information |\n"; + *standardOutput << "| -t : uses serial port |\n"; + *standardOutput << "| -i : immediate, doesn't show the connection countdown|\n"; + // *standardOutput << "| -ur : user mode reset* |\n"; + *standardOutput << "| |\n"; + *standardOutput << "| examples: |\n"; + *standardOutput << "| |\n"; + *standardOutput << "| program and verify the fist device device connected to COM1 |\n"; + *standardOutput << "| OPUploadTool -p c:/gpsp.opfw -v -t COM1 |\n"; + *standardOutput << "| |\n"; + *standardOutput << "| program and verify the fist device device connected to COM1 |\n"; + *standardOutput << "| OPUploadTool -p c:/gpsp.opfw -v -t COM1 |\n"; + *standardOutput << "| |\n"; + *standardOutput << "| Perform a quick compare of FW in file with FW in device #1 |\n"; + *standardOutput << "| OPUploadTool -ch /home/user1/gpsp.opfw -t ttyUSB0 |\n"; + *standardOutput << "| |\n"; + // *standardOutput << "| *requires valid user space firmwares already running |\n"; + *standardOutput << "|________________________________________________________________________|\n"; + *standardOutput << endl; +} + +void howToUsage(QTextStream *standardOutput) +{ + *standardOutput << "run the tool with -? for more informations" << endl; } diff --git a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp index 7ef5e3732..12323fc36 100644 --- a/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp +++ b/ground/openpilotgcs/src/experimental/USB_UPLOAD_TOOL/op_dfu.cpp @@ -42,7 +42,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) : qRegisterMetaType("Status"); if (use_serial) { - info = new port(portname, debug); + info = new port(portname, false); info->rxBuf = sspRxBuf; info->rxBufSize = MAX_PACKET_DATA_LEN; info->txBuf = sspTxBuf; @@ -54,7 +54,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) : mready = false; return; } - serialhandle = new qsspt(info, debug); + serialhandle = new qsspt(info, false); int count = 0; while ((serialhandle->ssp_Synchronise() == false) && (count < 10)) { @@ -311,25 +311,30 @@ bool DFUObject::UploadData(qint32 const & numberOfBytes, QByteArray & data) buf[5] = packetcount; // DFU Count char *pointer = data.data(); pointer = pointer + 4 * 14 * packetcount; - qDebug()<<"Packet Number="<