-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
Upload port detector improvements #2288
Conversation
…vided port This will ensure that a port is always returned.
Even if `waitForUploadPort` is true, we should extend the timeout to allow USB enumeration to complete. In this case we extend by only 1 second instead of 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works for me. Thank you 🙏
./arduino-cli version
arduino-cli Version: git-snapshot Commit: 7c77ed24 Date: 2023-08-31T08:53:35Z
cat ~/Documents/Arduino/minimal/minimal.ino
void setup() {}
void loop() {}
./arduino-cli compile -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal
Sketch uses 84080 bytes (8%) of program storage space. Maximum is 983040 bytes.
Global variables use 43968 bytes (16%) of dynamic memory, leaving 218176 bytes for local variables. Maximum is 262144 bytes.
Used platform Version Path
arduino:mbed_nano 4.0.4 /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/mbed_nano/4.0.4
./arduino-cli board list
Port Protocol Type Board Name FQBN Core
/dev/cu.BLTH serial Serial Port Unknown
/dev/cu.Bluetooth-Incoming-Port serial Serial Port Unknown
/dev/cu.usbmodem2 serial Serial Port (USB) Arduino Nano 33 BLE arduino:mbed_nano:nano33ble arduino:mbed_nano
./arduino-cli upload -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal -p /dev/cu.usbmodem2 --format json | jq .updated_upload_port
{
"address": "/dev/cu.usbmodem2",
"label": "/dev/cu.usbmodem2",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"properties": {
"pid": "0x805A",
"serialNumber": "131B9378799A643D",
"vid": "0x2341"
},
"hardware_id": "131B9378799A643D"
}
./arduino-cli board list
Port Protocol Type Board Name FQBN Core
/dev/cu.BLTH serial Serial Port Unknown
/dev/cu.Bluetooth-Incoming-Port serial Serial Port Unknown
/dev/cu.usbmodem14201 serial Serial Port (USB) Arduino Nano 33 BLE arduino:mbed_nano:nano33ble arduino:mbed_nano
./arduino-cli upload -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal -p /dev/cu.usbmodem14201 --format json | jq .updated_upload_port
{
"address": "/dev/cu.usbmodem14201",
"label": "/dev/cu.usbmodem14201",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"properties": {
"pid": "0x805A",
"serialNumber": "131B9378799A643D",
"vid": "0x2341"
},
"hardware_id": "131B9378799A643D"
}
./arduino-cli board list
Port Protocol Type Board Name FQBN Core
/dev/cu.BLTH serial Serial Port Unknown
/dev/cu.Bluetooth-Incoming-Port serial Serial Port Unknown
/dev/cu.usbmodem14301 serial Serial Port (USB) Arduino Nano 33 BLE arduino:mbed_nano:nano33ble arduino:mbed_nano
./arduino-cli upload -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal -p /dev/cu.usbmodem14301 --format json | jq .updated_upload_port
{
"address": "/dev/cu.usbmodem14301",
"label": "/dev/cu.usbmodem14301",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"properties": {
"pid": "0x805A",
"serialNumber": "131B9378799A643D",
"vid": "0x2341"
},
"hardware_id": "131B9378799A643D"
}
./arduino-cli board list
Port Protocol Type Board Name FQBN Core
/dev/cu.BLTH serial Serial Port Unknown
/dev/cu.Bluetooth-Incoming-Port serial Serial Port Unknown
/dev/cu.usbmodem14401 serial Serial Port (USB) Arduino Nano 33 BLE arduino:mbed_nano:nano33ble arduino:mbed_nano
./arduino-cli upload -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal -p /dev/cu.usbmodem14401 --format json | jq .updated_upload_port
{
"address": "/dev/cu.usbmodem14401",
"label": "/dev/cu.usbmodem14401",
"protocol": "serial",
"protocol_label": "Serial Port (USB)",
"properties": {
"pid": "0x805A",
"serialNumber": "131B9378799A643D",
"vid": "0x2341"
},
"hardware_id": "131B9378799A643D"
}
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## 0.34.x #2288 +/- ##
==========================================
+ Coverage 62.98% 63.10% +0.11%
==========================================
Files 221 221
Lines 19746 19747 +1
==========================================
+ Hits 12438 12462 +24
+ Misses 6206 6186 -20
+ Partials 1102 1099 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Here is with the complete debug output:
|
This is the
|
After chatting with @kittaakos we concluded that the latest commit is not necessary since the detector has already 5 seconds of timeout. The original problem was that his board was not able to leave the "bootloader" mode if connected directly to the PC (without a USB hub in the middle). So I'm removing the last commit here because it's not needed. |
This reverts commit 7c77ed2. The latest commit is not necessary since the detector has already 5 seconds of timeout.
* If the upload port-detector fails detection, fallback to the user-provided port This will ensure that a port is always returned. * Increased debug level * Extend timeout if candidate port is lost in any case Even if `waitForUploadPort` is true, we should extend the timeout to allow USB enumeration to complete. In this case we extend by only 1 second instead of 5. * Revert "Extend timeout if candidate port is lost in any case" This reverts commit 7c77ed2. The latest commit is not necessary since the detector has already 5 seconds of timeout.
Please check if the PR fulfills these requirements
See how to contribute
before creating one)
our contributing guidelines
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 patch takes into account the port connection/disconnection that may happen after the upload.This case was already handled, but this patch slightly increased the timeout to allow the port re-enumeration.I've added a fallback: if the algorithm is unable to find a port, it will return the user-provided port for the upload.
What is the current behavior?
No upload port detected:
See #2287 for details.
What is the new behavior?
It should always detect the port, BTW I'm unable to reproduce it so I'll wait for @kittaakos confirmation :-)
Does this PR introduce a breaking change, and is titled accordingly?
No
Other information
Fix #2287