Fix monitor after flash for ESP32-C2#330
Merged
jessebraham merged 3 commits intoesp-rs:mainfrom Jan 5, 2023
bjoernQ:bugfix/fix-esp32c2-monitor-after-flash
Merged
Fix monitor after flash for ESP32-C2#330jessebraham merged 3 commits intoesp-rs:mainfrom bjoernQ:bugfix/fix-esp32c2-monitor-after-flash
jessebraham merged 3 commits intoesp-rs:mainfrom
bjoernQ:bugfix/fix-esp32c2-monitor-after-flash
Conversation
Member
|
Thanks for cleaning up my mess 😁 This seems to have resolved the issue. Sorry to be a bother, but would you mind applying this patch as well which fixes diff --git a/cargo-espflash/src/main.rs b/cargo-espflash/src/main.rs
index 91ad64b..da8fc80 100644
--- a/cargo-espflash/src/main.rs
+++ b/cargo-espflash/src/main.rs
@@ -10,8 +10,8 @@ use espflash::{
cli::{
self, board_info, clap_enum_variants, config::Config, connect, erase_partitions,
flash_elf_image, monitor::monitor, parse_partition_table, partition_table,
- save_elf_as_image, serial_monitor, ConnectArgs, FlashConfigArgs, MonitorArgs,
- PartitionTableArgs,
+ print_board_info, save_elf_as_image, serial_monitor, ConnectArgs, FlashConfigArgs,
+ MonitorArgs, PartitionTableArgs,
},
image_format::ImageFormatKind,
logging::initialize_logger,
@@ -159,13 +159,14 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
let cargo_config = CargoConfig::load(&metadata.workspace_root, &metadata.package_root);
let mut flasher = connect(&args.connect_args, config)?;
- let build_ctx = build(&args.build_args, &cargo_config, flasher.chip())
- .wrap_err("Failed to build project")?;
+ print_board_info(&mut flasher)?;
- // Print the board information once the project has successfully built. We do
- // here rather than upon connection to show the Cargo output prior to the board
- // information, rather than breaking up cargo-espflash's output.
- board_info(&args.connect_args, config)?;
+ let chip = flasher.chip();
+ let target = chip.into_target();
+ let target_xtal_freq = target.crystal_freq(&mut flasher.connection())?;
+
+ let build_ctx =
+ build(&args.build_args, &cargo_config, chip).wrap_err("Failed to build project")?;
// Read the ELF data from the build path and load it to the target.
let elf_data = fs::read(build_ctx.artifact_path).into_diagnostic()?;
@@ -216,18 +217,13 @@ fn flash(args: FlashArgs, config: &Config) -> Result<()> {
if args.flash_args.monitor {
let pid = flasher.get_usb_pid()?;
- let chip = flasher.chip();
- let target = chip.into_target();
-
// The 26MHz ESP32-C2's need to be treated as a special case.
- let default_baud = if chip == Chip::Esp32c2
- && !args.connect_args.use_stub
- && target.crystal_freq(&mut flasher.connection())? == 26
- {
- 74_880
- } else {
- 115_200
- };
+ let default_baud =
+ if chip == Chip::Esp32c2 && !args.connect_args.use_stub && target_xtal_freq == 26 {
+ 74_880
+ } else {
+ 115_200
+ };
monitor(
flasher.into_interface(),
|
jessebraham
approved these changes
Jan 5, 2023
Member
jessebraham
left a comment
There was a problem hiding this comment.
Thanks for making those changes, LGTM!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--monitordidn't work for ESP32-C2 anymore