Skip to content

Commit

Permalink
Add no reset flag if realease mode is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
radurentea committed Sep 11, 2024
1 parent 0406553 commit 47b9390
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -4054,7 +4034,7 @@ const buildFlashAndMonitor = async (runMonitor: boolean = true) => {
monitorTerminal.sendText(ESP.CTRL_RBRACKET);
monitorTerminal.sendText(`exit`);
}
createMonitor();
await createMonitor();
}
}
);
Expand Down Expand Up @@ -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
Expand All @@ -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<boolean>} True if monitor reset should be disabled, false otherwise.
*/
const shouldDisableMonitorReset = async (): Promise<boolean> => {
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,
Expand Down

0 comments on commit 47b9390

Please sign in to comment.