-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
esptool via python code - Failed to enter Flash download mode. Only got 2 byte status response. (ESPTOOL-945) #1022
Comments
Duplicate here: https://esp32.com/viewtopic.php?f=13&t=42469 |
When you initialize the ESP32-S3 ROM sends 4 status bytes in a response (read here), but the stub flasher sends only 2 bytes.
If you inspect how |
Search for Btw, in the next release, we plan to make esptool easier to use as a Python module. Feel free to share more of your experience with writing a custom script using esptool. We'll take this as a feedback of the current state. |
@radimkarnis thank you for the quick reply. Happy to help provide feedback on flashing via code, if at least providing a concise example of how to flash through this effort here 👍 I'm getting further; I took you advise and I'm executing the commands via the stub.
I'm seeing the stub loader raising this error
I think I was getting this from an old example, possibly for an older version of esptool. Where would I look for an example of how to flash a region? |
Update, I think I have it working: Please advise if I'm doing it correctly, especially around if last block is handled correctly, since it will not be a whole block size:
|
In theory, this looks good, except for the last block handling. Esptool pads the last block with I would advise you to study the |
@radimkarnis Thank you for the feedback, I had a sense that last block might be an issue! In the spirit of making the library easier to use from code, I have a new, related question. Our workflow is this:
How we are triggering the bootloader via firmware:
Problem that happens:
demoesptool_flashing_after_soft_reboot-2024-10-29_07.39.34-ezgif.com-video-speed.1.mp4 |
I love the video and detailed issue report! I do not know the exact reason why this is happening, but I have a suspicion. Hopefully, you'll be able to find the culprit with my pointers: Do you really need the with detect_chip(try_port) as esp:
print(str(type(esp)))
esp.connect()
In your video, you can even see that the script works until you call Please see the logic for hard-resetting ESP32-S3. We found out, that it is impossible to exit the bootloader mode if a hard reset is performed (unplugging and plugging again while holding the BOOT button) in USB-Serial/JTAG mode. For this reason, the RTC WDT reset was introduced recently. There is logic to decide if an RTC WDT reset or a classic reset via RTS pin happens. In your case, maybe a different reset gets triggered in the two cases - one resulting in a reset back to the bootloader and the other resulting in running your firmware. I suggest adding a few print statements to see which one is being triggered. |
Thank you for the quick reply. Just confirmed, removing the extra .connect() does solve the problem! Our test script does seem to trigger the WDT reboot, so I trust that once the next version of esptool is released it will start working as expected. I will follow up with corrected example code that includes the 0xFF padding. Is there a place in your documentation this sample could be added to help others? I'll have to check to see how your documentation is designed, and if it is github based. I'll be happy to contribute it there. |
Here's the final example code. I can see where esptool could be updated to encapsulate this logic, but it's still pretty concise for people to use as-is.
|
Follow up: #1029 |
Operating System
Linux
Esptool Version
4.8.1
Python Version
3.11.9
Full Esptool Command Line that Was Run
N/A
Esptool Output
I'm trying to flash an ESP32-S3 within my python program. using esptool (4.8.1) I can successfully flash using the command line version of esptool.py:
However, my sample code (using the same esptool version) generates an error when calling esp.flash_begin():
Failed to enter Flash download mode. Only got 2 byte status response.
failing sample code
It works up until the flash_begin command:
I'm assuming there might be additional setup / configuration within the code, or there is a bug in esptool.
I have tested it successfully with this approach. However, I need to use a progress callback, so calling esptool.main() with args is not an option.
The text was updated successfully, but these errors were encountered: