mega2560s and avrdude?

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have 2 mega2560s... old one with a mega8u2, and a new one with a mega16u2. When I try to load a program with avrdude, I get the stk500v2 timeout error or the did not erase error. I have an avrispmkii, and I can read the fuses in the usb avrs, etc, and I can pgm the mega2560s using the avrisp, but I cant pgm using the dude. These errors are all over the arduino forums back years. I CAN pgm uno r3s no prob using avrdude. If the things cost a bunch, you could send it back to the factory, and a tech would hook it up to the production tester and figure out what needed to be reprogrammed, and send it back. Since it doesnt cost a lot, folks just search the web for how to get it back to working as designed. I'm stumped right now. Can any avrfreak program any model of mega2560 arduino using any version of avrdude? Thanks.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,
Connect your AVRISPmkII to the MEGA2560 board 3x2 header.
Run the Arduino IDE.
Select board, programmer in Tools menu.
Burn Bootloader.
Remove programmer. Dig hole. Bury it.
.
Your Arduino should work fine again.
If you want to use avrdude from outside the Arduino IDE type:

avrdude -c wiring -p ATmega2560 -P com#

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrdude: usbdev_open(): did not find any USB device "usb"
Error while burning bootloader.

 

 

Running arduino1.6.8, win7-32 bit

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why should it look for usb_dev from a COM device ?
Of course you need to tell Windoze about AVRISP-2 via win32-libusb before avrdude will recognise the AVRISP-2.
.
If you can't manage that, connect a STK500 to your MEGA2560. You might need to tell the Arduino IDE about STK500. The IDE definitely knows about USBASP if you can afford $3.
.
Of course you can always use arduinoISP on a good Arduino to burn the bootloader onto your duff MEGA2560.
.
David.

Last Edited: Sat. Sep 3, 2016 - 05:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So to try suggestion number three, I jack the usb into the 2560, I select board in Arduino ide as mega2560, and burn bootloader. I can burn unos using avrdude

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

 

Can you give a step by step for suggestion number 1? I can program the mega2560 using the avrisp and atmel studio. I can program the unos using avrdude. I tried to buy an avrasp a couple years ago, but that fischel dude said he wouldn't sell any of them to US guys. Just trying to get my mega2560s to work with avrdude.

 

Imagecraft compiler user

Last Edited: Sun. Sep 4, 2016 - 12:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you can Burn Biotloader on a UNO, you can do the same thing with a MEGA2560.
.
I am not sure which programmer you have connected. Or if you are able to use the avrdude command line to read the UNO's chip.
If you can read the ATmega328P signature with an external programmer, you can read the ATmega2560's signature too.
.
I don't know what arguments you have had with Mr Fischl. A Chinese USBASP has got perfectly good firmware.
I would guess that you have a choice of several competent hardware programmers, e.g. STK500, STK600, JTAGICE-mkII, AVRISP-2, USBASP, ArduinoISP, ...
.
Avrdude is capable of controlling all this hardware. Note that you have to use the libusb Filter wizard before you can use Atmel USB programmers with avrdude on Windoze. After you have done this, the programmer will work with both acrdude AND with Atmel's Jungo driver. (providing Atmel has not b*ggered its driver)
.
David.

Last Edited: Sat. Sep 3, 2016 - 10:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Let me restate my problem. I can edit and compile a c program and burn it into an uno using avrdude. I'd like to be able to do the same thing with my two megas. There are messages on the arduino forum about getting a recv timeout dating back several years. In the meantime, I have several atmel programmers and avrstudio7, the arduino ide 1.6.8 (which evidently uses ver 5.11 of avrdude), and the latest avrdude 6.3. Thats why I asked about the EXACT config that works. Note that one mega is old, has a mega8u2, other mega is r3, has a mega16u2. I guess the same bootloader goes in the mega2560 in each of them?

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I possess several Uno clones.   I use GCC, CV, ASM, Bascom, ICCv7, ... as well as the Arduino-ese language.

I always use the bootloader to upload the resultant HEX file. e.g.

avrdude -c arduino -p ATmega328P -P com# -U flash:w:project.hex:i

 

Very occasionally,   I use debugWIRE with some of the Uno clones.

When the project is finished,  I disable debugWIRE and restore the bootloader via Arduino IDE.

 

I only have one MEGA2560.   Very, very occasionally I use JTAG debugging during development.

When the project is finished,  I restore the bootloader via Arduino IDE.

avrdude -c wiring -p ATmega2560 -P com# -U flash:w:project.hex:i

It will make no difference what USB chip is used for the comms.   The ATmega2560 just sees a USART.   The bootloader uses the USART.

My assorted clones have got FTDI, CH340, ATmega16u2 USB bridge chips.

 

avrdude has supported both "arduino" and "wiring" for many years.    These are only "stk500v1" or "stk500v2" with added DTR pulse.

 

Of course the R3 boards with 16u2 have a fully functioning USB chip that appears as a regular COM device.

I guess that the older 8u2 chips will work fine too.

If necessary,  you can replace the 8u2 or 16u2 firmware via its separate 3x2 header using an external programmer.

 

@Bob,

If you have a problem,  please paste your actual command lines here.

I possess STK500, ATMEL-ICE, USBASP, ... and obviously ArduinoISP sketch on a Uno.

So I can replicate test / replicate most of your hardware.   I do not own an AVRISP-2.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks DP. I will try to burn the bootloader using my atmelice instead of the avrisp. Havent tried that combination yet.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Morning Dave. I picked up Yet Another mega2560 at Skycraft Saturday. I can compile and load Blink using arduino ide. So I hit the export hex file in tools, and saved blink.ino.with_bootloader.mega.hex in a dir called bgarduino/blink. In this dir I put avrdude .exe and .conf latest version 6.3, and my bat file with this in it;

--------------------

@rem file avrdudecom9.bat Oct 9 16 Bob G for blink
avrdude -v -v -v -p ATmega2560 -c wiring -P com9 -b 115200 -U -F flash:w:blink.ino.with_bootloader.mega.hex 
pause

-------------------------

But when I click on the bat file, no go. The dude says he has detected an AVRISP. What gives with that? Thanks if you or anyone else can upload a hex to a mega using the dude. Its got me stumped. Does the bat file look for avrdude in the local dir first? Or search along the path?

 

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Attached is a directory from Win XP, with AVRDUDE & a bat file.  I just ran the bat file and programmed my Mega2560 clone.

 

You should be able to just change the com port and execute the bat file.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,  at least put a correct command in your BAT file.

 

@rem file avrdudecom9.bat Oct 9 16 Bob G for blink
avrdude -v -v -v -p ATmega2560 -c wiring -P com9 -b 115200 -U -F flash:w:blink.ino.with_bootloader.mega.hex 
pause

e.g.

@rem file avrdudecom9.bat Oct 9 16 Bob G for blink
avrdude -v -v -v -p ATmega2560 -c wiring -P com9 -b 115200 -U flash:w:blink.ino.with_bootloader.mega.hex 
pause

I would simply type from the command line:

avrdude -p ATmega2560 -c wiring -P com9

Your virgin MEGA2560 Arduino board should respond with the Signature.    If you enjoy verbose dross,  add all the -v switches.

Never use the -F switch.   If you do,  do not put it in the middle of a -U argument.

 

You should be able to use the "-c wiring" 2560 Bootloader from AS7 Tools or from your ImageCraft IDE.

Likewise,   the "-c arduino" for a Uno.

 

Yes,  it is worth the bother of setting up the "External Tools" in AS7.   Or even a BAT file for the command line.

Design for your convenience.  e.g. burn2560 filename

This means setting your PATH correctly and using CLI parameters correctly.

 

David.
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you are telling me that the dude from 2014 works, and the one from 2016 is broke? Should I ask George? I do appreciate the reply. I'll get rid of the F when I get home after work. Hope that fixes this sticky wicket.

 

 

Imagecraft compiler user

Last Edited: Mon. Oct 10, 2016 - 04:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would guess that avrdude from 2009 to 2016 will all be 100% fine with both -c wiring and -c arduino
I have no idea who George is. I was just suggesting that you follow the command syntax.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AvrFreakExtraordinaire George Wunsch, Dude Maintainer. I have avrdude 6.3, and I found a doc file for avrdude 6.01. Taking the -F out didnt help.

 

Imagecraft compiler user

Last Edited: Tue. Oct 11, 2016 - 02:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you try the bat file and avrdude that I sent?

 

You said "I think you are telling me that the dude from 2014 works, and the one from 2016 is broke?"

 

no, I have been using that setup for awhile and haven't bothered to update.

 

I think it is the avrdude.conf file that is the problem.  I just copied the .exe and .conf files from Arduino to my setup directory.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Bob,

 

I don't believe you.   An unblemished MEGA2560 board fresh from the shops should work perfectly.

 

If you have placed the avrdude.exe, avrdude.conf and file.hex into the same directory as your BAT file,   everything should work fine.

i.e. the BAT will execute the EXE from your current directory.

 

Likewise,  if you just type a regular command at the command line,  it will search the current directory first.

As far as I know,  the Windows CMD.EXE always searches in this way before looking in PATH.

 

jstampfl's BAT file:

avrdude -cwiring -Pcom55 -b115200 -pm2560 -D -U flash:w:lights.hex:i -v -v -v
pause

I would expect jstampfl's approach to work just fine too.

 

I suggest that you document exactly how and what you have done.

e.g.  the actual current directory.  the actual command line.

e.g.  copy/paste the output.

 

There is nothing magical about a command line or a BAT file.   However,  there might be "differences" over how a PATH is searched.   And whether you have invoked some 'other' avrdude.exe from some 'other' directory.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob said "I think you are telling me that the dude from 2014 works, and the one from 2016 is broke?"

 

No, here is avrdude 6.3 (2016).  Works just fine.

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the bat file:

-----------------------

@rem file avrdudecom9.bat Oct 11 16 Bob G for blink
avrdude.exe -v -v -v -p m2560 -c stk500v2 -P \\.\com9 -b 115200 -U flash:w:blink.ino.mega.hex 
pause

-----------------------

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bob,

Your BAT file will only work if you press the reset button at exactly the right time.
If you use -c wiring then the reset pulse is done automagically.
.
Start with your new board.
Does it work in the Arduino IDE?
If ok, it will work from a sensible BAT file.
Or even directly from the command line.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

-D option required for arduino mega. Also  -c wiring is better than -c stk500v2

 

Last Edited: Wed. Oct 12, 2016 - 06:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well Mr bx1, you are De Man. That -D seems to Do The Trick. This is the Most Efficient Forum on the internet. Figure of merit is Problems Solved/Problems Posted.

 

Imagecraft compiler user