From 322af92d45d1d4cc74d0761b3837ca47fb8bf02b Mon Sep 17 00:00:00 2001 From: cTn Date: Sat, 30 Aug 2014 08:59:21 +0200 Subject: [PATCH] add / implement flash slowly option in firmware flasher this will allow flashing via serial adapters that doesn't support 921600 flashing via various bluetooth adapters will be also possible now (untested) --- _locales/en/messages.json | 6 ++++++ js/protocols/stm32.js | 13 +++++++++---- tabs/firmware_flasher.html | 7 ++++++- tabs/firmware_flasher.js | 25 ++++++++++++++++++++----- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index b5569f7696..eec2601be2 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -530,6 +530,12 @@ "firmwareFlasherFullChipErase": { "message": "Full Chip Erase" }, + "firmwareFlasherFlashSlowly": { + "message": "Flash slowly" + }, + "firmwareFlasherFlashSlowlyTitle": { + "message": "Use 115200 baudrate for flashing" + }, "firmwareFlasherButtonLoadLocal": { "message": "Load Firmware [Local]" }, diff --git a/js/protocols/stm32.js b/js/protocols/stm32.js index 8558bf1224..1cb4bdd94d 100644 --- a/js/protocols/stm32.js +++ b/js/protocols/stm32.js @@ -51,11 +51,12 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options) { var self = this; self.hex = hex; - // we will crunch the options here since doing it inside initialization routine would be too late / redundant + // we will crunch the options here since doing it inside initialization routine would be too late self.options = { no_reboot: false, reboot_baud: false, - erase_chip: false + erase_chip: false, + flash_slowly: false }; if (options.no_reboot) { @@ -68,8 +69,12 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options) { self.options.erase_chip = true; } + if (options.flash_slowly) { + self.options.flash_slowly = true; + } + if (self.options.no_reboot) { - serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) { + serial.connect(port, {bitrate: (!self.options.flash_slowly) ? baud : 115200, parityBit: 'even', stopBits: 'one'}, function (openInfo) { if (openInfo) { // we are connected, disabling connect button in the UI GUI.connect_lock = true; @@ -95,7 +100,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options) { serial.send(bufferOut, function () { serial.disconnect(function (result) { if (result) { - serial.connect(port, {bitrate: baud, parityBit: 'even', stopBits: 'one'}, function (openInfo) { + serial.connect(port, {bitrate: (!self.options.flash_slowly) ? baud : 115200, parityBit: 'even', stopBits: 'one'}, function (openInfo) { if (openInfo) { self.initialize(); } else { diff --git a/tabs/firmware_flasher.html b/tabs/firmware_flasher.html index 4f94451f64..59adba33a0 100644 --- a/tabs/firmware_flasher.html +++ b/tabs/firmware_flasher.html @@ -1,6 +1,6 @@
- empty
+ Please load firmware file
0 bytes
@@ -22,6 +22,11 @@
+ +
diff --git a/tabs/firmware_flasher.js b/tabs/firmware_flasher.js index d8daf285ca..d5b5ceb55f 100644 --- a/tabs/firmware_flasher.js +++ b/tabs/firmware_flasher.js @@ -111,9 +111,9 @@ TABS.firmware_flasher.initialize = function (callback) { if (parsed_hex != false) { if (String($('div#port-picker #port').val()) != 'DFU') { if (String($('div#port-picker #port').val()) != '0') { - var options = {}; - var port = String($('div#port-picker #port').val()); - var baud; + var options = {}, + port = String($('div#port-picker #port').val()), + baud; switch (GUI.operating_system) { case 'Windows': @@ -138,6 +138,10 @@ TABS.firmware_flasher.initialize = function (callback) { options.erase_chip = true; } + if ($('input.flash_slowly').is(':checked')) { + options.flash_slowly = true; + } + STM32.connect(port, baud, parsed_hex, options); } else { console.log('Please select valid serial port'); @@ -241,9 +245,20 @@ TABS.firmware_flasher.initialize = function (callback) { // bind UI hook so the status is saved on change $('input.erase_chip').change(function () { - var status = $(this).is(':checked'); + chrome.storage.local.set({'erase_chip': $(this).is(':checked')}); + }); + }); - chrome.storage.local.set({'erase_chip': status}); + chrome.storage.local.get('flash_slowly', function (result) { + if (result.flash_slowly) { + $('input.flash_slowly').prop('checked', true); + } else { + $('input.flash_slowly').prop('checked', false); + } + + // bind UI hook so the status is saved on change + $('input.flash_slowly').change(function () { + chrome.storage.local.set({'flash_slowly': $(this).is(':checked')}); }); });