From f2aa899fe0dd4ade077a3026ae83ef5da986ef84 Mon Sep 17 00:00:00 2001 From: cTn Date: Tue, 24 Jun 2014 14:57:41 +0200 Subject: [PATCH] polishing firmware flasher UI and messages --- _locales/en/messages.json | 4 ++-- js/stm32.js | 39 +++++++++++++++++--------------------- js/stm32dfu.js | 10 +++++----- tabs/firmware_flasher.css | 9 ++++++++- tabs/firmware_flasher.html | 14 ++++++++------ tabs/firmware_flasher.js | 12 ++++++------ 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index eab1bea3..b07cab91 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -563,8 +563,8 @@ "firmwareFlasherFirmwareNotLoaded": { "message": "Firmware not loaded" }, - "firmwareFlasherFirmwareLoaded": { - "message": "Firmware loaded, ready for flashing" + "firmwareFlasherLocalFirmwareLoaded": { + "message": "Local Firmware loaded, ready for flashing" }, "firmwareFlasherHexCorrupted": { "message": "HEX file appears to be corrupted" diff --git a/js/stm32.js b/js/stm32.js index 94917ec7..2d111c80 100644 --- a/js/stm32.js +++ b/js/stm32.js @@ -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('Please select valid serial port'); + GUI.log('Please select valid serial port'); } }; @@ -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: FAILED'); + GUI.log('STM32 - timed out, programming: FAILED'); // 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 failed, wrong response, expected: ' + val + ' received: ' + data[0]); + GUI.log('STM32 Communication failed, 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 failed'); + GUI.log('Communication with bootloader failed'); // 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('Flashing ...'); - // 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('Flashing ...'); - // 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('Verifying ...'); // 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: SUCCESSFUL'); + GUI.log('Programming: SUCCESSFUL'); // 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: FAILED'); + GUI.log('Programming: FAILED'); // update progress bar self.progress_bar_e.addClass('invalid'); diff --git a/js/stm32dfu.js b/js/stm32dfu.js index 7a046c7c..a2bae35c 100644 --- a/js/stm32dfu.js +++ b/js/stm32dfu.js @@ -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('Flashing ...'); + 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('Verifying ...'); + 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: SUCCESSFUL'); + GUI.log('Programming: SUCCESSFUL'); // 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: FAILED'); + GUI.log('Programming: FAILED'); // update progress bar self.progress_bar_e.addClass('invalid'); diff --git a/tabs/firmware_flasher.css b/tabs/firmware_flasher.css index 458e76ba..1b79862d 100644 --- a/tabs/firmware_flasher.css +++ b/tabs/firmware_flasher.css @@ -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; } diff --git a/tabs/firmware_flasher.html b/tabs/firmware_flasher.html index 6abebf44..4f94451f 100644 --- a/tabs/firmware_flasher.html +++ b/tabs/firmware_flasher.html @@ -2,7 +2,6 @@
empty
0 bytes
- Firmware not loaded
@@ -10,16 +9,19 @@


+ + +
+

+ + +
diff --git a/tabs/firmware_flasher.js b/tabs/firmware_flasher.js index 3e1d153b..1fce952c 100644 --- a/tabs/firmware_flasher.js +++ b/tabs/firmware_flasher.js @@ -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')); } } }