Pages: [1]   Go Down
Author Topic: ISP Bootloader onto ATMEGA328-AU + AVR Pocket Programmer  (Read 3355 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey All
I have a question about using the AVR Pocket Programmer from SparkFun and Bootloading an ATMEGA328-AU (digikey ATMEGA328-AU-ND)

I have a schema here


here is the board (you can see the ISP header in the lower right), there is an FTDI header for uploading sketches later


I set the board type to Arduino Mini (have tried FIO and Lily as well)
i am having an issue that when attempting to burn the bootloader is get an expecting error

for my sanity, can you guys take a look at the schema and tell me what i am doing wrong.
i am able to upload / make files using AVRDUDE but not burn the bootloader.

any suggestions / recommendations would be helpful


Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"when attempting to burn the bootloader is get an expecting error"

Do you mean that you are getting an error saying that device signature was not correct?

Each model of AVR processor has a different signature.  The expected value is in the boards.txt file under the device name you select.  If you want to program a new device you should create a "hardware" directory in the same directory as your Arduino sketches and inside that "hardware" directory, create a file called "boards.txt" that has the description of your board.  When you re-start the Arduino IDE your board(s) will show up in the Board menu.

Look in the datasheet for the correct signature bytes for your device.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the notification.

this is the error i get


avrdude: Expected signature for ATMEGA328P is 1E 95 0F
         Double check chip, or use -F to override this check.

Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bump!

anyone know how to fix the error.
i have  attempted to edit the programmers.txt as well as the boards.txt with no success.

googled the bejeezus out of this, no luck
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you look in the datasheet for your processor and find the signature bytes for that processor?

Did you put those signature bytes into the boards.txt entry?

Try those two things.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i checked the datasheet for the ATMEGA328AU

this is what it has on page 302 of this doc http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf
ATmega328P 0x1E 0x95 0x0F

maybe i am looking at it wrong

additionally i have changed the programmers text for usbtinyasp and added the force boolean

Code:
usbtinyasp.force=true
Logged

Malmö, Sweden
Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try using the signature bytes for the ATmega328 (i.e., 0x1E 0x95 0x14) instead of the signature bytes for ATmega328P.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks, will try.
now to confirm, the order you have there is low, high, extended?
Logged

Malmö, Sweden
Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The signature bytes identifies the device You are trying to program - they shouldn't be confused with the fuse bytes. BTW I got the values from the data sheet You linked to (the row above the one You refered to). I guess You need a new entry in Your config file for AVRDude where You input the correct signature bytes.
« Last Edit: July 14, 2011, 06:21:30 am by Henrik67 » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hmm, interesting, i am making some progress but now getting a whole new error

Arduino IDE
Code:
avrdude: initialization failed, rc=-1
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328 is 1E 95 14
 ***failed; 
avrdude: verification error, first mismatch at byte 0x0000
         0x3f != 0x00
avrdude: verification error; content mismatch

in the avrdude.conf file i added a new board (copied the m328p one)
Code:
    id              = "m328";
    desc            = "ATMEGA328";
     has_debugwire = yes;
     flash_instr   = 0xB6, 0x01, 0x11;
     eeprom_instr  = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
             0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
             0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode  = 0x86;
    # avr910_devcode = 0x;
    signature       = 0x1e 0x95 0x14;
...

in boards.txt i created a new board copied from 'pro5v328'
Code:
##############################################################

sparky.name=Sparky Jr + SparkyISP

sparky.upload.protocol=stk500
sparky.upload.maximum_size=30720
sparky.upload.speed=57600

sparky.bootloader.low_fuses=0xFF
sparky.bootloader.high_fuses=0xDA
sparky.bootloader.extended_fuses=0x05
sparky.bootloader.path=atmega
sparky.bootloader.file=ATmegaBOOT_168_atmega328.hex
sparky.bootloader.unlock_bits=0x3F
sparky.bootloader.lock_bits=0x0F

sparky.build.mcu=atmega328
sparky.build.f_cpu=16000000L
sparky.build.core=arduino

and in programmers.txt i added a new copy of USBtinyISP
note that i am forcing -F
Code:
sparkyisp.name=SparkyISP
sparkyisp.protocol=usbtiny
sparkyisp.force=true

now i am at a loss.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try adding this to your Arduino IDE preference.txt:

upload.verbose=true

This will turn on the debugging messages in avrdude.  From that you should be able to see what signature is being read.  You should also be able to tell what part of memory is not verifying.

When I got an error like this it was because I was using ArduinoISP without disabling auto-reset.  Avrdude was talking to the Arduino bootloader which responds to the STK500v1 "Write lock byte" command by saying "OK" but when you read the "lock byte" back it always returns 0x00.  If you are using a USBtiny (or equivalent) this should not be your problem.

Try doing the upload without the ISP programmer connected to the target board.  If you get the same results It's probably a problem in the programmer.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
Why is it so?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

bah.

this is what verbose gives me

Code:
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cusbtiny -F -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xFF:m

avrdude: Version 5.4-arduino, compiled on Oct  9 2007 at 11:20:31
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/eugene/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : unknown
         Using Programmer      : usbtiny
         AVR Part              : ATMEGA328P
avrdude: Using SCK period of 10 usec
         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 : USBTINY
         Description     : USBtiny simple USB programmer

CMD: [ac 53 00 00] [ae 53 00 00]
CMD: [ac 53 00 00] [ac 53 80 00]
avrdude: initialization failed, rc=-1
avrdude: AVR device initialized and ready to accept instructions

CMD: [30 00 00 00] [30 00 00 00]
CMD: [30 00 01 00] [30 00 01 00]
CMD: [30 00 02 00] [30 00 02 00]
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F
avrdude: current erase-rewrite cycle count is 8388736 (if being tracked)
avrdude: erasing chip
CMD: [ac 80 00 00] [be 80 00 00]
avrdude: Using SCK period of 10 usec
CMD: [ac 53 00 00] [ac 53 80 00]
CMD: [ac 53 00 00] [ae 53 80 00]
avrdude: reading input file "0x3F"
avrdude: writing lock (1 bytes):

CMD: [58 00 00 00] [1c 00 00 00]
CMD: [ac e0 00 ff] [ac 70 00 ff]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [5c 00 00 00]
CMD: [58 00 00 00] [08 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [58 00 00 00]
CMD: [58 00 00 00] [48 00 00 00]
Writing |  ***failed; 
################################################## | 100% 0.04s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3F:
avrdude: load data lock data from input file 0x3F:
avrdude: input file 0x3F contains 1 bytes
avrdude: reading on-chip lock data:

CMD: [58 00 00 00] [58 00 00 00]
Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0x3f != 0x00
avrdude: verification error; content mismatch

avrdude done.  Thank you.

Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Try lowering the bitclock with e.g. "-B 100" or greater values.
Logged

• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
CMD: [30 00 00 00] [30 00 00 00]
CMD: [30 00 01 00] [30 00 01 00]
CMD: [30 00 02 00] [30 00 02 00]
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
avrdude: Expected signature for ATMEGA328P is 1E 95 0F

The device signature of your chip is reading as 00 00 00 ???  THAT can't be good.

Are you sure the programmer is even connected to the chip?  Getting all 0's might mean that one or more of the SPI lines is disconnected or shorted to ground.  For example if power wasn't getting to the chip, or the clock signal was not getting to the chip, or the data line from the chip to the ISP  (MISO?) was not connected...

Has this programmer worked on other AVR chips in the past?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Pages: [1]   Go Up
Jump to: