-
Notifications
You must be signed in to change notification settings - Fork 130
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
Fix flasher::sync
#123
Fix flasher::sync
#123
Conversation
* `connection::read` now loops until all data have been read * connection is flushed between `Command::Sync` sent and response is read * Fixes esp-rs#116
What will happen if I try to connect, but there is no ESP32 attached to my usb-serial adapter? Do we just hang in the infinite loop? If yes, doing that inside a retry-100-times loop seems a bit risky. Other than that, I like how much simpler this patch is! |
Thanks! #117 worked nearly perfectly, but would sometimes get into a unrecoverable state. I've tried with this PR over 30 times and its working perfectly every time. @bugadani is correct though, we shouldn't retry in an infinite loop. We should probably time out after X milliseconds, I'm not sure one what a good value of X is, perhaps we could look at the esptool.py source or just eyeball it. |
From DEFAULT_TIMEOUT = 3 # timeout for most flash operations
START_FLASH_TIMEOUT = 20 # timeout for starting flash (may perform erase)
CHIP_ERASE_TIMEOUT = 120 # timeout for full chip erase
MAX_TIMEOUT = CHIP_ERASE_TIMEOUT * 2 # longest any command can run
SYNC_TIMEOUT = 0.1 # timeout for syncing with bootloader I would imagine |
I guess my real question is: is the flush a sufficient fix? Because if it is, we can keep the |
@bugadani I've added logging of read size earlier, it was reading in x12 chunks on my ESP32 devkit (12 and 24 bytes at a time), so looks like it should be enough for its current task. If there is no device on the other end, we will receive timeout error and it will be returned via |
The other situation I can imagine is when device responds slowly, then it may loop in iterations just shy of timeout, then |
You're right, it times out. I wasn't sure about it (I had to try & see, sorry :) ). Well then, thanks for fixing what I couldn't :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this seems to improve the success rate of flashing, I'm just going to go ahead and merge it as is. I do prefer not maintaining internal buffer state if it's not necessary.
There has been a fair amount of discussion regarding this, so I will leave the associated issue for the time being. Please move any further discussion to #116.
connection::read
now loops until all data have been readCommand::Sync
sent and response is readconnection::read
changes are not required, addingflush()
is enough, but buffering with shared state looks unnecessary anyway.Should I rollback it, or this is fine?