1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-13 19:40:22 +03:00

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)
This commit is contained in:
cTn 2014-08-30 08:59:21 +02:00
parent 6dec7dfbc1
commit 322af92d45
4 changed files with 41 additions and 10 deletions

View file

@ -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]"
},

View file

@ -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 {

View file

@ -1,6 +1,6 @@
<div class="tab-firmware_flasher">
<div class="info">
<strong i18n="firmwareFlasherPath"></strong><span class="path">empty</span><br />
<strong i18n="firmwareFlasherPath"></strong><span class="path">Please load firmware file</span><br />
<strong i18n="firmwareFlasherSize"></strong><span class="size">0 bytes</span><br />
<strong i18n="firmwareFlasherProgress"></strong><progress class="progress" value="0" min="0" max="100"></progress>
</div>
@ -22,6 +22,11 @@
<span i18n="firmwareFlasherFullChipErase"></span>
</label>
<div class="clear-both"></div>
<label i18n_title="firmwareFlasherFlashSlowlyTitle">
<input class="flash_slowly" type="checkbox" />
<span i18n="firmwareFlasherFlashSlowly"></span>
</label>
<div class="clear-both"></div>
</div>
<div class="clear-both"></div>
<div class="git_info">

View file

@ -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')});
});
});