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

Add board autodetection on upload #1581

Merged
merged 1 commit into from
Dec 7, 2021
Merged

Conversation

silvanocerza
Copy link
Contributor

@silvanocerza silvanocerza commented Dec 2, 2021

Please check if the PR fulfills these requirements

  • 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)
  • What kind of change does this PR introduce?

Adds a new feature.

  • What is the current behavior?

The user must always provide an FQBN when trying to upload either with the compile or upload commands.

Example:

  • arduino-cli upload -p /dev/ttyACM1 -b arduino:avr:uno

  • arduino-cli compile -u -p /dev/ttyACM1 -b arduino:avr:uno

  • What is the new behavior?

The user can now upload to a port without specifying an FQBN, if there is no ambiguity in the list of detected boards by the discoveries the commands will be successful. If the arduino-cli can't understand with 100% certainty which board is connected to the specified port the commands will exit with an error and let the user know that an FQBN must be provided.

Example commands:

  • arduino-cli upload -p /dev/ttyACM1
  • arduino-cli compile -u -p /dev/ttyACM1

Successful detection:

~/workspace/arduino-cli
$ arduino-cli board list
Port         Protocol Type              Board Name                FQBN             Core       
/dev/ttyACM0 serial   Unknown                                                     
/dev/ttyACM1 serial   Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega arduino:avr


~/workspace/arduino-cli
$ arduino-cli compile -u -p /dev/ttyACM1 ~/Arduino/Blink 
Sketch uses 1536 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
~/workspace/arduino-cli
$ arduino-cli board list                                 
Port         Protocol Type              Board Name                FQBN             Core       
/dev/ttyACM0 serial   Unknown                                                     
/dev/ttyACM1 serial   Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega arduino:avr


~/workspace/arduino-cli
$ arduino-cli upload -p /dev/ttyACM1 ~/Arduino/Blink

In case multiple boards are detected an error is returned telling the user to specify the FQBN:

~/workspace/arduino-cli
$ arduino-cli board list
Port         Protocol Type              Board Name                FQBN                              Core                        
/dev/ttyACM0 serial   Unknown                                                                      
/dev/ttyACM1 serial   Serial Port (USB) Arduino Mega or Mega 2560 arduino-beta-development:avr:mega arduino-beta-development:avr
                      Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega                  arduino:avr                 


~/workspace/arduino-cli
$ arduino-cli compile -u -p /dev/ttyACM1 ~/Arduino/Blink 
Error during FQBN detection: Please specify an FQBN. Multiple possible ports detected on port /dev/ttyACM1 with protocol serial
~/workspace/arduino-cli
$ arduino-cli board list                            
Port         Protocol Type              Board Name                FQBN                              Core                        
/dev/ttyACM0 serial   Unknown                                                                      
/dev/ttyACM1 serial   Serial Port (USB) Arduino Mega or Mega 2560 arduino-beta-development:avr:mega arduino-beta-development:avr
                      Serial Port (USB) Arduino Mega or Mega 2560 arduino:avr:mega                  arduino:avr                 


~/workspace/arduino-cli
$ arduino-cli upload -p /dev/ttyACM1 ~/Arduino/Blink
Error during Upload: Please specify an FQBN. Multiple possible ports detected on port /dev/ttyACM1 with protocol serial

This also affects the gRPC consumers.

Nope.

  • Other information:

New fields have been added to existing gRPC messages so consumers will need to regenerate the source files from the .proto but there is no breaking change.

Closes #1357.

To test this you'll have to connect a board to your PC and run the test_upload.py integration tests since upload tests are not run on CI.


See how to contribute

@silvanocerza silvanocerza added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: CLI Related to the command line interface topic: gRPC Related to the gRPC interface labels Dec 2, 2021
@silvanocerza silvanocerza self-assigned this Dec 2, 2021
@silvanocerza silvanocerza force-pushed the scerza/board-autodetect branch 4 times, most recently from ae4db7f to d11b7ee Compare December 3, 2021 11:15
Copy link
Contributor

@umbynos umbynos left a comment

Choose a reason for hiding this comment

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

Also if you try to compile without uploading (-u) and without specifying the fqbn the cli returns an errror message different than before:
Error during FQBN detection: Missing port protocol new
Error during build: Missing FQBN (Fully Qualified Board Name) old

cli/compile/compile.go Show resolved Hide resolved
@silvanocerza silvanocerza merged commit f106863 into master Dec 7, 2021
@silvanocerza silvanocerza deleted the scerza/board-autodetect branch December 7, 2021 08:56
umbynos pushed a commit that referenced this pull request Dec 7, 2021
@ubidefeo
Copy link

ubidefeo commented Feb 8, 2022

@silvanocerza @umbynos
this doesn't work for me

I have a Nano 33 IoT attached to my machine.
It is successfully discovered by arduino-cli board list but when running

$> arduino-cli compile -u -p /dev/cu.usbmodem101
Error during FQBN detection: Missing FQBN (Fully Qualified Board Name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect FQBN automatically when port is supplied to compile/upload
3 participants