From 3d4de2040205bd81c38b26d3ca190e3b264347b5 Mon Sep 17 00:00:00 2001 From: Peter Prince Date: Tue, 7 Sep 2021 13:07:14 +0100 Subject: [PATCH] Add 1.4.0 changes --- app.js | 8 ++++++++ communication.js | 4 ++-- firmwareInterface.js | 14 ++++++++++++-- index.html | 2 +- main.js | 9 +++++++++ package.json | 4 +++- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 83f54d4..08a5815 100644 --- a/app.js +++ b/app.js @@ -36,6 +36,8 @@ const statusDiv = document.getElementById('status-div'); const versionSelect = document.getElementById('version-select'); const downloadButton = document.getElementById('download-button'); +const overwriteBootloaderDiv = document.getElementById('overwrite-bootloader-div'); + /* Status set getStatus which enables/disables flash buttons */ var inFlashableState = false; @@ -955,6 +957,12 @@ electron.ipcRenderer.on('update-check', () => { }); +electron.ipcRenderer.on('toggle-bootloader-overwrite', () => { + + overwriteBootloaderDiv.style.display = (overwriteBootloaderDiv.style.display === '') ? 'none' : ''; + +}); + /* Prepare UI */ firmwareInterface.updateFirmwareDirectoryDisplay(''); diff --git a/communication.js b/communication.js index afecaac..5281b45 100644 --- a/communication.js +++ b/communication.js @@ -930,8 +930,8 @@ function crcCheck (expectedCRC, isDestructive, successCallback) { electronLog.error('Flash CRC was incorrect, ending communication'); - let errorString = 'Flash failed, CRC did not match.\n'; - errorString += 'Expected ' + expectedCRC + ' but received ' + receivedCRC + '.\n'; + let errorString = 'Flash failed, CRC did not match. '; + errorString += 'Expected ' + expectedCRC + ' but received ' + receivedCRC + '. '; errorString += 'Reconnect device and try again.'; displayError('Incorrect CRC', errorString); electron.ipcRenderer.send('set-bar-aborted'); diff --git a/firmwareInterface.js b/firmwareInterface.js index 9a39756..b29960a 100644 --- a/firmwareInterface.js +++ b/firmwareInterface.js @@ -8,6 +8,10 @@ /* global XMLHttpRequest */ +/* Firmware files open with a 32-bit address 0 which are valid if they fall between these two values */ +const MIN_ADDRESS_0 = 536870912; +const MAX_ADDRESS_0 = 536903680; + const electron = require('electron'); const dialog = electron.remote.dialog; const app = electron.remote.app; @@ -125,7 +129,7 @@ function fillDescription (i) { const month = (monthNum > 9) ? monthNum : '0' + monthNum; const publishDateString = day + '/' + month + '/' + publishDate.getFullYear(); - releaseDescriptionSpan.innerHTML = '

Version: ' + releases[i].name + '

'; + releaseDescriptionSpan.innerHTML = '

Firmware version: AudioMoth-Firmware-Basic ' + releases[i].name + '

'; releaseDescriptionSpan.innerHTML += '

Date released: ' + publishDateString + '

'; releaseDescriptionSpan.innerHTML += 'Changes:'; @@ -212,8 +216,14 @@ function isFirmwareFile (directory) { } + const array8 = new Uint8Array([contents[0], contents[1], contents[2], contents[3]]); + const array32 = new Uint32Array(array8.buffer); + const address0 = array32[0]; + + console.log('Firmware address 0: ' + address0); + /* The first bytes of all AudioMoth firmware follow this sequence of values */ - resolve((contents[0] === 0) && (contents[1] === 128) && (contents[2] === 0) && (contents[3] === 32)); + resolve(address0 >= MIN_ADDRESS_0 && address0 <= MAX_ADDRESS_0); }); diff --git a/index.html b/index.html index 222d0ff..c4662c6 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@ -
+