Skip to content

error on programming(make upload) #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Blackrose opened this issue Aug 3, 2013 · 27 comments
Closed

error on programming(make upload) #114

Blackrose opened this issue Aug 3, 2013 · 27 comments

Comments

@Blackrose
Copy link

I read readme and setting environment.When i use project WebServer to test it.I got these errors,Could i have resolve it?

make reset

make[1]: Entering directory `/home/blackrose/WebServer'
/opt/Arduino-Makefile/bin/ard-reset-arduino  /dev/ttyACM0
make[1]: Leaving directory `/home/blackrose/WebServer'

make do_upload

make[1]: Entering directory `/home/blackrose/WebServer'
/home/blackrose/arduino-1.0.5/hardware/tools/avrdude -q -V -p atmega2560 -C /home/blackrose/arduino-1.0.5/hardware/tools/avr/../avrdude.conf -c wiring -b 115200 -P /dev/ttyACM0 \
                -U flash:w:build-mega2560/WebServer.hex:i

avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9801
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: stk500v2_command(): command failed

avrdude done.  Thank you.

make[1]: *** [do_upload] Error 255
make[1]: Leaving directory `/home/blackrose/WebServer'
make: *** [upload] Error 2
@sudar
Copy link
Owner

sudar commented Aug 3, 2013

The error message says that, it was not able to find a Mega in port /dev/ttyACM0

Are you sure you have a working Arduino mega connected in port /dev/ttyACM0?

@Blackrose
Copy link
Author

I am sure.It is working fine when i use arduino IDE.

crw-rw---- 1 root      dialout 166,  0 Aug  3 21:04 /dev/ttyACM0

I use fedora15 as my os.

@sudar
Copy link
Owner

sudar commented Aug 3, 2013

Can you add the following line in your makefile (which will enable verbose output for avrdude) and then post the entire output?

AVRDUDE_OPTS = -V -v -v

@Blackrose
Copy link
Author

-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [USER]               ARDMK_DIR = /opt/Arduino-Makefile 
- [USER]               ARDMK_PATH = /opt/Arduino-Makefile/bin 
- [USER]               ARDUINO_DIR = /home/blackrose/arduino-1.0.5 
- [AUTODETECTED]       ARDUINO_VERSION = 105 
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/blackrose/.arduino/preferences.txt 
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/blackrose/sketchbook (from arduino preferences file)
- [BUNDLED]            AVR_TOOLS_DIR = /home/blackrose/arduino-1.0.5/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /home/blackrose/arduino-1.0.5/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = /home/blackrose/arduino-1.0.5/hardware/arduino/cores/arduino 
- [COMPUTED]           ARDUINO_VAR_PATH = /home/blackrose/arduino-1.0.5/hardware/arduino/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = /home/blackrose/arduino-1.0.5/hardware/arduino/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/blackrose/sketchbook/libraries (in user sketchbook)
- [USER]               BOARD_TAG = mega2560 
- [COMPUTED]           OBJDIR = build-mega2560 (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD = -std=gnu99 
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
-
-                      ARDUINO_LIBS =
- [SYSTEM]               Ethernet
- [SYSTEM]               SPI
- [SYSTEM]               Ethernet/utility
-------------------------
make reset
make[1]: Entering directory `/home/blackrose/WebServer'
/opt/Arduino-Makefile/bin/ard-reset-arduino  /dev/ttyACM0
make[1]: Leaving directory `/home/blackrose/WebServer'
make do_upload
make[1]: Entering directory `/home/blackrose/WebServer'
/home/blackrose/arduino-1.0.5/hardware/tools/avrdude -V -v -v -p atmega2560 -C /home/blackrose/arduino-1.0.5/hardware/tools/avr/../avrdude.conf -c wiring -b 115200 -P /dev/ttyACM0 \
                -U flash:w:build-mega2560/WebServer.hex:i

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

         System wide configuration file is "/home/blackrose/arduino-1.0.5/hardware/tools/avr/../avrdude.conf"
         User configuration file is "/home/blackrose/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyACM0
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: wiring_open(): releasing DTR/RTS
avrdude: wiring_open(): asserting DTR/RTS
         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      : 207.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FF
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: stk500v2_command(): command failed

avrdude done.  Thank you.

make[1]: *** [do_upload] Error 255
make[1]: Leaving directory `/home/blackrose/WebServer'
make: *** [upload] Error 2

@sudar
Copy link
Owner

sudar commented Aug 3, 2013

It still shows that there is some problem with the board.

Can you also enable verbose output in Arduino IDE and post that output as well?

@Blackrose
Copy link
Author

ok, i put the log on pastebin, here is link
http://pastebin.com/9uK54SNA

This board doesn't a standard arduino mega2560.It is a compatible board.

@sudar
Copy link
Owner

sudar commented Aug 4, 2013

I see that both are issuing the same avrdude command.

Since you mentioned that it is a compatible board, what are you selecting in the boards menu in Arduino IDE? You are select Arduino Mega or something else?

Also can you try the same sketch in both Arduino IDE and makefile? Just to rule out any sketch specific issues.

@Blackrose
Copy link
Author

I select board is arduino mega 2560 on Arduino IDE.And this time i use your example program, the webserver.
I put two log on pastebin.
One is webserver on arduino upload.(this is not include all information, just a part of head)
http://pastebin.com/ytSBM9ub

Two is webserver on arduino-makefile
http://pastebin.com/vmStFS6V

@sudar
Copy link
Owner

sudar commented Aug 4, 2013

This is really really strange, since both are issuing similar command to avrdude

IDE is issuing

/home/blackrose/arduino-1.0.5/hardware/tools/avrdude -C/home/blackrose/arduino-1.0.5/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:/tmp/build702881270538152475.tmp/WebServer.cpp.hex:i

Where as make file is issuing

/home/blackrose/arduino-1.0.5/hardware/tools/avrdude -V -v -v -p atmega2560 -C /home/blackrose/arduino-1.0.5/hardware/tools/avr/../avrdude.conf -c wiring -b 115200 -P /dev/ttyACM0 \
                -U flash:w:build-mega2560/WebServer.hex:i

I don't see any difference in these commands.

You said it is a Mega compatible board. Can you give me more details about this board? Is there a link or something?

Also as a final resort, can you execute this command manually after doing make and paste the output as well?

/home/blackrose/arduino-1.0.5/hardware/tools/avrdude -C/home/blackrose/arduino-1.0.5/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyACM0 -b115200 -D -Uflash:w:build-mega2560/WebServer.hex:i

@Blackrose
Copy link
Author

I have execute that command, it's programming is right.I saw some info about the board, all is same with standard.May be other place have a problem.
Here is success programming log.
http://pastebin.com/FPMjUnw2

@Blackrose
Copy link
Author

I find the difference of that two commands.The Arduino IDE use -D parameter in command.
I got some info when execute command of Arduino-Makefile.
avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D8
avrdude: safemode: efuse reads as FF
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: stk500v2_command(): command failed

It's programming success,when i add -D parameter after do_upload in Arduino.mk file.

@sej7278
Copy link
Collaborator

sej7278 commented Aug 6, 2013

the makefile also uses the -V (note uppercase = do not verify) when combined with -D (disable auto erase) it makes you wonder if -D is just silently failing and you have bad flash memory. do the sketches actually work?

@Blackrose
Copy link
Author

I try to programming more times and it works fine.You means the flash memory is bad.Why arduino IDE add this parameter? It will check flash before programming and to decide add -D or not.Is this right?

@sej7278
Copy link
Collaborator

sej7278 commented Aug 7, 2013

no the -D flag is set if in the IDE you tick the box that says "verify code after upload" in File->Preferences.

I really don't see how -D is solving your problem, unless its some weird timing thing.

@sudar
Copy link
Owner

sudar commented Aug 9, 2013

@Blackrose Is it working fine with the makefile?

As @sej7278 suggested, I guess there was some problem with the flash memory.

Can you try a very simple sketch like Blink and confirm that it works both with makefile and with the IDE?

@Blackrose
Copy link
Author

@sej7278 the -D flag always enabled whatever "verify code after upload" has been tick.The -V flag set by "verify code after upload".
@sudar I have try more times.It success that -D flag need added.

@sudar
Copy link
Owner

sudar commented Aug 11, 2013

@Blackrose So is it working if you add the -D flag?

@Blackrose
Copy link
Author

@sudar yeah, it works fine.

@sudar
Copy link
Owner

sudar commented Aug 12, 2013

@Blackrose Thanks for confirming that it works. I am closing the ticket for now.

@sudar sudar closed this as completed Aug 12, 2013
@matthijskooijman
Copy link
Contributor

I also just ran into this problem, it seems that the chip erase command is somehow not supported by the Arduino Mega2560's bootloader (that, or avrdude is sending the wrong command somehow).

Perhaps Arduino-Makefile can also unconditionally pass -D to avrdude (just like the IDE does), to suppress the auto-erase? IIUC, this only means that any parts of the flash not overwritten by the upload will just remain at their old values instead of being erased to 0xff, which I guess shouldn't hurt?

Looking at the stk500v2 bootloader sources, it seems that the erase command indeed isn't supported. The source says:

Erasing the device without flashing, through AVRISP GUI button "Erase Device"
is not implemented, due to AVRStudio limitations.
Flash is always erased before programming.

On the other hand, the code also has no-op handling for the CMD_CHIP_ERASE_ISP command. Running avrdude with enough -v's shows that this is indeed the command run (0x12 about halfway the message):

avrdude: erasing chip
avrdude: Send: . [1b] . [17] . [00] . [07] . [0e] . [12] . [09] . [00] . [ac] . [80] . [00] . [00] 2 [32]
avrdude: Recv: . [1b]
avrdude: Recv: . [17]
avrdude: Recv: . [00]
avrdude: Recv: . [02]
avrdude: Recv: . [0e]
avrdude: Recv: . [12]
avrdude: Recv: . [c0]
avrdude: Recv: . [d2]
avrdude: stk500v2_command(): command failed

However, the return status returned by my Mega 2560 is 0xc0, which is STATUS_CMD_FAILED not STATUS_CMD_OK as the code shows. Looking a bit further, it seems this was changed in the IDE branch:
https://github.com/arduino/Arduino/blob/ide-1.5.x/hardware/arduino/avr/bootloaders/stk500v2/stk500boot.c#L972
arduino/Arduino@8e1f626
arduino/Arduino#543

@sudar sudar reopened this Sep 25, 2013
@sudar
Copy link
Owner

sudar commented Sep 25, 2013

@matthijskooijman Thanks for digging this up and also for the detailed analysis.

Perhaps Arduino-Makefile can also unconditionally pass -D to avrdude (just like the IDE does), to suppress the auto-erase?

It is always better to emulate the IDE as much as possible to prevent any compatibility issues. Will do this.

@sudar sudar closed this as completed in 0f68487 Sep 25, 2013
@sej7278
Copy link
Collaborator

sej7278 commented Sep 29, 2013

ide 1.0.5 doesn't pass -D to avrdude

/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P/dev/ttyACM0 -b19200 -Uflash:w:/tmp/build2003961473513720293.tmp/Blink.cpp.hex:i 

@matthijskooijman
Copy link
Contributor

That's weird, the code says it always adds -D: https://github.com/arduino/Arduino/blob/1.0.5/app/src/processing/app/debug/AvrdudeUploader.java#L169

I wonder if I'm looking at the wrong code...

@sudar
Copy link
Owner

sudar commented Oct 2, 2013

ide 1.0.5 doesn't pass -D to avrdude

@sej7278 I just tried in both Arduino 1.0.5 and 1.5.4 that I downloaded from Arduino website and they indeed seem to be adding -D

/home/sudar/apps/arduino-1.5.4/hardware/tools/avrdude -C/home/sudar/apps/arduino-1.5.4/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -PCOM1 -b115200 -D -Uflash:w:/tmp/build7420687799204564485.tmp/Blink.cpp.hex:i 
/home/sudar/apps/arduino-1.0.5/hardware/tools/avrdude -C/home/sudar/apps/arduino-1.0.5/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyS0 -b115200 -D -V -Uflash:w:/tmp/build3748615820587520950.tmp/Blink.cpp.hex:i 

Did you download your Arduino IDE from arduino website or installed it using some other means?

@sej7278
Copy link
Collaborator

sej7278 commented Oct 2, 2013

no i used the debian package, which seems to have the line mentioned above in its source, and i can't find a patch that removes it....

@matthijskooijman
Copy link
Contributor

I just also tried the Debian version 1:1.0.5+dfsg2-1 and it's passing -D normally:

/usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega2560 -cwiring -P/dev/ttyUSB0 -b115200 -D -Uflash:w:/tmp/build8086441477997339045.tmp/Blink.cpp.hex:i 

Weird...

@Fusseldieb
Copy link

@Blackrose So is it working if you add the -D flag?

Same problem here too. Adding the -D flashes the chip successfully, but doesn't erase it beforehand, which could lead to problems, I guess...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants