Mega2560 board refuse to lod sketch

Hi
I have been fighting with this problem for about 2 days now. I can upload a sketch I have written to both a Uno and a Nano (using 2 different COM ports due to different connection types) but both the Uno and the Mega are using the SAME port connection physically.

DM shows that it recognises a Mega 2560 on COM16, and allgoes well until it cmes to writing to the chip when I receive the following upload log.

avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM16
Using Programmer : wiring
Overriding Baud Rate : 115200
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
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 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 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 : Wiring
Description : Wiring
Programmer Model: AVRISP
Hardware Version: 15
Firmware Version Master : 2.10
Vtarget : 0.0 V
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "C:\Users\olwen\AppData\Local\Temp\arduino_build_469192/Railway_master_point_controller.ino.hex"
avrdude: writing flash (10162 bytes):

Writing | ################################################avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

Eventually it gives up..

This is Windows 10, I have just installed 1.8.5 of the interface

I canot use the uno in this application as 1) I have already built the controlboard that it powers, AND 2) wired it all up behind the facia the Mega should sit behind. In desperation I have disconnected the I2C wires and the 5V/GND takes offs from the board that feeds other stuff - JIC

I even had the driver being a RAMPS (from my 3d printer stuff), but nothing seems to make any differnce.

Interestingly, the L bliks constantly during the upload attempt, and there are intermittent TX/RX flashes.

The other thing I notice after reading everything else on the forum is that the L only blink O~NCE on power up, but my reading suggests it should flash 3 times ?

I tried to burn the bootloader from the interface, but that reports :

System wide configuration file is "C:\Users\olwen\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

Using Port : usb
Using Programmer : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb" (0x03eb:0x2104)

avrdude done. Thank you.

Error while burning bootloader.

At the end of my tether really, so any help would really be appreciated.

Ian

Hi,

It seems that you have the same problem I encounter...

See here : Arduino MEGA 2560 programming problems with IDE 1.8.5 - Installation & Troubleshooting - Arduino Forum

I still haven't find a solution

On your side, could you explain how did you program the booltoader ?

To be continued.....
:confused:

Yep, I read that thread before posting !
I just used the "Burn Bootloader" option on the bottom of the TOOLS menu, but it seems that the data is not there ? wherever there is, and whatever the required missing file is ?

NB As I understand it, you need to have the Mega connected and the port set correctly to do this. Not that it made any difference for me, even with the latest Arduino software installed.

Ian

OK, so ot means that you are using another Arduino board as ISP ?

pat-ase30:
OK, so ot means that you are using another Arduino board as ISP ?

No, nothing clever.... If I use the exact USB same cable for both Uno and Mega (connected to the self same USB port extender board on my PC), other than having to change the COM port that is, as they switch somehow in the PC, and change the board type, Uno works fine, Mega fails.

My system is set to use the "AVRISP mkII" board, but I have even tried using other progrmmer options - none of those options work on the Mega.

"My system is set to use the "AVRISP mkII" board, but I have even tried using other progrmmer options - none of those options work on the Mega."

You need an actual programmer.
Usbasp is a good cheap choice.

Something like this.

kprims:
"My system is set to use the "AVRISP mkII" board, but I have even tried using other progrmmer options - none of those options work on the Mega."

You need an actual programmer.
Usbasp is a good cheap choice.

Something like this.

https://www.ebay.com/itm/10-Pin-Convert-to-Standard-6-Pin-Adapter-Board-USBASP-USBISP-AVR-Programmer-USB/311565595115?epid=1831346192&hash=item488ac1b1eb:g:TTYAAOxyF19SGbJr

Hi kprims

Thanks for that, but I cannot understand why I may need any form of external programmer card just for a mega2560 ? It is listed as being supported by the Arduino environment, so why can I not simply upload sketches in exactly the same way as with Uno, Nano, or all the other sundry boards also supported by Arduino, and that work just fine. ?

"Thanks for that, but I cannot understand why I may need any form of external programmer card just for a mega2560 ? It is listed as being supported by the Arduino environment, so why can I not simply upload sketches in exactly the same way as with Uno, Nano, or all the other sundry boards also supported by Arduino, and that work just fine. ?"

Should be able to load sketches compiled for atmega2560 the same as for Uno or Nano. Remove your wiring if you have any, on Tx and Rx. Show what you have connected and you will probably get some better help

You need an external programmer to load/reload the bootloader and in some cases to load a sketch using said programmer which would remove the bootloader and make you use the programmer to reload the bootloader.

kprims:
You need an external programmer to load/reload the bootloader and in some cases to load a sketch using said programmer which would remove the bootloader and make you use the programmer to reload the bootloader.

Holy hell, why is the Mega so difficult compared to the rest. When I decided on it there was no info telling me I would need all sorts of extra "stuff" just to upload a damned sketch to it. It is claimed to be a totally "standard" arduino compatible board, just lots more pins, which is what I need from it despite using I2c to drive a nano elsewhere to perform the commands. ?

Why can I not burn the correct bootloader directly ? it is not greyed out, it just fails miserably.?

I happen to have 10 pin USBASP adaptor on my shelf, but when I try to install the drvers for it, W10 balks at the fact the driver is not signed, and gives me no option to continue without them having to pay Mickey any money. So even using this oppption is a non starter for me on W10, cos I cannot install the driver. !!!!!!

I'm sorry. I am not communicating very well. A working Mega doesn't need an external programmer. When you suspect the bootloader isn't working right is when you could try a programmer.

chopperaddict:
Holy hell, why is the Mega so difficult compared to the rest. When I decided on it there was no info telling me I would need all sorts of extra "stuff" just to upload a damned sketch to it. It is claimed to be a totally "standard" arduino compatible board, just lots more pins, which is what I need from it despite using I2c to drive a nano elsewhere to perform the commands. ?

Why can I not burn the correct bootloader directly ? it is not greyed out, it just fails miserably.?

I happen to have 10 pin USBASP adaptor on my shelf, but when I try to install the drvers for it, W10 balks at the fact the driver is not signed, and gives me no option to continue without them having to pay Mickey any money. So even using this oppption is a non starter for me on W10, cos I cannot install the driver. !!!!!!

The mega is no more difficult. Reloading the bootloader on any Arduino board requires an external programmer. The bootloader is what allows you to program it with just a serial adapter (which is built into most Arduinos)

That said, you should never have to reload the bootloader unless you do something with an external programmer, or manage to do something really weird to it. More often, those errors indicate that something is connected to the 0, 1, or Reset pins (or - heaven forbid - hardware damage); it can also happen if the wrong board or speed is selected.

You are using the wrong driver for the USBAsp. Use Zadig to load the correct one.

There have been versions of bootloaders that entered debug mode when they see "!!!" in the data,
any chance your code contains three consecutive exclamation marks?

Hi again !

I confirm what Kprims is telling us : A functionnal Mega2560 doesn't need anything else that Arduinon IDE for sketch loading.

I already used Mega2560 boards on two other projects, and I never had such an issue.
That's the first time I have similar programming problems, and at the beginning, with my actual board, all was Ok, the probem appeared later.

So, I think that if the bootloader is out of service it's very complicated to reload it... and there is no real and clear procedure (or maybe I still don't find it !).

As I understand, there are several ways for programming :

  • use external ISP (
  • use another Arduino board as an ISP
  • use DFU mode and a programmer software such as FLIP from Atmel

Am I right ?

Kprims, if you know such a reliable procedure, it would be great for us !

"Kprims, if you know such a reliable procedure, it would be great for us !"

This works well for me. I made up a cable like the one described and also use it for Arduino as ISP. Have had less trouble using the Gammon procedure.

http://www.gammon.com.au/bootloader

Some good information on Usbasp. I have been using the updated firmware on the Usbasp's I use with no problems on many different chips. I prefer the Usbasp over most other methods. Use a 10pin to 6pin converter and learn how to connect to the ISP header and you are good to go. Check out some Youtube videos.
This may take some study and is more complicated but it is worth it and fairly cheap.

Whandall:
There have been versions of bootloaders that entered debug mode when they see "!!!" in the data,
any chance your code contains three consecutive exclamation marks?

Well well, you are absolutely correct in so far that I do (DID) indeed have a few instance of multiple shrieks, mostly in my comments, which I have now removed. Sadly I cannot prove or disprove your quite logical theory at present for the following reason(s).

I downloaded and used Zadig as suggested above, and that installed a driver named libusb-win32. The properties sheet for this shows the Manufacturer (of UBasp I assume) as being www.fischl.de. The problem is that is listed in my DM as being a new and separate device class named "libusb-win32 devices" that cotains my USBasp device. The downside of that is that it no longer has, or can even get a COM port assigned to it. Therefore I cannot address it from the Arduino. I have tried after setting the USBASP as the programmer etc, but I get error messages all over the place, mostly that it cannot find a MEGA2560 device.

I have made up what I believe to be a correctly wired adaptor to go between the 10 pin output of the programmer and the 6 pins of the board's ICP header, based on endless checking and double checking on Utube and Google in an attempt to get it right. I read that a lot of these USBASP programmer boards are received from China wired incorrectly, so the red line is on the wrong side etc, and have gone to the lengths of pinging the 10 pin output to validate the 5v pin. This showed that all other pins on that side are all GND's strangely.

So my current position is that I cannot access the MEGA2560 at all. Plugging it in to a USB cable shows it in DM as being a USB Device all of its own, and of course, no COM port is available.

PLEASE HELP ! I seem to have gone backwards here so far. As an aside, this MEGA board was brand new, unused at the start of this saga, and as you already know, it did used to get a COM port assigned when plugged in previously, it just continually timed out when uploading the real sketch it is due to use, but accepted a smaller test sketch without problems. Maybe indeed the multiple !!! that were in my code are indeed the cause as suggested above, but without allocation of a COM port, I cannot try it out..

W10, multi processor, 16GB ram, fast graphics card etc.

I have a Mega clone here, that shows the "debug" feature.

void setup() {
  Serial.begin(250000);
  Serial.println(F("!!!"));
}
void loop() {}
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\Tim-Mobil\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM30
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         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    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 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 : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file "C:\Users\TIM-MO~1\AppData\Local\Temp\arduino_build_987249/KillerExclamation.ino.hex"
avrdude: writing flash (1816 bytes):

Writing | avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
void setup() {
  Serial.begin(250000);
  Serial.println(F("!*!!"));
}
void loop() {}

Whandall:
I have a Mega clone here, that shows the "debug" feature.

Grea stuff Whandall

No I just need to be able to actually connect to my mega somehow or other (as per my previous message) and I can hopefully upload my non shriek filled code :slight_smile: !!!