Can't flash with USB after flashing HEX with bootloader

Hoping someone has run into this issue before because I am a bit stumped. I have some Atmega328p chips on custom PCB's that I want to program in one operation using an Arudino Uno as an ISCP in custom software. I have exported the sketch as a Hex with bootloader and use avrdude from a .net program I wrote like this:

avrdude.exe -c avrisp -p m328p -P {port} -b 19200 -U flash:w:"{hexWithBootLoader}":a

This works fine, however....if I then try to update the sketch over USB from the IDE I get messages saying that the programmer is not responding. If I first burn the bootloader from the IDE over ISCP, then use my program to burn the hex file with bootloader I can then flash the chip through USB.

So i am hoping that someone has the knowledge that I am struggling to find on why burning the hex with bootloader doesn't actually seem to result in a working bootloader unless the chip already had a bootloader on it? Can anyone let me know what I am missing here?

Thanks in advance.

Hi @collusionbdbh. Arduino IDE's "Burn Bootloader" feature actually does two things:

  1. Set the configuration fuses on the target chip according to the values specified in the board definition.
  2. Flash the bootloader binary.

The command you are using only does the latter. So the chip has whatever fuse settings it started with.

You can learn the command to set the fuses by examining the output from performing a "Burn Bootloader" operation in Arduino IDE when you have the verbose output preference enabled:

  1. Select File > Preferences... from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Check the box next to Show verbose output during: ☐ upload in the "Preferences" dialog.
    This preference applies to "Burn Bootloader" operations in addition to uploads.
  3. Click the "OK" button.
    The "Preferences" dialog will close.
  4. Perform a "Burn Bootloader" operation, just the same as you did before.
  5. Wait for the "Burn Bootloader" operation to finish.

Now examine the content of the black "Output" panel at the bottom of the Arduino IDE window. You will find two avrdude commands there.

That completely fixed my issue. Thanks so much for your help, you rock.

You are welcome. I'm glad it is working now.

Regards, Per