Skip to content

Conversation

bugadani
Copy link
Contributor

@bugadani bugadani commented Sep 12, 2025

Some terrible timer+signal hackery but this seems to be the recommended way in case tcdrain blocks indefinitely.

I've also added a bit of a flush-throttling so that we're not completely swamped by timeouting blocking calls on every keypress if the user mashes the keyboard.

The reason for all this is that nothing moves the data out of the USB endpoing on the device, so it doesn't accept new data.

I don't feel qualified, prepared or well enough equipped to try this on macOS.

cc #681

@bugadani bugadani changed the title Fix hanging terminall Fix hanging terminal Sep 12, 2025
@bugadani bugadani force-pushed the crash branch 2 times, most recently from cca3622 to e05601d Compare September 12, 2025 13:32
@bugadani bugadani marked this pull request as ready for review September 12, 2025 13:32
@bugadani bugadani changed the title Fix hanging terminal [Linux] Fix hanging terminal Sep 12, 2025
Copy link
Member

@SergioGasquez SergioGasquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Just tried it and works perfectly! Ill try to understand whats going on on Monday

@sirhcel
Copy link
Contributor

sirhcel commented Sep 14, 2025

I don't feel qualified, prepared or well enough equipped to try this on macOS.

Kudos for this deep dive @bugadani! I'm sorry that did not manage to to look deeper into it so far, but I gave the fix from this PR a spin on macOS 15.6 on a M1 machine. I still end up in a locked state after about ten key strokes in the monitor.

@bugadani
Copy link
Contributor Author

Thanks for trying! I think it's not too surprising that a 1:1 port doesn't work - it took me quite a bit of trial and error to figure out something working. Can you perhaps share your code? Maybe it's a good enough start to work on.

@sirhcel
Copy link
Contributor

sirhcel commented Sep 14, 2025

Can you perhaps share your code?

I just ran espflash as of e05601d on macOS as follows:

$ cargo run -- flash --monitor test.elf

There was no bespoke code involved.

@bugadani
Copy link
Contributor Author

Ah all the workarounds here are gated for linux (macos has a different timer API), and the small throttling shouldn't really affect much if the second flush never returns :)

Copy link
Member

@SergioGasquez SergioGasquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Im trying to investigate and port this changes to MacOS!

Edit: Mind rebasing your changes to resolve the conflict?

@SergioGasquez SergioGasquez added this pull request to the merge queue Sep 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 15, 2025
@bugadani bugadani added this pull request to the merge queue Sep 15, 2025
Merged via the queue into main with commit 1e34651 Sep 15, 2025
41 checks passed
@bugadani bugadani deleted the crash branch September 15, 2025 12:02
@SergioGasquez SergioGasquez linked an issue Sep 16, 2025 that may be closed by this pull request
@sirhcel
Copy link
Contributor

sirhcel commented Sep 16, 2025

Ah all the workarounds here are gated for linux (macos has a different timer API), and the small throttling shouldn't really affect much if the second flush never returns :)

I'm sorry for the noise! I misread the description that this PR also applies to macOS and did not notice the gating. Thank you for #947 @SergioGasquez!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

espflash monitor takes over the terminal
3 participants