Atmega168 bootloader internal 8Mhz

Hello,
I am trying to set up a minimal Arduino board with a Atmega168 using the internal 8Mhz osci. This worked fine with an Atmega8, Atmega88 and Atmega328
but I cannot get this Atmega168 to bootload after fusing to internal osci!
Since the Pro mini with 8mhz should be compatible, I burned this bootloader and changed the fuses to
avrdude -p m168 -P usb -c stk500v2 -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U efuse:w:0x00:m
afterwards, with no success: "out of sync" or "not responding"

This from here Arduino Bootloader on ATmega168 | Birds Like Wires

##############################################################

atmega168bb.name=ATmega168 on a breadboard (8 MHz internal clock)

atmega168bb.upload.protocol=stk500
atmega168bb.upload.maximum_size=14336
atmega168bb.upload.speed=19200

atmega168bb.bootloader.low_fuses=0xe2
atmega168bb.bootloader.high_fuses=0xdd
atmega168bb.bootloader.extended_fuses=0x00
atmega168bb.bootloader.path=arduino:atmega
atmega168bb.bootloader.file=ATmegaBOOT_168_pro_8MHz.hex
atmega168bb.bootloader.unlock_bits=0x3F
atmega168bb.bootloader.lock_bits=0x0F

atmega168bb.build.mcu=atmega168
atmega168bb.build.f_cpu=8000000L
atmega168bb.build.core=arduino:arduino

##############################################################

didn't work either. Any help would be greatly appreciated!
Best regards

Did the bootloader end up on it OK?

Can you run this sketch and report what you get?

Wiring for a breadboard:

Arduino Uno         Target Atmega328

D10 (SS)            Reset (pin 1)
D11 (MOSI)          Pin 17
D12 (MISO)          Pin 18
D13 (SCK)           Pin 19

Gnd                 Gnd (pins 8 and 22)
+5V                 +5V (pins 7 and 20)

Yes, bootloader and fuses burn successfully.
Sorry, I do not have the Atmega328 at hand. I got an mkII, 2xAtmega168, Atmega8, Atmega32 and 8Mhz, 16Mhz crystals for now to work with.
I tried flashing the chip detector to a Atmega168 without bootloader which is still very tight. The Serial output starts ok but turns to garbage.
I used this config:

pro5vNoBL.name=Arduino Pro (5V, 16 MHz) w/ ATmega168, no BL

pro5vNoBL.upload.protocol=arduino
pro5vNoBL.upload.maximum_size=16384
pro5vNoBL.upload.speed=19200

pro5vNoBL.bootloader.low_fuses=0xff
pro5vNoBL.bootloader.high_fuses=0xdd
pro5vNoBL.bootloader.extended_fuses=0x00
pro5vNoBL.bootloader.path=atmega
pro5vNoBL.bootloader.file=ATmegaBOOT_168_diecimila.hex
pro5vNoBL.bootloader.unlock_bits=0x00
pro5vNoBL.bootloader.lock_bits=0x00

pro5vNoBL.build.mcu=atmega168
pro5vNoBL.build.f_cpu=16000000L
pro5vNoBL.build.core=arduino
pro5vNoBL.build.variant=standard

Using the Atmega32 wasn't successful either, it freezes after the init text "Atmega chip detector.", doesn't reach the loop.

Used this:

atmega32.name=Atmega32 board 16Mhz

atmega32.upload.protocol=arduino
atmega32.upload.maximum_size=30720
atmega32.upload.speed=19200

atmega32.bootloader.low_fuses=0xFF
atmega32.bootloader.high_fuses=0xDA
atmega32.bootloader.path=atmega32
atmega32.bootloader.file=ATmegaBOOT_168_atmega32.hex
atmega32.bootloader.unlock_bits=0x3F
atmega32.bootloader.lock_bits=0x0F

atmega32.build.mcu=atmega32
atmega32.build.f_cpu=16000000L
atmega32.build.core=arduino
atmega32.build.variant=standard

Magreet:
The Serial output starts ok but turns to garbage.

Could you explain that comment in more detail?

This is my output:

Atmega chip detector.

1E 94 06 
Atmega chip detector.

1E 94 06 

62 
DF 
}yeªe?eÓeF9 
eFF 
93 

yeªe?eÓeF9 
eFF 
93 

yeªe?eÓeF9 e

0eF9 %FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
10F FFFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
20 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
30FF FFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
40F FF	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
505050FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
605050;FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
70FF F4FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
80F FF-FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
90 FF &FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
A0FF FFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
B0F FFFF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
C0 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
D0FF F
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
E0
E0
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
F0
E0
<FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF

What baud rate do you have set in the Serial Monitor? It should be 115200.

If it is, and you can't communicate with my sketch, I'm not surprised the bootloader doesn't work. You have serial comms issues.

The internal oscillator may need tuning.

Try dropping the baud rate in my chip detector sketch (see setup function) and also in your serial monitor. eg. to 9600 baud.

No change.
Maybe the sketch does not fit entirely because of the fuse settings?

You can take out the MD5 sumcheck to save a lot of program memory on the chip detector sketch.

Find these lines and comment them out as shown. Then re-upload.

  /*  **************************************
  Serial.print ("MD5 sum of bootloader = ");
  
  md5_context ctx;
  byte md5sum [16];
  byte mem;

  md5_starts( &ctx );
  
  while (len--)
    {
    mem = readFlash (addr++);
    md5_update( &ctx, &mem, 1);
    }  // end of doing MD5 sum on each byte
    
  md5_finish( &ctx, md5sum );

  for (int i = 0; i < sizeof md5sum; i++)
    showHex (md5sum [i]);
  Serial.println ();  

   **************************************   */

That cuts the program size down to 5,706 bytes or thereabouts.

Wow, 10k for md5, did not think of that!
Even though the Arduino ascii example works fine, I get this:

Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
A
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
Atmeg
A

With 9600 baud, he at least finishes the
"
Atmega chip detector.
"
I've set some printlns in between the setup code which causes it to return nothing...
Seems to reset itself. I've got 100nF and a 10k pullup on reset on both chips. I put a blinking LED in the loop, doesn't reach that.
Thank you so much for your help!

You seem to have at least two issues here. Why the serial comms was out at 115200 baud, and why the processor resets.

Your earlier output did not appear to indicate it resetting as much. Is there more to this than meets the eye? Decoupling capacitors might be required, perhaps?

Magreet:
Since the Pro mini with 8mhz should be compatible, I burned this bootloader and changed the fuses to

I don't know if this is your problem or not, but I think there is only one entry in boards.txt that is configured out of the box to work with the internal oscillator - and that is "LilyPad Arduino w/ ATmega168".

The Pro mini actually has an external 8Mhz (or 16Mhz) oscillator.

Regards,

Brad
KF7FER

The Pro mini actually has an external 8Mhz (or 16Mhz) oscillator.

Yes, but I changed the fuses to internal osc. afterwards.

avrdude -p m168 -cavrispmkii -P usb -U lfuse:w:0xf2:m

The internal osc. works fine but the bootloader doesn't work.

I checked the Arduino boards and thought they would all use external crystals. The LilyPad got one too? After flashing the boot loader, I could not get it programmed via serial. I wasn't the first though: http://arduino.cc/forum/index.php/topic,26706.0.html
I tried his fuse settings but still wasn't able to program via bootloader.

BTW, I'm reminded that 1.0 introduced a bug in ArduinoISP; I keep forgetting because it's one of the bugs that's actually been fixed in 1.0.1
If you're still using 1.0, you should upgrade or apply one of the patches!
http://code.google.com/p/arduino/issues/detail?id=860

Magreet:
I checked the Arduino boards and thought they would all use external crystals. The LilyPad got one too?

All but the ATmega168 version, yes (which means the '328 version uses an external crystal/resonator).

I didn't mean to muddy the waters here, I was just trying to point out that if you want to burn a bootloader for an ATmega168 to run at 8MHz (with the internal oscillator) don't pick the pro mini but select the "LilyPad Arduino w/ ATmega168" (then "Burn Bootloader" from the menu). That will work on a stock install, out of the box so to speak.

If it's not a software problem as westfw suggests, perhaps it's time to post a picture of your setup?

Regards,

Brad.
KF7FER

I am on 1.0.1.

@Brad: Thanks for the info, I'll keep it in mind!
I have several Atmega168A but they all show the same behaviour by now.

Burning bootloader for external 8Mhz or 16Mhz: everything works as supposed to (with the crystal of course), ASCII example works fine, serial flashing works

Burning Lilypad bootloader with internal 8Mhz: Clock seems pretty off. ASCII example at 115200 works fine but this is at 9600 (anything below 115200 is not much better)
Maybe that is why it cannot be flashed with 19200 bauds via serial.
But how come?
There is not much to see: a 10k pull up, the SPI pins and Rx,Tx and the blick cable I use to reset the bootloader.

Internal 8Mhz at 9600bauds:

Áª¥É¢?b«~¡a®ôY.j?pC¡b V:?3	Â?x'?±	zt'¢1	?¥n'?0?0LHHb"?c'?4	B?x'?2,zt'¢2	¥n'?0?1j
$	"?ã'?5	B?x'?³	zt'¢3	¥n'?0?1LH$	¢?c'?6	Â?ø'?´	úô'¢4	¥n'?0?0j?I	¢?c'?ºbB?áé 2M	zt'¢ªb¥¹é 10?0LHÈb"?é 38, hYé &	zt'¢²b¥n'?0?1j
	"?é 39,B?x'?7	zt'¢ºbbZË?±?1Ìj??dY,4b «á:?8	zt'ª0	¥n'?0L?0C¡?	"?c'¢1	Â?x'?9	zt'ª1	¥n'?0L?1
!?dY,4&	B?á: 2A, oct:ª2	¥¹:??????j
+	"?c'¢3	B?áé 2B	zt'ª3, bin: L?0Lj??dY,4	B?áé 2C	zt'ª¢b¥¹é 101100
-, dec: 45, hex: 2D	zÑé 55, bin: 10L??
!?dY,4	B?á:?Å	út'ª6	¥n'?0L?0C¡?dec: 47,B?á:?2± oct: 57, bin:?01L?
!b VÖé b «áé 30,zt'²0	¥n'??0000
1, dec:¢9	B?áé 31, kÑ:²1, bin: 110001
&	"?c'ª0	B?x'?2	zt'²2	¥¹é 110010
3	"?: 51, hex: 33,zt'²3	¥¹é L?0Lj
	"?c'ª2	B?x'?´	zô'²4	¥¹:?1?0j
M	"?c'ª3,B?ø'?µ	zt'²5	¥n'?1?°ÌH6	"?c'ª4	Â?ø'?¶	zt'²6	¥î'?1?1j
	"?c: M	B?ø'?7	zt: Ób ¬Ëé L?1Lj
b V:ª6	B?x'?8	zt'º0	?¥î'?±L?0C¡bdY,5	B?x'?9	zt'º1	¥n'?1L?1C!â ֍ºª8	B?x'?A	zô'º2	¥î'?1L?0C¡b V:ª9, hex: 3(	zt'º3	¥¹é 111?1C!b V:²0, hex:?C	zt'º¢b¥n: 111100
=, dec: 61, hex: &	zÑé 75, bin: 11LL?j
>, dec: 62, hYé 3E, oct: 76, bin: L????j
?, dY,63	B?x'?2± oct: 77, bin:??11Lj
± V:²4	B?x: 40, oct'?0b ¬ËK1000000
¡± V:²5, hex: 41, oc?1?b ¬ËK???????j
(	"?: 66, hex'¢2	zt:?02, bin: 1?0?0
¡± dec: 67, heé Ób oct: 103, biK1?0??j
D, dec:²8	B?á: 44, oct: 104, bin: 1000100
E,"?c'²9, hex: 45, oct: 105, bin: 1000101
F	"?c'º?bB?áé 46, oct:??²b¥¹é 1000L?j
G, dec: 71, hex: 47, oct: 107, bin: 1000111
H, dec: 72, hex: 48, oct: 110, bin: 1001000
I, dec: 73, hex: 49, oct: 111, bin: 1001001
J, dec: 74, hex: 4A, o,????,¥n'?0?0Lj
K, dec: 75, hex: 4B, oct: 113, bin: L??0LLHL, dec: 7	Â?x'¢C, oct: 114, bin: 1001100
M, de,7	B?áé 4D, oct:?15	¥n'???????j
N	"?é 78, hex: 4E, oct'??²b¥¹é 1001110
O, dec: 79, hex: 4F	zt'??ºb¥¹é 1?1L?j
P, dec: 80, «á:ª0	zÑé 120, bin'?0L?0j
T	"?é ?,B?x:ª1, oct: L¦b ¬Ëé 1010001
R	"?c'Â2	B?x'ª?bzt:?22, bin: 1010?0C¡ÅdY,'Â?, hex: 53	zt'???b¥¹é 10100LLC!	"?é 84, heé M	zÑ: 124, bin:?0L???j
U, dec: 85,B?á: 55, oct: 125,¥n: 1010101
V, V:Â6	B?x: 56, o,?1&	¥¹: 10L?1j
	"?é º,B?áé 57, kÑ: 1¦	¥¹é 10101LLHX	"?c'Â8	B?x'ª8	zt'?3b¥¹é 1011000
Y, dec: 89, hex: 59, oct: 131, bin: 1011001
Z, dY,9b «á:ª
± oct: 132, bin: 1011010
[, V: NbB?áé 5B, kÑé 133, bin: 1011011
Å"?é N&	B?x'ªC	zÑé 134,¥¹é L?1L?
¡ÅdY,'Ê3	B?x'ª"± o,?1¦	¥n'?0L?0LHÈÅdY,'Ê4	B?x'ªE,zt'?3	¥n'???1L?
¡ÅdY,9M	B?x: 5F, kѺ?³	¥n: 1??1Lj
± ֍ºÊ6	B?x:²0	úô'?4b ¬Ëé LL?0?
¡± V:Ê7	B?x'²±	zt'?4L	¥n'?1?0?
!± dY,9b «á:²?bzÑé 14&	¥n'?1?010
c, de,9N	B?x'²3	zt'?´&	¥¹é 1100011
!	"?c'???bB?áé 64, kÑ:?4	¥n'????1?
¡	"?: L?bB?áé 65, oct: 145, bin: LL????j
f, dec: 102, hex: 66, oct: 146,¥¹é 1100110
g, dec: 103, hex: 67, oct: 14	¥n'???0111
h, dec: L¢b heé b kÑé 150, bZK1L?000
i, dec: 105, hex: 69, oct: 151, bZK1L?0?j
j, dec'?0	B?áé S± oct: 1M&	¥n'???1010C¡?dY,1º,B?x:²± kÑ: 153, bin: 11?0Lj
?dY,'??ÂbB?áé Ó± kÑé 154,¥n'?1?1?
¡?	"?é 109, hex: 6D, oct: 155	¥n'?1?1?j
n, dY,1Lb «áé S	zt'?5	¥¹: 1101LLj
?dY,1LL	B?áé 6F, oc?1M	¥¹é L?±Ì?
!± dY,'???bB?áé 70, oct: 160, bin'?110000
q, dec: 113, hex: 71, oct: 1Sb ¬Ëé 1110001
.	"?c'??¢bB?áé 72, oct: 162, bin: 11100Lj
s, dec: 115, hex'º3	zt: 163, bin'?1L???
!	"?c'?1	B?x'º¢bzÑé 164,¥¹é 1110100
u, dec: 117, hex: 75, oc?1Sb bin: 111?0LHv	¢?c'??ÂbB?áé 76	zt'?6	¥¹é L?0L?
¡	"?é 119, hYé Ó	zÑ:?6	¥n'?1L???j
x, dec: 120, hex: 78, oct: 170	¥n'?111000
^	"?c'?21, hex: 79,zt'?71	¥¹é 1L?0?
¡± V:?2&	B?x'º
± oct: 172, bin'?1L???j
{, dec: 123, hex: 7B, oct: 173, ¬Ëé LLLL??j
|, dec: L&	B?x'ºÃ	zt: 17	¥¹é 11LLL?
¡± Vé 125, hex: 7D, kÑé 175, bin: 1111101
~, dec: 126, hex:º*± oct: 176, bin: 1111110

If the chip fuses set to external oscillator, you can't upload any bootloader but with external oscillator connected, even if you tring to set fuses for internal oscillator.

Why not?
If I use the Lilypad bootloader, it should use the internal osc?

A clock is required for the ISP circuitry to function, so if the chip fuses are set to use an external oscillator (or external crystal, which is not the same thing), it MUST have one before you can even set the fuses back to use the internal oscillator.