platformio / platformio-docs

PlatformIO Documentation
https://docs.platformio.org
Apache License 2.0
249 stars 328 forks source link

avrdude upload error. content mismatch #198

Open pistoletov1974 opened 3 years ago

pistoletov1974 commented 3 years ago

Hi. I suppouse the problem is in erase flag. I use buton PlatformIO:Upload Platformio.ini:

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
board_build.f_cpu = 8000000L
board_build.mcu = atmega2560

framework = arduino
upload_protocol = usbasp -B4.0

This is verbose output of upload command:

Total                      9591
<lambda>(["upload"], [".pio\build\megaatmega2560\firmware.hex"])
AVAILABLE: usbasp -B4.0
CURRENT: upload_protocol = usbasp -B4.0
BeforeUpload(["upload"], [".pio\build\megaatmega2560\firmware.hex"])
avrdude -v -p atmega2560 -C C:\Users\Me\.platformio\packages\tool-avrdude\avrdude.conf -c usbasp -B4.0 -D -U flash:w:.pio\build\megaatmega2560\firmware.hex:i

avrdude: Version 5.11-Patch#7610, compiled on Aug 31 2011 at 08:02:19
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Users\Me\.platformio\packages\tool-avrdude\avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbasp
         Setting bit clk period        : 4.0
         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 : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: set SCK frequency to 187500 Hz
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e9801
avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as 99
avrdude: safemode: efuse reads as FF
avrdude: reading input file ".pio\build\megaatmega2560\firmware.hex"
avrdude: writing flash (1548 bytes):

Writing | ################################################## | 100% 0.98s

avrdude: 1548 bytes of flash written
avrdude: verifying flash memory against .pio\build\megaatmega2560\firmware.hex:
avrdude: load data flash data from input file .pio\build\megaatmega2560\firmware.hex:
avrdude: input file .pio\build\megaatmega2560\firmware.hex contains 1548 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.63s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0002
         0x17 != 0x01
avrdude: verification error; content mismatch

avrdude: safemode: lfuse reads as 62
avrdude: safemode: hfuse reads as 99
avrdude: safemode: efuse reads as FF
avrdude: safemode: Fuses OK

avrdude done.  Thank you.
eismeraldo commented 3 years ago

I had the same problem. The solution is the following entry in the platformio.ini upload_flags = -e -e means to erease the memory before the upload