168 Bootloader Error

So after all the trouble I had getting a parallel programmer to put a bootloader onto a 168, I went out and bought the AVRISP MKII. I’m using AVRStudio 4 and the 168 hex file. It gets through the loading portion, but when it tries to verify, it returns an error. I tried getting AVRdude to work on a mac, but I’m unix incompetent. Has anyone had any success getting AVRstudio to successful program the ATMEG168 with the bootloader?

I have a similar problem with the AVRISP MKII. I tried burning a bootloader for the atmega8 (and i believe i do have the right hex file) with avrstudio 4. I have inserted the chip into an Arduino NG, powered via USB.

I found that when I try to burn it onto a new (never used) Atmega8-16PU, burning fails (AVRSTudio says: "PROGRAMMING FLASH....FAILED / A problem occured when executing the command"). But when I try to burn on the Atmega8-16PU which came with the Arduino, it works nicely. I presume it might have to do with the fuses & lock bits settings. These are different in both of the chips, but I get the sme error message when I try to set the new chip to the values read from the arduino chip.

Can anyone help me out? I can't find any more hints anywhere. Are there more subtyped to the atmega8-16pu? or what?

Well I got a bootloader on my 168 ok. From using AVRDude, I think you have to unlock the bootloader segment, erase the chip and set the fuses before you can burn the new bootloader. Then you have to relock the bootloader segement The process is covered here for the 168 using avrdude: http://wolfpaulus.com/journal/embedded/arduino2.html I'm not sure if AVRstudio will do all that for you when you try to burn a new hex file, but I doubt it. I don't even know what the fuse setting would need to be for the 16, but I think once you find them, you should be set.

Well I've uncovered an interesting problem. I want to use a 20MHz external clock with my 168 on a breadboard, but in the process of burning the new bootloader, I had to set the fuses to expect a 16Mhz clock. Can I change the clock fuse to 20MHz and still use the board to program my chip? Does anyone know which fuses to use? Thanks!


there's a handy online calculator for AVR fuse settings here: http://palmavr.sourceforge.net/cgi-bin/fc.cgi


Actually the fuse settings are the same for a 16 MHz clock and a 20 MHz one. You'll probably need to compile a new version of the bootloader that knows that it's running at 20 MHz instead of 16 MHz however.

How would I go about doing that?

You can download the code from: http://www.arduino.ws/. Go to upload > software > bootloader_v5. You need to change AVR_FREQ in the Makefile and recompile with make. You'll also need to make sure the avr tools are in your path.

I am a bit confused due to the sometimes conflicting information. Which ISP programmer will work and which one won't? Can I get away with using a quick and dirty parallel programmer? What about all those non-Atmel programmers which claim to be STK500 or AVR ISP compatible (but sometimes have additional features, like USB)? Don't want to spend lots of money on an Atmel serial programmer when I can get a compatible one with USB for a fraction of the money. And then it supposedly seems to depend on which OS and programming software you use... Too much input.

So what's the consensus for the most reliable and cheapest idiot-proof programmer out there? Can't hurt if it's available locally so it doesn't need to be ordered abroad which usually adds a lot of taxes and postage.

I did the easy part and changed the makefile, but I don't know what you mean my recompiling with make. What is make? and which avr tools are you talking about? Should I be doing this in UNIX or something? I think I'm missing a very critical step.

Are you on Windows? You could try downloading WinAVR and using that to compile the bootloader. Alternatively, you could just use a 16 MHz clock. Or since, you have a hardware programer (at least, I assume you do, since you need one to get the bootloader onto the chip), you could just burn your code directly to the chip without using a bootloader. See: http://www.arduino.cc/en/Hacking/Programmer

I’m a windows user but have an intel mac at my disposal (I just don’t know how to use it very wll). I was hoping to use the bootloader so I could update the code quickly and easily. I think I was able to compile the new make file, but my new hex file has a very long name (ATmegaBOOT_168_CRUMB168_F20000000_050815.hex), and I’m not sure I trust it. I was only ever able to upload the bootloader using AVRdude on the mac, but I think I’ll see if WinAVR can get it to work. Any suggestions on how to make that happen? I tried AVRstudio that came with my hardware programmer but wasn’t able to get it to work either.


On the Mac I use AVR Stdio, running under Parallels Build 3150. With the AVR ISP MKII programmer , it works like a charm. You can get parallels free as a trial, so the only real outlay is the AVRISP, which runs about 35USD. Pricey, but it works.


I've tried using AVR studio with my AVRISPmkII, but when I try to connect to my Atmega168 I get an error: "ISP Mode Error" and it recomends I lower the ISP programming frequency specified on the board page. Well I've tried everyone of those and it still gives me the same error. I find that odd since all the LED's are green. I can't change any fuses or lock bits because it gives me that same error. What's going on here?

I probably shouldn't be posting here since I obviously have no clue, I guess I'll do it anyway...

You mentioned:


The Crumb168 is a microcontroller module similar to the Arduino Mini


Are you sure this bootloader will work with the Arduino? Do they both use the same bootloader?

well I think I must have done something drastic to my 168. AVR dude tells me it's having trouble communicating with the programmer and that there is an invalid device signature. I haven't even got around to trying to put the new bootloader on yet. Just out of curiosity, why would people want to use a 168 with a slower clock? Isn't the 20Mhz oscillator one of the major advantages of the 168 over the regular 16? Thanks!

Well when I changed the makefile, the only thing I changed was the oscillator frequency. I think the reason the name is so long is because it saves it according to program, product, and build parameters in the makefile. It seemed to work ok when I was just using the standard 16Mhz osciallator.

The name of the .hex file should be fine. It’s got CRUMB168 because it originally came from the crumb168, but it’s been adapted to work with the Arduino. I’m not sure what to suggest about your problems with the 168 chip though.

The ATmega168 has a number of advantages over the ATmega8: twice as much flash (program space), and extra PWMs, and the 20 Mhz clock.

That's what I thought. As for the 168 chip, could it be that while trying to use AVR studio I set some kind of fuse to require an external oscillator? I think I saw someone with that problem on AVR freaks. If it's dead then I'll just have to get another one I suppose.

If you're trying to run the ATmega168 at 20 MHz, then, yes, you need an external oscillator. It's likely that you've set the fuses to require one, as most of the documentation tells you to, and the scripts do so.