File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737- ` address ` and ` size ` in ` erase-region ` have to be multiples of 4096 (#771 )
3838- Fixed typos in error variant names (#782 )
3939- Fix ` read-flash ` which didn't work with some lengths (#804 )
40+ - espflash can now flash an ESP32-S2 in download mode over USB (#813 )
4041
4142### Removed
4243
Original file line number Diff line number Diff line change @@ -181,16 +181,23 @@ impl Connection {
181181 // Reset the chip to bootloader (download mode)
182182 reset_strategy. reset ( & mut self . serial ) ?;
183183
184+ // S2 in USB download mode responds with 0 available bytes here
184185 let available_bytes = self . serial . bytes_to_read ( ) ?;
185- buff = vec ! [ 0 ; available_bytes as usize ] ;
186- let read_bytes = self . serial . read ( & mut buff) ? as u32 ;
187186
188- if read_bytes != available_bytes {
189- return Err ( Error :: Connection ( ConnectionError :: ReadMissmatch (
190- available_bytes,
191- read_bytes,
192- ) ) ) ;
193- }
187+ buff = vec ! [ 0 ; available_bytes as usize ] ;
188+ let read_bytes = if available_bytes > 0 {
189+ let read_bytes = self . serial . read ( & mut buff) ? as u32 ;
190+
191+ if read_bytes != available_bytes {
192+ return Err ( Error :: Connection ( ConnectionError :: ReadMissmatch (
193+ available_bytes,
194+ read_bytes,
195+ ) ) ) ;
196+ }
197+ read_bytes
198+ } else {
199+ 0
200+ } ;
194201
195202 let read_slice = String :: from_utf8_lossy ( & buff[ ..read_bytes as usize ] ) . into_owned ( ) ;
196203
You can’t perform that action at this time.
0 commit comments