Tuesday, June 18, 2013

Arduino Nano v3.0 with avr-dude



My order of two Arduino Nano-compatible v3.0 from eBay (shipped from China) just arrived. Also bought the USBASP USBISP AVR Programmer from eBay (about $3.0, from China too, see the picture on the left).


The good thing about this USBISP AVR programmer, besides the unbelievable price, I was told that it is  also compatible with avrdude, even Atmel AVR Studio (never tried it, thought)

But when I tried to program it with avr-dude, it always failed with various errors, such as:






avrdude: ser_recv(): programmer is not responding
avrdude: stk500v2_ReceiveMessage(): timeout

avrdude: stk500v2_getsync(): timeout communicating with programmer
or:
...
         Using Port                    : /dev/ttyUSB2
         Using Programmer              : avrisp
         Overriding Baud Rate          : 57600
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
...



I tried "-c arduino" without setting the baud-rate, I also tried different programmer type (stk500v2, etc.), nothing worked.  Turned out, the parameters combination I used was wrong.
In this case, the programmer should be "arduino" but the baudrate must be set to something (in this case, 57600).

The following is the correct one:


bash-4.2$ avrdude -c arduino -b 57600 -P /dev/ttyUSB2 -p atmega328p -vv -U flash:w:blink.hex

avrdude: Version 5.11, compiled on Sep  9 2011 at 16:00:41
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/usr/local/etc/avrdude.conf"
         User configuration file is "/home/mlutfi/.avrduderc"

         Using Port                    : /dev/ttyUSB2
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
         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
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 2
         Firmware Version: 1.16
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "blink.hex"
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: writing flash (1468 bytes):

Writing | ################################################## | 100% 0.41s

avrdude: 1468 bytes of flash written
avrdude: verifying flash memory against blink.hex:
avrdude: load data flash data from input file blink.hex:
avrdude: input file blink.hex auto detected as Intel Hex
avrdude: input file blink.hex contains 1468 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.30s

avrdude: verifying ...
avrdude: 1468 bytes of flash verified

avrdude: safemode: lfuse reads as 0
avrdude: safemode: hfuse reads as 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

4 comments:

  1. Nice work, thanks. Setting the baud rate in combination with the arduino programmer worked directly. I'm working with a cheap Chinese clone which uses a CH340G chip for USB to serial communication. Again, thanks a lot!

    ReplyDelete
  2. Nice work, thanks. Setting the baud rate in combination with the arduino programmer worked directly. I'm working with a cheap Chinese clone which uses a CH340G chip for USB to serial communication. Again, thanks a lot!

    ReplyDelete
  3. what is option -DF_CPU in avrdude is for?

    ReplyDelete