Problems with megaTinyCore in IDE 2

That is expected. Deleting that folder is not the fix for the issue. It is only a required step in the instructions for a minimal demonstration of the bug that will be used by the developers to understand the bug and to verify the fix.

OK, here we go.

Assumptions

The following instructions are based on the following assumptions I have made:

  • You are using the Tools > Board > megaTinyCore > ATtiny3224/1624/1614/1604/824/814/804/424/414/404/214/204 board selection.
  • You are using the Tools > Clock > 16 MHz internal clock setting.

If you are using a different board (e.g., "ATtiny1614/1604/814/804/414/404 w/Optiboot") or clock (e.g., "16 MHz internal - tuned"), then please let me know as some minor adjustments will need to be made to the provided boards.local.txt file before the instructions will do you any good.

Instructions

  1. Download this file: boards.local.zip (181 Bytes)
  2. Unzip the downloaded file.
  3. Select File > Preferences... from the Arduino IDE menus.
  4. Check the box next to Show verbose output during > ☐ compile.
  5. Click the OK button.
  6. Select Sketch > Verify/Compile from the Arduino IDE menus.
    It doesn't matter which sketch you compile. We are just using this to gather some information.
  7. Wait for compilation to finish.
  8. Scroll up in "Output" panel of the Arduino IDE.
    There you will see a line that looks something like this:
    Using board 'atxy4' from platform in folder: C:\Users\per\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.5.10
    
  9. Copy the file boards.local.txt from the folder you unzipped at step (2) to the path you found at that line of the compilation output.
    For the example output above, the target path of the file would be:
    C:\Users\per\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\2.5.10\boards.local.txt
    
  10. Select File > Quit from the Arduino IDE menus.
    (this is needed because the IDE must be restarted to recognize the change you made to the megaTinyCore boards platform configuration)
  11. Start the Arduino IDE.

Now try uploading again. You should see OSCCFG is now using 0x01 as expected.

Additional information

In case you are curious, I'll provide some supplemental information about the bug and workaround. Feel free to ignore it if you are not interested in esoteric details of the Arduino boards platform system.

Cause

This bug occurs only under specific somewhat rare Arduino boards platform configurations:

The default setting of the "Clock" custom board option for this board is "20 MHz internal". This option (megaTinyCore:megaavr:atxy4:clock=20internal) has an associated platform configuration property named bootloader.OSCCFG:

atxy4.menu.clock.20internal.bootloader.OSCCFG=0x02

But the clock=16internal option does not have an associated bootloader.OSCCFG property. The reason is because DrAzzy/SpenceKonde defined a default value for the bootloader.OSCCFG property, which should be used whenever the custom board option does not set the property:

atxy4.bootloader.OSCCFG=0x01

The arduino/arduino-cli#1614 bug causes the IDE to use the property value set by the default custom board option when the currently selected board option does not explicitly set it.

Workaround

This means the workaround is simply to add a property definition associated with the custom board option you are using:

atxy4.menu.clock.16internal.bootloader.OSCCFG=0x01

If Arduino CLI was working correctly, that would be redundant to the default definition.

Use of boards.local.txt

I set this property in a supplemental boards.local.txt platform configuration file in order to avoid the need to edit megaTinyCore's primary boards.txt platform configuration file. That makes the workaround a little more simple and also allows it to easily be re-applied, which will be necessary after updating to each new release of megaTinyCore, since the modification to the platform will be lost during the update. But the use of boards.local.txt is only done for convenience. The workaround would work exactly the same if you added that line directly to boards.txt.