-
Notifications
You must be signed in to change notification settings - Fork 107
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
Connect ESP32-S2 built-in USB_CDC Error: Timeout #38
Comments
When try to do it again:
|
I am facing exactly the same error, is there an update on this? In my case, it decides to randomly work one in 10 times. |
Same here. Any stub or baud rate eventually times-out sometime during Same, Is there anything I'm doing wrong? Example Invoking Update Function: export const updateDFUDeviceTest = async (
devType = DFUDeviceTypes.TESTDevice,
erase = false,
newFirmware?: File,
offset?: number
) => {
console.log("Updating Device FW!");
// const romBaudRate = 115200;
//Attempt to get the most recent firmware
if (devType.getUpdatedFirmware) {
const updates = await devType.getUpdatedFirmware();
devType = { ...devType, ...updates };
if (devType.firmwareFile)
console.log(`Updated Firmware is ${devType.firmwareFile.name}`);
}
try {
// Look for devices in DFU mode
const port = await navigator.serial.requestPort({
filters: webSerialDFUDeviceFilters,
});
if (!port) throw new Error("No DFU Device");
const loader = new ESPLoader(
new Transport(port),
devType.programBaud,
undefined,
devType.romBaud
);
loader.MAX_TIMEOUT = 2000;
await loader.connect(devType.connectResetMode, 10, false);
// Get the Chip's STA MAC ADDRESS (SERIAL NUMBER)
const name = loader.chip.CHIP_NAME;
const sizes = Object.keys(loader.chip.FLASH_SIZES).join(",");
console.log(`Connected to ${name} with Flash Sizes: ${sizes}`);
const desc = await loader.chip.get_chip_description(loader);
if (desc !== "ESP32-S2FH32") throw new Error("Not a Synergy ESP32-S2");
console.log(`Devie Description matches Synergy: ${desc}`);
const freq = await loader.chip.get_crystal_freq(loader);
console.log(`CPU Cryastal Freq: ${freq}Mhz`);
const features = (await loader.chip.get_chip_features(loader)).join(",");
console.log(`Chip Features: ${features}`);
const mac = await loader.chip.read_mac(loader);
console.log(`Chip STA MAC Address (USB S/N): ${mac}`);
// Load default bin files into our command
const flashSections = [] as { address: number; data: string }[];
if (devType.bootloaderFile) {
const bBA = await devType.bootloaderFile.arrayBuffer();
const bBytesString = new TextDecoder().decode(bBA);
console.log(
`Using Bootloader Image ${devType.bootloaderFile.name} at 0x${
devType.bootloaderOffset?.toString(16) || 0
}`
);
flashSections.push({
address: devType.bootloaderOffset || 0x1000,
data: bBytesString,
});
}
if (devType.partitionsMapFile) {
const pBA = await devType.partitionsMapFile.arrayBuffer();
const pBytesString = new TextDecoder().decode(pBA);
console.log(
`Using Partition Table Image ${devType.partitionsMapFile.name} at 0x${
devType.partitionsMapOffset?.toString(16) || 0
}`
);
flashSections.push({
address: devType.partitionsMapOffset || 0x8000,
data: pBytesString,
});
}
if (devType.uf2AppFile) {
const uBA = await devType.uf2AppFile.arrayBuffer();
const uBytesString = new TextDecoder().decode(uBA);
console.log(
`Using UF2 Update App Image ${devType.uf2AppFile.name} at 0x${
devType.uf2AppOffset?.toString(16) || 0
}`
);
flashSections.push({
address: devType.uf2AppOffset || 0x2d000,
data: uBytesString,
});
}
// Override firmware file with argument if needed
if (newFirmware) {
const byteArray = await newFirmware.arrayBuffer();
const bytesString = new TextDecoder().decode(byteArray);
console.log(
`Overriding Firmware With New Image ${newFirmware.name} at 0x${
offset?.toString(16) || 0x10000
}`
);
flashSections.push({
address: offset || 0x10000,
data: bytesString,
});
} else if (devType.firmwareFile && !newFirmware) {
// Just use the default file firmware for the device
const fwBA = await devType.firmwareFile.arrayBuffer();
const fwBytesString = new TextDecoder().decode(fwBA);
console.log(
`Using Firmware Image ${devType.firmwareFile.name} at 0x${
devType.firmwareOffset?.toString(16) || 0
}`
);
flashSections.push({
address: devType.firmwareOffset || 0x10000,
data: fwBytesString,
});
}
if (flashSections.length == 0) {
throw new Error("No files to flash!");
}
await sleep(100);
await loader.write_flash(
flashSections,
devType.flashSize,
devType.flashMode,
devType.flashFreq,
erase
);
} catch (e) {
if (e instanceof Error) {
console.warn(`Error: ${e.message}`);
}
}
}; Consistently produces the result:
|
You are doing nothing wrong. Flashing S2 via CDC does not work with esptool.js |
Is there activity and if yes when can a fix be expected? |
@Jason2866 At the moment, no one from Espressif is working on this issue. The main reason why this type of issues doesn't get resolved quickly is that they require someone with deep knowledge of both ESP boot and with web development skills (JS/TS) to contribute. Since these two topics are pretty far apart, people with both of these skills are hard to come by. I think after #107 it will get easier to compare the traces against esptool.py implementation, so issues like this will get easier to troubleshoot. Then the task will become somewhat simpler. Instead of "figure out why this timeout is happening" it will be something like "change this code so that it produces the same trace as that reference implementation". Longer term, the plan is to get the whole flashing algorithm from https://github.com/esp-rs/espflash (compiled to WebAssembly) and hide it behind the same-ish API as we have now. This way we will have to troubleshoot fewer independent implementations of the flashing protocol, which means fewer issues or faster response times. |
@igrr Thank you for this infos. Knowing the reasons why "something" makes no visible process does help ;-) |
Hello @Jason2866 @musicmindmachine @danielminson @newpsgo @Wind-stormger @jonasniesner Have you guys tried the latest master to see if this issue is fixed ? There is a now a tracing feature to track the communication too. Please check the live example. |
I have similar issue
|
@brianignacio5 After cloning and building the main branch, and running the TS example, I can confirm that I still get a timeout when trying to connect to an ESP32-S2. EDIT: I just noticed, that the detected chip is slightly wrong with the js tool:
Compared to python:
|
esptool.js v0.1-dev
Serial port WebSerial VendorID 0x303a ProductID 0x2
Connecting.........._
Detecting chip type... ESP32-S2
Chip is ESP32-S2
Features: Wi-Fi
Crystal is 40MHz
MAC: 68:67:25:2d:f4:0c
Uploading stub...
Error: Timeout
The text was updated successfully, but these errors were encountered: