add handling to check the chip type in the update UI

This commit is contained in:
andreas 2023-09-07 17:30:19 +02:00
parent 2b42cc53e7
commit 54693e0b27
3 changed files with 23 additions and 3 deletions

View File

@ -94,6 +94,7 @@ __attribute__((section(".rodata_custom_desc"))) esp_app_desc_t custom_app_desc =
String firmwareType(FIRMWARE_TYPE); String firmwareType(FIRMWARE_TYPE);
String chipType(BOARD_INFO);
typedef std::map<String,String> StringMap; typedef std::map<String,String> StringMap;
@ -371,7 +372,7 @@ public:
protected: protected:
virtual void processRequest() virtual void processRequest()
{ {
GwJsonDocument status(290 + GwJsonDocument status(300 +
countNMEA2KIn.getJsonSize()+ countNMEA2KIn.getJsonSize()+
countNMEA2KOut.getJsonSize() + countNMEA2KOut.getJsonSize() +
channels.getJsonSize() channels.getJsonSize()
@ -386,6 +387,7 @@ protected:
GwConfigHandler::toHex(base,buffer,bsize); GwConfigHandler::toHex(base,buffer,bsize);
status["salt"] = buffer; status["salt"] = buffer;
status["fwtype"]= firmwareType; status["fwtype"]= firmwareType;
status["chiptype"]=chipType.substring(2);
status["heap"]=(long)xPortGetFreeHeapSize(); status["heap"]=(long)xPortGetFreeHeapSize();
Nmea2kTwai::Status n2kState=NMEA2000.getStatus(); Nmea2kTwai::Status n2kState=NMEA2000.getStatus();
Nmea2kTwai::STATE driverState=n2kState.state; Nmea2kTwai::STATE driverState=n2kState.state;

View File

@ -100,6 +100,10 @@
<span class="label">firmware type</span> <span class="label">firmware type</span>
<span class="value status-fwtype">---</span> <span class="value status-fwtype">---</span>
</div> </div>
<div class="row">
<span class="label">chip type</span>
<span class="value status-chiptype">---</span>
</div>
<div class="row"> <div class="row">
<span class="label">currentVersion</span> <span class="label">currentVersion</span>
<span class="value status-version">---</span> <span class="value status-version">---</span>

View File

@ -1564,9 +1564,15 @@ function uploadBin(ev){
.then(function (result) { .then(function (result) {
let currentType; let currentType;
let currentVersion; let currentVersion;
let chiptype;
forEl('.status-version', function (el) { currentVersion = el.textContent }); forEl('.status-version', function (el) { currentVersion = el.textContent });
forEl('.status-fwtype', function (el) { currentType = el.textContent }); forEl('.status-fwtype', function (el) { currentType = el.textContent });
forEl('.status-chiptype', function (el) { chiptype = el.textContent });
let confirmText = 'Ready to update firmware?\n'; let confirmText = 'Ready to update firmware?\n';
if (result.chip.match(/^@@/) && (result.chip.substr(2) != chiptype)){
confirmText += "WARNING: the chiptype in the image ("+result.chip.substr(2);
confirmText +=") does not match the current chip type ("+chiptype+").\n";
}
if (currentType != result.fwtype) { if (currentType != result.fwtype) {
confirmText += "WARNING: image has different type: " + result.fwtype + "\n"; confirmText += "WARNING: image has different type: " + result.fwtype + "\n";
confirmText += "** Really update anyway? - device can become unusable **"; confirmText += "** Really update anyway? - device can become unusable **";
@ -1643,7 +1649,8 @@ function uploadBin(ev){
let HDROFFSET=288; let HDROFFSET=288;
let VERSIONOFFSET=16; let VERSIONOFFSET=16;
let NAMEOFFSET=48; let NAMEOFFSET=48;
let MINSIZE=HDROFFSET+NAMEOFFSET+32; let CHIPOFFSET=NAMEOFFSET+64;
let MINSIZE = HDROFFSET + CHIPOFFSET + 32;
let imageCheckBytes={ let imageCheckBytes={
0: 0xe9, //image magic 0: 0xe9, //image magic
288: 0x32, //app header magic 288: 0x32, //app header magic
@ -1678,9 +1685,11 @@ function checkImageFile(file){
} }
let version=decodeFromBuffer(content,HDROFFSET+VERSIONOFFSET,32); let version=decodeFromBuffer(content,HDROFFSET+VERSIONOFFSET,32);
let fwtype=decodeFromBuffer(content,HDROFFSET+NAMEOFFSET,32); let fwtype=decodeFromBuffer(content,HDROFFSET+NAMEOFFSET,32);
let chip=decodeFromBuffer(content,HDROFFSET+CHIPOFFSET,32);
let rt={ let rt={
fwtype:fwtype, fwtype:fwtype,
version: version, version: version,
chip:chip
}; };
resolve(rt); resolve(rt);
}); });
@ -1742,7 +1751,12 @@ window.addEventListener('load', function () {
checkImageFile(file) checkImageFile(file)
.then(function(res){ .then(function(res){
forEl('#imageProperties',function(iel){ forEl('#imageProperties',function(iel){
iel.textContent=res.fwtype+", "+res.version; let txt="";
if (res.chip.match(/^@@/)){
txt=res.chip.substr(2)+", "
}
txt+=res.fwtype+", "+res.version;
iel.textContent=txt;
iel.classList.remove("error"); iel.classList.remove("error");
}) })
}) })