Programming "Custom" Boards.

I have a small board I designed for a 328P. I guess I didn't read the fine print, because I ended up buying 328PB's, so programming the bootloader as a Nano or Uno did not work, as the signature is different. So, I created a custom entry in boards.txt, identical to the Uno, except for the processor type. This appears to have worked fine for programming the bootloader, using a USBTinyISP.

Now I want to program a simple application. While I have a serial port connection I can use with an FTDI cable, shouldn't I be able to program the application using the USBTinyISP?

When I try, I get this:

Sketch uses 1802 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 194 bytes (9%) of dynamic memory, leaving 1854 bytes for local variables. Maximum is 2048 bytes.
E:\Users\RayL\Documents\AppData\Arduino\arduino-1.8.9\hardware\tools\avr/bin/avrdude -CE:\Users\RayL\Documents\AppData\Arduino\arduino-1.8.9\hardware\tools\avr/etc/avrdude.conf -v -patmega328pb -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\RayL\AppData\Local\Temp\arduino_build_730743/sketch_aug21a.ino.hex:i

avrdude: Version 6.3-20171130
Copyright (c) 2000-2005 Brian Dean,
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "E:\Users\RayL\Documents\AppData\Arduino\arduino-1.8.9\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

avrdude done. Thank you.

Problem uploading to board. See for suggestions.

Why is it trying to access COM3 when USBTinyISP is selected as the programmer?

Ray L.

If you want to upload using the USBtinyISP, you need to do Sketch > Upload Using Programmer, or hold the Shift key while clicking the Upload button.

If you always want to do Upload Using Programmer, it is possible to modify your custom board definition so that the Upload button always acts as Upload Using Programmer. This is done by removing the upload.protocol property from boards.txt.

By the way, MiniCore provides excellent support for the ATmega328PB, including the special features that the ATmega328P doesn't have:

Well, this is peculiar.... My board seems to basically work, except.... The Serial seems flaky. I have no problems FLASHING new code using the ISP, but when I do it over Serial, using an FTDI adaptor, is is hit-or-miss, working no more than half the time, if that. The other half of the time it fails with a variety of avrdude errors, from sync errors, to bad responses, etc.

If I run a simple program that just toggles D2, it seems to work just fine. If I add a Serial.print every second, it will invariably either crash or reset in fairly short order. The more data I send over Serial, the sooner it crashes. The Rx and Tx pins are directly connected to the FTDI board, with no additional circuitry or components, and I've tried two different FTDI boards with the same results.

I can find nothing wrong with the board, and there is no other active circuitry on the board that could possibly be interfering, so I'm just about down to either swapping out the 328, or building up another whole board, on the theory I simply managed to get a defective chip?

Ray L.

Is there anything about the 328PB that could be causing my problem? I am using the 328PB Ultiboot bootloader, and it (somehow!) changes the device ID to read like a 328P, so my assumption was that, for all practical purposes, using this bootloader turns the 328PB into a 328P, and any 328P software should function perfectly. Is that correct? Or is there perhaps some fuse setting or something that is different that might explain the flaky behavior I see?

Ray L.

I've never heard of Ultiboot. You could try using optiboot instead to see if it makes the problem go away. MiniCore provides optiboot compiled for ATmega328PB, so you can just select that board and then do a Tools > Burn Bootloader to install optiboot on your ATmega328PB.

Sorry, typo. I meanr Optiboot.

I think I know what the problem is - one major difference between the 328P and 328PB is the oscillator. The PB has removed the option for a full-scale oscillator mode, leaving only the low-power mode, which seems very sensitive to the specific crystal and capacitors. Today I'm going to remove the PB and replace it with a P (yanked off a ProMini), and I'm guessing that will solve all my problems.

Ray L.

Yup! The clock is the problem. Put a 328P on it, and it is now stable!

I have another problem I don't understand, however. I tried to burn a new bootloader, using the USBTinyISP.
It can't seem to even read the device ID, usually getting either all 0's, or all F's! Fortunately, the chip already had a bootloader on it, so I can upload using the serial port. But why does the USBTinyISP not work? It did with the PB. All the soldering appears fine.

Ray L.