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

Spurious "Please select a Port before Upload" error with Upload Using Programmer #8052

Closed
fpgaminer opened this issue Oct 3, 2018 · 20 comments
Assignees
Labels
Component: Uploading Uploading programs to an Arduino board Type: Bug

Comments

@fpgaminer
Copy link

Tested on nightly: 28 September 2018 3:2:58 GMT
OS: macOS 10.14

The Bug
Attempting to upload a sketch using USBtinyISP as the selected programmer will always fail on macOS with the error "Please select a Port before Upload". This is a bug because, as far as I understand, USBtinyISP is a USB device, not serial, so it is impossible to select a Port for it (this is at least true of the Adafruit Trinket).

This is a regression bug; uploading works fine on 1.6.13.

According to another party this bug is not present on Windows.

Steps to reproduce:

  • Write an LED blink sketch (or any sketch)
  • Select Tools->Board->Adafruit Trinket (ATtiny85 @ 8MHz)
  • Select Tools->Programmer->USBtinyISP
  • Click Upload

Error Message:

Please select a Port before Upload

Expected Behavior:

Arduino IDE should not require a Port to be selected when the programmer is USBtinyISP.

Opinion:

Looking through the code, it seems this was a "feature" added some point after v1.6. Before, the code didn't care if there was a serial port or not and would just blunder forward through newUploader anyway (with boardPort left as null). The correct fix, I guess, is for getUploaderByPreferences to be aware of which Programmer is selected and whether it needs a serial port or not. Alternatively this feature could simply be rolled back (I've found no way to work around it; so it breaks Arduino 1.8 on macOS).

@per1234 per1234 added the Component: Uploading Uploading programs to an Arduino board label Oct 3, 2018
@per1234 per1234 changed the title macOS: Cannot upload using USBtinyISP Spurious "Please select a Port before Upload" error with Upload Using Programmer Oct 3, 2018
@facchinm
Copy link
Member

facchinm commented Oct 4, 2018

It looks like the bug starts from 4ccf9bb (included in #7958)
@PaulStoffregen the best way to tackle this could be parsing the upload rule in advance to decide if it's ok to fail for the missing serial port, otherwise I think we should revert to the old behaviour.
@fpgaminer the patch is contained in both 1.8.6 and 1.8.7 so the newest stable version you can use at the moment is 1.8.5 .

@per1234
Copy link
Collaborator

per1234 commented Oct 4, 2018

The workaround is to select any port from the Tools > Port menu. It doesn't matter what port that is. That only needs to be done once. Of course that requires that either the computer has a native serial port or that the user can connect some device to the computer that creates a port.

The bug does occur on Windows. Steps to reproduce it:

  1. Click the link at the line following [b]File > Preferences > More preferences can be edited directly in the file[/b]. This will open the Arduino15 (or similar name) folder.
  2. Close the Arduino IDE.
  3. Rename preferences.txt to preferences.txt.bak. This is necessary to emulate a fresh IDE installation, where no port has ever been selected from the Tools > Port menu.
  4. Start the Arduino IDE.
  5. Sketch > Upload Using Programmer (or standard upload to a board that doesn't define upload.protocol, such as the ATtiny85-based Trinket).

@PaulStoffregen
Copy link
Contributor

Opps, sorry for this. Looking at it now.

I don't personally own a Trinket or USBtinyISP programmer. I can get them if needed, but that will take several days.

Before we fully revert this, please consider the Arduino forum would repeatedly get the same new user question, where avrdude would try to access COM1. We really should find a way to fix this, but avoid the extremely common case where first time users get stuck only because the default was COM1 and they use Windows and their PC really does have a COM1 port (usually on a motherboard header without any cable connected to the outside world).

@PaulStoffregen
Copy link
Contributor

@fpgaminer - I'm trying to follow your steps to reproduce the problem. But I'm not able to do step 2:

Select Tools->Board->Adafruit Trinket (ATtiny85 @ 8MHz)

It does not appear in Tools > Boards. I can not find any installation for it in Tools > Boards > Boards Manager.

Perhaps at some point you added another URL to the "Additional Boards Manager URLs" in File > Preferences? Any chance you could look at that list and give me the URL needed to be able to install support for Trinket?

@per1234
Copy link
Collaborator

per1234 commented Oct 4, 2018

@PaulStoffregen here it is:
https://adafruit.github.io/arduino-board-index/package_adafruit_index.json
It's in the "Adafruit AVR Boards" package.

You don't need the hardware to reproduce the bug.

@PaulStoffregen
Copy link
Contributor

Confirmed, I can reproduce the problem here on a Linux system.

Still looking for a clean way to fix this and prevent the extremely common case of avrdude cryptic (and very slow) messages when COM1 exists but isn't connected to anything.

@fpgaminer
Copy link
Author

Thank you for taking a look at this bug!

I'm not familiar enough with the codebase to contribute meaningfully beyond the bug report, but I'm curious; is getUploaderByPreferences able to get information about the currently selected programmer? If so, I noticed that in the packaged programmers.txt a communication option is defined for most programmers specifying either serial or usb. Perhaps that value could be checked, and if it's not serial then don't require that a serial port is selected?

@PaulStoffregen
Copy link
Contributor

PaulStoffregen commented Oct 4, 2018

Saw that too. But some done define it at all, so I want to dig into this a little more. Sadly, I have to do customer service stuff for the rest of today (PJRC is a tiny company, only 4 people...) Will look at this again tomorrow morning.

@chrisjsmith
Copy link

Confirmed reproduced this on windows 10 / Arduino 1.8.7 with USBasp

@ladyada
Copy link

ladyada commented Oct 15, 2018

@PaulStoffregen hiya will you be able to take a look at this bug? some customers are asking me about it. perhaps for now i can tell them to just use arduino 1.8.6

@ladyada
Copy link

ladyada commented Oct 15, 2018

FYI this also would affect Arduino Gemma because it uses the same technique

@PaulStoffregen PaulStoffregen added this to the Release 1.8.8 milestone Oct 23, 2018
@PaulStoffregen
Copy link
Contributor

Sorry about the delay... I haven't forgotten about this issue, but at the moment I'm bringing up new hardware that's consuming all my dev cycles. Hope to work on this in a week or so. Please feel free to ping me if the silence goes on too long, or if there are any signs Arduino might be preparing for 1.8.8 (I'm as much in the dark as anyone regarding when they intend to publish non-beta releases).

I took the liberty of adding this to the 1.8.8 milestone list.

In the meantime, the 2 workarounds are to select any port from the Ports menu, or on a PC without any ports to select, use 1.8.6 or 1.8.5.

@ajquick
Copy link

ajquick commented Nov 1, 2018

Just came across this problem myself. Had to roll back to 1.8.6 in order to get the USBtinyISP to work, and I'm on Windows. So it doesn't seem to be a Mac only problem.

@jjok
Copy link

jjok commented Nov 7, 2018

Me too with a Trinket on Linux.

facchinm added a commit to facchinm/Arduino that referenced this issue Nov 8, 2018
@cmaglie
Copy link
Member

cmaglie commented Nov 9, 2018

I'm looking at this one.

@cmaglie
Copy link
Member

cmaglie commented Nov 12, 2018

I've published a possible solution in #8194, please test and report back if it works.

@cmaglie
Copy link
Member

cmaglie commented Nov 14, 2018

Fixed by #8194

@cmaglie cmaglie closed this as completed Nov 14, 2018
@ladyada
Copy link

ladyada commented Nov 18, 2018

yayyy!

@FredCailloux
Copy link

I had the same problem with my Arduino installation until I tried this solution which worked perfectly for me. See: per1234 commented on Oct 4, 2018 , up here in this blog.
Be prepared to redo any important configuration of your Arduino installation for this solution involve to replace the whole file "preferences.txt" . Once deleted Arduino detected my TinyProgrammer and I could upload my sketch no problem. Thanks per1234

@TheCrazyT
Copy link

TheCrazyT commented Nov 10, 2019

Is it normal to have this bug on version 1.8.11 (hourly build 2019/10/29/ 10:33) on windows?
The problem is that i have no serial interfaces and use "AVRISP mkII".
Avrdude itself works with " -Pusb" but the arduino IDE fails to upload.
Deleting preferences.txt didn't help,too.

Edit:
Alright, figured out a workaround.
I edited the board.txt and outcommented the line of "upload.protocol" of the board i was using.
Now it is forced to use the programmer that i selected.
Because of https://github.com/arduino/Arduino/blob/master/arduino-core/src/cc/arduino/packages/uploaders/SerialUploader.java#L89.
But i have absolutely no idea why "usingProgrammer" was not set to true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Uploading Uploading programs to an Arduino board Type: Bug
Projects
None yet
Development

No branches or pull requests