8000 Define usersig memory for ATmega*RF[AR]* parts by stefanrueger · Pull Request #1406 · avrdudes/avrdude · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Define usersig memory for ATmega*RF[AR]* parts #1406

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

Merged
merged 7 commits into from
Jun 23, 2023

Conversation

stefanrueger
Copy link
Collaborator
@stefanrueger stefanrueger commented Jun 15, 2023

With a bit of fair wind the following memory definition for ATmega128RFA1 ATmega256RFR2 ATmega128RFR2 ATmega64RFR2 ATmega2564RFR2 ATmega1284RFR2 ATmega644RFR2 could be sufficient to solve Issue #379. Only tests will tell whether JTAG or HVPP programmers "do the right thing" with this special memory of these special parts. If anything, perhaps the offset might be problematic but let's see who can help testing.

   #####
    # Three separate flash pages
    #   - Offset 0x100 in signature row
    #   - Only programmable with JTAG or HVPP
    #   - Readable from an application
    #   - Cannot be read using ISP
    #   - Not erased by chip erase
    #
    memory "usersig"
        paged              = yes;
        size               = 768;
        page_size          = 256;
        num_pages          = 3;
        offset             = 0x100;
        mode               = 0x41;
        delay              = 50;
        blocksize          = 256;
        readsize           = 256;
    ;

    #####
    # Three separate flash pages
    #   - Offset 0x100 in signature row
    #   - Only programmable with JTAG or HVPP
    #   - Readable from an application
    #   - Cannot be read using ISP
    #   - Not erased by chip erase
    #
    memory "usersig"
        paged              = yes;
        size               = 768;
        page_size          = 256;
        num_pages          = 3;
        offset             = 0x100;
        mode               = 0x41;
        delay              = 50;
        blocksize          = 256;
        readsize           = 256;
    ;
@stefanrueger stefanrueger added the bug Something isn't working label Jun 15, 2023
@mcuee
Copy link
Collaborator
mcuee commented Jun 15, 2023

@jkent

Since you have access to ATmega128RFA1, just wondering if you can help testing this PR once you have some time. Thanks.

@MCUdude
Copy link
Collaborator
MCUdude commented Jun 16, 2023

I don't have any hardware I can test this with, sorry.
But is there no need for read_lo, read_hi, loadpage_lo, loadpage_hi, load_ext_addr, and writepage?

@stefanrueger
Copy link
Collaborator Author

is there no need for read_lo, read_hi, loadpage_lo, loadpage_hi, load_ext_addr, and writepage?

No. My understanding is that usersig is special. Apparently it does not allow ISP programming. Has to be Jtag or HVPP.

x

@stefanrueger
Copy link
Collaborator Author

My hope(!) is that the current code base caters for this special usersig memory:

$ grep -r _USERSIG src

@mcuee
Copy link
Collaborator
mcuee commented Jun 17, 2023

I think we can still merge this if no one comes forward to help testing before 7.2 release. I tend to think it may work. Even if it does not, it does not really make things worse.

@mcuee
Copy link
Collaborator
mcuee commented Jun 17, 2023

But we may want to hear from @dl8dtl to see if he is comfortable to merge without testing, as this usersig memory for the RF AVRs seem to be quite different from others.

@stefanrueger
Copy link
Collaborator Author
stefanrueger commented Jun 20, 2023

Updated the definition of the ATmega*RF(A1|R2) parts. I would argue that while this might not be sufficient to deal with Issue #379 it is at least necessary to do so. Edit: while I was at it, I also updated the memory write delays and chip write delays for all ATmega8/16/32/64/128[A] parts

@stefanrueger
Copy link
Collaborator Author

merge without testing

I'd ague we can, as the memory description is taken from the relevant datasheet entries.

@mcuee
Copy link
Collaborator
mcuee commented Jun 20, 2023

merge without testing

I'd ague we can, as the memory description is taken from the relevant datasheet entries.

@stefanrueger

I agree with you. I think this PR is good to go now.

This is especially true after seeing that bug #1292 was fixed by your PR #1343, based on the investigation by @MCUdude here.

@stefanrueger stefanrueger merged commit e3f8260 into avrdudes:main Jun 23, 2023
@stefanrueger stefanrueger deleted the usersig-m256rfr2 branch June 23, 2023 14:50
@MCUdude
Copy link
Collaborator
MCUdude commented Jul 10, 2023

How important is it for us to really test this?

Someone in Norway sells a complete Atmel Zigbee kit with an ATmega256RFR2 Xplained Pro board for ~$8 including shipping.
I don't really need all the Zigbee stuff though. Should pull the trigger?

https://www.finn.no/bap/forsale/ad.html?finnkode=309369539&ci=16

@mcuee
Copy link
Collaborator
mcuee commented Jul 10, 2023

@MCUdude

At that price, I will say go ahead. Thanks.
We still have one remaining issue #379.

@MCUdude
Copy link
Collaborator
MCUdude commented Jul 10, 2023

OK, I just bought it. It will arrive within a week or so. Hopefully, I can use this to make sure #379 can be closed

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 10, 2023

Umm, sorry, I read it too late. I have been part of the development team of the ATmega…RF… devices, and have a number of boards to test with (including a small self-built temperature sensor network).

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 10, 2023

I'll dig out a board, and test. Promised. ;-)

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 10, 2023
j@rock:~/src/avrdude % ./build_freebsd/src/avrdude -c jtag2 -p atmega256rfr2 -t
avrdude warning: OCDEN fuse not programmed, single-byte EEPROM updates not possible
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1ea802 (probably m256rfr2)

avrdude: processing -t interactive terminal
avrdude> d usersig
Reading | ################################################## | 100% 0.05 s 
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
avrdude> w usersig 0 "Hello, world!"
Caching | ################################################## | 100% 0.00 s 
avrdude> d usersig 0 32
Reading | ################################################## | 100% 0.00 s 
0000  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 00 ff ff  |Hello, world!...|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
avrdude> 
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 0.08 s 
avrdude error: bad response to leave progmode command: RSP_FAILED

avrdude done.  Thank you.

j@rock:~/src/avrdude % ./build_freebsd/src/avrdude -c jtag2 -p atmega256rfr2 -t
avrdude warning: OCDEN fuse not programmed, single-byte EEPROM updates not possible
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1ea802 (probably m256rfr2)

avrdude: processing -t interactive terminal
avrdude> d usersig
Reading | ################################################## | 100% 0.05 s 
0000  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 00 ff ff  |Hello, world!...|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
avrdude> 
avrdude error: bad response to leave progmode command: RSP_FAILED

avrdude done.  Thank you.

That RSP_FAILED is a long-standing issue, quite benign, just a bit annoying.
I'd interpret that as "Success".

Btw., test conducted on FreeBSD/arm64.

I wonder how much work it would be to also have (read-only) access to prodsig. ;-)

@MCUdude
Copy link
Collaborator
MCUdude commented Jul 10, 2023

That RSP_FAILED is a long-standing issue, quite benign, just a bit annoying.
I'd interpret that as "Success".

Great to hear it works! I own a really flakey AVR Dragon (I have to touch the JTAG ping with a wet finger in order to get it to work), and I'm always getting an RSP_FAILED error, so I'll always assume it was the flakey Dragon's fault.

I wonder how much work it would be to also have (read-only) access to prodsig. ;-)

Is it only the "RF" AVRs that has this memory?

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 10, 2023

Basically all (newer) AVRs have a kind of production signature flash row, but for most of them, neither the access nor the contents is documented. Only the very first cells are documented (the device signature, and oscillator calibration values). Usually, they also contain the lot number, the number of the wafer inside the lot, and the X/Y position of the chip on the wafer – maybe more.

Hmm, I thought they were documented for the RF devices, but it seems they aren't. It's only the Xmegas that started to document some of them.

So OK, let's forget about that right now. ;-)

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 10, 2023

Btw., using the AtmelICE, access to the user signature row does not work. Instead, it returns me the production signature row:

avrdude> d usersig
Reading | -------------------------------------------------- | 0% 10.00 s 
0000  1e ae a8 ff 02 ff ff ff  ed ff ff f7 ff ff 50 31  |..............P1|
0010  38 30 34 38 15 0e 27 20  17 04 12 04 13 04 ff ff  |8048..' ........|
0020  86 23 86 25 86 22 86 25  ff ff ff ff 00 30 00 69  |.#.%.".%.....0.i|
0030  ff ff ff ff 00 99 00 29  ff ff ff ff 86 23 86 25  |.......).....#.%|
0040  86 22 86 25 00 30 00 80  ff ff ff ff 00 90 00 20  |.".%.0......... |
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

You can for example recognize the "1e a8 02" signature ID (the flash is organized in 16-bit words, but the signature only uses the even bytes). However, if I proceed reading, I get the user signature (offset one page):

avrdude> d usersig
Reading | ################################################## | 100% 0.02 s 
0100  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 00 ff ff  |Hello, world!...|
0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0120  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0130  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0140  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0150  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0160  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0170  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0180  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0190  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

Also, as soon as I switch to a different memory region, the command starts to timeout, even though it eventually returns the correct data:

avrdude> d fl
Reading | ################################################## | 100% 0.02 s 
00000  0c 94 6f 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | .o. ... ... ...|
00010  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00020  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00030  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00040  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00050  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00060  0c 94 90 01 0c 94 5e 1a  0c 94 90 01 0c 94 8a 1a  | ... .^. ... ...|
00070  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00080  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
00090  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
000a0  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
000b0  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
000c0  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
000d0  0c 94 90 01 0c 94 90 01  0c 94 90 01 0c 94 90 01  | ... ... ... ...|
000e0  0c 94 90 01 0c 94 a7 1b  0c 94 b1 1b 0c 94 9d 1b  | ... ... ... ...|
000f0  0c 94 1c 1b 0c 94 47 1b  0c 94 bb 1b 0c 94 f1 1a  | ... .G. ... ...|
avrdude> d usersig
Reading | -------------------------------------------------- | 0% 10.00 s 
avrdude error: short read, read only 0 out of 512 bytes
0000  1e ae a8 ff 02 ff ff ff  ed ff ff f7 ff ff 50 31  |..............P1|
0010  38 30 34 38 15 0e 27 20  17 04 12 04 13 04 ff ff  |8048..' ........|
0020  86 23 86 25 86 22 86 25  ff ff ff ff 00 30 00 69  |.#.%.".%.....0.i|
0030  ff ff ff ff 00 99 00 29  ff ff ff ff 86 23 86 25  |.......).....#.%|
0040  86 22 86 25 00 30 00 80  ff ff ff ff 00 90 00 20  |.".%.0......... |

This behaviour could not be observed with version 7.1. (I have both compile trees in parallel here.)

@MCUdude
Copy link
Collaborator
MCUdude commented Jul 11, 2023

@dl8dtl So with this PR applied to v7.1, it works fine with the Atmel ICE, but not with the git main version?
Maybe @stefanrueger can have a look at this.

BTW I'll receive an ATmega256RFR2 Xplained Pro board (together with various zigbee addons) soon that I can use to help out with testing

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 11, 2023

It works as intended with the Git version, and a JTAGICEmkII.
With the Git version, and an AtmelICE, it displays the entire signature memory, with address 0x0 for the prodsig, and 0x100 for the usersig area. Also, with the AtmelICE, I occasionally get a long wait time, and that "short read" error, even though it seemingly works.

@stefanrueger
Copy link
Collaborator Author
stefanrueger commented Jul 11, 2023

So different programmers do different things when instructed to read the signature usersig memory. Is it the programmer firmware at fault or has AVRDUDE forgotten to apply the offset of 0x100 when serving an AtmelICE programmer?

@dl8dtl
Copy link
Contributor
dl8dtl commented Jul 12, 2023

Is it the programmer firmware at fault or has AVRDUDE forgotten to apply the offset of 0x100 when serving an AtmelICE programmer?

Good question.

@stefanrueger
Copy link
Collaborator Author

@dl8dtl Please try PR #1466 to see whether AtmelICE now works for the ATmega256RFR2's usersig data.

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.

4 participants
0