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": { "firmwareFlasherFirmwareNotLoaded": {
"message": "<span style=\"color: red\">Firmware not loaded</span>" "message": "<span style=\"color: red\">Firmware not loaded</span>"
}, },
"firmwareFlasherFirmwareLoaded": { "firmwareFlasherLocalFirmwareLoaded": {
"message": "<span style=\"color: green\">Firmware loaded, ready for flashing</span>" "message": "<span style=\"color: green\">Local Firmware loaded, ready for flashing</span>"
}, },
"firmwareFlasherHexCorrupted": { "firmwareFlasherHexCorrupted": {
"message": "<span style=\"color: red\">HEX file appears to be corrupted</span>" "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; this.page_size = 0;
}; };
// string = string .. duh
STM32_protocol.prototype.GUI_status = function(string) {
$('span.status').html(string);
};
// no input parameters // no input parameters
STM32_protocol.prototype.connect = function(hex) { STM32_protocol.prototype.connect = function(hex) {
var self = this; var self = this;
@ -118,7 +113,7 @@ STM32_protocol.prototype.connect = function(hex) {
} }
} else { } else {
console.log('Please select valid serial port'); 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; self.upload_process_alive = false;
} else { } else {
console.log('STM32 - timed out, programming failed ...'); 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 // protocol got stuck, clear timer and disconnect
GUI.interval_remove('STM32_timeout'); GUI.interval_remove('STM32_timeout');
@ -155,7 +150,7 @@ STM32_protocol.prototype.initialize = function() {
// exit // exit
self.upload_procedure(99); self.upload_procedure(99);
} }
}, 1000); }, 2000);
self.upload_procedure(1); 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) { STM32_protocol.prototype.verify_response = function(val, data) {
if (val != data[0]) { if (val != data[0]) {
console.log('STM32 Communication failed, wrong response, expected: ' + val + ' received: ' + 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 // disconnect
this.upload_procedure(99); this.upload_procedure(99);
@ -334,6 +329,8 @@ STM32_protocol.prototype.upload_procedure = function(step) {
switch (step) { switch (step) {
case 1: case 1:
// initialize serial interface on the MCU side, auto baud rate settings // initialize serial interface on the MCU side, auto baud rate settings
GUI.log('Contacting bootloader ...');
var send_counter = 0; 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 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) { self.send([0x7F], 1, function(reply) {
@ -345,7 +342,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
self.upload_procedure(2); self.upload_procedure(2);
} else { } else {
GUI.interval_remove('stm32_initialize_mcu'); 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 // disconnect
self.upload_procedure(99); self.upload_procedure(99);
@ -392,10 +389,11 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break; break;
case 4: case 4:
// erase memory // erase memory
GUI.log('Erasing ...');
if (!$('input.erase_chip').is(':checked')) { if (!$('input.erase_chip').is(':checked')) {
// EXPERIMENTAL // EXPERIMENTAL
console.log('Executing local erase (only needed pages)'); console.log('Executing local erase (only needed pages)');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { 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) { self.send(buff, 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done'); console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step // proceed to next step
self.upload_procedure(5); self.upload_procedure(5);
} }
@ -426,16 +421,12 @@ STM32_protocol.prototype.upload_procedure = function(step) {
}); });
} else { } else {
console.log('Executing global chip erase'); console.log('Executing global chip erase');
STM32.GUI_status('Erasing');
self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF self.send([self.command.erase, 0xBC], 1, function(reply) { // 0x43 ^ 0xFF
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
self.send([0xFF, 0x00], 1, function(reply) { self.send([0xFF, 0x00], 1, function(reply) {
if (self.verify_response(self.status.ACK, reply)) { if (self.verify_response(self.status.ACK, reply)) {
console.log('Erasing: done'); console.log('Erasing: done');
console.log('Writing data ...');
STM32.GUI_status('<span style="color: green">Flashing ...</span>');
// proceed to next step // proceed to next step
self.upload_procedure(5); self.upload_procedure(5);
} }
@ -446,6 +437,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break; break;
case 5: case 5:
// upload // upload
console.log('Writing data ...');
GUI.log('Flashing ...');
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var flashing_block = 0; var flashing_block = 0;
var address = self.hex.data[flashing_block].address; var address = self.hex.data[flashing_block].address;
@ -507,8 +501,6 @@ STM32_protocol.prototype.upload_procedure = function(step) {
} else { } else {
// all blocks flashed // all blocks flashed
console.log('Writing: done'); console.log('Writing: done');
console.log('Verifying data ...');
STM32.GUI_status('<span style="color: green">Verifying ...</span>');
// proceed to next step // proceed to next step
self.upload_procedure(6); self.upload_procedure(6);
@ -521,6 +513,9 @@ STM32_protocol.prototype.upload_procedure = function(step) {
break; break;
case 6: case 6:
// verify // verify
console.log('Verifying data ...');
GUI.log('Verifying ...');
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var reading_block = 0; var reading_block = 0;
var address = self.hex.data[reading_block].address; var address = self.hex.data[reading_block].address;
@ -592,7 +587,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); 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 // update progress bar
self.progress_bar_e.addClass('valid'); self.progress_bar_e.addClass('valid');
@ -601,7 +596,7 @@ STM32_protocol.prototype.upload_procedure = function(step) {
self.upload_procedure(7); self.upload_procedure(7);
} else { } else {
console.log('Programming: FAILED'); 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 // update progress bar
self.progress_bar_e.addClass('invalid'); self.progress_bar_e.addClass('invalid');

View File

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

View File

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

View File

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

View File

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