Go Down

Topic: Burning bootloader to ATMEGA328 via ATMEGA168 (Read 5667 times) previous topic - next topic

sonicvsb

Tested the FTDI... no problems. Checked connections again and again, it seems now that I even can't upload a sketch to the 168. What's going on here?!?

Riva

I can only guess the bootloader on your 168 has corrupted, do you have any other arduino you can use as a programmer? Maybe need to invest in something like this or this.
Don't PM me for help as I will ignore it.

sonicvsb

#17
Jun 19, 2014, 04:40 pm Last Edit: Jun 19, 2014, 04:43 pm by sonicvsb Reason: 1
So, more problems...
It's like the chips are laughing at me.. :D
The only problem is that here where I live I cannot find any such AVR programmers, and if I order from Ebay I will have to wait 1 month :(

Last week I was trying to burn the bootloader on to the 328 via bitbanging, as I had done before with my 168.  However, I had some problems and when I discovered I could do it via the other working chip, I abandoned it. Maybe I'll be looking back to it....

Here is some food for thought: I connected DTR, RX and TX pins to the 328 chip to try and upload a sketch, although I knew the bootloader may have not been uploaded correctly with my trying. When I did, I got the same not in sync message, but the whole time the RX LED on my FTDI board was SOLIDLY ON. And it did not turn off. What can this indicate?

I have had some not-in-sync problems before as well with my 168. Every time the solution has been different, but it seemed like if I got that error, the RX LED was dimly lit. I have tried all these solutions and now nothing works.

Will try bitbanging next. I will post results.

sonicvsb

I tried bitbanging on both my 328's and my 168. Opened command line Avrdude, got this:

avrdude.exe: AVR device not responding

I will try Linux now. Meanwhile, have you guys have any ideas?

Riva

I had a long spiel for you but this site is sh*te today with lots of 502 error and I lost it so the short version is...
Get a programmer anyway as it worth the few bucks to keep in your toolbox also consider investing in something like this as it cheaper than buying a bare 328 chip.
Cannot help with bitbanging, never had to do it as I have a programmer.  :smiley-red:
Don't PM me for help as I will ignore it.

Budvar10

1. FTDI works ? You've wrote yes,  but check it again.
2. ATmega168 works? Are you able to upload some simple program as blinking LED?
3. Check connection once more CAREFULLY and try to burn 328 again.
Arduino clone with ATmega1284P   http://forum.arduino.cc/index.php?topic=277260.0

sonicvsb

1. Yes, loopback on the FTDI works so I'm assuming that the FTDI chip itself works.
2. I am not able to upload a Blink sketch to the 168 because now I get a non-sync error there as well...
3. I will check the connections, however there are some new things I shall introduce to you:

I finally bought an AVR USBASP programmer and I will try burning the bootloaders to the 168 and 328 respectively. I will post results. If the chips are dead, that means that I won't be able to program them. We'll see.

sonicvsb

When connected, I used to get the error "the target doesn't answer" from avrdude.
Now, I used the "Slow SCK" in order to read the fuses and lock bits. I got a device signature, the fuses were as follows:
hfuse: D9          lfuse: 62          efuse: 07      lock bit: 3F

I burned the bootloader on using the Arduino IDE and then I connected my FTDI chip. It gets a device signature, but it does not upload. Here is the verbose output:

Code: [Select]
Binary sketch size: 1 084 bytes (of a 32 256 byte maximum)
C:\Users\Kiril\Desktop\Arduino\hardware/tools/avr/bin/avrdude -CC:\Users\Kiril\Desktop\Arduino\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P\\.\COM3 -b115200 -D -Uflash:w:C:\Users\Kiril\AppData\Local\Temp\build152634650870489019.tmp\Blink.cpp.hex:i

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Users\Kiril\Desktop\Arduino\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : \\.\COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [03]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
         Hardware Version: 3
         Firmware Version: -2.620035894
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
         Vtarget         : 429496729.4 V
         Varef           : 62003589.4 V
         Oscillator      : 1.372 Hz
         SCK period      : 2914288.2 us

avrdude: Send: A [41] . [81]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x41
avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20]
avrdude: Recv:
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0x42
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

avrdude done.  Thank you.


Now I read the fuses and lock bits again: hfuse DE lfuse FF efuse 05 lockbits 0F
My suspicion is that it is set to use internal 8MHz clock (divided by 8), instead of the external 16Mhz clock I have connected. Is it possible that this is the problem? And how could I fix it? Which values of the fuses and lock bits should I write to the chip?

Riva

#23
Jun 22, 2014, 08:55 am Last Edit: Jun 22, 2014, 05:50 pm by Riva Reason: 1
Sorry I cannot check and give proper answer but on iPad that sux on this site. If you set internal 8mhz fuse you should still be okay. Maybe you have disabled reset pin? There is a nice online fuse calculator that you cold put your fuse settings into and see how they are set. The correct fuse settings will be in the boards.txt file for you device along with a clue to the correct boot loader.

EDIT: The fuse calculator is here and below is excerpt from the UNO boards.txt to show default fuse settings. Just type them into the above link to see what's set. If you have disabled the reset pin then look for 'arduino high voltage programmer' to reset fuses.
Quote
uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
Don't PM me for help as I will ignore it.

sonicvsb

Thank you very much for your input. Here is where I have gotten so far:

- I managed to burn the fuses, as well as the bootloader using avrdude, not the Arduino environment, on the Slow SCK speed setting on my usbasp. Then, I actually found what the problem may have been before that - I had been trying Arduino Uno as the board type, but when I chose Arduino Duemilanove w/ ATmega328, it uploaded fine. I assume that's because my setup is more similar to the Duemilanove as it has a FTDI converter IC instead of a ATmega8u2 or ATmega16u2 (as the UNO does) or so on.
So, I got one of my 328's up and running.

- After that, I started reviving my 168. I just unplugged the usbasp, swapped the chip out on the breadboard for the 168, so the connections were the same, and when I plugged it in, and tried to read the fuses from avrdude, I got the error that: "no programmer usbasp was found". I think it is an OS/driver problem as I had problems with those unsigned drivers before on my machine (Win 8.1) and now when I open Device Manager, it shows that the driver is installed and up-to-date but shows a little exclamation mark because the driver is not trusted. I tried all my USB ports, the same result. Also tried the other 328 chip but the real problem is now the programmer again.

I think I will try Windows 7 or Linux tomorrow so I do not have those weird driver problems.

- And after my failure, I also tried making the revived 328 into an ISP programmer, it didn't work. So I'm stuck again now and I will post soon if I am able to revive the other chips.

sonicvsb

Little update on the situation:

I uploaded this version of the Arduino ISP to my already revived 328. It allowed me to set a SLOW SCK speed and I programmed the fuses that way. After that, I was able to burn the bootloader normally via the ArduinoISP.  Now, the second 328 is working as well!! Yeah!

I will tomorrow be trying to revive the 168 last. I think it is a different case because it is not a virgin chip and it should have been able to have been burnt at a normal speed by now. I will try to set the slow SCK speed tomorrow as well on that one and try to revive it :D

Go Up