Atmega328p standalone without quartz

Hey,
I'd like to program a uC with the Arduino board and afterwards it should work in a new circuit. I've got 5 uC's with the arduino bootloader and the fuses are set like an original controller, so either I could place a quartz in the new circuit or I customize the fuses so it takes the internal oscillator. But I like the second method better so I searched for two days to find a solution. There a several ways but nothing works. I tried the following ways:

  1. The official way from the Arduino homepage:
    http://www.arduino.cc/en/Tutorial/ArduinoToBreadboard
    The problem is, that when I try to burn the bootloader, I get to following error message:

missing bootloader.tool configuration parameter

After googling (is that an English word?!), I put the following line into the boards.txt from the zip file:

atmega328bb.bootloader.tool=arduino:avrdude

The new error message is:

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03

(10x)
This says me exactly nothing, because google gives me felt 100 different reasons for this. Some people write, you have to press the reset button after starting the upload but it doesn't work for burning. So here I gave up. Does anybody know, how it could work?
2. My second method is to change the fuse bits in the original boards.txt. Then I tried to burn this modified bootloader, but I weren't sure, which programmer is the right one. So I took AVR ISP and AVRISP mkII and got after two minutes of waiting the same error message like in the first method. What am I doing wrong?
3. The third method is very different: I tried the optiLoader: http://www.asaxen.com/tutorials/arduino/burning-arduino-bootloader-using-arduino-uno
But there I got the error code 0x0. I think, it has something to do with the magic "spi_transaction". There are functions like "spi_transaction(0xAC, 0x53, 0x00, 0x00)" but I can't find a definition, only calls. So I've no idea, what I'm doing wrong.

Maybe I tried also a fourth way but after 2 days of this stuff, I can't remember everything.
So has anyone an idea, how to tame these stupid little electrical flash cells?

To answer your question we need to know a lot more.
Which operating system ? How is it connected ? Did you connect the reset (sometimes via DTR and 100nF) ? Can you make a photo of it ? At what MHz do you want your ATmega to run ? Do you know there are Arduino boards that use the internal clock at 8MHz ? Did you try avrdude with the -vvv option ?

When the bootloader is burned onto a ATmega within the Arduino IDE, also the fuses are set. It is okay to change the fuse afterwards for internal or external clock. I used an internal clock of 8MHz, but that was not accurate enough. So I added an external 8MHz crystal and two 22pF and changed a fuse with avrdude and it worked.

[ADDED] The DTR with 100nF is for uploading a sketch not to burn a bootloader, thanks DrAzzy.

You're using a boards.txt file from 1.0.6 - those need modifications (like the ones you've performed) to work with 1.6.x versions of the IDE. There are a lot of resources online that have not been updated - the Arduino developers have not exactly treated people who make custom cores and custom board definitions kindly with the 1.6.x releases.

If you have a microcontroller with the fuses set to use a crystal, but you have not connected a crystal, you must provide a clock of some sort, or temporarily connect a crystal (and associated caps) long enough to change the fuse settings. Some of the bootloader loading sketches (I think Nick Gammon wrote one) will output a square wave that can be used in order to fix the fuses to use internal oscillator.

That error, unfortunately, is one of the less useful errors - it doesn't definitively point to one particular problem. IT could be because you are not providing a clock signal but your chips have fuse set to require one. It could also be caused by wiring problems, or not having a 0.1uf decoupling cap between ground and Vcc

ISP reset wire should go straigth to reset pin, not through a capacitor.
The cap peter_n was thinkign about is the one that goes between the reset pin and the DTR pin of a serial adapter in order to enable autoreset so you can program it over serial. It has no relevance to burning the bootloader, since that's done over ISP.

I'm using W7 HP 64bit. I uploaded a photo were you can see, how it's connected. Sorry, i know it's a bit confusing. I only connected the reset to port 9 on the Arduino because i thought, that the internal pullup resistor does the rest. I want to run it at 8Mhz. I didn't know it but I think it shouldn't be very complicated when you know how to set the fuses.

Did you try avrdude with the -vvv option ?

I red something about it, but I've no idea, where I should add this argument. Could you explain, please?

It is okay to change the fuse afterwards for internal or external clock. I used an internal clock of 8MHz, ...

It's exactly what I want to do. I've got no crystal and such little capacitors, so I wanted to see, if the internal oscillator works for my application. How did you set the fuses?

There are a lot of resources online that have not been updated

Do you have any idea, where I could find current resources? I only found code like I posted in the links.

If you have a microcontroller with the fuses set to use a crystal, but you have not connected a crystal, you must provide a clock of some sort, or temporarily connect a crystal (and associated caps) long enough to change the fuse settings.

IT could be because you are not providing a clock signal but your chips have fuse set to require one. It could also be caused by wiring problems, or not having a 0.1uf decoupling cap between ground and Vcc

But I'm doing everything like the instructions show me...

Some of the bootloader loading sketches (I think Nick Gammon wrote one) will output a square wave that can be used in order to fix the fuses to use internal oscillator.

I'm trying to find out something about it.

You need a clock to burn a bootloader. When I changed from internal to external, that was no problem. But when you have set the fuse for external, and there is no clock... then it won't work. The Nick Gammon sketch for ArduinoISP generates a clock.
I have a oscillator of a few megahertz, for such cases.

I used this : http://www.engbedded.com/fusecalc/
I read in boards.txt what the original fuse was, filled that in, and changed the clock settings and got a new value.
After that I used avrdude (in linux) to set just that one fuse.
You could change it also in boards.txt, but I prefer that you make a copy in boards.txt for a new board.

I'm so happy! Many thanks! I took the ArduinoISP from Nick Gammon and now, I could set the fuses! :smiley:
The last step is to flash the firmware (stands in the description of the ArduinoISP). There, I got the following error message:

//my input
C:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\bin>avrdude -C..\etc\avrdude.conf -patmega328p -cstk500v1 -PCOM3 -b19200 -e -Uflash:w:firmware.hex:i -vvv -F

//excerpt from output
avrdude: reading input file "firmware.hex"
avrdude: can't open input file firmware.hex: No such file or directory
avrdude: read from file 'firmware.hex' failed

How could I solve this problem?

I also tried to use the uC without this flash, but it doesn't work... I can't upload files.

Is that file really called "firmware.hex" ? Which Arduino board did you select ? Or did you change boards.txt ?

RoyalRIDEr:
I'm so happy! Many thanks! I took the ArduinoISP from Nick Gammon and now, I could set the fuses! :smiley:
The last step is to flash the firmware (stands in the description of the ArduinoISP). There, I got the following error message:

//my input

C:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\bin>avrdude -C..\etc\avrdude.conf -patmega328p -cstk500v1 -PCOM3 -b19200 -e -Uflash:w:firmware.hex:i -vvv -F

//excerpt from output
avrdude: reading input file "firmware.hex"
avrdude: can't open input file firmware.hex: No such file or directory
avrdude: read from file 'firmware.hex' failed




How could I solve this problem?

I also tried to use the uC without this flash, but it doesn't work... I can't upload files.

"firmware.hex" is intended to be replaced with the actual name of the firmware.hex file ...
See the article: Here
Pay attention to the section, "Uploading Code - Hard Way"

When you are a little comfortable with the command line, check out this post:
Windows Duplication Script

Ray

So, I were able to upload the firmware, but it didn't work. Then I tried again many different ways. And now, I could solve the whole problem :smiley:
First, I have to upload the sketch to the uC. Then I have to connect it to my other arduino and set the low fuse to 0xe2 with avrdude:

C:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\bin\avrdude -CC:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\etc\avrdude.conf -patmega328p -cstk500v1 -PCOM3 -b19200 -Ulfuse:w:0xd2:m

Then, I can use the uC on a breadboard. The Problem is, that I can't upload new sketches, so when I want to upload a new sketch, I have to burn the original bootloader, upload the sketch and set the fuse.
Is there a way to upload the sketches directly?

Sure. Get a Programmer, and upload using the ICSP header (SCK, MOSI, MISO, Reset, Power, Gnd).
If the Programmer works in the IDE, can use File:Upload Using Programmer. Burn the bootloader first to set the fuses for the board type you are mimicking. (I use Uno for 16 MHz DIP parts for example).

I also worked with Nick to run his program on these cards to Program files from SD card onto a board with ICSP header (or use an adapter cable to connect to the pins, listed above).
http://www.crossroadsfencing.com/BobuinoRev17/

RoyalRIDEr:
So, I were able to upload the firmware, but it didn't work. Then I tried again many different ways. And now, I could solve the whole problem :smiley:
First, I have to upload the sketch to the uC. Then I have to connect it to my other arduino and set the low fuse to 0xe2 with avrdude:

C:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\bin\avrdude -CC:\Programme\Arduino\arduino-1.6.3-windows\arduino-1.6.3\hardware\tools\avr\etc\avrdude.conf -patmega328p -cstk500v1 -PCOM3 -b19200 -Ulfuse:w:0xd2:m

Then, I can use the uC on a breadboard. The Problem is, that I can't upload new sketches, so when I want to upload a new sketch, I have to burn the original bootloader, upload the sketch and set the fuse.
Is there a way to upload the sketches directly?

You can program it using ISP by doing Upload using Programmer instead of normal Upload.

So the bootloader works to upload a sketch via serial, but it only works once?
That usually happens when the fuses (BOOTRST/BOOTSZ) are wrong, or if you haven't wired up the auto reset (reset line of '328p should be connected to 10k pullup resistor, and one side of a 0.1uf cap; other side should go to the DTR line of the serial programmer, thus converting the transition of DTR from high to low (signifying the opening of serial connection) into a pulse to reset the chip so the bootloader runs.