Arduino to ATMega328-MMH

I've made my own custom PCBA using the ATmega328-MMH (NOT ATmega328P) and was hoping to program and develop on this board using the Arduino IDE. The package type is the 28pin package, not 32 as on the Nano.

I'm having trouble finding any board support for this specific IC in Arduino - I only see support for the ATMega328P by selecting the Nano, and even then I'm expecting the device signatures to be different based on package and part number.

I intend to program/debug this board using either my Atmel-ICE (though it's currently not showing up as an available COM port device, will need to change the driver via Zadig I believe but that's a different issue), or with an Arduino Uno as ISP.

Am I screwed here? Is there no direct Arduino IDE support for this specific IC in this package?

I may be wrong here, but essentially you have the same chip as in the UNO etc. The newer P variant has been developed with lower power requirements - picopower. Your device is packaged as the 28-pin version - so you loose a few pins over the 32-pin. A quick look at the datasheet says there's one less pair of VCC & GND pins and you don't have ADC6 & ADC7.

I think you can still load in a standard bootloader using AVRDUDE. I don't know if you can do this via the IDE as the device signatures won't match - as you suspected. I think you can use AVRDUDE from the command line and specify the correct chip so that the signatures match.

I'm guessing that once you have a standard bootloader installed in the 328, then you should be able to program it as if it were an UNO via the IDE. Just remember you don't have ADC6 & ADC7.

Thanks for your helpful response - as expected, the signatures don't match when trying to burn the bootloader:

avrdude: Device signature = 0x1e9514 (probably m328)
avrdude: Expected signature for ATmega328P is 1E 95 0F

         Double check chip, or use -F to override this check.

avrdude done.  Thank you.

So it looks like there is no native support for the ATmega328 directly in the IDE as an available "Board" - I assumed there would be as I've done similar device level flashing on Attiny's like this before.

Wondering if I'll brick the IC if I override with -F......

Not knowing much about the inner workings of the IDE, but if you can get in there to add in the -F, then can you instead insert the correct chip into the Avrdude call?

It might be easier to work direct with Avrdude from the command line.

I can, but this is a project for an end client who is expecting to seamlessly use the Arduino IDE and is not very comfortable with command line work. It's looking like I'll need to change this to the 328p for ease of use.

I wonder if you can add a custom file, it might be a boards.txt file in the MySketchbook/hardware (I think!) to make a new board appear in the menu? That way the end client simply chooses the custom board in the menu and used the IDE as normal. I think that's where you can specify the processor you are using.

Edit: Have a look at this post RE boards.txt, or go with the advice below.

Despite the similar model numbers and equivalent specs in the respects that matter for our purposes, the ATmega328 and ATmega328P have different signatures and so the upload will fail.

Although you can use the avrdude -f flag in this particular case, or a bespoke boards platform, there is a better way. Just use the excellent 3rd party MiniCore, which provides true support for the ATmega328.

  1. Install MiniCore:
  2. Select Tools > Board > ATmega328 from the Arduino IDE's menus.
  3. Select Tools > Variant > 328 / 328A from the Arduino IDE's menus.
  4. Make sure all the other custom Tools menus are configured appropriately for your custom board (most notably Tools > Clock.

Now you can use your ATmega328 board just like any other Arduino board.

This is EXACTLY the response I was looking for - thank you!

You're welcome. I'm glad if I was able to be of assistance. Enjoy!