Sketch not updated on Arduino Mega 2560 clone even though output shows uploaded without problems on macOS, Arduino IDE 2.x

Hey. I've just gotten into programming with Arduino and have borrowed a Mega 2560 clone board for testing my sketches. But when I try to upload a test sketch to turn on an LED, the sketch doesn't seem to get updated on the board itself, even though the rx light blinks during upload and no errors show up on the output. When I go into the serial monitor, I see the output for an example sketch from some IR library that was apparently uploaded to the board before I got my hands on it. Pressing the reset button or trying to upload a blank sketch doesn't work. I'm using the latest version of the Arduino 2.x IDE. How should I fix this ? I have confirmed that the led works, I'm wiring through I breadboard. This is my first post, so please excuse mistakes!

My output in the IDE:
Use code tags to format code for the forum


Sketch uses 1334 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.

My program:

void setup() {
  // put your setup code here, to run once:

pinMode(2, OUTPUT);
}
void loop() {
  // put your main code here, to run repeatedly:
digitalWrite(2, HIGH);
}

A picture of the Serial Monitor:

Welcome to the forum

Are you sure that you are uploading the code and not just verifying it ?

1 Like

Yup
I've tried quite a few times too.

Please try uploading a sketch again, perhaps th BareMinimum example, and post the whole of the output from the bottom window of the IDE

Before you do that, got into File/Preferences in the IDE and enable verbose output for both compile and upload and enable all compiler warnings

Ah, I got an error now:

It turns out, I had actually changed the port but hadn't updated in the IDE for this particular upload. But I fixed that and the original problem still persists, without any apparent errors in the output...

Here's the new output:

FQBN: arduino:avr:mega
Using board 'mega' from platform in folder: /Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/sketch/BareMinimum.ino.cpp -o /dev/null
Generating function prototypes...
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/sketch/BareMinimum.ino.cpp -o /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/4118549820/sketch_merged.cpp
/Users/Siddhu/Library/Arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/4118549820/sketch_merged.cpp
Compiling sketch...
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/Users/Siddhu/Library/Arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/sketch/BareMinimum.ino.cpp -o /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/sketch/BareMinimum.ino.cpp.o
Compiling libraries...
Compiling core...
Using precompiled core: /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/cores/arduino_avr_mega_cpu_atmega2560_1f37b8b4dd29b296b762e1c4d7701583/core.a
Linking everything together...
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -Wall -Wextra -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.elf /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/sketch/BareMinimum.ino.cpp.o /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/../../cores/arduino_avr_mega_cpu_atmega2560_1f37b8b4dd29b296b762e1c4d7701583/core.a -L/private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD -lm
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.elf /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.eep
/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy -O ihex -R .eeprom /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.elf /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.hex

/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-size -A /private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.elf
Sketch uses 1334 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
"/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/bin/avrdude" "-C/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega2560 -cwiring "-P/dev/cu.usbserial-110" -b115200 -D "-Uflash:w:/private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.hex:i"

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/Users/Siddhu/Library/Arduino15/packages/arduino/tools/avrdude/6.3.0-arduino17/etc/avrdude.conf"
         User configuration file is "/Users/Siddhu/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbserial-110
         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 "/private/var/folders/mx/_kbrjzmj3d9f5136wqz9qgn00000gp/T/arduino/sketches/4228508A3FAB46CE152AAC84276B8BCD/BareMinimum.ino.hex"
avrdude: writing flash (1334 bytes):

Writing | ################################################## | 100% 0.20s

avrdude: 1334 bytes of flash written

avrdude done.  Thank you.

Sorry for the silly error...

It appears that the "Bare Minimum" sketch was successfully loaded on the board.

What is the Mega doing?

Can you load the "Blink" basic example?

I used the "Bare Minimum" sketch but added my own code in to test:

void setup() {
  // put your setup code here, to run once:
  pinMode(2, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(2, HIGH);
}

I'm trying to make an led turn on as a test

How is the led connected to pin 2. Perhaps it is connected backwards, or perhaps it is burned out, or not wired correctly. If you connect the led to the 5V pin, does it light up?

You would do better to test the Mega itself with the "Blink" sketch using the onboard led.

If the Mega is indeed working without problems, then you can figure out why your led is not working with pin2.

I tried the blink program, it doesn't light up any extra led on the board, much less blink.
The external LED works, I tested it as you said.

I'm starting to think this is an error with the board's USB to Serial Convertor not updating the EEPROM memory even though it shows it is in the output. But this is just a guess...
(Excuse any wrong terminology as I'm new to Arduino)

I tried the blink program, it doesn't light up any extra led on the board

Since this is a borrowed and unknown Mega, the onboard led is perhaps not working. Can you try some of the other basic example sketches.

What is the usb interface chip, and do you have the driver for that installed on the computer? I'm not familiar with Linux and how what errors related to the USB port are detected and reported.

If none of the basic example sketches work, and the driver is correct and if the 2580 chip is not being written by the usb converter then that could be a hardware defect on the board. Perhaps a broken trace, or a lifted pin, or a defective processor or interface chip.

If you had a scope or logic analyzer you might be able to figure out what is wrong, but how much time and energy to do you have to spend on this board?

I'm on macOS, and I've used a uno and mega with my computer before, without this problem so I don't think this is a driver problem

What do you mean by a scope or logic analyzser ? Is it some other board that I would have to get or a piece of software that I could install on my computer ? I could try to get that as I really don't want to condemn the board without trying all reasonable avenues that wouldn't cost too much. Thanks.

I'm not familiar with a Mac. I know there have been some issues reported with version of the OS and some boards.

I'm using the latest version of the Arduino 2.x IDE.

Have you tried with 1.8.19?

If you have successfully used the computer and version of the OS before, you have probably done all the basic "reasonable" things.

I can't be of much more help. Perhaps if you retitled posting to be more Mac specific you might be able to get some others involved. If you make the posting both Mac and V2.x specific, @pert who monitor V2.x issues might get involved.

Hi @sid_g1. Since there is some doubt about the reliability of the approach of using the LED as an indicator of whether the new sketch program is running on the board, I'll suggest an alternative experiment:

Try uploading this sketch to your Arduino board:

  1. Copy and paste this code as a new sketch in Arduino IDE:

    void setup() {
      Serial.begin(9600);
    }
    
    void loop() {
      Serial.println("hello");
      delay(1000);
    }
    
  2. Upload the sketch to your Arduino board.

  3. Select Tools > Serial Monitor from the Arduino IDE menus to open the Serial Monitor view if it is not already open.

  4. Make sure the baud rate menu at the top right corner of the Serial Monitor panel is set to "9600".

Do you now see the word "hello" being printed in the Serial Monitor's output field once a second?

Sure, Thanks a lot for your help! @cattledog

No, I don't. Rather I see the serial output of a library example which was probably installed by the previous user.

Even pressing the reset button doesn't work.

I suppose something has happened to the board, causing it to become unwrite-able to.