mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-1476 - Clanup upload_tool and add Makefile target
This commit is contained in:
parent
b971b713d6
commit
1de46ae493
44
Makefile
44
Makefile
@ -439,7 +439,7 @@ sim_osx_%: uavobjects_flight
|
|||||||
##############################
|
##############################
|
||||||
|
|
||||||
.PHONY: all_ground
|
.PHONY: all_ground
|
||||||
all_ground: openpilotgcs
|
all_ground: openpilotgcs uploader
|
||||||
|
|
||||||
# Convenience target for the GCS
|
# Convenience target for the GCS
|
||||||
.PHONY: gcs gcs_clean
|
.PHONY: gcs gcs_clean
|
||||||
@ -479,6 +479,40 @@ openpilotgcs_clean:
|
|||||||
@$(ECHO) " CLEAN $(call toprel, $(BUILD_DIR)/openpilotgcs_$(GCS_BUILD_CONF))"
|
@$(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)"
|
$(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
|
# Android GCS related components
|
||||||
@ -972,6 +1006,14 @@ help:
|
|||||||
@$(ECHO) " gcs_clean - Remove the Ground Control System (GCS) application (debug|release)"
|
@$(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) " Supported build configurations: GCS_BUILD_CONF=debug|release (default is $(GCS_BUILD_CONF))"
|
||||||
@$(ECHO)
|
@$(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]"
|
||||||
@$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application"
|
@$(ECHO) " androidgcs - Build the Android Ground Control System (GCS) application"
|
||||||
@$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application"
|
@$(ECHO) " androidgcs_install - Use ADB to install the Android GCS application"
|
||||||
|
@ -61,8 +61,9 @@ port::portstatus port::status()
|
|||||||
int16_t port::pfSerialRead(void)
|
int16_t port::pfSerialRead(void)
|
||||||
{
|
{
|
||||||
char c[1];
|
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);
|
sport->read(c, 1);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) {
|
if (((uint8_t)c[0]) == 0xe1 || rxDebugBuff.count() > 50) {
|
||||||
|
@ -282,7 +282,7 @@ uint16_t qssp::ssp_SendDataBlock(uint8_t *data, uint16_t length)
|
|||||||
* \note
|
* \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;
|
int16_t value = SSP_TX_WAITING;
|
||||||
|
|
||||||
|
@ -3,21 +3,15 @@
|
|||||||
#include "op_dfu.h"
|
#include "op_dfu.h"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#define PRIVATE false
|
void showProgress(QString status);
|
||||||
|
void progressUpdated(int percent);
|
||||||
|
void usage(QTextStream *standardOutput);
|
||||||
|
QString label;
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
///SSP/////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
|
QTextStream standardOutput(stdout);
|
||||||
// argc=4;
|
int argumentCount = QCoreApplication::arguments().size();
|
||||||
// argv[1]="-ls";
|
|
||||||
// argv[2]="-t";
|
|
||||||
// argv[3]="COM3";
|
|
||||||
if (argc > 1 || !PRIVATE) {
|
|
||||||
bool use_serial = false;
|
bool use_serial = false;
|
||||||
bool verify;
|
bool verify;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
@ -27,47 +21,29 @@ int main(int argc, char *argv[])
|
|||||||
QString serialport;
|
QString serialport;
|
||||||
QString description;
|
QString description;
|
||||||
int device = -1;
|
int device = -1;
|
||||||
QStringList args;
|
QStringList args = QCoreApplication::arguments();
|
||||||
for (int i = 0; i < argc; ++i) {
|
|
||||||
args << argv[i];
|
|
||||||
}
|
|
||||||
if (args.contains("-debug")) {
|
if (args.contains("-debug")) {
|
||||||
debug = true;
|
debug = true;
|
||||||
}
|
}
|
||||||
if (args.contains("-ur")) {
|
if (args.contains("-ur")) {
|
||||||
umodereset = true;
|
umodereset = true;
|
||||||
}
|
}
|
||||||
if (args.contains("-?") || (!PRIVATE && argc == 1)) {
|
standardOutput << "OpenPilot serial firmware uploader tool." << endl;
|
||||||
cout << "_________________________________________________________________________\n";
|
if (args.indexOf(PROGRAMFW) + 1 < args.length()) {
|
||||||
cout << "| Commands |\n";
|
file = args[args.indexOf(PROGRAMFW) + 1];
|
||||||
cout << "| |\n";
|
}
|
||||||
cout << "| -ls : lists available devices |\n";
|
if (args.contains(DEVICE)) {
|
||||||
cout << "| -p <file> : program hw (requires:-d - optionals:-v,-w) |\n";
|
if (args.indexOf(DEVICE) + 1 < args.length()) {
|
||||||
cout << "| -v : verify (requires:-d) |\n";
|
device = (args[args.indexOf(DEVICE) + 1]).toInt();
|
||||||
cout << "| -dn <file> : download firmware to file (requires:-d) |\n";
|
}
|
||||||
// cout << "| -dd <file> : download discription (requires:-d) |\n";
|
} else {
|
||||||
cout << "| -d <number Of Device : (requires: -p or -dn) |\n";
|
device = 0;
|
||||||
cout << "| -w <description> : (requires: -p) |\n";
|
}
|
||||||
cout << "| -ca <file> : compares byte by byte current firmware with file|\n";
|
|
||||||
cout << "| -cc <file> : compares CRC of current firmware with file |\n";
|
if (argumentCount == 0 || args.contains("-?") || !args.contains(USE_SERIAL)) {
|
||||||
cout << "| -s : requests status of device |\n";
|
usage(&standardOutput);
|
||||||
cout << "| -r : resets the device |\n";
|
return -1;
|
||||||
cout << "| -j : exits bootloader and jumps to user FW |\n";
|
|
||||||
cout << "| -debug : prints debug information |\n";
|
|
||||||
cout << "| -t <port> : uses serial port(requires:-ur) |\n";
|
|
||||||
cout << "| -ur <port> : 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";
|
|
||||||
return 0;
|
|
||||||
} else if (args.contains(PROGRAMFW)) {
|
} else if (args.contains(PROGRAMFW)) {
|
||||||
if (args.contains(VERIFY)) {
|
if (args.contains(VERIFY)) {
|
||||||
verify = true;
|
verify = true;
|
||||||
@ -80,17 +56,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
action = OP_DFU::actionProgram;
|
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)) {
|
} else if (args.contains(COMPARECRC) || args.contains(COMPAREALL)) {
|
||||||
int index;
|
int index;
|
||||||
if (args.contains(COMPARECRC)) {
|
if (args.contains(COMPARECRC)) {
|
||||||
@ -100,33 +65,10 @@ int main(int argc, char *argv[])
|
|||||||
index = args.indexOf(COMPAREALL);
|
index = args.indexOf(COMPAREALL);
|
||||||
action = OP_DFU::actionCompareAll;
|
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)) {
|
} else if (args.contains(DOWNLOAD)) {
|
||||||
int index;
|
int index;
|
||||||
index = args.indexOf(DOWNLOAD);
|
index = args.indexOf(DOWNLOAD);
|
||||||
action = OP_DFU::actionDownload;
|
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)) {
|
} else if (args.contains(STATUSREQUEST)) {
|
||||||
action = OP_DFU::actionStatusReq;
|
action = OP_DFU::actionStatusReq;
|
||||||
} else if (args.contains(RESET)) {
|
} else if (args.contains(RESET)) {
|
||||||
@ -137,7 +79,7 @@ int main(int argc, char *argv[])
|
|||||||
action = OP_DFU::actionListDevs;
|
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) {
|
if ((file.isEmpty() || device == -1) && action != OP_DFU::actionReset && action != OP_DFU::actionStatusReq && action != OP_DFU::actionListDevs && action != OP_DFU::actionJump) {
|
||||||
cout << "wrong parameters";
|
usage(&standardOutput);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (args.contains(USE_SERIAL)) {
|
if (args.contains(USE_SERIAL)) {
|
||||||
@ -147,26 +89,40 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
qDebug() << "Action=" << (int)action;
|
qDebug() << "Action=" << (int)action << endl;
|
||||||
qDebug() << "File=" << file;
|
qDebug() << "File=" << file << endl;
|
||||||
qDebug() << "Device=" << device;
|
qDebug() << "Device=" << device << endl;
|
||||||
qDebug() << "Action=" << action;
|
qDebug() << "Action=" << action << endl;
|
||||||
qDebug() << "Desctription" << description;
|
qDebug() << "Desctription" << description << endl;
|
||||||
qDebug() << "Use Serial port" << use_serial;
|
qDebug() << "Use Serial port" << use_serial << endl;
|
||||||
if (use_serial) {
|
if (use_serial) {
|
||||||
qDebug() << "Port Name" << serialport;
|
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///////////////////////////////////////////////////
|
///////////////////////////////////ACTIONS START///////////////////////////////////////////////////
|
||||||
OP_DFU::DFUObject dfu(debug, use_serial, serialport);
|
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()) {
|
if (!dfu.ready()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dfu.AbortOperation();
|
dfu.AbortOperation();
|
||||||
if (!dfu.enterDFU(0)) {
|
if (!dfu.enterDFU(0)) {
|
||||||
cout << "Could not enter DFU mode\n";
|
standardOutput << "Could not enter DFU mode\n" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
@ -176,57 +132,60 @@ int main(int argc, char *argv[])
|
|||||||
if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) {
|
if (!(action == OP_DFU::actionStatusReq || action == OP_DFU::actionReset || action == OP_DFU::actionJump)) {
|
||||||
dfu.findDevices();
|
dfu.findDevices();
|
||||||
if (action == OP_DFU::actionListDevs) {
|
if (action == OP_DFU::actionListDevs) {
|
||||||
cout << "Found " << dfu.numberOfDevices << "\n";
|
standardOutput << "Found " << dfu.numberOfDevices << "\n" << endl;
|
||||||
for (int x = 0; x < dfu.numberOfDevices; ++x) {
|
for (int x = 0; x < dfu.numberOfDevices; ++x) {
|
||||||
cout << "Device #" << x << "\n";
|
standardOutput << "Device #" << x << "\n" << endl;
|
||||||
cout << "Device ID=" << dfu.devices[x].ID << "\n";
|
standardOutput << "Device ID=" << dfu.devices[x].ID << "\n" << endl;
|
||||||
cout << "Device Readable=" << dfu.devices[x].Readable << "\n";
|
standardOutput << "Device Readable=" << dfu.devices[x].Readable << "\n" << endl;
|
||||||
cout << "Device Writable=" << dfu.devices[x].Writable << "\n";
|
standardOutput << "Device Writable=" << dfu.devices[x].Writable << "\n" << endl;
|
||||||
cout << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n";
|
standardOutput << "Device SizeOfCode=" << dfu.devices[x].SizeOfCode << "\n" << endl;
|
||||||
cout << "BL Version=" << dfu.devices[x].BL_Version << "\n";
|
standardOutput << "BL Version=" << dfu.devices[x].BL_Version << "\n" << endl;
|
||||||
cout << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n";
|
standardOutput << "Device SizeOfDesc=" << dfu.devices[x].SizeOfDesc << "\n" << endl;
|
||||||
cout << "FW CRC=" << dfu.devices[x].FW_CRC << "\n";
|
standardOutput << "FW CRC=" << dfu.devices[x].FW_CRC << "\n";
|
||||||
|
|
||||||
int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc;
|
int size = ((OP_DFU::device)dfu.devices[x]).SizeOfDesc;
|
||||||
dfu.enterDFU(x);
|
dfu.enterDFU(x);
|
||||||
cout << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n";
|
standardOutput << "Description:" << dfu.DownloadDescription(size).toLatin1().data() << "\n" << endl;
|
||||||
cout << "\n";
|
standardOutput << "\n";
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (device > dfu.numberOfDevices - 1) {
|
if (device > dfu.numberOfDevices - 1) {
|
||||||
cout << "Error:Invalid Device";
|
standardOutput << "Error:Invalid Device" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (dfu.numberOfDevices == 1) {
|
if (dfu.numberOfDevices == 1) {
|
||||||
dfu.use_delay = false;
|
dfu.use_delay = false;
|
||||||
}
|
}
|
||||||
if (!dfu.enterDFU(device)) {
|
if (!dfu.enterDFU(device)) {
|
||||||
cout << "Error:Could not enter DFU mode\n";
|
standardOutput << "Error:Could not enter DFU mode\n" << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (action == OP_DFU::actionProgram) {
|
if (action == OP_DFU::actionProgram) {
|
||||||
if (((OP_DFU::device)dfu.devices[device]).Writable == false) {
|
if (((OP_DFU::device)dfu.devices[device]).Writable == false) {
|
||||||
cout << "ERROR device not Writable\n";
|
standardOutput << "ERROR device not Writable\n" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
standardOutput << "Uploading..." << endl;
|
||||||
bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device);
|
bool retstatus = dfu.UploadFirmware(file.toLatin1(), verify, device);
|
||||||
if (!retstatus) {
|
if (!retstatus) {
|
||||||
cout << "Upload failed with code:" << retstatus;
|
standardOutput << "Upload failed with code:" << retstatus << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!description.isEmpty()) {
|
if (!description.isEmpty()) {
|
||||||
retstatus = dfu.UploadDescription(description);
|
retstatus = dfu.UploadDescription(description);
|
||||||
if (retstatus != OP_DFU::Last_operation_Success) {
|
if (retstatus != OP_DFU::Last_operation_Success) {
|
||||||
cout << "Upload failed with code:" << retstatus;
|
standardOutput << "Upload failed with code:" << retstatus << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << "Uploading Succeded!\n";
|
while (!dfu.isFinished()) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
standardOutput << "Uploading Succeded!\n" << endl;
|
||||||
} else if (action == OP_DFU::actionDownload) {
|
} else if (action == OP_DFU::actionDownload) {
|
||||||
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
|
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
|
||||||
cout << "ERROR device not readable\n";
|
standardOutput << "ERROR device not readable\n" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode;
|
qint32 size = ((OP_DFU::device)dfu.devices[device]).SizeOfCode;
|
||||||
@ -239,23 +198,88 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
} else if (action == OP_DFU::actionCompareAll) {
|
} else if (action == OP_DFU::actionCompareAll) {
|
||||||
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
|
if (((OP_DFU::device)dfu.devices[device]).Readable == false) {
|
||||||
cout << "ERROR device not readable\n";
|
standardOutput << "ERROR device not readable\n" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device);
|
dfu.CompareFirmware(file.toLatin1(), OP_DFU::bytetobytecompare, device);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (action == OP_DFU::actionStatusReq) {
|
} else if (action == OP_DFU::actionStatusReq) {
|
||||||
cout << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n";
|
standardOutput << "Current device status=" << dfu.StatusToString(dfu.StatusRequest()).toLatin1().data() << "\n" << endl;
|
||||||
} else if (action == OP_DFU::actionReset) {
|
} else if (action == OP_DFU::actionReset) {
|
||||||
dfu.ResetDevice();
|
dfu.ResetDevice();
|
||||||
} else if (action == OP_DFU::actionJump) {
|
} else if (action == OP_DFU::actionJump) {
|
||||||
dfu.JumpToApp(false, false);
|
dfu.JumpToApp(false, false);
|
||||||
}
|
}
|
||||||
while(!dfu.isFinished()){
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
return a.exec();
|
// 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 <file> : program hw (requires:-d - optionals:-v,-w) |\n";
|
||||||
|
*standardOutput << "| -v : verify (requires:-d) |\n";
|
||||||
|
*standardOutput << "| -dn <file> : download firmware to file |\n";
|
||||||
|
// *standardOutput << "| -dd <file> : download discription (requires:-d) |\n";
|
||||||
|
*standardOutput << "| -d <Device Number> : target device number (default 0, first device) |\n";
|
||||||
|
// *standardOutput << "| -w <description> : (requires: -p) |\n";
|
||||||
|
*standardOutput << "| -ca <file> : compares byte by byte current firmware with file|\n";
|
||||||
|
*standardOutput << "| -cc <file> : 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 <port> : uses serial port |\n";
|
||||||
|
*standardOutput << "| -i : immediate, doesn't show the connection countdown|\n";
|
||||||
|
// *standardOutput << "| -ur <port> : 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;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
|
|||||||
qRegisterMetaType<OP_DFU::Status>("Status");
|
qRegisterMetaType<OP_DFU::Status>("Status");
|
||||||
|
|
||||||
if (use_serial) {
|
if (use_serial) {
|
||||||
info = new port(portname, debug);
|
info = new port(portname, false);
|
||||||
info->rxBuf = sspRxBuf;
|
info->rxBuf = sspRxBuf;
|
||||||
info->rxBufSize = MAX_PACKET_DATA_LEN;
|
info->rxBufSize = MAX_PACKET_DATA_LEN;
|
||||||
info->txBuf = sspTxBuf;
|
info->txBuf = sspTxBuf;
|
||||||
@ -54,7 +54,7 @@ DFUObject::DFUObject(bool _debug, bool _use_serial, QString portname) :
|
|||||||
mready = false;
|
mready = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
serialhandle = new qsspt(info, debug);
|
serialhandle = new qsspt(info, false);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while ((serialhandle->ssp_Synchronise() == false) && (count < 10)) {
|
while ((serialhandle->ssp_Synchronise() == false) && (count < 10)) {
|
||||||
@ -311,25 +311,30 @@ bool DFUObject::UploadData(qint32 const & numberOfBytes, QByteArray & data)
|
|||||||
buf[5] = packetcount; // DFU Count
|
buf[5] = packetcount; // DFU Count
|
||||||
char *pointer = data.data();
|
char *pointer = data.data();
|
||||||
pointer = pointer + 4 * 14 * packetcount;
|
pointer = pointer + 4 * 14 * packetcount;
|
||||||
qDebug()<<"Packet Number="<<packetcount<<"Data0="<<(int)data[0]<<" Data1="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9];
|
// if (debug) {
|
||||||
|
// qDebug() << "Packet Number=" << packetcount << "Data0=" << (int)data[0] << " Data1=" << (int)data[1] << " Data0=" << (int)data[2] << " Data0=" << (int)data[3] << " buf6=" << (int)buf[6] << " buf7=" << (int)buf[7] << " buf8=" << (int)buf[8] << " buf9=" << (int)buf[9];
|
||||||
|
// }
|
||||||
CopyWords(pointer, buf + 6, packetsize * 4);
|
CopyWords(pointer, buf + 6, packetsize * 4);
|
||||||
//for (int y=0;y<packetsize*4;++y) {
|
// for (int y=0;y<packetsize*4;++y) {
|
||||||
// qDebug()<<y<<":"<<(int)data[packetcount*14*4+y]<<"---"<<(int)buf[6+y];
|
// qDebug()<<y<<":"<<(int)data[packetcount*14*4+y]<<"---"<<(int)buf[6+y];
|
||||||
//}
|
// }
|
||||||
//qDebug()<<" Data0="<<(int)data[0]<<" Data0="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9];
|
// qDebug()<<" Data0="<<(int)data[0]<<" Data0="<<(int)data[1]<<" Data0="<<(int)data[2]<<" Data0="<<(int)data[3]<<" buf6="<<(int)buf[6]<<" buf7="<<(int)buf[7]<<" buf8="<<(int)buf[8]<<" buf9="<<(int)buf[9];
|
||||||
// delay::msleep(send_delay);
|
// delay::msleep(send_delay);
|
||||||
|
|
||||||
if(StatusRequest()!=OP_DFU::uploading) return false;
|
if (StatusRequest() != OP_DFU::uploading) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int result = sendData(buf, BUF_LEN);
|
int result = sendData(buf, BUF_LEN);
|
||||||
qDebug()<<"sent:"<<result;
|
// if (debug) {
|
||||||
|
// qDebug() << "sent:" << result;
|
||||||
|
// }
|
||||||
if (result < 1) {
|
if (result < 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// if (debug) {
|
||||||
qDebug() << "UPLOAD:"<<"Data="<<(int)buf[6]<<(int)buf[7]<<(int)buf[8]<<(int)buf[9]<<";"<<result << " bytes sent";
|
// qDebug() << "UPLOAD:" << "Data=" << (int)buf[6] << (int)buf[7] << (int)buf[8] << (int)buf[9] << ";" << result << " bytes sent";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
cout << "\n";
|
|
||||||
// while(true){}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ enum CompareType {
|
|||||||
#define RESET "-r"
|
#define RESET "-r"
|
||||||
#define JUMP "-j"
|
#define JUMP "-j"
|
||||||
#define USE_SERIAL "-t"
|
#define USE_SERIAL "-t"
|
||||||
|
#define NO_COUNTDOWN "-i"
|
||||||
|
|
||||||
Q_ENUMS(Status)
|
Q_ENUMS(Status)
|
||||||
enum Status {
|
enum Status {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user