Skip to content
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

Fix proposal for #1832 #1834

Closed
wants to merge 0 commits into from
Closed

Fix proposal for #1832 #1834

wants to merge 0 commits into from

Conversation

dbuchwald
Copy link
Contributor

This fix should enable correct operation of bootrow memory on compatible devices using serialupdi programming protocol.

Before the fix:

❯ ./build_darwin/src/avrdude -c serialupdi -p 16eb28 -U bootrow:w:'"this is a test"':m -P /dev/cu.usbserial-1410
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e943f (probably 16eb28)
avrdude: reading 15 bytes for bootrow from input file "this is a test"
         in 1 section [0, 14]: 1 page and 49 pad bytes
         writing 15 bytes to bootrow ...
         writing | -------------------------------------------------- | 0% 0.02 s
avrdude error: invalid memory: <bootrow:64>, 0x000000, 64 (0x0040)
         reading | ################################################## | 100% 0.02 s
avrdude warning: bootrow verification mismatch
        device 0xff != input 0x74 at addr 0x0000 (error)
avrdude error: bootrow verification mismatch

avrdude done.  Thank you.

After the fix:

❯ ./build_darwin/src/avrdude -c serialupdi -p 16eb28 -U bootrow:w:'"this is a test"':m -P /dev/cu.usbserial-1410
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e943f (probably 16eb28)
avrdude: reading 15 bytes for bootrow from input file "this is a test"
         in 1 section [0, 14]: 1 page and 49 pad bytes
         writing 15 bytes to bootrow ...
         writing | ################################################## | 100% 0.06 s
         reading | ################################################## | 100% 0.02 s
         15 bytes of bootrow verified

avrdude done.  Thank you.

@stefanrueger
Copy link
Collaborator

Perfect, I also checked with the 64du28. Works, too.

Create random multi-memory file for AVR64DU28

avrdude -c dryrun -p 64du28 -xrandom -xseed=7 -U all:r:64du28-dry-backup.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9622 (probably 64du28)
         reading multiple memories ...
         eeprom          | ################################################## | 100% 0.00 s 
         flash           | ################################################## | 100% 0.00 s 
         fuses           | ################################################## | 100% 0.00 s 
         lock            | ################################################## | 100% 0.00 s 
         prodsig/sigrow  | ################################################## | 100% 0.00 s 
         bootrow         | ################################################## | 100% 0.00 s 
         userrow/usersig | ################################################## | 100% 0.00 s 
         sib             | ################################################## | 100% 0.01 s 
         writing 66740 bytes to output file 64du28-dry-backup.hex

avrdude done.  Thank you.

Write that file to, and verify it against, a real AVR16DU28 using serialupdi (incl bootrow)

avrdude -c serialupdi -p 64du28 -U all:w:64du28-dry-backup.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9622 (probably 64du28)
avrdude: Note: carrying out an erase cycle as flash memory needs programming (-U all:w:...)
         specify the -D option to disable this feature
avrdude: erasing chip
avrdude: reading 66740 bytes for multiple memories from input file 64du28-dry-backup.hex
avrdude: 256 bytes eeprom in 1 section [0, 0xff]
         writing 256 bytes to eeprom ...
         writing | ################################################## | 100% 10.25 s 
         reading | ################################################## | 100% 1.05 s 
         256 bytes of eeprom verified
avrdude: 65536 bytes flash in 1 section [0, 0xffff]: 128 pages and 0 pad bytes
         writing 65536 bytes to flash ...
         writing | ################################################## | 100% 9.90 s 
         reading | ################################################## | 100% 8.97 s 
         65536 bytes of flash verified
avrdude: 16 bytes fuses in 1 section [0, 15]
         writing 16 bytes to fuses ..., 16 bytes written, 16 verified
avrdude: 4 bytes lock in 1 section [0, 3]
         writing 4 bytes to lock ..., 4 bytes written, 4 verified
avrdude: 256 bytes bootrow in 1 section [0, 0xff]: 1 page and 0 pad bytes
         writing 256 bytes to bootrow ...
         writing | ################################################## | 100% 0.05 s 
         reading | ################################################## | 100% 0.04 s 
         256 bytes of bootrow verified
avrdude: 512 bytes userrow/usersig in 1 section [0, 0x1ff]: 1 page and 0 pad bytes
         writing 512 bytes to userrow/usersig ...
         writing | ################################################## | 100% 0.17 s 
         reading | ################################################## | 100% 0.23 s 
         512 bytes of userrow/usersig verified

avrdude done.  Thank you.

Terminal also works

avrdude -p 64du28 -c serialupdi -t

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9622 (probably 64du28)
avrdude> d boo
Reading | ################################################## | 100% 0.04 s 
0000  20 40 40 40 40 20 20 20  40 20 40 40 20 20 40 20  | @@@@   @ @@  @ |
0010  20 20 40 40 40 20 40 20  40 40 40 40 20 40 20 20  |  @@@ @ @@@@ @  |
0020  20 20 40 20 40 20 20 40  20 40 40 40 40 40 40 20  |  @ @  @ @@@@@@ |
0030  40 40 40 20 40 40 20 20  40 40 20 20 20 20 20 20  |@@@ @@  @@      |
0040  20 20 40 20 40 40 20 20  40 20 20 40 40 40 40 20  |  @ @@  @  @@@@ |
0050  20 20 20 20 40 20 40 40  20 20 40 40 20 40 20 20  |    @ @@  @@ @  |
0060  40 40 20 40 40 40 40 20  40 40 40 20 40 40 20 40  |@@ @@@@ @@@ @@ @|
0070  20 40 40 20 20 40 40 20  40 20 40 40 20 20 40 20  | @@  @@ @ @@  @ |
0080  20 20 20 20 40 40 20 40  20 20 40 20 20 40 40 20  |    @@ @  @  @@ |
0090  40 20 20 40 40 40 40 20  40 20 20 40 40 20 40 20  |@  @@@@ @  @@ @ |
00a0  40 20 40 20 20 40 40 20  40 20 20 40 40 40 20 40  |@ @  @@ @  @@@ @|
00b0  40 40 40 20 40 20 20 40  20 20 20 20 20 20 20 20  |@@@ @  @        |
00c0  40 40 20 20 20 40 20 40  20 40 40 40 40 40 20 40  |@@   @ @ @@@@@ @|
00d0  40 20 40 20 40 40 20 40  20 40 40 20 40 40 40 20  |@ @ @@ @ @@ @@@ |
00e0  40 20 20 20 40 40 20 40  40 40 20 20 20 20 40 20  |@   @@ @@@    @ |
00f0  20 40 40 20 20 40 20 40  20 62 6f 6f 74 72 6f 77  | @@  @ @ bootrow|
avrdude> w boo 0 "This is a test"
Caching | ################################################## | 100% 0.00 s 
avrdude> flush
avrdude: synching cache to device ... done

avrdude> d boo
Reading | ################################################## | 100% 0.00 s 
0000  54 68 69 73 20 69 73 20  61 20 74 65 73 74 00 20  |This is a test. |
0010  20 20 40 40 40 20 40 20  40 40 40 40 20 40 20 20  |  @@@ @ @@@@ @  |
0020  20 20 40 20 40 20 20 40  20 40 40 40 40 40 40 20  |  @ @  @ @@@@@@ |
0030  40 40 40 20 40 40 20 20  40 40 20 20 20 20 20 20  |@@@ @@  @@      |
0040  20 20 40 20 40 40 20 20  40 20 20 40 40 40 40 20  |  @ @@  @  @@@@ |
0050  20 20 20 20 40 20 40 40  20 20 40 40 20 40 20 20  |    @ @@  @@ @  |
0060  40 40 20 40 40 40 40 20  40 40 40 20 40 40 20 40  |@@ @@@@ @@@ @@ @|
0070  20 40 40 20 20 40 40 20  40 20 40 40 20 20 40 20  | @@  @@ @ @@  @ |
0080  20 20 20 20 40 40 20 40  20 20 40 20 20 40 40 20  |    @@ @  @  @@ |
0090  40 20 20 40 40 40 40 20  40 20 20 40 40 20 40 20  |@  @@@@ @  @@ @ |
00a0  40 20 40 20 20 40 40 20  40 20 20 40 40 40 20 40  |@ @  @@ @  @@@ @|
00b0  40 40 40 20 40 20 20 40  20 20 20 20 20 20 20 20  |@@@ @  @        |
00c0  40 40 20 20 20 40 20 40  20 40 40 40 40 40 20 40  |@@   @ @ @@@@@ @|
00d0  40 20 40 20 40 40 20 40  20 40 40 20 40 40 40 20  |@ @ @@ @ @@ @@@ |
00e0  40 20 20 20 40 40 20 40  40 40 20 20 20 20 40 20  |@   @@ @@@    @ |
00f0  20 40 40 20 20 40 20 40  20 62 6f 6f 74 72 6f 77  | @@  @ @ bootrow|
avrdude> 
avrdude done.  Thank you.

$ avrdude -p 64du28 -c serialupdi -U bootrow:r:-:I
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9622 (probably 64du28)
         reading bootrow memory ...
         reading | ################################################## | 100% 0.04 s 
         writing 256 bytes to output file <stdout>
:200000005468697320697320612074657374002020204040402040204040404020402020AB // 00000> This is a test.   @@@ @ @@@@ @   bootrow
:200020002020402040202040204040404040402040404020404020204040202020202020C0 // 00020>   @ @  @ @@@@@@ @@@ @@  @@      
:200040002020402040402020402020404040402020202020402040402020404020402020E0 // 00040>   @ @@  @  @@@@     @ @@  @@ @  
:20006000404020404040402040404020404020402040402020404020402040402020402000 // 00060> @@ @@@@ @@@ @@ @ @@  @@ @ @@  @ 
:20008000202020204040204020204020204040204020204040404020402020404020402080 // 00080>     @@ @  @  @@ @  @@@@ @  @@ @ 
:2000A000402040202040402040202040404020404040402040202040202020202020202080 // 000a0> @ @  @@ @  @@@ @@@@ @  @        
:2000C0004040202020402040204040404040204040204020404020402040402040404020A0 // 000c0> @@   @ @ @@@@@ @@ @ @@ @ @@ @@@ 
:2000E00040202020404020404040202020204020204040202040204020626F6F74726F7774 // 000e0> @   @@ @@@    @  @@  @ @ bootrow
:00000001FF

avrdude done.  Thank you.

@dbuchwald
Copy link
Contributor Author

Yeah, there is still the issue with repeated operation - if you perform bootrow write operation twice in a row without erasing the chip between the two, second write will be unsuccessful. Maybe I need to perform page erase first?

Bottom line: if possible, wait with the merge, I might need to add more changes to the PR.

@mcuee mcuee added the bug Something isn't working label Jul 5, 2024
@dbuchwald
Copy link
Contributor Author

There is now alternative PR for this issue and if accepted, I would suggest to merge the other one and reject this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants