I need to hook up Bluefruit LE Breakout (nRF8001-based) to ATMega328 chip (to use it as wireless UART), and it seems like the library provided is for Arduino.

What I have is just bare ATMega328 (note the lack of "p"), which I am going to program (using avrispmkii directly). As I already have the MCU assembled, I do not want to change to, say, Arduino Uno to be able to use the library. Most likely, I will "play" with the Bluefruit on Arduino first to get the feel of it, but the code needs to be run on the "bare" ATMega328. The other part of the program (which prepare data to be sent from atmega) is trivial, so I will have no problem to rewrite it from C to Arduino. Porting Adafruit library from C++ to C is probably much more difficult.

Thus, one of the possible approaches is to compile the my code + Bluefruit LE code for Arduino, but upload to the ATMega328.

And this is where I need help:

How to make Arduino (command line tool is ok) to compile to the MCU I have? I guess, the result should be some kind of hex-file for flash (and eeprom?).

And, may be useful, which flags to use with avrdude, if there is anything specific for the Arduino-generated code. (I do not need any bootloaders on the chip, just the program, and I do not have UART-USB connected to atmega).

Of course, please, mention if there are better ways I overlooked, like some Arduino-compatible gcc toolchain to compile C++/C mix into avr code (avr-g++?). Or maybe there is some C-library for the component atmega needs to talk to.

UPDATE: Similar question: http://www.avrfreaks.net/forum/using-arduino-ide-general-atmel-microcontroller-no-bootloader-no-cristal

1 Answer 1


The UNO is basically just an ATMega328(P). So you can run the same compiled code for the UNO just fine on a bare ATMega328.

You don't have to worry about the P versus non-P version. They are basically the same except for some minor differences concerning low power settings.

You can just select the Arduino UNO board as you target. Select the avrispmkii as programmer. Then instead of Upload, choose Upload using Programmer (in the Sketch menu).

  • It is that simple then, thanks. I will check this as soon as I figure out how to adjust F_CPU and fuses in Arduino (I am using 8MHz internal clock) and decide what to do with RST pin for the BLE module.
    – Roman Susi
    Oct 3, 2015 at 12:45
  • Just download my boards definition. Just extract and place inside the hardware folder in the Arduino sketches folder (create if not yet present). The 328 @ 8mhz board should be added to the Tools->Boards menu after restarting the IDE.
    – Gerben
    Oct 3, 2015 at 14:28
  • 1
    The one place you will have to worry about the 328 vs 328P is in the programmer configuration - while the file will usually work between chips, the program will refuse to load it into a different one than it is expecting. Oct 3, 2015 at 16:47
  • Just to confirm: I made my "board" definition (MCU, fuses, frequency), And "Upload using Programmer" definitely works: I was able to use BLE "UART"! As for refusing to load, yes, there was one warning, when I had intermediate configuration (forgot to change mcu from atmega328p to atmega328). I have not tried to change frequencies (and bootloader) on the Uno though, so switched to "bare" chip as soon as uart was understood.
    – Roman Susi
    Oct 3, 2015 at 17:33
  • A, right. In my boards from above, edit boards.txt and change atmega328-8mhz.build.mcu=atmega328p to atmega328-8mhz.build.mcu=atmega328.
    – Gerben
    Oct 3, 2015 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.