Thanks for the instructions! That's very helpful.
I can reproduce the issue when using the bootloader from watterott/ATmega328PB-Testing.
When I use the MiniCore bootloader the problem does not occur.
I isolated the problem to the bootloader by using the MiniCore board definition with the watterott bootloader and vice versa. The problem relates to the bootloader used rather than the hardware package. Note that when doing this you need to adjust the upload.speed value in boards.txt since MiniCore's bootloader communicates at 115200 and watterott's at 57600.
So the workaround I can provide is to use MiniCore. But I'm sure we're both curious as to how this code could break the upload. I'm not qualified to answer that question.
I'm not sure whether you noticed, but the watterott bootloader can be uploaded to again after unplugging the board and then plugging back in, even after waiting for the sketch to run and put the board back to sleep. This makes me think the problem is related to the MCUSR register since as far as I know that is the only thing that would be changed by a power on.
Unfortunately watterott did not provide the source code for their bootloader, makefile, or any other information so that makes it difficult to investigate further.
canique:
I've changed the boards.txt of the atmega328pb package to contain:
atmega328pbcc.bootloader.low_fuses=0xDE
atmega328pbcc.bootloader.high_fuses=0xD6
atmega328pbcc.bootloader.extended_fuses=0xF5
What was the reason for that?
canique:
I had to edit avrdude.conf too to include:part parent "m328"
id = "m328pb";
desc = "ATmega328PB";
signature = 0x1e 0x95 0x16;
ocdrev = 1;
;
That's not necessary if you install Arduino AVR Boards 1.6.206 (actually latest is now 1.6.207), as instructed: