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

Easier recovery from soft bricked native USB boards #2173

Merged
merged 3 commits into from
May 18, 2023

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented May 8, 2023

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

This PR should make it easier to recover from soft-bricked boards with native USB (in cases where the serial port is unavailable because the bootloader has a too-short timeout).

What is the current behavior?

Trying the upload without a port selected would cause the upload to immediately fail, without leaving any room for the user to synchronize with the upload by tapping the reset button. See #1943 for more details.

What is the new behavior?

The upload should wait a reasonable amount of time for the user to tap the reset button and make the bootloader avaiable.

Does this PR introduce a breaking change, and is titled accordingly?

No, in theory...

Other information

Fix #1943

@cmaglie cmaglie self-assigned this May 8, 2023
@cmaglie cmaglie added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels May 8, 2023
@cmaglie cmaglie added this to the Arduino CLI 0.33.0 milestone May 8, 2023
@codecov
Copy link

codecov bot commented May 8, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (03159d1) 62.61% compared to head (7e8cc09) 62.64%.

❗ Current head 7e8cc09 differs from pull request most recent head cbdb3b0. Consider uploading reports for the commit cbdb3b0 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2173      +/-   ##
==========================================
+ Coverage   62.61%   62.64%   +0.03%     
==========================================
  Files         223      223              
  Lines       19489    19498       +9     
==========================================
+ Hits        12203    12215      +12     
+ Misses       6200     6198       -2     
+ Partials     1086     1085       -1     
Flag Coverage Δ
unit 62.64% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arduino/serialutils/serialutils.go 68.33% <100.00%> (+0.53%) ⬆️
commands/upload/upload.go 74.25% <100.00%> (+0.97%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@umbynos
Copy link
Contributor

umbynos commented May 12, 2023

CLI 0.32.2:

❰umberto❙~/Downloads/arduino-cli_test-2173-c626c5af87608b229e9993ddc68e60f59ee8d65d-git-snapshot_Linux_64bit❱✔≻ arduino-cli compile -b arduino:avr:micro -u soft_brick/ -p /dev/ttyACM0 
Sketch uses 3464 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44


Used platform Version Path                                                        
arduino:avr   1.8.6   /home/umberto/.arduino15/packages/arduino/hardware/avr/1.8.6
❰umberto❙~/Downloads/arduino-cli_test-2173-c626c5af87608b229e9993ddc68e60f59ee8d65d-git-snapshot_Linux_64bit❱✔≻ ./arduino-cli board list
Port         Protocol Type              Board Name FQBN Core
/dev/ttyUSB0 serial   Serial Port (USB) Unknown             

❰umberto❙~/Downloads/arduino-cli_test-2173-c626c5af87608b229e9993ddc68e60f59ee8d65d-git-snapshot_Linux_64bit❱✔≻ arduino-cli compile -b arduino:avr:micro /opt/arduino-1.8.13/examples/01.Basics/Blink/Blink.ino -u
Sketch uses 3958 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Error during Upload: Failed uploading: no upload port provided

CLI from this PR:

./arduino-cli compile -b arduino:avr:micro -u soft_brick/ -p /dev/ttyACM0
Sketch uses 3464 bytes (12%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44


Used platform Version Path                                                        
arduino:avr   1.8.6   /home/umberto/.arduino15/packages/arduino/hardware/avr/1.8.6
❰umberto❙~/Downloads/arduino-cli_test-2173-c626c5af87608b229e9993ddc68e60f59ee8d65d-git-snapshot_Linux_64bit❱✔≻ ./arduino-cli board list
Port         Protocol Type              Board Name FQBN Core
/dev/ttyUSB0 serial   Serial Port (USB) Unknown             

❰umberto❙~/Downloads/arduino-cli_test-2173-c626c5af87608b229e9993ddc68e60f59ee8d65d-git-snapshot_Linux_64bit❱✔≻ ./arduino-cli compile -b arduino:avr:micro /opt/arduino-1.8.13/examples/01.Basics/Blink/Blink.ino -u
Sketch uses 3958 bytes (13%) of program storage space. Maximum is 28672 bytes.
Global variables use 149 bytes (5%) of dynamic memory, leaving 2411 bytes for local variables. Maximum is 2560 bytes.
Skipping 1200-bps touch reset: no serial port selected!
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
    Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.

Programmer supports the following devices:
    Device code: 0x44


Used platform Version Path                                                        
arduino:avr   1.8.6   /home/umberto/.arduino15/packages/arduino/hardware/avr/1.8.6

@cmaglie cmaglie force-pushed the easier_native_usb_recovery branch from 7e8cc09 to cbdb3b0 Compare May 15, 2023 14:35
@cmaglie cmaglie requested a review from umbynos May 15, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Recovery of soft bricked native USB boards w/o double-tap impossible without port selection
2 participants