PlatformIO Community

Atmega328p bootloader burning attempt = "Error: Couldn't find bootloader image"

I had a little free time today, so tried out the bootloader burning functionality of PlatformIO with an Atmega328.

I put my file in [project directory]/Bootloader/[bootloader file].hex

And I am pretty sure I am following the instructions here:

When I open a new terminal in the project directory and issue this command:

platformio run --target bootloader

I get “Error: Couldn’t find bootloader image”

platformio.ini contents:

platform = atmelavr
board = Supervisor_8mhz
framework = arduino
upload_protocol = atmelice_isp

upload_flags = -e

board_bootloader.file = /Bootloader/Supervisor_8mhz_bootloader.hex

I have checked that the path the the hex file is correct a few times, and I tried an absolute path too… Does anyone out there ALSO have some free time today to tell me what I am doing wrong?

Thanks for reading!

Seems like paths are relative to the Arduino core directory, e.g. see

Let’s modify the Python script to tell you what’s wrong. The error in question is thrown here

Go into your platformio directory (/home/<user>/.platformio or C:\Users\<user>\.platformio and navigate to the platforms\atmelavr\builder\ file. Change the line where the error message is thrown to

    sys.stderr.write("Error: Couldn't find bootloader image %s\n" % bootloader_path)

What is the output of platformio run --target bootloader now?

1 Like

Thanks Max!

PlatformIO is looking for the bootloader file here:

Then the previous check must have failed for “is the file path existing at all”:

I suggest printing the bootloader_path at after the original line 66 and putting a print to check whether you path in line 68.

Very likely the issue is that the file path you give it really doesn’t exist and it thus attempts this correction logic.

1 Like

Sorry… My response was vague. I will add the lines you suggested for future debugging.

Once I put my bootloader hex file in a sub-directory I created named “supervisor” in this directory:

(The chip I am loading this onto is considered a “supervisor”)

Then I changed my path in my platformio.ini file to:

board_bootloader.file = supervisor/Supervisor_8mhz_bootloader.hex

The bootloader was loaded successfully. Thank you for your help.

I did have two fuse values swapped… I would not suggest doing that if you want to use the chip ever again… (editing my previous comment above so no one copies the values and bricks their Atmega328). Luckily I had a few extra.

Thanks again for your help.