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
37
37
- ` address ` and ` size ` in ` erase-region ` have to be multiples of 4096 (#771 )
38
38
- Fixed typos in error variant names (#782 )
39
39
- 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 )
40
41
41
42
### Removed
42
43
Original file line number Diff line number Diff line change @@ -181,16 +181,23 @@ impl Connection {
181
181
// Reset the chip to bootloader (download mode)
182
182
reset_strategy. reset ( & mut self . serial ) ?;
183
183
184
+ // S2 in USB download mode responds with 0 available bytes here
184
185
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 ;
187
186
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
+ } ;
194
201
195
202
let read_slice = String :: from_utf8_lossy ( & buff[ ..read_bytes as usize ] ) . into_owned ( ) ;
196
203
You can’t perform that action at this time.
0 commit comments