[SOLVED] ATMega2560 Bootloader on GT2560 Board

Hi,

I have a board from a 3d printer with an ATMega2560 and try to reinstall the bootloader on it. The upload of the bootloader works without error messages but an upload of a program over USB does not work. Error "timeout". I looked at the signals on the chip: Rx, TX and Reset. Everything looks as expected: after the reset the IDE sends a few bytes, but the 2560 does not respond as expected.
Uploading a program with the programmer works. The fuses are all set as they should be (compared to a working Arduino Mega).
Is there anything that could prevent the bootloader from running?

Reinhard

When you upload to the board with your programmer the bootloader is erased. After doing that, you need to do another Tools > Burn Bootloader before you can go back to regular uploads over USB.

Yes I know, I did it several times.

  1. Upload the bootloader -> no errors
  2. Try to upload a program over USB -> didn't work
  3. Upload a program with the programmer -> worked

back to 1 and try again -> no success

Attached is the debug output when burning the bootloader, in my eyes everything looks fine

debug_bootloader.txt (10.1 KB)

SOLVED

I used Nick Gammons Bootloader on an Arduino UNO and it worked right out of the box.
https://www.gammon.com.au/bootloader

I don't know what was wrong before. I never had problems before with my programmer mySmartUSB.

I'm glad to hear you got it working. I had a look at the output you posted from using your other programmer and it all looks good to me.

I'm not familiar with the mySmartUSB programmer. Are you using Tools > Programmer > AVRISP mkII?

I have the same "timeout()" problem with atmega2560 Rev3. Reading some suggestions around the www I realized that my board has CH340-like programmer that I do not know how to make doing its work. Experimenting on my board I've tried the following:

  1. One of the most "famous" recipes to press Reboot just before uploading firmware.hex. Doesn't work for me at all.
    (Arduino: Upload Timeout error - Stack Overflow)
  2. Some folks on this forum suggested to put a 15kOhm jumper on ICSP pins 5 and 6. Busted... (Mega2560/CH340G, bootloader woes, avrdude timeout [SOLVED with solution] - Microcontrollers - Arduino Forum)
  3. I've started to use USBasp programmer, and been able to "Burn bootloader", but... What happens after burning it is still a secret for me cuz on-board pin is starting to blink, through that I've started experimenting, uploading sketches through USBasp... but there were no success. Sketches simply did not work.
  4. Then I've got AVRDUDESS app, pretty handy tho', believing that I can program firmware.hex using the same USBasp... there were no success again, it uploads with success but the programs aren't work at all.
  5. Finally I've installed CH340 drivers on both Win and mac machines using a port it provides to upload firmwares... Neither succeed.

I have to mention though that the very first upload was successfull, however as many folks were commenting they were able to burn bootloader and repeat their very first upload I couldn't repeat that lucky moment.
It also quite a bit uncomfortable way for me to be able to upload programs only from PCs and rather ONLY using ArduinoIDE, because I am using another IDE.
So, I completely lost any hope to bring atmega2560+CH340 to work. The only thing I have not tried is Nick's Bootloader.

I cannot get rid of the feeling that the problem is actually in hardware... Could anyone point me to a solution or at least to a true reason of this issue?
Thanks!


PS: Sorry for posting in a SOLVED thread, I found there are many similar themes so I won't to create another one.


UPD: Useful links
code.google.com/archive/p/arduino/issues/806
forum.arduino.cc/index.php?topic=83079.150

  • USBasp
    www.freetronics.com.au/pages/usbasp-icsp-programmer-quickstart-guide
  • dfu-programmer:
    www.arduino.cc/en/Hacking/DFUProgramming8U2
    blog.realhe.ro/hardware/how-to-restore-or-update-arduino-mega-2560-firmware/
  • CH3** chips
    http://www.wch.cn/products/category/1.html

way5:
been able to "Burn bootloader", but... What happens after burning it is still a secret for me cuz on-board pin is starting to blink

That's normal. I just means the bootloader was successfully installed.

way5:
through that I've started experimenting, uploading sketches through USBasp... but there were no success. Sketches simply did not work.

This is the single flaw of the USBasp. With the stock USBasp firmware and Arduino Mega fuse settings, if you do an Upload Using Programmer with the USBasp, the sketch never runs. Details here (though note the discussion gets split between the issue as it occurrs with Arduino as ISP as well as USBasp):

My preferred solution to that issue with the USBasp is to install the 3rd party firmware provided by some of the Arduino community members:

However, Upload Using Programmer is kind of inconvenient. I would suggest you make an effort to get regular uploads working before resigning yourself to only being able to upload to your Mega via the USBasp. The thing you need to know is that when you do an Upload Using Programmer, it erases the bootloader. So, after doing that, you always need to do another Burn Bootloader before you can go back to doing standard upload.

Thanks @pert, I am doing update of USBasp I have.

pert:
I would suggest you make an effort to get regular uploads working before resigning yourself to only being able to upload to your Mega via the USBasp.

That brings us back to my question about "how to make it work" and where lies a problem?

way5:
That brings us back to my question about "how to make it work" and where lies a problem?

From your previous reply, it sounded like you successfully burned the bootloader, saw a blinking light, then did an Upload Using Programmer and found the sketch never started running. You never mentioned that you actually tried a standard upload after doing the Burn Bootloader (and before doing an Upload Using Programmer).

BTW, Burn Bootloader will work fine with the stock USBasp firmware. It's only Upload Using Programmer that requires the 3rd party firmware.

pert:
You never mentioned that you actually tried a standard upload after doing the Burn Bootloader (and before doing an Upload Using Programmer).

You're right, I thought I did... Every time I am trying to flash the device there are the following traces:

Using Port                    : /dev/cu.usbserial-14620
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
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
avrdude done.  Thank you.
An error occurred while uploading the sketch

That is equal for both Win and Mac. Once again let me to go over the procedure:

3.1. Using USBasp to burn the bootloader. After that I have on-board LED blinking.
3.2. Connect the board directly using usb cable, and using programmer "AVRISP mkll" upload the sketch.

Afterwards I have an exhaust that I've mentioned above. Nothing changing if I am using jumpers with resistors or capasitors over RST and GND pins or whatever. All the same procedure with different programmers.
The port provided by driver for CH340 doesn't work either.

UPD: I think also will be useful to mention onboard leds behavior while uploading. RX and TX leds are just blinking once every time programmer does a new attempt, for instance in comparison with UNO board while uploading RX+TX leds are flashing until the board being rebooted. Here it seems the hardware does reboot immediately after being flashed.

It looks like you did everything correctly. It may be that the board is defective or damaged in a way that prevents standard uploads. Perhaps someone else here will have some additional advice on resolving this problem. Otherwise, you could proceed with the Upload Using Programmer alternative. Let me know if you have any difficulties with the USBasp firmware update process.

I successfully updated USBasp, thanks again for the links with an explanation. Looks like now I am able to upload sketches via programmer.
This thing is really helpful but nothing can replace direct "Upload". Going to try to flash using ArduinoISP...

I agree about standard upload being much more convenient. I am almost always using serial debug output, so I prefer to use that same connection to upload. Well, at least you now have the best AVR ISP programmer on the market! I own all the popular ones but the USBasp with the 3rd party firmware is by far my favorite.