Skip to content

"Blink" variants of Caterina bootloader are used to generate "with_bootloader" exported binaries for some boards #411

Open
@kuroneko

Description

@kuroneko

Describe the problem

Background

When an "Export Compiled Binary" operation is performed, the Arduino development tools generate two variants of the binary:

  • The sketch application alone (e.g., FooSketch.ino.hex)
  • The sketch application merged with the bootloader binary of the board (e.g., FooSketch.ino.with_bootloader.hex)

The latter of these variant is useful in case you want to allow uploading via the bootloader at some point in time after flashing a board with the exported binary file, without being forced to first perform a "Burn Bootloader" operation to replace the bootloader on the board (which is lost if you flash the board with the first variant on the above list.

Bootloader binaries may include an application program. This is the case with the platform's "Caterina" bootloader binaries, which contain an application to blink the built-in LED at 0.5 Hz.

The "with_bootloader" variant of the exported binary will not function as intended if the application is merged with a bootloader binary that already contains an application.

For this reason, the Arduino boards platform platform framework allows the location of the bootloader binary file to be defined via either one of two (undocumented 😢) platform properties (implementation here):

  • bootloader.file
  • bootloader.noblink

If bootloader.noblink is not defined, then the bootloader binary specified by the bootloader.file property (which is also traditionally used in the bootloader action command template of the "Burn Bootloader" operation) will be used for the "Export Compiled Binary" operation.

Problem

The following boards have an application embedded in their bootloader binary, but do not specify a bootloader-only binary via a bootloader.noblink property:

  • Arduino Leonardo
  • Arduino Leonardo ETH
  • Arduino Micro

🐛 This results in the "with_bootloader" binary file generated by performing an "Export Compiled Binary" operation for these boards having a blink application instead of the sketch exported.

To reproduce

Equipment

  • One of the boards listed above.
  • An ISP programmer.

Demo

  1. Create a sketch with the following code:
    const byte LEDPin = LED_BUILTIN;
    const unsigned int duration = 100;
    
    void setup() {
      pinMode(LEDPin, OUTPUT);
    }
    
    void loop() {
      digitalWrite(LEDPin, HIGH);
      delay(duration);
      digitalWrite(LEDPin, LOW);
      delay(duration);
    }
  2. Select the board you are using from Arduino IDE's Tools > Board menu.
  3. Select Sketch > Export Compiled Binary from the Arduino IDE menus.
    A compile operation will begin.
  4. Wait for the compilation to finish successfully.
  5. Select Sketch > Show Sketch Folder from the Arduino IDE menus.
    The folder of the sketch will open in your file manager.
  6. Find the binary with the .with_bootloader.hex filename suffix that is located under the build subfolder of the sketch subfolder (e.g., build/arduino.avr.leonardo/FooSketch.ino.with_bootloader.hex).
  7. Use AVRDUDE to flash the binary to your board.

🐛 The built-in LED on the does not blink at 0.05 Hz as it should if the compiled sketch program was running.

Arduino AVR Boards version

Original report

Not stated.

Last verified with

fff865837b225d17b932f9c416c7fd36a6b3a645

Additional context

Unlike the boards listed above, the "Arduino Yún" is correctly configured:

yun.bootloader.file=caterina/Caterina-Yun.hex
yun.bootloader.noblink=caterina/Caterina-Yun-noblink.hex

Additional reports

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions