ATMEGA2560 bootloader issues

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to flash my custom chip with our bootloader the commands I am running is this

'avrdude -v -p atmega2560 -c stk500v1 -P /dev/ttyACM0 -b 19200 -e -U lock:w:0xFF:m -U efuse:w:0xFD:m -U hfuse:w:0xDE:m -U lfuse:w:0xFF:m'

'avrdude -v -p atmega2560 -c stk500v1 -P /dev/ttyACM0 -b 19200 -U flash:w:bootloaders/stk500boot_v2_mega2560.hex:i -U lock:w:0xCF:m'

So initially it appears to be working when I run this command on my bootloader rig system ( Raspberry pi with button - > ArduinoISP  -> target), but I notice an error when I try to upload my sketch via Arduino IDE on the Mac OSX. First, it tries to write, then it reads and that's where the issue arises

 

10678 bytes
avrdude: reading on-chip flash data:Reading | ###############################################An error occurred while uploading the sketch
### | 100% 2.31savrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x7c
avrdude: verification error; content mismatchavrdude done.  Thank you

 

 

 

 

 

 

 

I know there is something going on with these fuse bits I am writing but I don't understand how to correct this; if someone can give me a hand that would be awesome in addition to explaining these fuse bits to in regards to why your solution or his/her solution works, thanks!

Last Edited: Sun. Jun 14, 2020 - 05:06 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try adding more and more -v's to the command. Up to four it will get more and more verbose about what is/isn't happening.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

will give this a try shortly and get back to you, thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wrong fuses?

wrong clock speed?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
avrdude: avr_read(): skipping page 986: no interesting data
avrdude: avr_read(): skipping page 987: no interesting data
avrdude: avr_read(): skipping page 988: no interesting data
avrdude: avr_read(): skipping page 989: no interesting data
avrdude: avr_read(): skipping page 990: no interesting data
avrdude: avr_read(): skipping page 991: no interesting data
avrdude: avr_read(): skipping page 1022: no interesting data
avrdude: avr_read(): skipping page 1023: no interesting data
avrdude: verifying ...
avrdude: 261406 bytes of flash verified
avrdude: reading input file "0xCF"
avrdude: writing lock (1 bytes):

Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xCF:
avrdude: load data lock data from input file 0xCF:
avrdude: input file 0xCF contains 1 bytes
avrdude: reading on-chip lock data:

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

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude: safemode read 1, lfuse value: ff
avrdude: safemode read 2, lfuse value: ff
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: safemode read 1, hfuse value: de
avrdude: safemode read 2, hfuse value: de
avrdude: safemode read 3, hfuse value: de
avrdude: safemode: hfuse reads as DE
avrdude: safemode read 1, efuse value: fd
avrdude: safemode read 2, efuse value: fd
avrdude: safemode read 3, efuse value: fd
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)

avrdude done.  Thank you.

pi@raspberrypi3:

I put -vvv here as it got quite noisy, please let me know if you would like me to run it with more verbose output

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

here is additional 5 level v output @clawson

 

avrdude: Recv: . [c1] ] [5d] . [de] O [4f] . [08] . [81] . [cf] R [52] . [d1] @ [40] . [0f] _ [5f] . [c1] ] [5d] . [de] O [4f] . [08] . [83] . [cf] R [52] . [d1] @ [40] . [90] . [e0] . [a0] . [e0] . [b0] . [e0] . [0d] . [94] . [1a] . [f4] ' [27] . [98] / [2f] . [98] . [80] . [e0] . [90] . [e0]   [20] . [ed] 7 [37] . [e0] . [f9] . [01] 1 [31] . [97] . [f1] . [f7] . [01] . [96] . [84] 6 [36] . [91] . [05] . [c9] . [f7] . [00] . [00] . [80] . [91] . [c0] . [00] . [8d] . [7f] . [80] . [93] . [c0] . [00] . [81] . [e1] . [80] . [93] W [57] . [00] . [e8] . [95] . [ee] ' [27] . [ff] ' [27] . [09] . [94] . [ff] . [cf] . [90] . [e0] . [0d] . [94] . [1a] . [f4] . [97] . [fb] . [09] . [2e] . [07] & [26] . [0a] . [d0] w [77] . [fd] . [04] . [d0] . [2e] . [d0] . [06] . [d0] . [00]   [20] . [1a] . [f4] p [70] . [95] a [61] . [95] . [7f] O [4f] . [08] . [95] . [f6] . [f7] . [90] . [95] . [81] . [95] . [9f] O [4f] . [08] . [95] . [a1] . [e2] . [1a] . [2e] . [aa] . [1b] . [bb] . [1b] . [fd] . [01] . [0d] . [c0] . [aa] . [1f] . [bb] . [1f] . [ee] . [1f] . [ff] . [1f] . [a2] . [17] . [b3] . [07] . [e4] . [07] . [f5] . [07]   [20] . [f0] . [a2] . [1b] . [b3] . [0b] . [e4] . [0b] . [f5] . [0b] f [66] . [1f] w [77] . [1f] . [88] . [1f] . [99] . [1f] . [1a] . [94] i [69] . [f7] ` [60] . [95] p [70] . [95] . [80] . [95] . [90] . [95] . [9b] . [01] . [ac] . [01] . [bd] . [01] . [cf] . [01] . [08] . [95] . [aa] . [1b] . [bb] . [1b] Q [51] . [e1] . [07] . [c0] . [aa] . [1f] . [bb] . [1f] . [a6] . [17] . [b7] . [07] . [10] . [f0] . [a6] . [1b] . [b7] . [0b] . [88] . [1f] . [99] . [1f] Z [5a] . [95] . [a9] . [f7] . [80] . [95] . [90] . [95] . [bc] . [01] . [cd] . [01] . [08] . [95] . [f9] . [99] . [fe] . [cf] . [92] . [bd] . [81] . [bd] . [f8] . [9a] . [99] ' [27] . [80] . [b5] . [08] . [95] & [26] / [2f] 
avrdude: Recv: . [10] 
avrdude: Send: U [55] . [80] . [fe]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude: Send: t [74] . [01] . [00] F [46]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [f9] . [99] . [fe] . [cf] . [1f] . [ba] . [92] . [bd] . [81] . [bd]   [20] . [bd] . [0f] . [b6] . [f8] . [94] . [fa] . [9a] . [f9] . [9a] . [0f] . [be] . [01] . [96] . [08] . [95] . [f8] . [94] . [ff] . [cf] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] . [ff] 
avrdude: Recv: . [10] 
avrdude: avr_read(): skipping page 1022: no interesting data
avrdude: avr_read(): skipping page 1023: no interesting data
avrdude: verifying ...
avrdude: 261406 bytes of flash verified
avrdude: reading input file "0xCF"
avrdude: writing lock (1 bytes):

Writing |                                                    | 0% 0.00savrdude: Send: V [56] X [58] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
avrdude: Send: V [56] . [ac] . [e0] . [00] . [cf]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: Send: V [56] X [58] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [cf] 
avrdude: Recv: . [10] 
Writing | ################################################## | 100% 0.03s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0xCF:
avrdude: load data lock data from input file 0xCF:
avrdude: input file 0xCF contains 1 bytes
avrdude: reading on-chip lock data:

Reading |                                                    | 0% 0.00savrdude: Send: V [56] X [58] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [cf] 
avrdude: Recv: . [10] 
Reading | ################################################## | 100% 0.01s

avrdude: verifying ...
avrdude: 1 bytes of lock verified

avrdude: Send: V [56] P [50] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
avrdude: safemode read 1, lfuse value: ff
avrdude: Send: V [56] P [50] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
avrdude: safemode read 2, lfuse value: ff
avrdude: Send: V [56] P [50] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [ff] 
avrdude: Recv: . [10] 
avrdude: safemode read 3, lfuse value: ff
avrdude: safemode: lfuse reads as FF
avrdude: Send: V [56] X [58] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [de] 
avrdude: Recv: . [10] 
avrdude: safemode read 1, hfuse value: de
avrdude: Send: V [56] X [58] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [de] 
avrdude: Recv: . [10] 
avrdude: safemode read 2, hfuse value: de
avrdude: Send: V [56] X [58] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [de] 
avrdude: Recv: . [10] 
avrdude: safemode read 3, hfuse value: de
avrdude: safemode: hfuse reads as DE
avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [fd] 
avrdude: Recv: . [10] 
avrdude: safemode read 1, efuse value: fd
avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [fd] 
avrdude: Recv: . [10] 
avrdude: safemode read 2, efuse value: fd
avrdude: Send: V [56] P [50] . [08] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [fd] 
avrdude: Recv: . [10] 
avrdude: safemode read 3, efuse value: fd
avrdude: safemode: efuse reads as FD
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I dont think so there should be no issue as we have used this from the Arduino IDE before to burn the bootloader all im doing is taking the command and putting it in a different system with the bootloader hex 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

zavrdude: reading on-chip flash data:Reading | ###############################################An error occurred while uploading the sketch
### | 100% 2.31savrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000

It looks like it is failing at the 64kword boundary.  Are you sure your bootloader properly handles the commands needed to access the 2nd 128k?

Usually with stk500v1 this is handled by sneaking in an "SPI Universal command" - so the bootloader doesn't actually understand more than 128k; it just sets RAMPZ and thinks it is re-writing the first 128k.

https://github.com/Optiboot/opti...
https://github.com/Optiboot/opti...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not sure exactly if it properly handles this I just assumed it did since it was the closest contender that I could find in my Arduino paths "stk500boot_v2_mega2560.hex"  is this not the correct bootloader hex for the 2560 chip ? i'm a little confused with this

as I do not see anymore 2560 bootloader hexes in the Arduino paths where it contains the resources for operations such as this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

and if this is not the proper bootloader I am rather unsure where to obtain the correct one for my board?