arduino / arduino-ide

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

Changes to programmers.txt are not recognized #591

Open per1234 opened 3 years ago

per1234 commented 3 years ago

Describe the problem

🐛 The first time a board is selected, its programmers are cached by the IDE. After that, changes to the programmers.txt configuration file of the boards platform are not reflected in the IDE's Tools > Programmer menu.

To reproduce

  1. Close all Arduino IDE windows.
  2. Clear the Programmer menu cache by deleting the C:\Users\<user name>\AppData\Roaming\arduino-ide (Windows) or ~/.config/arduino-ide (Linux) folder. This is done in order to ensure there are boards available without a cached Programmer menu to compare with the board that has a cache.
  3. Start the Arduino IDE.
  4. Use Boards Manager to install "Arduino AVR Boards" (if it is not already installed).
  5. Select Tools > Board > Arduino AVR Board > Arduino Uno from the Arduino IDE menus. The Programmer menu entries have now been cached for the "Arduino Uno" board, but not for the other boards of the "Arduino AVR Boards" platform that have not yet been selected in the IDE.
  6. Open the Tools > Programmer menu and take note of the programmers listed there: image
  7. Close all Arduino IDE windows
  8. Open C:\Users\<user name>\AppData\Local\Arduino15\packages\arduino\hardware\avr\<platform version>\programmers.txt (Windows) or ~/.arduino15/packages/arduino/hardware/avr/<platform version>/programmers.txt (Linux) in a text editor.
  9. Add a new programmer definition to the file by adding the following lines to the file:
    foo.name=Added Programmer
    foo.program.tool=avrdude
  10. Modify a programmer definition by changing this line:
    avrisp.name=AVR ISP

    to this:

    avrisp.name=Modified Programmer
  11. Remove a programmer definition by deleting these lines:
    
    avrispmkii.name=AVRISP mkII
    avrispmkii.communication=usb
    avrispmkii.protocol=stk500v2
    avrispmkii.program.protocol=stk500v2
    avrispmkii.program.tool=avrdude
    avrispmkii.program.extra_params=-Pusb
  12. Save the file.
  13. Start the Arduino IDE.
  14. Select Tools > Board > Arduino AVR Board > Arduino Uno from the Arduino IDE menus.
  15. Open the Tools > Programmer menu. 🐛 The menu contents don't reflect any of the changes that were made to programmers.txt: image
  16. Select Tools > Board > Arduino AVR Board > Arduino Leonardo from the Arduino IDE menus. This is the first time selecting this board so its Programmers menu cache is populated now.
  17. Open the Tools > Programmer menu. 🙂 The menu contents reflect the changes that were made to programmers.txt: image
  18. Select Tools > Board > Arduino AVR Board > Arduino Uno from the Arduino IDE menus.
  19. Select File > Save As... from the Arduino IDE menus.
  20. Save the sketch to any convenient name and location. The purpose of this step is to allow the sketch with the incorrect associated state metadata to be opened after restarting the IDE.
  21. Select File > New Sketch from the Arduino IDE menus.
  22. Open the Tools > Programmer menu. 🙂 The menu contents reflect the changes that were made to programmers.txt.
  23. Close all Arduino IDE windows.
  24. Delete the "user data" folder at the following path:

    • Windows:
      C:\Users\<username>\AppData\Roaming\arduino-ide\

      (where <username> is your Windows username) ❗ If looking for it with your file manager or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".

    • Linux:
      /home/<username>/.config/arduino-ide/

      (where <username> is your Linux username) ❗ The .config folder may be hidden by default in your file manager and terminal.

    • macOS:
      /Users/<username>/Library/Application Support/arduino-ide/

      (where <username> is your macOS username) ❗ The Library folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.

    ⚠ Please be very careful when deleting things from your computer. When in doubt, back up!

  25. Start the Arduino IDE.
  26. Select Tools > Board > Arduino AVR Board > Arduino Uno from the Arduino IDE menus.
  27. Open the Tools > Programmer menu. 🙂 The menu contents reflect the changes that were made to programmers.txt. image

Expected behavior

Tools > Programmer menu always reflects the contents of the programmers.txt files at the time the Arduino IDE was started, just as it is in the classic Arduino IDE.

Arduino IDE version

2.0.0-beta.12-nightly.20211028

Operating system

Operating system version

Additional context

The `programmers.txt` changes are recognized as expected by Arduino CLI: ``` $ arduino-cli version arduino-cli.exe alpha Version: 0.19.1 Commit: 718bbbf2 Date: 2021-09-29T08:28:11Z $ arduino-cli board details -b arduino:avr:uno --list-programmers Id Programmer name parallel Parallel Programmer usbGemma Arduino Gemma atmel_ice Atmel-ICE (AVR) buspirate BusPirate as ISP foo Added Programmer usbasp USBasp arduinoisporg ArduinoISP.org usbtinyisp USBtinyISP jtag3isp Atmel JTAGICE3 (ISP mode) arduinoisp ArduinoISP stk500 Atmel STK500 development board avrisp Modified Programmer arduinoasisp Arduino as ISP jtag3 Atmel JTAGICE3 (JTAG mode) arduinoasispatmega32u4 Arduino as ISP (ATmega32U4) ```

Complete modified `programmers.txt` file: ``` foo.name=Added Programmer foo.program.tool=avrdude avrisp.name=Modified Programmer avrisp.communication=serial avrisp.protocol=stk500v1 avrisp.program.protocol=stk500v1 avrisp.program.tool=avrdude avrisp.program.extra_params=-P{serial.port} usbtinyisp.name=USBtinyISP usbtinyisp.protocol=usbtiny usbtinyisp.program.tool=avrdude usbtinyisp.program.extra_params= arduinoisp.name=ArduinoISP arduinoisp.protocol=arduinoisp arduinoisp.program.tool=avrdude arduinoisp.program.extra_params= arduinoisporg.name=ArduinoISP.org arduinoisporg.protocol=arduinoisporg arduinoisporg.program.tool=avrdude arduinoisporg.program.extra_params= usbasp.name=USBasp usbasp.communication=usb usbasp.protocol=usbasp usbasp.program.protocol=usbasp usbasp.program.tool=avrdude usbasp.program.extra_params=-Pusb parallel.name=Parallel Programmer parallel.protocol=dapa parallel.force=true # parallel.delay=200 parallel.program.tool=avrdude parallel.program.extra_params=-F arduinoasisp.name=Arduino as ISP arduinoasisp.communication=serial arduinoasisp.protocol=stk500v1 arduinoasisp.speed=19200 arduinoasisp.program.protocol=stk500v1 arduinoasisp.program.speed=19200 arduinoasisp.program.tool=avrdude arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed} arduinoasispatmega32u4.name=Arduino as ISP (ATmega32U4) arduinoasispatmega32u4.communication=serial arduinoasispatmega32u4.protocol=arduino arduinoasispatmega32u4.speed=19200 arduinoasispatmega32u4.program.protocol=arduino arduinoasispatmega32u4.program.speed=19200 arduinoasispatmega32u4.program.tool=avrdude arduinoasispatmega32u4.program.extra_params=-P{serial.port} -b{program.speed} usbGemma.name=Arduino Gemma usbGemma.protocol=arduinogemma usbGemma.program.tool=avrdude usbGemma.program.extra_params= usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf ## Notes about Dangerous Prototypes Bus Pirate as ISP ## Bus Pirate V3 need Firmware v5.10 or later ## Bus Pirate V4 need Firmware v6.3-r2151 or later ## Could happen that BP does not have enough current to power an Arduino board ## through the ICSP connector. In this case disconnect the +Vcc from ICSP connector ## and power Arduino board in the normal way. buspirate.name=BusPirate as ISP buspirate.communication=serial buspirate.protocol=buspirate buspirate.program.protocol=buspirate buspirate.program.tool=avrdude buspirate.program.extra_params=-P{serial.port} # STK500 firmware version v1 and v2 use different serial protocols. # Using the 'stk500' protocol tells avrdude to try and autodetect the # firmware version. If this leads to problems, we might need to add # stk500v1 and stk500v2 entries to allow explicitly selecting the # firmware version. stk500.name=Atmel STK500 development board stk500.communication=serial stk500.protocol=stk500 stk500.program.protocol=stk500 stk500.program.tool=avrdude stk500.program.extra_params=-P{serial.port} jtag3isp.name=Atmel JTAGICE3 (ISP mode) jtag3isp.communication=usb jtag3isp.protocol=jtag3isp jtag3isp.program.protocol=jtag3isp jtag3isp.program.tool=avrdude jtag3isp.program.extra_params= jtag3.name=Atmel JTAGICE3 (JTAG mode) jtag3.communication=usb jtag3.protocol=jtag3 jtag3.program.protocol=jtag3 jtag3.program.tool=avrdude # Set a bitclock of 0.1us (the fastest supported value). This should # work regardless of the crystal used, since JTAG doesn't use the MCU # clock but dictates its own clock. jtag3.program.extra_params=-B0.1 atmel_ice.name=Atmel-ICE (AVR) atmel_ice.communication=usb atmel_ice.protocol=atmelice_isp atmel_ice.program.protocol=atmelice_isp atmel_ice.program.tool=avrdude atmel_ice.program.extra_params=-Pusb ```

Originally reported at https://forum.arduino.cc/t/programmers-txt-change-ignored/862718

Additional Reports

Workaround

  1. Select File > Quit (or Arduino > Quit Arduino for macOS users) from the Arduino IDE menus if it is running.
  2. Delete the following folder to force Arduino IDE to update the Tools > Programmer menu data:

    • Windows:
      C:\Users\<username>\AppData\Roaming\arduino-ide\

      (where <username> is your Windows username) ❗ If looking for it with your file manager or command line, note that the AppData folder is hidden by default. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".

    • Linux:
      /home/<username>/.config/arduino-ide/

      (where <username> is your Linux username) ❗ The .config folder may be hidden by default in your file manager and terminal.

    • macOS:
      /Users/<username>/Library/Application Support/arduino-ide/

      (where <username> is your macOS username) ❗ The Library folder is hidden by default. You can make it visible by pressing the Command+Shift+. keyboard shortcut.

    ⚠ Please be very careful when deleting things from your computer. When in doubt, back up!

  3. Start Arduino IDE.

You should now see the expected list of programmers under the Tools > Programmer menu.

Issue checklist

JAndrassy commented 2 years ago

at least some workaround? where does it cache the content of programmers.txt?

per1234 commented 2 years ago

The workaround is to delete the folder where the cache is:

Windows

%APPDATA%\arduino-ide\

(e.g., C:\Users\<user name>\AppData\Roaming\arduino-ide\)

Linux

~/.config/arduino-ide/

macOS

~/Library/Application Support/arduino-ide/
KevWal commented 2 years ago

Gosh it took me a while to find this and hence resolve why I was not getting programmer updates! I can confirm the bug exists, and that deleting %APPDATA%\arduino-ide\ resolves it (as a work around as a one time fix)

Version: 2.0.0 Date: 2022-09-14T07:06:37.759Z CLI Version: 0.27.1 [a900cfb2]

interbiznw commented 1 year ago

I don't have a %APPDATA%\arduino-ide\ ?? not sure how to clear the programmers.txt Cache??????????

image

per1234 commented 1 year ago

Hi @interbiznw. For support with the workaround, please post on the Arduino Forum:

https://forum.arduino.cc/c/software/arduino-ide-2-0/93

I'll be happy to provide assistance over there.

kroko commented 1 year ago

Stuck with the same Issue. Opened forum entry on this https://forum.arduino.cc/t/custom-isp-programmers-txt-on-2-x-and-macos-location-structure/1116766

dlitz commented 1 year ago

I seem to be able to get the programmers list to refresh by doing the following:

  1. Running arduino-ide --open-devtools to open the Chromium Developer Tools
  2. Going to Application -> Local Storage -> file://
  3. Searching for "programmers" (it should return some keys starting with theia:.arduinoIDE-configOptions-arduino:)
  4. Deleting the entry/entries for the board(s) I'm using.
  5. Quitting and restarting Arduino IDE
bsdmry commented 7 months ago

Thanks a lot @dlitz! You saved me a lot of time!