Skip to content

Commit

Permalink
Fix flash on connect (#3858)
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis authored Mar 26, 2024
1 parent 7384910 commit c3bc74c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/js/tabs/firmware_flasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,22 +1014,24 @@ firmware_flasher.initialize = function (callback) {

$('a.flash_firmware').on('click', function () {
self.isFlashing = true;
const isFlashOnConnect = $('input.flash_on_connect').is(':checked');

self.enableFlashButton(false);
self.enableDfuExitButton(false);
self.enableLoadRemoteFileButton(false);
self.enableLoadFileButton(false);

function initiateFlashing() {
if (self.developmentFirmwareLoaded) {
if (self.developmentFirmwareLoaded && !isFlashOnConnect) {
checkShowAcknowledgementDialog();
} else {
startFlashing();
}
}

// Backup not available in DFU, manual or virtual mode.
if (self.isSerialPortAvailable()) {
// When flash on connect is enabled, the backup dialog is not shown.
if (self.isSerialPortAvailable() && !isFlashOnConnect) {
GUI.showYesNoDialog(
{
title: i18n.getMessage('firmwareFlasherRemindBackupTitle'),
Expand Down Expand Up @@ -1119,6 +1121,8 @@ firmware_flasher.initialize = function (callback) {
} catch (e) {
console.log(`Flashing failed: ${e.message}`);
}
// Disable flash on connect after flashing to prevent continuous flashing
$('input.flash_on_connect').prop('checked', false).change();
} else {
$('span.progressLabel').attr('i18n','firmwareFlasherFirmwareNotLoaded').removeClass('i18n-replaced');
i18n.localizePage();
Expand Down Expand Up @@ -1199,6 +1203,9 @@ firmware_flasher.initialize = function (callback) {

catch_new_port();
} else {
// Cancel the flash on connect
GUI.timeout_remove('initialization_timeout');

PortHandler.flush_callbacks();
}
}).change();
Expand Down Expand Up @@ -1237,7 +1244,9 @@ firmware_flasher.validateBuildKey = function() {
firmware_flasher.verifyBoard = function() {
const self = this;

if (!self.isSerialPortAvailable()) {
const isFlashOnConnect = $('input.flash_on_connect').is(':checked');

if (!self.isSerialPortAvailable() || isFlashOnConnect) {
// return silently as port-picker will trigger again when port becomes available
return;
}
Expand Down

0 comments on commit c3bc74c

Please sign in to comment.