Conversation
7fcaad3 to
f8f860c
Compare
|
My initial assumption that responses are up to 44 bytes long clearly was incorrect. However, I assume that response cannot be longer than the entire flash memory, so I bounded it by 5Mi now. |
0b4c554 to
e065772
Compare
|
Using 8MiB as a static upper bound still causes the tool to hang -- apparently, reading 8MiB one-by-one takes a while. So I've added max response length guessing based of the
Apparently, this is enough to both pass the CI and solve the issue. Please let me know what you think. |
SergioGasquez
left a comment
There was a problem hiding this comment.
Changes look good to me, but they introduce major breaking changes. There are two options:
- Restoring
read_response, marking it as deprecated and adding two new functions - Waiting for the espflash@v5 development to get this merged
b902a06 to
7a161c5
Compare
| const FLASH_DEFLATE_END_TIMEOUT: Duration = Duration::from_secs(10); | ||
| const FLASH_MD5_TIMEOUT_PER_MB: Duration = Duration::from_secs(8); | ||
|
|
||
| const SYNC_MAX_LEN: u64 = 44; |
There was a problem hiding this comment.
Maybe we should add a comment about why you chose 44
|
Hello @Dzuchun! Would you like to continue working on this PR or you would prefer me to add the two last changes and merge it? |
|
Sorry for the long delay. A lot had happended, including a complete workstation change. So now I can't even check if the problem still occurs, or if the fix is still applicable. I don't have a good source for why I've chosen Pulled the main branch and made the requested changes, to the best of my abillity. |
they are only used by the `connection` module, and I assume CI gets angry because of that
|
I am sorry, but I have no idea as of what would be the real cause here, and why it occurs on esp32 with UART specifically. Maybe some vector response gets stuck in the buffer, and https://github.com/esp-rs/espflash/actions/runs/24286820167/job/70917563010?pr=1007 UPD: slip has the convept of escapes, but from what I could see in the code, this can at most double the received data length. Doubling all the max lengths did not help. |
Reruning the HIL test made it green, not sure what happened on that run, but tried it several times now and it passes the test. |
|
@Dzuchun could you rebase the PR so its mergeable? |
I've encountered an issue with the same symptoms as #989, except in my case
espflashwould sometimes start working again after re-plugging the cable.I reproduced the issue on the
mainbranch, and traced to core reason -- when sending theSynccommand,slip-codec's decoder appeared to be stuck reading bytes indefinitely here. Specifically -- byte0x0awould be read indefinitely, never terminating the loop.So I've added a byte count bounded variant of
Connection::read(Connection::read_bounded), and used it to read the response(right now, the code expects responses of at most.44bytes, so that was selected as an upper bound)I also removed the claim that response is read with the timeout -- I am sure I've spent more than 100ms waiting for the
Synccommand to complete. My guess is that reading0x0afrom the port overrides the timeout, and thus the command itself never times out. This change is questionable, let me know if I should revert it, or...?The tool works fine for me now -- ELF gets flashed every time.
As you could probably tell, I have little knowledge of what's actually going on. So I would appreciate extra attention to make sure this change doesn't actually break anything.