diff --git a/src/extension.ts b/src/extension.ts index fb00d95ac..c95e265e6 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3991,26 +3991,6 @@ const buildFlashAndMonitor = async (runMonitor: boolean = true) => { ? vscode.ProgressLocation.Notification : vscode.ProgressLocation.Window; - // This validation doesn't allows users to use build,flash, monitor command if flash encryption is enabled for release mode - // because monitoring command resets the device which is not recommended. - // Reset should happen by Bootloader itself once it completes encrypting all artifacts. - if (isFlashEncryptionEnabled(workspaceRoot)) { - const valueReleaseModeEnabled = await utils.getConfigValueFromSDKConfig( - "CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE", - workspaceRoot - ); - if (valueReleaseModeEnabled == "y") { - const errorMessage = - "Flash, Build, Monitor command is not available while Flash Encryption is set for 'Release mode'. Use normal build and flash commands"; - const error = new Error(errorMessage); - OutputChannel.appendLineAndShow(errorMessage, "Build, Flash, Monitor"); - Logger.errorNotify(errorMessage, error, { - tag: "Build, Flash, Monitor", - }); - return; - } - } - await vscode.window.withProgress( { cancellable: true, @@ -4054,7 +4034,7 @@ const buildFlashAndMonitor = async (runMonitor: boolean = true) => { monitorTerminal.sendText(ESP.CTRL_RBRACKET); monitorTerminal.sendText(`exit`); } - createMonitor(); + await createMonitor(); } } ); @@ -4200,12 +4180,9 @@ function createIdfTerminal() { }); } -function createMonitor() { +async function createMonitor() { PreCheck.perform([webIdeCheck, openFolderCheck], async () => { - const noReset = idfConf.readParameter( - "idf.monitorNoReset", - workspaceRoot - ) as boolean; + const noReset = await shouldDisableMonitorReset(); const enableTimestamps = idfConf.readParameter( "idf.monitorEnableTimestamps", workspaceRoot @@ -4218,6 +4195,35 @@ function createMonitor() { }); } +/** + * Determines if the monitor reset should be disabled. + * If flash encryption is enabled for release mode, we add --no-reset flag for monitoring + * because by default monitoring command resets the device which is not recommended. + * Reset should happen by Bootloader itself once it completes encrypting all artifacts. + * + * @returns {Promise} True if monitor reset should be disabled, false otherwise. + */ +const shouldDisableMonitorReset = async (): Promise => { + const configNoReset = idfConf.readParameter( + "idf.monitorNoReset", + workspaceRoot + ); + + if (configNoReset === true) { + return true; + } + + if (isFlashEncryptionEnabled(workspaceRoot)) { + const valueReleaseModeEnabled = await utils.getConfigValueFromSDKConfig( + "CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE", + workspaceRoot + ); + return valueReleaseModeEnabled === "y"; + } + + return false; +}; + async function createIdfMonitor( noReset: boolean = false, enableTimestamps: boolean = false,