1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

Start of Uploader plugin parsing of packaged firmware. work in progress, not fully working yet.

This commit is contained in:
elafargue 2011-05-08 00:57:59 +02:00
parent a2656ed589
commit b61bd5bf31
3 changed files with 70 additions and 11 deletions

View File

@ -199,6 +199,49 @@ void deviceWidget::uploadFirmware()
return;
}
// TODO : parse the firmware last 100 bytes and see whether it is
// packaged:
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
status("Can't open file", STATUSICON_FAIL);
return;
}
QByteArray arr = file.readAll();
QByteArray desc = arr.right(100);
if (desc.startsWith("OpFw")) {
// This looks like a binary with a description at the end
/*
# 4 bytes: header: "OpFw"
# 4 bytes: GIT commit tag (short version of SHA1)
# 4 bytes: Unix timestamp of compile time
# 2 bytes: target platform. Should follow same rule as BOARD_TYPE and BOARD_REVISION in board define files.
# 26 bytes: commit tag if it is there, otherwise "Unreleased". Zero-padded
# ---- 40 bytes limit ---
# 20 bytes: SHA1 sum of the firmware.
# 40 bytes: free for now.
*/
// I don't want to use structs, ok ?
QByteArray gitCommitTag = desc.mid(4,4);
quint32 buildDate = desc.at(8)&0xFF;
for (int i=1;i<4;i++) {
buildDate = buildDate<<8;
buildDate += desc.at(8+i) & 0xFF;
}
myDevice->buildDate->setText(QDateTime::fromTime_t(buildDate).toString());
QByteArray targetPlatform = desc.mid(12,2);
// TODO: check platform compatibility
QString dscText = QString(desc.mid(14,26));
myDevice->description->setText(dscText);
return;
} else {
// TODO : tell the user that the firmware is not packaged.
}
status("Starting firmware upload", STATUSICON_RUNNING);
// We don't know which device was used previously, so we
// are cautious and reenter DFU for this deviceID:

View File

@ -33,6 +33,8 @@
#include "op_dfu.h"
#include <QWidget>
#include <QFileDialog>
#include <QErrorMessage>
#include <QByteArray>
#include <QtSvg/QGraphicsSvgItem>
#include <QtSvg/QSvgRenderer>

View File

@ -19,28 +19,28 @@
<item row="2" column="0" colspan="3">
<widget class="QLineEdit" name="description"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="deviceID">
<property name="text">
<string>DeviceID</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QLabel" name="deviceACL">
<property name="text">
<string>ReadWrite</string>
</property>
</widget>
</item>
<item row="3" column="2" rowspan="2">
<item row="3" column="2" rowspan="3">
<widget class="QGraphicsView" name="devicePicture">
<property name="maximumSize">
<size>
@ -56,7 +56,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="6" column="2">
<widget class="QPushButton" name="verifyButton">
<property name="enabled">
<bool>false</bool>
@ -66,7 +66,7 @@
</property>
</widget>
</item>
<item row="6" column="2">
<item row="7" column="2">
<widget class="QPushButton" name="updateButton">
<property name="toolTip">
<string>Update the firmware on this board.</string>
@ -76,7 +76,7 @@
</property>
</widget>
</item>
<item row="7" column="2">
<item row="8" column="2">
<widget class="QPushButton" name="retrieveButton">
<property name="toolTip">
<string>Download the current board firmware to your computer</string>
@ -86,28 +86,28 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QLabel" name="BLVersion">
<property name="text">
<string>BootLoaderVersion</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="fwCRC">
<property name="text">
<string>fwCRC</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="maxCodeSize">
<property name="text">
<string>MaxCodeSize</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="statusIcon">
@ -137,6 +137,20 @@
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="QLabel" name="buildDate">
<property name="text">
<string>Compile Date</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="commitTag">
<property name="text">
<string>Commit tag:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>