mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 05:15:21 +03:00
Added button to exit DFU.
This commit is contained in:
parent
4475586e59
commit
d293d6b1e7
8 changed files with 261 additions and 191 deletions
|
@ -2811,6 +2811,9 @@
|
|||
"firmwareFlasherButtonDownloading": {
|
||||
"message": "Downloading..."
|
||||
},
|
||||
"firmwareFlasherExitDfu": {
|
||||
"message": "Exit DFU Mode"
|
||||
},
|
||||
"firmwareFlasherFlashFirmware": {
|
||||
"message": "Flash Firmware"
|
||||
},
|
||||
|
|
|
@ -215,6 +215,17 @@
|
|||
background-color: #dedcdc;
|
||||
}
|
||||
|
||||
.tab-firmware_flasher .buttons a.exit_dfu.locked {
|
||||
float: left;
|
||||
background-color: #b8b8b8;
|
||||
}
|
||||
|
||||
.tab-firmware_flasher .buttons a.exit_dfu.locked:hover {
|
||||
float: left;
|
||||
cursor: default;
|
||||
background-color: #b8b8b8;
|
||||
}
|
||||
|
||||
.tab-firmware_flasher .buttons a.flash_firmware.locked {
|
||||
background-color: #b8b8b8;
|
||||
}
|
||||
|
|
|
@ -150,15 +150,17 @@ PortHandler.check = function () {
|
|||
|
||||
PortHandler.check_usb_devices = function (callback) {
|
||||
chrome.usb.getDevices(usbDevices, function (result) {
|
||||
const portPickerElement = $("div#port-picker #port");
|
||||
const dfuElement = portPickerElement.children("[value='DFU']");
|
||||
if (result.length) {
|
||||
if (!$("div#port-picker #port [value='DFU']").length) {
|
||||
$('div#port-picker #port').append($('<option/>', {value: "DFU", text: "DFU", data: {isDFU: true}}));
|
||||
$('div#port-picker #port').val('DFU');
|
||||
if (!dfuElement.length) {
|
||||
portPickerElement.append($('<option/>', {value: "DFU", text: "DFU", data: {isDFU: true}}));
|
||||
portPickerElement.val('DFU').change();
|
||||
}
|
||||
self.dfu_available = true;
|
||||
} else {
|
||||
if ($("div#port-picker #port [value='DFU']").length) {
|
||||
$("div#port-picker #port [value='DFU']").remove();
|
||||
if (dfuElement.length) {
|
||||
dfuElement.remove();
|
||||
}
|
||||
self.dfu_available = false;
|
||||
}
|
||||
|
@ -168,15 +170,15 @@ PortHandler.check_usb_devices = function (callback) {
|
|||
};
|
||||
|
||||
PortHandler.update_port_select = function (ports) {
|
||||
$('div#port-picker #port').html(''); // drop previous one
|
||||
const portPickerElement = $("div#port-picker #port");
|
||||
portPickerElement.empty();
|
||||
|
||||
for (var i = 0; i < ports.length; i++) {
|
||||
$('div#port-picker #port').append($("<option/>", {value: ports[i], text: ports[i], data: {isManual: false}}));
|
||||
portPickerElement.append($("<option/>", {value: ports[i], text: ports[i], data: {isManual: false}}));
|
||||
}
|
||||
|
||||
$('div#port-picker #port').append($("<option/>", {value: 'manual', i18n: 'portsSelectManual', data: {isManual: true}}));
|
||||
portPickerElement.append($("<option/>", {value: 'manual', i18n: 'portsSelectManual', data: {isManual: true}}));
|
||||
i18n.localizePage();
|
||||
|
||||
};
|
||||
|
||||
PortHandler.port_detected = function(name, code, timeout, ignore_timeout) {
|
||||
|
|
|
@ -73,10 +73,13 @@ STM32DFU_protocol.prototype.connect = function (device, hex, options, callback)
|
|||
self.callback = callback;
|
||||
|
||||
self.options = {
|
||||
erase_chip: false
|
||||
erase_chip: false,
|
||||
exitDfu: false,
|
||||
};
|
||||
|
||||
if (options.erase_chip) {
|
||||
if (options.exitDfu) {
|
||||
self.options.exitDfu = true;
|
||||
} else if (options.erase_chip) {
|
||||
self.options.erase_chip = true;
|
||||
}
|
||||
|
||||
|
@ -85,9 +88,7 @@ STM32DFU_protocol.prototype.connect = function (device, hex, options, callback)
|
|||
self.verify_hex = [];
|
||||
|
||||
// reset progress bar to initial state
|
||||
TABS.firmware_flasher.flashingMessage(null, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL)
|
||||
.flashProgress(0);
|
||||
|
||||
TABS.firmware_flasher.flashingMessage(null, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL).flashProgress(0);
|
||||
|
||||
chrome.usb.getDevices(device, function (result) {
|
||||
if (result.length) {
|
||||
|
@ -157,12 +158,16 @@ STM32DFU_protocol.prototype.claimInterface = function (interfaceNumber) {
|
|||
chrome.usb.claimInterface(this.handle, interfaceNumber, function claimed() {
|
||||
if(self.checkChromeError()) {
|
||||
console.log('Failed to claim USB device!');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
|
||||
console.log('Claimed interface: ' + interfaceNumber);
|
||||
|
||||
if (self.options.exitDfu) {
|
||||
self.leave();
|
||||
} else {
|
||||
self.upload_procedure(0);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -523,7 +528,7 @@ STM32DFU_protocol.prototype.loadAddress = function (address, callback, abort) {
|
|||
} else {
|
||||
console.log('Failed to execute address load');
|
||||
if(typeof abort === "undefined" || abort) {
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
} else {
|
||||
callback(data);
|
||||
}
|
||||
|
@ -532,7 +537,7 @@ STM32DFU_protocol.prototype.loadAddress = function (address, callback, abort) {
|
|||
}, delay);
|
||||
} else {
|
||||
console.log('Failed to request address load');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -562,7 +567,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
self.getChipInfo(0, function (chipInfo, resultCode) {
|
||||
if (resultCode != 0 || typeof chipInfo === "undefined") {
|
||||
console.log('Failed to detect chip info, resultCode: ' + resultCode);
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
} else {
|
||||
if (typeof chipInfo.internal_flash !== "undefined") {
|
||||
// internal flash
|
||||
|
@ -577,7 +582,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
GUI.log(i18n.getMessage('dfu_error_image_size',
|
||||
[(self.hex.bytes_total / 1024.0).toFixed(1),
|
||||
(self.available_flash_size / 1024.0).toFixed(1)]));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
} else {
|
||||
self.getFunctionalDescriptor(0, function (descriptor, resultCode) {
|
||||
self.transferSize = resultCode ? 2048 : descriptor.wTransferSize;
|
||||
|
@ -604,7 +609,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
GUI.log(i18n.getMessage('dfu_error_image_size',
|
||||
[(self.hex.bytes_total / 1024.0).toFixed(1),
|
||||
(self.available_flash_size / 1024.0).toFixed(1)]));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
} else {
|
||||
self.getFunctionalDescriptor(0, function (descriptor, resultCode) {
|
||||
self.transferSize = resultCode ? 2048 : descriptor.wTransferSize;
|
||||
|
@ -616,7 +621,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
}
|
||||
} else {
|
||||
console.log('Failed to detect internal or external flash');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -624,7 +629,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
case 1:
|
||||
if (typeof self.chipInfo.option_bytes === "undefined") {
|
||||
console.log('Failed to detect option bytes');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
|
||||
var unprotect = function() {
|
||||
|
@ -666,7 +671,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
GUI.log(i18n.getMessage('stm32UnprotectFailed'));
|
||||
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32UnprotectFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
|
||||
console.log(data);
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
}, 2000); // this should stall/disconnect anyways. so we only wait 2 sec max.
|
||||
}, incr);
|
||||
|
@ -675,7 +680,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
let messageUnprotectInitFailed = i18n.getMessage('stm32UnprotectInitFailed')
|
||||
GUI.log(messageUnprotectInitFailed);
|
||||
TABS.firmware_flasher.flashingMessage(messageUnprotectInitFailed, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID)
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -686,7 +691,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
self.controlTransfer('in', self.request.UPLOAD, 2, 0, self.chipInfo.option_bytes.total_size, 0, function (ob_data, errcode) {
|
||||
if(errcode) {
|
||||
console.log('USB transfer error while reading option bytes: ' + errcode1);
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
return;
|
||||
}
|
||||
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
|
||||
|
@ -710,16 +715,16 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
|
||||
if (data[4] == self.state.dfuDNLOAD_IDLE) {
|
||||
console.log('Failed to write ob');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
} else {
|
||||
console.log('Success writing ob');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
} else {
|
||||
console.log('Failed to initiate write ob');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -750,7 +755,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
self.clearStatus(tryReadOB);
|
||||
} else {
|
||||
GUI.log(i18n.getMessage('stm32AddressLoadUnknown'));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,7 +797,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
if (erase_pages.length === 0) {
|
||||
console.log('Aborting, No flash pages to erase');
|
||||
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32InvalidHex'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -851,7 +856,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
erase_page_next();
|
||||
} else {
|
||||
console.log('Failed to erase page 0x' + page_addr.toString(16) + ' (did not reach dfuIDLE after clearing');
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -859,13 +864,13 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
erase_page_next();
|
||||
} else {
|
||||
console.log('Failed to erase page 0x' + page_addr.toString(16));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
} else {
|
||||
console.log('Failed to initiate page erase, page 0x' + page_addr.toString(16));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -914,13 +919,13 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
write();
|
||||
} else {
|
||||
console.log('Failed to write ' + bytes_to_write + 'bytes to 0x' + address.toString(16));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
}, delay);
|
||||
} else {
|
||||
console.log('Failed to initiate write ' + bytes_to_write + 'bytes to 0x' + address.toString(16));
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
});
|
||||
})
|
||||
|
@ -1022,38 +1027,50 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);
|
||||
|
||||
// proceed to next step
|
||||
self.upload_procedure(6);
|
||||
self.leave();
|
||||
} else {
|
||||
console.log('Programming: FAILED');
|
||||
// update progress bar
|
||||
TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
|
||||
|
||||
// disconnect
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
// jump to application code
|
||||
var address = self.hex.data[0].address;
|
||||
}
|
||||
};
|
||||
|
||||
STM32DFU_protocol.prototype.leave = function () {
|
||||
// leave DFU
|
||||
|
||||
const self = this;
|
||||
|
||||
let address;
|
||||
if (self.hex) {
|
||||
address = self.hex.data[0].address;
|
||||
} else {
|
||||
// Assuming we're running off internal flash
|
||||
address = 0x08000000;
|
||||
}
|
||||
|
||||
self.clearStatus(function () {
|
||||
self.loadAddress(address, leave);
|
||||
});
|
||||
|
||||
var leave = function () {
|
||||
self.loadAddress(address, function () {
|
||||
// 'downloading' 0 bytes to the program start address followed by a GETSTATUS is used to trigger DFU exit on STM32
|
||||
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, 0, function () {
|
||||
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
|
||||
self.upload_procedure(99);
|
||||
self.cleanup();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
STM32DFU_protocol.prototype.cleanup = function () {
|
||||
const self = this;
|
||||
|
||||
break;
|
||||
case 99:
|
||||
// cleanup
|
||||
self.releaseInterface(0);
|
||||
|
||||
GUI.connect_lock = false;
|
||||
|
@ -1062,8 +1079,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
|
|||
|
||||
console.log('Script finished after: ' + (timeSpent / 1000) + ' seconds');
|
||||
|
||||
if (self.callback) self.callback();
|
||||
break;
|
||||
if (self.callback) {
|
||||
self.callback();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -48,22 +48,27 @@ function initializeSerialBackend() {
|
|||
GUI.configuration_loaded = false;
|
||||
|
||||
var selected_baud = parseInt($('div#port-picker #baud').val());
|
||||
var selected_port = $('div#port-picker #port option:selected').data().isManual ?
|
||||
$('#port-override').val() :
|
||||
String($('div#port-picker #port').val());
|
||||
if (selected_port === 'DFU') {
|
||||
GUI.log(i18n.getMessage('dfu_connect_message'));
|
||||
const selectedPort = $('div#port-picker #port option:selected');
|
||||
|
||||
let portName;
|
||||
if (selectedPort.data().isManual) {
|
||||
portName = $('#port-override').val();
|
||||
} else {
|
||||
portName = String($('div#port-picker #port').val());
|
||||
}
|
||||
else if (selected_port != '0') {
|
||||
|
||||
if (selectedPort.data().isDFU) {
|
||||
$('select#baud').hide();
|
||||
} else if (portName !== '0') {
|
||||
if (!clicks) {
|
||||
console.log('Connecting to: ' + selected_port);
|
||||
GUI.connecting_to = selected_port;
|
||||
console.log(`Connecting to: ${portName}`);
|
||||
GUI.connecting_to = portName;
|
||||
|
||||
// lock port select & baud while we are connecting / connected
|
||||
$('div#port-picker #port, div#port-picker #baud, div#port-picker #delay').prop('disabled', true);
|
||||
$('div.connect_controls a.connect_state').text(i18n.getMessage('connecting'));
|
||||
|
||||
serial.connect(selected_port, {bitrate: selected_baud}, onOpen);
|
||||
serial.connect(portName, {bitrate: selected_baud}, onOpen);
|
||||
|
||||
toggleStatus();
|
||||
} else {
|
||||
|
|
|
@ -56,6 +56,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
// send data/string over for processing
|
||||
worker.postMessage(str);
|
||||
}
|
||||
|
||||
function show_loaded_hex(summary) {
|
||||
self.flashingMessage('<a class="save_firmware" href="#" title="Save Firmware">' + i18n.getMessage('firmwareFlasherFirmwareOnlineLoaded', self.parsed_hex.bytes_total) + '</a>',
|
||||
self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||
|
@ -87,6 +88,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
});
|
||||
$('div.release_info').slideDown();
|
||||
}
|
||||
|
||||
function process_hex(data, summary) {
|
||||
self.intel_hex = data;
|
||||
|
||||
|
@ -388,7 +390,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
i18n.localizePage();
|
||||
|
||||
buildType_e.change(function() {
|
||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHANNEL, $(this).find('option:selected').text());
|
||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHANNEL, $('option:selected', this).text());
|
||||
|
||||
$("a.load_remote_file").addClass('disabled');
|
||||
var build_type = $(this).val();
|
||||
|
@ -664,6 +666,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', self.parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||
}
|
||||
}
|
||||
|
||||
function cleanUnifiedConfigFile(input) {
|
||||
let output = [];
|
||||
let inComment = false;
|
||||
|
@ -686,6 +689,127 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
return output.join('');
|
||||
}
|
||||
|
||||
const portPickerElement = $('div#port-picker #port');
|
||||
function flashFirmware(firmware) {
|
||||
var options = {};
|
||||
|
||||
var eraseAll = false;
|
||||
if ($('input.erase_chip').is(':checked')) {
|
||||
options.erase_chip = true;
|
||||
|
||||
eraseAll = true
|
||||
}
|
||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_ERASE_ALL, eraseAll.toString());
|
||||
|
||||
if (!$('option:selected', portPickerElement).data().isDFU) {
|
||||
if (String(portPickerElement.val()) !== '0') {
|
||||
const port = String(portPickerElement.val());
|
||||
|
||||
if ($('input.updating').is(':checked')) {
|
||||
options.no_reboot = true;
|
||||
} else {
|
||||
options.reboot_baud = parseInt($('div#port-picker #baud').val());
|
||||
}
|
||||
|
||||
let baud = 115200;
|
||||
if ($('input.flash_manual_baud').is(':checked')) {
|
||||
baud = parseInt($('#flash_manual_baud_rate').val());
|
||||
}
|
||||
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'Flashing', self.unifiedTargetConfigName || null);
|
||||
|
||||
STM32.connect(port, baud, firmware, options);
|
||||
} else {
|
||||
console.log('Please select valid serial port');
|
||||
GUI.log(i18n.getMessage('firmwareFlasherNoValidPort'));
|
||||
}
|
||||
} else {
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'Flashing', self.unifiedTargetConfigName || null);
|
||||
|
||||
STM32DFU.connect(usbDevices, firmware, options);
|
||||
}
|
||||
}
|
||||
|
||||
ConfigStorage.get('erase_chip', function (result) {
|
||||
if (result.erase_chip) {
|
||||
$('input.erase_chip').prop('checked', true);
|
||||
} else {
|
||||
$('input.erase_chip').prop('checked', false);
|
||||
}
|
||||
|
||||
$('input.erase_chip').change(function () {
|
||||
ConfigStorage.set({'erase_chip': $(this).is(':checked')});
|
||||
}).change();
|
||||
});
|
||||
|
||||
chrome.storage.local.get('show_development_releases', function (result) {
|
||||
$('input.show_development_releases')
|
||||
.prop('checked', result.show_development_releases)
|
||||
.change(function () {
|
||||
chrome.storage.local.set({'show_development_releases': $(this).is(':checked')});
|
||||
}).change();
|
||||
|
||||
});
|
||||
|
||||
chrome.storage.local.get('selected_build_type', function (result) {
|
||||
// ensure default build type is selected
|
||||
buildType_e.val(result.selected_build_type || 0).trigger('change');
|
||||
});
|
||||
|
||||
ConfigStorage.get('no_reboot_sequence', function (result) {
|
||||
if (result.no_reboot_sequence) {
|
||||
$('input.updating').prop('checked', true);
|
||||
$('.flash_on_connect_wrapper').show();
|
||||
} else {
|
||||
$('input.updating').prop('checked', false);
|
||||
}
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('input.updating').change(function() {
|
||||
var status = $(this).is(':checked');
|
||||
|
||||
if (status) {
|
||||
$('.flash_on_connect_wrapper').show();
|
||||
} else {
|
||||
$('input.flash_on_connect').prop('checked', false).change();
|
||||
$('.flash_on_connect_wrapper').hide();
|
||||
}
|
||||
|
||||
ConfigStorage.set({'no_reboot_sequence': status});
|
||||
});
|
||||
|
||||
$('input.updating').change();
|
||||
});
|
||||
|
||||
ConfigStorage.get('flash_manual_baud', function (result) {
|
||||
if (result.flash_manual_baud) {
|
||||
$('input.flash_manual_baud').prop('checked', true);
|
||||
} else {
|
||||
$('input.flash_manual_baud').prop('checked', false);
|
||||
}
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('input.flash_manual_baud').change(function() {
|
||||
var status = $(this).is(':checked');
|
||||
ConfigStorage.set({'flash_manual_baud': status});
|
||||
});
|
||||
|
||||
$('input.flash_manual_baud').change();
|
||||
});
|
||||
|
||||
ConfigStorage.get('flash_manual_baud_rate', function (result) {
|
||||
$('#flash_manual_baud_rate').val(result.flash_manual_baud_rate);
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('#flash_manual_baud_rate').change(function() {
|
||||
var baud = parseInt($('#flash_manual_baud_rate').val());
|
||||
ConfigStorage.set({'flash_manual_baud_rate': baud});
|
||||
});
|
||||
|
||||
$('input.flash_manual_baud_rate').change();
|
||||
});
|
||||
|
||||
// UI Hooks
|
||||
$('a.load_file').click(function () {
|
||||
self.enableFlashing(false);
|
||||
|
@ -778,7 +902,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
|
||||
let release = $("option:selected", evt.target).data("summary");
|
||||
let isCached = FirmwareCache.has(release);
|
||||
if (evt.target.value=="0" || isCached) {
|
||||
if (evt.target.value === "0" || isCached) {
|
||||
if (isCached) {
|
||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'cache');
|
||||
|
||||
|
@ -835,50 +959,32 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
function flashFirmware(firmware) {
|
||||
var options = {};
|
||||
|
||||
var eraseAll = false;
|
||||
if ($('input.erase_chip').is(':checked')) {
|
||||
options.erase_chip = true;
|
||||
|
||||
eraseAll = true
|
||||
const exitDfuElement = $('a.exit_dfu');
|
||||
exitDfuElement.click(function () {
|
||||
if (!$(this).hasClass('disabled')) {
|
||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'ExitDfu', null);
|
||||
try {
|
||||
STM32DFU.connect(usbDevices, self.parsed_hex, { exitDfu: true });
|
||||
} catch (e) {
|
||||
console.log(`Exiting DFU failed: ${e.message}`);
|
||||
}
|
||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_ERASE_ALL, eraseAll.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (String($('div#port-picker #port').val()) != 'DFU') {
|
||||
if (String($('div#port-picker #port').val()) != '0') {
|
||||
var port = String($('div#port-picker #port').val()), baud;
|
||||
baud = 115200;
|
||||
|
||||
if ($('input.updating').is(':checked')) {
|
||||
options.no_reboot = true;
|
||||
portPickerElement.change(function () {
|
||||
if ($('option:selected', this).data().isDFU) {
|
||||
exitDfuElement.removeClass('disabled');
|
||||
} else {
|
||||
options.reboot_baud = parseInt($('div#port-picker #baud').val());
|
||||
}
|
||||
|
||||
if ($('input.flash_manual_baud').is(':checked')) {
|
||||
baud = parseInt($('#flash_manual_baud_rate').val());
|
||||
}
|
||||
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'Flashing', self.unifiedTargetConfigName || null);
|
||||
|
||||
STM32.connect(port, baud, firmware, options);
|
||||
} else {
|
||||
console.log('Please select valid serial port');
|
||||
GUI.log(i18n.getMessage('firmwareFlasherNoValidPort'));
|
||||
}
|
||||
} else {
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'Flashing', self.unifiedTargetConfigName || null);
|
||||
|
||||
STM32DFU.connect(usbDevices, firmware, options);
|
||||
}
|
||||
exitDfuElement.addClass('disabled');
|
||||
}
|
||||
}).change();
|
||||
|
||||
$('a.flash_firmware').click(function () {
|
||||
if (!$(this).hasClass('disabled')) {
|
||||
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
||||
if (self.parsed_hex != false) {
|
||||
if (self.parsed_hex) {
|
||||
try {
|
||||
if (self.unifiedTargetConfig && !self.parsed_hex.configInserted) {
|
||||
var configInserter = new ConfigInserter();
|
||||
|
@ -905,7 +1011,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
$(document).on('click', 'span.progressLabel a.save_firmware', function () {
|
||||
$('span.progressLabel a.save_firmware').click(function () {
|
||||
var summary = $('select[name="firmware_version"] option:selected').data('summary');
|
||||
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: summary.file, accepts: [{description: 'HEX files', extensions: ['hex']}]}, function (fileEntry) {
|
||||
if (chrome.runtime.lastError) {
|
||||
|
@ -936,6 +1042,8 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FIRMWARE, 'SaveFirmware', path);
|
||||
};
|
||||
|
||||
writer.write(blob);
|
||||
|
@ -951,64 +1059,6 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
});
|
||||
});
|
||||
|
||||
chrome.storage.local.get('selected_build_type', function (result) {
|
||||
// ensure default build type is selected
|
||||
buildType_e.val(result.selected_build_type || 0).trigger('change');
|
||||
});
|
||||
|
||||
ConfigStorage.get('no_reboot_sequence', function (result) {
|
||||
if (result.no_reboot_sequence) {
|
||||
$('input.updating').prop('checked', true);
|
||||
$('.flash_on_connect_wrapper').show();
|
||||
} else {
|
||||
$('input.updating').prop('checked', false);
|
||||
}
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('input.updating').change(function() {
|
||||
var status = $(this).is(':checked');
|
||||
|
||||
if (status) {
|
||||
$('.flash_on_connect_wrapper').show();
|
||||
} else {
|
||||
$('input.flash_on_connect').prop('checked', false).change();
|
||||
$('.flash_on_connect_wrapper').hide();
|
||||
}
|
||||
|
||||
ConfigStorage.set({'no_reboot_sequence': status});
|
||||
});
|
||||
|
||||
$('input.updating').change();
|
||||
});
|
||||
|
||||
ConfigStorage.get('flash_manual_baud', function (result) {
|
||||
if (result.flash_manual_baud) {
|
||||
$('input.flash_manual_baud').prop('checked', true);
|
||||
} else {
|
||||
$('input.flash_manual_baud').prop('checked', false);
|
||||
}
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('input.flash_manual_baud').change(function() {
|
||||
var status = $(this).is(':checked');
|
||||
ConfigStorage.set({'flash_manual_baud': status});
|
||||
});
|
||||
|
||||
$('input.flash_manual_baud').change();
|
||||
});
|
||||
|
||||
ConfigStorage.get('flash_manual_baud_rate', function (result) {
|
||||
$('#flash_manual_baud_rate').val(result.flash_manual_baud_rate);
|
||||
|
||||
// bind UI hook so the status is saved on change
|
||||
$('#flash_manual_baud_rate').change(function() {
|
||||
var baud = parseInt($('#flash_manual_baud_rate').val());
|
||||
ConfigStorage.set({'flash_manual_baud_rate': baud});
|
||||
});
|
||||
|
||||
$('input.flash_manual_baud_rate').change();
|
||||
});
|
||||
|
||||
$('input.flash_on_connect').change(function () {
|
||||
var status = $(this).is(':checked');
|
||||
|
||||
|
@ -1040,29 +1090,6 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
}).change();
|
||||
|
||||
ConfigStorage.get('erase_chip', function (result) {
|
||||
if (result.erase_chip) {
|
||||
$('input.erase_chip').prop('checked', true);
|
||||
} else {
|
||||
$('input.erase_chip').prop('checked', false);
|
||||
}
|
||||
|
||||
$('input.erase_chip').change(function () {
|
||||
ConfigStorage.set({'erase_chip': $(this).is(':checked')});
|
||||
}).change();
|
||||
});
|
||||
|
||||
chrome.storage.local.get('show_development_releases', function (result) {
|
||||
$('input.show_development_releases')
|
||||
.prop('checked', result.show_development_releases)
|
||||
.change(function () {
|
||||
chrome.storage.local.set({'show_development_releases': $(this).is(':checked')});
|
||||
}).change();
|
||||
|
||||
});
|
||||
|
||||
self.flashingMessage(i18n.getMessage('firmwareFlasherLoadFirmwareFile'), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||
|
||||
$(document).keypress(function (e) {
|
||||
if (e.which == 13) { // enter
|
||||
// Trigger regular Flashing sequence
|
||||
|
@ -1070,6 +1097,8 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
}
|
||||
});
|
||||
|
||||
self.flashingMessage(i18n.getMessage('firmwareFlasherLoadFirmwareFile'), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||
|
||||
// Update Firmware button at top
|
||||
$('div#flashbutton a.flash_state').addClass('active');
|
||||
$('div#flashbutton a.flash').addClass('active');
|
||||
|
|
|
@ -89,7 +89,7 @@ function read_hex_file(data) {
|
|||
if (result.end_of_file && hexfile_valid) {
|
||||
postMessage(result);
|
||||
} else {
|
||||
postMessage(false);
|
||||
postMessage(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,6 +138,9 @@
|
|||
<progress class="progress" value="0" min="0" max="100"></progress>
|
||||
<span class="progressLabel"></span>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<a class="exit_dfu disabled" href="#" i18n="firmwareFlasherExitDfu"></a>
|
||||
</div>
|
||||
<div class="btn">
|
||||
<a class="flash_firmware disabled" href="#progressbar" i18n="firmwareFlasherFlashFirmware"></a>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue