polishing firmware flasher UI and messages

10.3.x-maintenance
cTn 2014-06-24 14:57:41 +02:00
parent 86aa6a282c
commit f2aa899fe0
6 changed files with 46 additions and 42 deletions

View File

@ -563,8 +563,8 @@
"firmwareFlasherFirmwareNotLoaded": {
"message": "<span style=\"color: red\">Firmware not loaded</span>"
},
"firmwareFlasherFirmwareLoaded": {
"message": "<span style=\"color: green\">Firmware loaded, ready for flashing</span>"
"firmwareFlasherLocalFirmwareLoaded": {
"message": "<span style=\"color: green\">Local Firmware loaded, ready for flashing</span>"
},
"firmwareFlasherHexCorrupted": {
"message": "<span style=\"color: red\">HEX file appears to be corrupted</span>"

View File

@ -42,11 +42,6 @@ var STM32_protocol = function() {
this.page_size = 0;
};
// string = string .. duh
STM32_protocol.prototype.GUI_status = function(string) {
$('span.status').html(string);
};
// no input parameters
STM32_protocol.prototype.connect = function(hex) {
var self = this;
@ -118,7 +113,7 @@ STM32_protocol.prototype.connect = function(hex) {
}
} else {
console.log('Please select valid serial port');
STM32.GUI_status('<span style="color: red">Please select valid serial port</span>');
GUI.log('<span style="color: red">Please select valid serial port</span>');
}
};
@ -147,7 +142,7 @@ STM32_protocol.prototype.initialize = function() {
self.upload_process_alive = false;
} else {
console.log('STM32 - timed out, programming failed ...');
STM32.GUI_status('STM32 - timed out, programming: <strong style="color: red">FAILED</strong>');
GUI.log('STM32 - timed out, programming: <strong style="color: red">FAILED</strong>');
// protocol got stuck, clear timer and disconnect
GUI.interval_remove('STM32_timeout');
@ -155,7 +150,7 @@ STM32_protocol.prototype.initialize = function() {
// exit
self.upload_procedure(99);
}
}, 1000);
}, 2000);
self.upload_procedure(1);
};
@ -226,7 +221,7 @@ STM32_protocol.prototype.send = function(Array, bytes_to_read, callback) {
STM32_protocol.prototype.verify_response = function(val, data) {
if (val != data[0]) {
console.log('STM32 Communication failed, wrong response, expected: ' + val + ' received: ' + data[0]);
STM32.GUI_status('STM32 Communication <span style="color: red">failed</span>, wrong response, expected: ' + val + ' received: ' + data[0]);
GUI.log('STM32 Communication <span style="color: red">failed</span>, wrong response, expected: ' + val + ' received: ' + data[0]);
// disconnect
this.upload_procedure(99);
@ -334,6 +329,8 @@ STM32_protocol.prototype.upload_procedure = function(step) {
switch (step) {
case 1:
// initialize serial interface on the MCU side, auto baud rate settings
GUI.log('Contacting bootloader ...');
var send_counter = 0;
GUI.interval_add('stm32_initialize_mcu', function() { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
self.send([0x7F], 1, function(reply) {
@ -345,7 +342,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
self.upload_procedure(2);
} else {
GUI.interval_remove('stm32_initialize_mcu');
STM32.GUI_status('STM32 Communication with bootloader <span style="color: red">failed</span>');
GUI.log('Communication with bootloader <span style="color: red">failed</span>');
// disconnect
self.upload_procedure(99);
@ -392,10 +389,11 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break;
case 4:
// erase memory
GUI.log('Erasing ...');
if (!$('input.erase_chip').is(':checked')) {
// EXPERIMENTAL
console.log('Executing local erase (only needed pages)');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
@ -415,9 +413,6 @@ STM32_protocol.prototype.upload_procedure = function(step) {
self.send(buff, 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step
self.upload_procedure(5);
}
@ -426,16 +421,12 @@ STM32_protocol.prototype.upload_procedure = function(step) {
});
} else {
console.log('Executing global chip erase');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) {
self.send([0xFF, 0x00], 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step
self.upload_procedure(5);
}
@ -446,6 +437,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break;
case 5:
// upload
console.log('Writing data ...');
GUI.log('Flashing ...');
var blocks = self.hex.data.length - 1;
var flashing_block = 0;
var address = self.hex.data[flashing_block].address;
@ -507,8 +501,6 @@ STM32_protocol.prototype.upload_procedure = function(step) {
} else {
// all blocks flashed
console.log('Writing: done');
console.log('Verifying data ...');
STM32.GUI_status('<span style="color: green">Verifying ...</span>');
// proceed to next step
self.upload_procedure(6);
@ -521,6 +513,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break;
case 6:
// verify
console.log('Verifying data ...');
GUI.log('Verifying ...');
var blocks = self.hex.data.length - 1;
var reading_block = 0;
var address = self.hex.data[reading_block].address;
@ -592,7 +587,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
if (verify) {
console.log('Programming: SUCCESSFUL');
STM32.GUI_status('Programming: <strong style="color: green">SUCCESSFUL</strong>');
GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>');
// update progress bar
self.progress_bar_e.addClass('valid');
@ -601,7 +596,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
self.upload_procedure(7);
} else {
console.log('Programming: FAILED');
STM32.GUI_status('Programming: <strong style="color: red">FAILED</strong>');
GUI.log('Programming: <strong style="color: red">FAILED</strong>');
// update progress bar
self.progress_bar_e.addClass('invalid');

View File

@ -254,7 +254,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
case 2:
// full chip erase
console.log('Executing global chip erase');
STM32.GUI_status('Erasing');
GUI.log('Erasing ...');
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, [0x41], function() {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function(data) {
@ -282,7 +282,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
// upload
// we dont need to clear the state as we are already using DFU_DNLOAD
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
GUI.log('Flashing ...');
var blocks = self.hex.data.length - 1;
var flashing_block = 0;
@ -353,7 +353,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
case 5:
// verify
console.log('Verifying data ...');
STM32.GUI_status('<span style="color: green">Verifying ...</span>');
GUI.log('Verifying ...');
var blocks = self.hex.data.length - 1;
var reading_block = 0;
@ -420,7 +420,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
if (verify) {
console.log('Programming: SUCCESSFUL');
STM32.GUI_status('Programming: <strong style="color: green">SUCCESSFUL</strong>');
GUI.log('Programming: <strong style="color: green">SUCCESSFUL</strong>');
// update progress bar
self.progress_bar_e.addClass('valid');
@ -429,7 +429,7 @@ STM32DFU_protocol.prototype.upload_procedure = function(step) {
self.upload_procedure(6);
} else {
console.log('Programming: FAILED');
STM32.GUI_status('Programming: <strong style="color: red">FAILED</strong>');
GUI.log('Programming: <strong style="color: red">FAILED</strong>');
// update progress bar
self.progress_bar_e.addClass('invalid');

View File

@ -27,10 +27,17 @@
.tab-firmware_flasher .note p {
margin-bottom: 5px;
}
.tab-firmware_flasher .note input {
.tab-firmware_flasher .note label {
float: left;
}
.tab-firmware_flasher .note label input {
float: left;
margin-top: 2px;
}
.tab-firmware_flasher .note label span {
font-weight: bold;
margin-left: 6px;
}
.tab-firmware_flasher .note .flash_on_connect_wrapper {
display: none;
}

View File

@ -2,7 +2,6 @@
<div class="info">
<strong i18n="firmwareFlasherPath"></strong><span class="path">empty</span><br />
<strong i18n="firmwareFlasherSize"></strong><span class="size">0 bytes</span><br />
<strong i18n="firmwareFlasherStatus"></strong><span class="status">Firmware not loaded</span><br />
<strong i18n="firmwareFlasherProgress"></strong><progress class="progress" value="0" min="0" max="100"></progress>
</div>
<div class="note">
@ -10,16 +9,19 @@
</p>
<label>
<input class="updating" type="checkbox" />
<span style="font-weight: bold; margin-left: 6px" i18n="firmwareFlasherNoReboot"></span>
</label><br />
<span i18n="firmwareFlasherNoReboot"></span>
</label>
<div class="clear-both"></div>
<label class="flash_on_connect_wrapper">
<input class="flash_on_connect" type="checkbox" />
<span style="font-weight: bold; margin-left: 6px" i18n="firmwareFlasherFlashOnConnect"></span><br />
<span i18n="firmwareFlasherFlashOnConnect"></span><br />
</label>
<div class="clear-both"></div>
<label>
<input class="erase_chip" type="checkbox" />
<span style="font-weight: bold; margin-left: 6px" i18n="firmwareFlasherFullChipErase"></span>
</label><br />
<span i18n="firmwareFlasherFullChipErase"></span>
</label>
<div class="clear-both"></div>
</div>
<div class="clear-both"></div>
<div class="git_info">

View File

@ -46,12 +46,12 @@ function tab_initialize_firmware_flasher() {
parsed_hex = data;
if (parsed_hex) {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherFirmwareLoaded'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherLocalFirmwareLoaded'));
$('a.flash_firmware').removeClass('locked');
$('span.size').html(parsed_hex.bytes_total + ' bytes');
} else {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
}
});
}
@ -71,17 +71,17 @@ function tab_initialize_firmware_flasher() {
parsed_hex = data;
if (parsed_hex) {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherRemoteFirmwareLoaded'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherRemoteFirmwareLoaded'));
$('a.flash_firmware').removeClass('locked');
$('span.path').text('Using remote Firmware');
$('span.size').text(parsed_hex.bytes_total + ' bytes');
} else {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
}
});
}).fail(function() {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
$('a.flash_firmware').addClass('locked');
});
@ -109,7 +109,7 @@ function tab_initialize_firmware_flasher() {
STM32DFU.connect(parsed_hex);
}
} else {
STM32.GUI_status(chrome.i18n.getMessage('firmwareFlasherFirmwareNotLoaded'));
GUI.log(chrome.i18n.getMessage('firmwareFlasherFirmwareNotLoaded'));
}
}
}