From f4464c01a73249d147ebb01af3718e0a1ccc4215 Mon Sep 17 00:00:00 2001 From: zedamota Date: Thu, 2 Sep 2010 22:46:06 +0000 Subject: [PATCH] OP-21/Flight Bootloader - More functions added, file hash now automagicaly created and uploaded. Device discovery working. As with the bootloader embedded SW this is highly experimental. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1509 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/experimental/USB_UPLOAD_TOOL/main.cpp | 14 ++- .../experimental/USB_UPLOAD_TOOL/op_dfu.cpp | 101 +++++++++++++++--- .../src/experimental/USB_UPLOAD_TOOL/op_dfu.h | 18 +++- 3 files changed, 116 insertions(+), 17 deletions(-) diff --git a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp index 7cee37dc3..13661116a 100644 --- a/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp +++ b/ground/src/experimental/USB_UPLOAD_TOOL/main.cpp @@ -13,6 +13,7 @@ int main(int argc, char *argv[]) filename = QString(argv[1]); OP_DFU dfu; + dfu.enterDFU(0); // dfu.enterDFU(1); // dfu.StartUpload(4,OP_DFU::Descript); // QByteArray array; @@ -25,10 +26,15 @@ int main(int argc, char *argv[]) // array[6]=7; // array[7]=8; // dfu.UploadData(8,array); - //dfu.UploadDescription(1,"jose manuel"); - //QString str=dfu.DownloadDescription(1,12); +// dfu.UploadDescription(1,"jose manuel"); + // QString str=dfu.DownloadDescription(1,12); // dfu.JumpToApp(); - dfu.UploadFirmware(filename.toAscii()); - //qDebug()<<"Description="<>(x*2) & 1); + dev.Writable=(bool)(RWFlags>>(x*2+1) & 1); + devices.append(dev); + buf[0] =0x02;//reportID + buf[1] = OP_DFU::Req_Capabilities;//DFU Command + buf[2] = 0; + buf[3] = 0; + buf[4] = 0; + buf[5] = 0; + buf[6] = x+1; + buf[7] = 0; + buf[8] = 0; + buf[9] = 0; + int result = hidHandle.send(0,buf, BUF_LEN, 5000); + result = hidHandle.receive(0,buf,BUF_LEN,5000); + devices[x].ID=buf[9]; + devices[x].SizeOfHash=buf[7]; + qDebug()<<"---------------"<<(int)buf[8]; + devices[x].SizeOfDesc=buf[8]; + quint32 aux; + aux=(quint8)buf[2]; + aux=aux<<8 |(quint8)buf[3]; + aux=aux<<8 |(quint8)buf[4]; + aux=aux<<8 |(quint8)buf[5]; + devices[x].SizeOfCode=aux; + } + qDebug()<<"Found "<