From 01b4c5d0e3f004d46a94367210da7e7f30882fa8 Mon Sep 17 00:00:00 2001 From: zedamota Date: Sun, 5 Sep 2010 23:15:45 +0000 Subject: [PATCH] OP-21/Flight Bootloader PC APP- Finished, not tested on HW though. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1543 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/experimental/USB_UPLOAD_TOOL/main.cpp | 178 +++++++++++------- .../experimental/USB_UPLOAD_TOOL/op_dfu.cpp | 58 +++++- .../src/experimental/USB_UPLOAD_TOOL/op_dfu.h | 31 +-- 3 files changed, 184 insertions(+), 83 deletions(-) diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp index 4f0fc373a..27615e928 100644 --- a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp +++ b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp @@ -4,10 +4,12 @@ #include "op_dfu.h" #include +#define PRIVATE false + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); - if(argc>1) + if(argc>1||!PRIVATE) { bool verify; bool debug=false; @@ -20,36 +22,50 @@ int main(int argc, char *argv[]) { args< : 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<<"| -ch : compares hash of current firmware with file\n"; - cout<<"| -s : requests status of device\n"; + 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<<"| -ch : compares hash 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<<"| |\n"; + cout<<"| examples: |\n"; + cout<<"| |\n"; + cout<<"| program and verify device #1 |\n"; + cout<<"| OPUploadTool -p c:/OpenPilot.bin -w \"Openpilot Firmware\" -v -d 1 |\n"; + cout<<"| |\n"; + cout<<"| Perform a quick compare of FW in file with FW in device #2 |\n"; + cout<<"| OPUploadTool -ch c:/OpenPilot.bin -d 2 |\n"; + cout<<"|________________________________________________________________________|\n"; return 0; } - else if(args.contains(DOWNDESCRIPTION)) - { - action=OP_DFU::downdesc; - if(args.contains(DEVICE)) - { - if(args.indexOf(DEVICE)+1dfu.numberOfDevices) + { + cout<<"Error:Invalid Device"; + return -1; + } + if(!dfu.enterDFU(device)) + { + cout<<"Error:Could not enter DFU mode\n"; + return -1; + } + if (action==OP_DFU::actionProgram) { - if(device>dfu.numberOfDevices) - { - cout<<"Error:Invalid Device"; - return -1; - } - if(!dfu.enterDFU(device)) - { - cout<<"Error:Could not enter DFU mode\n"; - return -1; - } OP_DFU::Status retstatus=dfu.UploadFirmware(file.toAscii(),verify); if(retstatus!=OP_DFU::Last_operation_Success) { @@ -213,30 +243,42 @@ int main(int argc, char *argv[]) } cout<<"Uploading Succeded!\n"; } - else if (action==OP_DFU::download) + else if (action==OP_DFU::actionDownload) { - if(device>dfu.numberOfDevices) - { - cout<<"Error:Invalid Device"; - return -1; - } - if(!dfu.enterDFU(device)) - { - cout<<"Error:Could not enter DFU mode\n"; - return -1; - } qint32 size=((OP_DFU::device)dfu.devices[device]).SizeOfCode; bool ret=dfu.SaveByteArrayToFile(file.toAscii(),dfu.StartDownload(size,OP_DFU::FW)); return ret; - } - else if(action==OP_DFU::downdesc) + // else if(action==OP_DFU::downdesc) + // { + // int size=((OP_DFU::device)dfu.devices[device]).SizeOfDesc; + // cout<<"Description:"< devices; int numberOfDevices; QString StatusToString(OP_DFU::Status); + OP_DFU::Status CompareFirmware(const QString &sfile, const CompareType &type); private: bool debug; int RWFlags;