Skip to content

Fix espflash::write_bin - #353

Merged
jessebraham merged 1 commit into
esp-rs:mainfrom
Rimpampa:patch-1
Feb 15, 2023
Merged

Fix espflash::write_bin#353
jessebraham merged 1 commit into
esp-rs:mainfrom
Rimpampa:patch-1

Conversation

@Rimpampa

Copy link
Copy Markdown
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

@jessebraham jessebraham left a comment

Copy link
Copy Markdown
Member

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