arduino / arduino-ide

Arduino IDE 2.x
https://www.arduino.cc/en/software
GNU Affero General Public License v3.0
2.3k stars 390 forks source link

Firmware Updater fails when target port has multiple identifications #2175

Closed per1234 closed 1 year ago

per1234 commented 1 year ago

Describe the problem

Arduino boards platforms may associate a board definition with port identification properties. Arduino IDE identifies a port as being that board when the port has these properties.

The platform framework doesn't provide any mechanism for restricting the association of a given set of identification properties to a single board definition, so it is possible (and even inherent to some use cases) for a port to be identified with multiple board definitions.

πŸ› If the port of the target board is identified with multiple board definitions, the Firmware Updater fails.

To reproduce

Equipment

One of the boards supported by the "WiFi101 / WiFiNINA Firmware Updater" feature:

Steps

  1. Select File > Quit (or Arduino IDE > Quit Arduino IDE for macOS users) from the Arduino IDE menus if it is running.
  2. Click the following link to download the dummy boards platform used to efficiently create the conditions required to produce the fault: hardware.zip
  3. Unzip the downloaded file to your sketchbook folder. The folder structure should look like this:
    <sketchbook location>/
    β”œβ”€β”€ hardware/
    β”‚   └── fwuploader-board-dummies/
    β”‚       └── foo/
    β”‚           └── boards.txt
    [...]
  4. Start Arduino IDE.
  5. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
  6. Select "Developer (Arduino): Clear the Board and Port Selection" from the Command Palette menu.
  7. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
  8. Select "Developer (Arduino): Clear the Board List History" from the Command Palette menu. β“˜ This and the three steps before are not required to reproduce the fault that is the primary subject of this report. They are included in order to demonstrate a related fault associated with the conditions of using "WiFi101 / WiFiNINA Firmware Updater" when there are multiple identifications of the target port.
  9. Connect the firmware update target board to your computer with a USB cable if it is not already.
  10. Select Tools > WiFi101 / WiFiNINA Firmware Updater from the Arduino IDE menus. The "WiFi101 / WiFiNINA Firmware Updater" dialog will open.
  11. Attempt to select the target board from the "Select Board" menu in the "WiFi101 / WiFiNINA Firmware Updater" dialog. πŸ› The menu doesn't open.
  12. Close the "WiFi101 / WiFiNINA Firmware Updater" dialog.
  13. Select the port of the target board from the Board Selector menu on the Arduino IDE toolbar. The "Select Other Board and Port" dialog will open.
  14. Select the board name that does not have a "(dummy)" suffix from the "BOARDS" menu.
  15. Click the "OK" button.
  16. Select Tools > WiFi101 / WiFiNINA Firmware Updater from the Arduino IDE menus.
  17. Select the target board from the "Select Board" menu in the "WiFi101 / WiFiNINA Firmware Updater" dialog.
  18. Click the "CHECK UPDATES" button.
  19. Click the "INSTALL" button.

πŸ› The update process immediately fails:

⚠ Installation failed. Please try again.

Clean up

  1. Delete the folder of the dummy platform at the hardware/fwuploader-board-dummies subfolder of your sketchbook folder.

Expected behavior

It is possible to update firmware on target boards for which the port has multiple identifications.

Arduino IDE version

69ae38e

Operating system

Windows

Operating system version

11

Additional context

I bisected the regression to 69ae38e (neither of the faults occur when using the build from the previous commit 9a6a457bc44fb16f646b9e61a9e8b336b3666412 under the same conditions).


The minimal "dummy" boards platform used to produce the required conditions in the demo is not anything a real user would have installed, but the fault also occurs in the more common (but more work to reproduce) conditions of having an additional real boards platform installed that associates a board definition with the identification properties of the target board's port. A real world example of this would be having both a release version and a development version of a platform installed at the same time, as is common for platform developers and beta testers.

Issue checklist

kittaakos commented 1 year ago

11. Attempt to select the target board from the "Select Board" menu in the "WiFi101 / WiFiNINA Firmware Updater" dialog. πŸ› The menu doesn't open.

What do you expect to see in the <select> before confirming the board between steps (12) and (15)? Do you expect to see two board items? This would imply showing 27 different ESP32 boards on the same port in some corner cases. Thank you

per1234 commented 1 year ago

Do you expect to see two board items?

The menu should only offer the boards that are supported by Arduino Firmware Uploader:

$ ./arduino-fwuploader.exe firmware list
Board                       FQBN                                Module     Version
Arduino MKR1000             arduino:samd:mkr1000                WINC1500   19.4.4 
Arduino MKR1000             arduino:samd:mkr1000                WINC1500   19.5.2 
Arduino MKR1000             arduino:samd:mkr1000                WINC1500   19.5.4 
Arduino MKR1000             arduino:samd:mkr1000                WINC1500 βœ” 19.6.1 
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.0.0  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.1.0  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.2.1  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.2.2  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.2.3  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.2.4  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.3.0  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.0  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.1  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.2  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.3  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.4  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.5  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.6  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.7  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA       1.4.8  
Arduino MKR WiFi 1010       arduino:samd:mkrwifi1010            NINA     βœ” 1.5.0  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.0.0  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.1.0  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.2.1  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.2.2  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.2.3  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.2.4  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.3.0  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.0  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.1  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.2  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.3  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.4  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.5  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.6  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.7  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA       1.4.8  
Arduino NANO 33 IoT         arduino:samd:nano_33_iot            NINA     βœ” 1.5.0  
Arduino MKR Vidor 4000      arduino:samd:mkrvidor4000           NINA       1.0.0  
Arduino MKR Vidor 4000      arduino:samd:mkrvidor4000           NINA     βœ” 1.1.0  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.2.1  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.2.2  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.2.3  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.2.4  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.3.0  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.0  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.1  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.2  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.3  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.4  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.5  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.6  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.7  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA       1.4.8  
Arduino Uno WiFi Rev2       arduino:megaavr:uno2018             NINA     βœ” 1.5.0  
Arduino Nano RP2040 Connect arduino:mbed_nano:nanorp2040connect NINA       1.4.5  
Arduino Nano RP2040 Connect arduino:mbed_nano:nanorp2040connect NINA       1.4.6  
Arduino Nano RP2040 Connect arduino:mbed_nano:nanorp2040connect NINA       1.4.7  
Arduino Nano RP2040 Connect arduino:mbed_nano:nanorp2040connect NINA       1.4.8  
Arduino Nano RP2040 Connect arduino:mbed_nano:nanorp2040connect NINA     βœ” 1.5.0  
Arduino UNO R4 WiFi         arduino:renesas_uno:unor4wifi       ESP32-S3   0.1.0  
Arduino UNO R4 WiFi         arduino:renesas_uno:unor4wifi       ESP32-S3   0.2.0  
Arduino UNO R4 WiFi         arduino:renesas_uno:unor4wifi       ESP32-S3 βœ” 0.2.1  

Even when there are multiple board identifications for a port in general, it is likely that only one of those will ever be supported by the Firmware Updater. Even if at some point in the future there was a situation where the tool supported multiple boards that shared the same port identification properties, as long as the boards supported by tool continues to be curated by Arduino, there would never be a case where there was a problematic number of supported boards for a given port.

In the demo I provided, there are two general identifications for the port (e.g., arduino:renesas_uno:unor4wifi, fwuploader-board-dummies:foo:unor4wifi), but only one of the identifications is for a board supported by the Firmware Uploader.