Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flash on connect #3858

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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