Skip to content

Commit

Permalink
Support: Add support of proper console baudrate for chips with 26MHz …
Browse files Browse the repository at this point in the history
…frequency. (espressif#58)

Co-authored-by: Rushikesh Patange <rushikesh.patange@espressif.com>
  • Loading branch information
RushikeshPatange and Rushikesh Patange committed Feb 6, 2024
1 parent ca01866 commit 86c44a3
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 25 deletions.
4 changes: 3 additions & 1 deletion config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ image.esp32-c3 = "SINGLE_BIN_FOR_ESP32-C3.bin"
android_app_url = ""
ios_app_url = ""
# Optional: URL of the Markdown file for additional information about the app
readme.text = "<URL to your Markdown file>"
readme.text = "<URL to your Markdown file>"
# Optional: Supported console baudrate for app firmware (default value is 115200)
console_baudrate = <SUPPORTED_CONSOLE_BAUDRATE>
21 changes: 15 additions & 6 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ let device = null;
let transport = undefined;
let chip = "default";
let chipDesc = "default";
let consoleBaudrateFromToml;
let esploader;
let connected = false;
let ios_app_url = "";
Expand Down Expand Up @@ -137,6 +138,10 @@ function buildQuickTryUI_v1_0() {
if (config[supported_apps[0]].readme?.text) {
markdown_payload_url = config[supported_apps[0]].readme.text;
}

if (config[supported_apps[0]].console_baudrate) {
consoleBaudrateFromToml = config[supported_apps[0]].console_baudrate;
}
}
setAppURLs(config[supported_apps[0]]);
}
Expand Down Expand Up @@ -227,6 +232,10 @@ $('#device').on('change', function() {
} else {
markdown_payload_url = "";
}

if (config[deviceTypeSelect.value].console_baudrate) {
consoleBaudrateFromToml = config[deviceTypeSelect.value].console_baudrate;
}
});

$(function () {
Expand Down Expand Up @@ -263,10 +272,10 @@ async function connectToDevice() {
};
esploader = new ESPLoader(loaderOptions);
connected = true;
chipDesc = await esploader.main_fn();
chipDesc = await esploader.main();
chip = esploader.chip.CHIP_NAME;

await esploader.flash_id();
await esploader.flashId();
} catch(e) {
}

Expand Down Expand Up @@ -319,7 +328,7 @@ resetButton.onclick = async () => {
await device.close();
}
}
await transport.connect();
await transport.connect(consoleBaudrateFromToml);
await transport.setDTR(false);
await new Promise(resolve => setTimeout(resolve, 100));
await transport.setDTR(true);
Expand Down Expand Up @@ -350,7 +359,7 @@ eraseButton.onclick = async () => {
terminalContainer.classList.remove("fade-in-down");
eraseButton.disabled = true;
$('#v-pills-console-tab').click();
await esploader.erase_flash();
await esploader.eraseFlash();
postFlashDone();
eraseButton.disabled = false;
}
Expand Down Expand Up @@ -511,7 +520,7 @@ programButton.onclick = async () => {
eraseAll: false,
compress: true,
};
await esploader.write_flash(flashOptions);
await esploader.writeFlash(flashOptions);
postFlashDone();
terminalContainer.classList.remove("fade-in-down");
} catch (e) {
Expand All @@ -531,7 +540,7 @@ async function downloadAndFlash(fileURL) {
eraseAll: false,
compress: true,
};
await esploader.write_flash(flashOptions);
await esploader.writeFlash(flashOptions);
}
} catch (e) {
}
Expand Down
10 changes: 6 additions & 4 deletions minimal-launchpad/minimal_ui_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ let device = null;
let transport;
let chip = "default";
let chipDesc = "default";
let consoleBaudrateFromToml;
let esploader;
let connected = false;
let resizeTimeout = false;
Expand Down Expand Up @@ -92,7 +93,7 @@ async function downloadAndFlash() {
eraseAll: true, // Always erasing before flash
compress: true,
};
await esploader.write_flash(flashOptions);
await esploader.writeFlash(flashOptions);
} catch (error) {
errorTroubleshootModalToggleButton.click();
waitButton.style.display = "none";
Expand Down Expand Up @@ -232,14 +233,14 @@ async function connectToDevice() {
esploader = new ESPLoader(loaderOptions);
connected = true;

chipDesc = await esploader.main_fn();
chipDesc = await esploader.main();
clearTimeout(deviceConnectionTimeout);
if (errorTroubleshootModal.classList.contains("show")) {
errorTroubleshootModalToggleButton.click();
}
chip = esploader.chip.CHIP_NAME;

await esploader.flash_id();
await esploader.flashId();
} catch (error) {
clearTimeout(deviceConnectionTimeout);
if (!errorTroubleshootModal.classList.contains("show")) {
Expand Down Expand Up @@ -300,7 +301,8 @@ consoleStartButton.onclick = async () => {
if (config.portConnectionOptions?.length) {
await transport.connect(parseInt(config.portConnectionOptions[0]?.baudRate), serialOptions);
} else {
await transport.connect();
consoleBaudrateFromToml = config[config['supported_apps'][0]].console_baudrate;
await transport.connect(consoleBaudrateFromToml);
}
await transport.setDTR(false);
await new Promise(resolve => setTimeout(resolve, 100));
Expand Down
108 changes: 95 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "esp-launchpad",
"dependencies": {
"crypto-js": "^4.1.1",
"esptool-js": "^0.3.2",
"esptool-js": "^0.4.1",
"smol-toml": "^1.1.2",
"xterm": "^4.17.0",
"xterm-addon-fit": "^0.5.0"
Expand Down

0 comments on commit 86c44a3

Please sign in to comment.