diff --git a/cargo-espflash/src/main.rs b/cargo-espflash/src/main.rs index f3275cee..e57296bd 100644 --- a/cargo-espflash/src/main.rs +++ b/cargo-espflash/src/main.rs @@ -240,7 +240,13 @@ fn flash( if opts.flash_opts.monitor { let pid = flasher.get_usb_pid()?; - monitor(flasher.into_serial(), Some(&elf_data), pid).into_diagnostic()?; + monitor( + flasher.into_serial(), + Some(&elf_data), + pid, + opts.connect_opts.monitor_speed.unwrap_or(115200), + ) + .into_diagnostic()?; } Ok(()) diff --git a/espflash/README.md b/espflash/README.md index 3573739e..f64d5050 100644 --- a/espflash/README.md +++ b/espflash/README.md @@ -43,6 +43,9 @@ OPTIONS: --monitor Open a serial monitor after flashing + --monitor-speed + Baud rate at which to read console output + --partition-table Path to a CSV file containing partition table diff --git a/espflash/src/cli/mod.rs b/espflash/src/cli/mod.rs index b53c0fbe..fd4ab7e2 100644 --- a/espflash/src/cli/mod.rs +++ b/espflash/src/cli/mod.rs @@ -41,6 +41,10 @@ pub struct ConnectOpts { #[clap(long)] pub speed: Option, + /// Baud rate at which to read console output + #[clap(long)] + pub monitor_speed: Option, + /// Use RAM stub for loading #[clap(long)] pub use_stub: bool, @@ -161,7 +165,14 @@ pub fn board_info(opts: ConnectOpts, config: Config) -> Result<()> { pub fn serial_monitor(opts: ConnectOpts, config: Config) -> Result<()> { let flasher = connect(&opts, &config)?; let pid = flasher.get_usb_pid()?; - monitor(flasher.into_serial(), None, pid).into_diagnostic()?; + + monitor( + flasher.into_serial(), + None, + pid, + opts.monitor_speed.unwrap_or(115200), + ) + .into_diagnostic()?; Ok(()) } diff --git a/espflash/src/cli/monitor.rs b/espflash/src/cli/monitor.rs index f38e4738..56e104e8 100644 --- a/espflash/src/cli/monitor.rs +++ b/espflash/src/cli/monitor.rs @@ -87,6 +87,7 @@ pub fn monitor( mut serial: Box, elf: Option<&[u8]>, pid: u16, + baud: u32, ) -> serialport::Result<()> { println!("Commands:"); println!(" CTRL+R Reset chip"); @@ -95,7 +96,7 @@ pub fn monitor( // Explicitly set the baud rate when starting the serial monitor, to allow using // different rates for flashing. - serial.set_baud_rate(115_200)?; + serial.set_baud_rate(baud)?; serial.set_timeout(Duration::from_millis(5))?; let _raw_mode = RawModeGuard::new(); diff --git a/espflash/src/main.rs b/espflash/src/main.rs index 14caa7fb..c1f419e2 100644 --- a/espflash/src/main.rs +++ b/espflash/src/main.rs @@ -177,7 +177,14 @@ fn flash(opts: Opts, config: Config) -> Result<()> { if opts.flash_opts.monitor { let pid = flasher.get_usb_pid()?; - monitor(flasher.into_serial(), Some(&elf_data), pid).into_diagnostic()?; + + monitor( + flasher.into_serial(), + Some(&elf_data), + pid, + opts.connect_opts.monitor_speed.unwrap_or(115200), + ) + .into_diagnostic()?; } Ok(())