Skip to content

Commit

Permalink
Windows: Set RTS before DTR to avoid issues (#562)
Browse files Browse the repository at this point in the history
* windows usb serial workaround: set dtr after rts

* feat: Set rts before dtr for UsbJtagSerialReset

* docs: Update changelog

---------

Co-authored-by: Hailey Somerville <[email protected]>
  • Loading branch information
SergioGasquez and haileys authored Feb 1, 2024
1 parent 2f3d110 commit d7f800e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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 @@ -101,24 +101,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 @@ -179,13 +179,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 @@ -195,8 +195,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

0 comments on commit d7f800e

Please sign in to comment.