Skip to content

Commit

Permalink
Merge pull request #36 from RushikeshPatange/support/esp_c2_console_baud
Browse files Browse the repository at this point in the history
Support: Add Support Of Proper Console Baudrate For C2 Chipset
  • Loading branch information
RushikeshPatange committed Jan 31, 2024
2 parents ca01866 + 4e207e1 commit 5a3186b
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 24 deletions.
18 changes: 12 additions & 6 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,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 +319,13 @@ resetButton.onclick = async () => {
await device.close();
}
}
await transport.connect();

if (esploader.chip.CHIP_NAME === "ESP32-C2") {
await transport.connect(utilities.consoleBaudrateC2);
} else {
await transport.connect();
}

await transport.setDTR(false);
await new Promise(resolve => setTimeout(resolve, 100));
await transport.setDTR(true);
Expand Down Expand Up @@ -350,7 +356,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 +517,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 +537,7 @@ async function downloadAndFlash(fileURL) {
eraseAll: false,
compress: true,
};
await esploader.write_flash(flashOptions);
await esploader.writeFlash(flashOptions);
}
} catch (e) {
}
Expand Down
2 changes: 2 additions & 0 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export const usbPortFilters = [
{ usbVendorId: 0x0403, usbProductId: 0x6001 }, /* FT232R */
];

export const consoleBaudrateC2 = 74880; // supported console baudrate for C2

export function getTerminalColumns(mainContainer = null) {
const mainContainerWidth = mainContainer?.offsetWidth || 1320;
return Math.round(mainContainerWidth / 8.25);
Expand Down
12 changes: 8 additions & 4 deletions minimal-launchpad/minimal_ui_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 +232,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 +300,11 @@ consoleStartButton.onclick = async () => {
if (config.portConnectionOptions?.length) {
await transport.connect(parseInt(config.portConnectionOptions[0]?.baudRate), serialOptions);
} else {
await transport.connect();
if (esploader.chip.CHIP_NAME === "ESP32-C2") {
await transport.connect(utilities.consoleBaudrateC2);
} else {
await transport.connect();
}
}
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 5a3186b

Please sign in to comment.