File tree 2 files changed +22
-6
lines changed 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 7
7
use std:: {
8
8
io:: { BufWriter , Write } ,
9
9
iter:: zip,
10
+ str:: from_utf8,
10
11
thread:: sleep,
11
12
time:: Duration ,
12
13
} ;
@@ -132,9 +133,14 @@ impl Connection {
132
133
Ok ( _) => {
133
134
return Ok ( ( ) ) ;
134
135
}
135
- Err ( e) => {
136
- debug ! ( "Failed to reset, error {:#?}, retrying" , e) ;
137
- }
136
+ Err ( e) => match e {
137
+ Error :: InvalidSerialRead => {
138
+ return Err ( Error :: InvalidSerialRead ) ;
139
+ }
140
+ _ => {
141
+ debug ! ( "Failed to reset, error {:#?}, retrying" , e) ;
142
+ }
143
+ } ,
138
144
}
139
145
}
140
146
@@ -168,7 +174,10 @@ impl Connection {
168
174
) ) ) ;
169
175
}
170
176
171
- let read_slice = std:: str:: from_utf8 ( & buff[ ..read_bytes as usize ] ) . unwrap ( ) ;
177
+ let read_slice = from_utf8 ( & buff[ ..read_bytes as usize ] ) . map_err ( |err| {
178
+ debug ! ( "Error: {}" , err) ;
179
+ Error :: InvalidSerialRead
180
+ } ) ?;
172
181
173
182
let pattern = Regex :: new ( r"boot:(0x[0-9a-fA-F]+)(.*waiting for download)?" ) . unwrap ( ) ;
174
183
Original file line number Diff line number Diff line change @@ -96,6 +96,13 @@ pub enum Error {
96
96
#[ error( "The provided bootloader binary is invalid" ) ]
97
97
InvalidBootloader ,
98
98
99
+ #[ error( "Invalid byte sequence read from the serial port while trying to detect Boot Mode" ) ]
100
+ #[ diagnostic(
101
+ code( espflash:: invalid_serial_read) ,
102
+ help( "This might be caused by a xtal frequency mismatch" )
103
+ ) ]
104
+ InvalidSerialRead ,
105
+
99
106
#[ error( "Specified bootloader path is not a .bin file" ) ]
100
107
#[ diagnostic( code( espflash:: invalid_bootloader_path) ) ]
101
108
InvalidBootloaderPath ,
@@ -104,8 +111,8 @@ pub enum Error {
104
111
#[ diagnostic(
105
112
code( espflash:: invalid_direct_boot) ,
106
113
help(
107
- "See the following page for documentation on how to set up your binary for direct boot:\
108
- https://github.com/espressif/esp32c3-direct-boot-example"
114
+ "See the following page for documentation on how to set up your binary for direct boot:\
115
+ https://github.com/espressif/esp32c3-direct-boot-example"
109
116
)
110
117
) ]
111
118
InvalidDirectBootBinary ,
You can’t perform that action at this time.
0 commit comments