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

[bug #40702] fix: enable AVRISPmkII to read prodsig #314

Closed
avrs-admin opened this issue Dec 10, 2021 · 3 comments
Closed

[bug #40702] fix: enable AVRISPmkII to read prodsig #314

avrs-admin opened this issue Dec 10, 2021 · 3 comments
Labels
invalid This doesn't seem right

Comments

@avrs-admin
Copy link

Stephan Baerwolf stephan@matrixstorm.com
Mon 25 Nov 2013 03:13:43 PM UTC

file #29709: 0003-fix-enable-AVRISPmkII-to-read-prodsig.patch

This issue was migrated from https://savannah.nongnu.org/bugs/?40702

@MCUdude
Copy link
Collaborator

MCUdude commented Mar 19, 2022

@@ -3984,7 +3984,8 @@ static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
         b[1] = XPRG_MEM_TYPE_FUSE;
     } else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) {
         b[1] = XPRG_MEM_TYPE_LOCKBITS;
-    } else if (strcmp(mem->desc, "calibration") == 0) {
+    } else if (strcmp(mem->desc, "calibration") == 0 ||
+               strcmp(mem->desc, "prodsig") == 0) {
         b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
     } else if (strcmp(mem->desc, "usersig") == 0) {
         b[1] = XPRG_MEM_TYPE_USERSIG;

I don't see how this is useful. None of the "classic" AVRs has a memory named "prodsig" in avrdude.conf.
@dl8dtl should we just close this?

@dl8dtl
Copy link
Contributor

dl8dtl commented Mar 19, 2022

Xmegas (and their more recent relatives AVR8X and AVR Dx) do have "prodsig".

@MCUdude
Copy link
Collaborator

MCUdude commented May 30, 2022

It's already possible to read prodsig using a Dragon and an AVRISPmkII. It looks like this patch has already been applied (line 3946).

avrdude/src/stk500v2.c

Lines 3925 to 3972 in feaa1c6

static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value)
{
unsigned char b[8];
if (strcmp(mem->desc, "flash") == 0) {
b[1] = stk600_xprog_memtype(pgm, addr);
} else if (strcmp(mem->desc, "application") == 0 ||
strcmp(mem->desc, "apptable") == 0) {
b[1] = XPRG_MEM_TYPE_APPL;
} else if (strcmp(mem->desc, "boot") == 0) {
b[1] = XPRG_MEM_TYPE_BOOT;
} else if (strcmp(mem->desc, "eeprom") == 0) {
b[1] = XPRG_MEM_TYPE_EEPROM;
} else if (strcmp(mem->desc, "signature") == 0) {
b[1] = XPRG_MEM_TYPE_APPL;
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
b[1] = XPRG_MEM_TYPE_FUSE;
} else if (strncmp(mem->desc, "lock", strlen("lock")) == 0) {
b[1] = XPRG_MEM_TYPE_LOCKBITS;
} else if (strcmp(mem->desc, "calibration") == 0 ||
strcmp(mem->desc, "prodsig") == 0) {
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
} else if (strcmp(mem->desc, "usersig") == 0 ||
strcmp(mem->desc, "userrow") == 0) {
b[1] = XPRG_MEM_TYPE_USERSIG;
} else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
progname, mem->desc);
return -1;
}
addr += mem->offset;
b[0] = XPRG_CMD_READ_MEM;
b[2] = addr >> 24;
b[3] = addr >> 16;
b[4] = addr >> 8;
b[5] = addr;
b[6] = 0;
b[7] = 1;
if (stk600_xprog_command(pgm, b, 8, 3) < 0) {
avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): XPRG_CMD_READ_MEM failed\n",
progname);
return -1;
}
*value = b[2];
return 0;
}

$ ./avrdude -p atxmega128a3u -c avrispmkii -Uprodsig:r:-:h

avrdude: AVR device initialized and ready to accept instructions

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

avrdude: Device signature = 0x1e9742 (probably x128a3u)
avrdude: NOTE: Programmer supports page erase for Xmega devices.
         Each page will be erased before programming it, but no chip erase is performed.
         To disable page erases, specify the -D option; for a chip-erase, use the -e option.
avrdude: reading prodsig memory:

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

avrdude: writing output file "<stdout>"
0xc,0x40,0x75,0xa,0x40,0x9f,0xff,0x1,0x31,0x4a,0x30,0x37,0x33,0x30,0xff,0xff,0x5,0xff,0xe,0x0,0x7,0x0,0xff,0xff,0xff,0xff,0x7e,0xf8,0x24,0x40,0xff,0xff,0x0,0x0,0x0,0xff,0x0,0x0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0x9,0xff,0xff

@MCUdude MCUdude closed this as completed May 30, 2022
@mcuee mcuee added the invalid This doesn't seem right label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants