Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix espflash::write_bin #353

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Fix espflash::write_bin #353

merged 1 commit into from
Feb 15, 2023

Conversation

Rimpampa
Copy link
Contributor

I was encountering this error while using the espflash CLI utility, more specifically the write-bin subcommand:

> cargo run -p espflash -- write-bin 0x0 file.bin
[2023-02-14T08:08:28Z INFO ] Serial port: 'COM20'
[2023-02-14T08:08:28Z INFO ] Connecting...
[2023-02-14T08:08:28Z INFO ] Serial port: 'COM20'
[2023-02-14T08:08:28Z INFO ] Connecting...
Error: espflash::connection_failed

  x Failed to open serial port COM20
  |-> Failed to open serial port COM20
  |-> Error while connecting to device
  `-> Serial port not found
  help: Ensure that the device is connected and your host recognizes the serial adapter

And I found it strange that the serial port was being opened twice in a row, and by looking at the code I found the problem: board_info tries to open a new connection when a connect was already previously called.

Switching to print_board_info which reuses the same connection solved the problem

The problem with `write_bin` is that `board_info`, that was used instead of `print_board_info`, tries to open a new connection to the serial port and because a connection is made at the start of `write_bin`, when `board_info` gets called, it fails because the port is already being used
Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix, must have missed this back when I changed this last.

@jessebraham jessebraham merged commit 32bb951 into esp-rs:main Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants