File tree Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Expand file tree Collapse file tree 3 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -215,11 +215,25 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
215
215
216
216
if args. flash_args . monitor {
217
217
let pid = flasher. get_usb_pid ( ) ?;
218
+
219
+ let chip = flasher. chip ( ) ;
220
+ let target = chip. into_target ( ) ;
221
+
222
+ // The 26MHz ESP32-C2's need to be treated as a special case.
223
+ let default_baud = if chip == Chip :: Esp32c2
224
+ && !args. connect_args . use_stub
225
+ && target. crystal_freq ( & mut flasher. connection ( ) ) ? == 26
226
+ {
227
+ 74_880
228
+ } else {
229
+ 115_200
230
+ } ;
231
+
218
232
monitor (
219
233
flasher. into_interface ( ) ,
220
234
Some ( & elf_data) ,
221
235
pid,
222
- args. flash_args . monitor_baud . unwrap_or ( 115_200 ) ,
236
+ args. flash_args . monitor_baud . unwrap_or ( default_baud ) ,
223
237
)
224
238
. into_diagnostic ( ) ?;
225
239
}
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ use espflash::{
15
15
} ,
16
16
image_format:: ImageFormatKind ,
17
17
logging:: initialize_logger,
18
+ targets:: Chip ,
18
19
update:: check_for_update,
19
20
} ;
20
21
use log:: { debug, LevelFilter } ;
@@ -154,11 +155,24 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
154
155
if args. flash_args . monitor {
155
156
let pid = flasher. get_usb_pid ( ) ?;
156
157
158
+ let chip = flasher. chip ( ) ;
159
+ let target = chip. into_target ( ) ;
160
+
161
+ // The 26MHz ESP32-C2's need to be treated as a special case.
162
+ let default_baud = if chip == Chip :: Esp32c2
163
+ && !args. connect_args . use_stub
164
+ && target. crystal_freq ( & mut flasher. connection ( ) ) ? == 26
165
+ {
166
+ 74_880
167
+ } else {
168
+ 115_200
169
+ } ;
170
+
157
171
monitor (
158
172
flasher. into_interface ( ) ,
159
173
Some ( & elf_data) ,
160
174
pid,
161
- args. flash_args . monitor_baud . unwrap_or ( 115_200 ) ,
175
+ args. flash_args . monitor_baud . unwrap_or ( default_baud ) ,
162
176
)
163
177
. into_diagnostic ( ) ?;
164
178
}
Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ pub fn board_info(args: ConnectArgs, config: &Config) -> Result<()> {
285
285
286
286
/// Open a serial monitor
287
287
pub fn serial_monitor ( args : MonitorArgs , config : & Config ) -> Result < ( ) > {
288
- let flasher = connect ( & args. connect_args , config) ?;
288
+ let mut flasher = connect ( & args. connect_args , config) ?;
289
289
let pid = flasher. get_usb_pid ( ) ?;
290
290
291
291
let elf = if let Some ( elf_path) = args. elf {
@@ -297,11 +297,24 @@ pub fn serial_monitor(args: MonitorArgs, config: &Config) -> Result<()> {
297
297
None
298
298
} ;
299
299
300
+ let chip = flasher. chip ( ) ;
301
+ let target = chip. into_target ( ) ;
302
+
303
+ // The 26MHz ESP32-C2's need to be treated as a special case.
304
+ let default_baud = if chip == Chip :: Esp32c2
305
+ && !args. connect_args . use_stub
306
+ && target. crystal_freq ( & mut flasher. connection ( ) ) ? == 26
307
+ {
308
+ 74_880
309
+ } else {
310
+ 115_200
311
+ } ;
312
+
300
313
monitor (
301
314
flasher. into_interface ( ) ,
302
315
elf. as_deref ( ) ,
303
316
pid,
304
- args. connect_args . baud . unwrap_or ( 115_200 ) ,
317
+ args. connect_args . baud . unwrap_or ( default_baud ) ,
305
318
)
306
319
. into_diagnostic ( ) ?;
307
320
You can’t perform that action at this time.
0 commit comments