Skip to content

Windows: Set RTS before DTR to avoid issues #562

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

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use partition table instead of hard-coded values for the location of partitions (#516)
- Fixed a missed `flush` call that may be causing communication errors (#521)
- Fix "SHA-256 comparison failed: [...] attempting to boot anyway..." (#567)
- Windows: Update RST/DTR order to avoid issues.

### Changed
- Created `FlashData`, `FlashDataBuilder` and `FlashSettings` structs to reduce number of input arguments in some functions (#512, #566)
Expand Down
16 changes: 8 additions & 8 deletions espflash/src/connection/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,24 @@ impl ResetStrategy for ClassicReset {
"Using Classic reset strategy with delay of {}ms",
self.delay
);
self.set_dtr(interface, false)?;
self.set_rts(interface, false)?;
self.set_dtr(interface, false)?;

self.set_dtr(interface, true)?;
self.set_rts(interface, true)?;
self.set_dtr(interface, true)?;

self.set_dtr(interface, false)?; // IO0 = HIGH
self.set_rts(interface, true)?; // EN = LOW, chip in reset
self.set_dtr(interface, false)?; // IO0 = HIGH

sleep(Duration::from_millis(100));

self.set_dtr(interface, true)?; // IO0 = LOW
self.set_rts(interface, false)?; // EN = HIGH, chip out of reset
self.set_dtr(interface, true)?; // IO0 = LOW

sleep(Duration::from_millis(self.delay));

self.set_dtr(interface, false)?; // IO0 = HIGH, done
self.set_rts(interface, false)?;
self.set_dtr(interface, false)?; // IO0 = HIGH, done

Ok(())
}
Expand Down Expand Up @@ -170,13 +170,13 @@ impl ResetStrategy for UsbJtagSerialReset {
fn reset(&self, interface: &mut Interface) -> Result<(), Error> {
debug!("Using UsbJtagSerial reset strategy");

self.set_dtr(interface, false)?; // Idle
self.set_rts(interface, false)?;
self.set_dtr(interface, false)?; // Idle

sleep(Duration::from_millis(100));

self.set_dtr(interface, true)?; // Set IO0
self.set_rts(interface, false)?;
self.set_dtr(interface, true)?; // Set IO0

sleep(Duration::from_millis(100));

Expand All @@ -186,8 +186,8 @@ impl ResetStrategy for UsbJtagSerialReset {

sleep(Duration::from_millis(100));

self.set_dtr(interface, false)?;
self.set_rts(interface, false)?;
self.set_dtr(interface, false)?;

Ok(())
}
Expand Down