avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
696 stars 136 forks source link

Read ATmega324PB and ATmega328PB serial number #1509

Closed MCUdude closed 10 months ago

MCUdude commented 11 months ago

The ATmega324PB and 328PB (not the 48/88/168PB) have a unique serial number that can be read using an ISP or JTAG programmer. Currently, the serial number can not be read using Avrdude.

From the ATmega324PB datasheet: image

stefanrueger commented 11 months ago

can be read using an ISP [...] programmer

The data sheet certainly hides it a bit how. I suspect that access to sigrow works by using the signature read ISP command for even addresses and calibration read ISP command for the odd addresses. Could try to treat sigrow like a flash memory with page size 4 and size 24 with read_lo (signature) read_hi (calibration) ISP commands. About time #1330 is tackled as to make it easy to tell AVRDUDE sigrow is a flash-like memory.

I quickly had a bash script read a few hundred data sheets. Looks like ATtiny102 and ATtiny104 (TPI) also have this memory as do all UPDI devices. Can the t102/t104 sigrow be read with jtag/tpi?

MCUdude commented 11 months ago

I quickly had a bash script read a few hundred data sheets. Looks like ATtiny102 and ATtiny104 (TPI) also have this memory as do all UPDI devices. Can the t102/t104 sigrow be read with jtag/tpi?

I'm able to read SIGROW using the ATtiny104 Xplained Nano board:

$ ./avrdude -cxplainedmini_tpi -pattiny104 -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e900b (probably t104)

avrdude: processing -t interactive terminal
avrdude> part
AVR Part                      : ATtiny104
RESET disposition             : dedicated
RETRY pulse                   : SCK
Serial program mode           : yes
Parallel program mode         : yes
Memory Detail                 :

                                  Block Poll               Page                       Polled
  Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
  ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
  fuse                    0     0     4    0 no          1   16      0     0     0 0x00 0x00
  lockbits                0     0     0    0 no          1   16      0     0     0 0x00 0x00
  signature               0     0     0    0 no          3   16      0     0     0 0x00 0x00
  calibration             0     0     0    0 no          1   16      0     0     0 0x00 0x00
  flash                   0     0   128    0 no       1024   16      0     0     0 0x00 0x00
  io                      0     0     0    0 no         64    1      0     0     0 0x00 0x00
  sigrow                  0     0     0    0 no         16   16      0     0     0 0x00 0x00
avrdude> read sigrow
Reading | ################################################## | 100% 0.29 s 
0000  35 59 30 38 34 34 2f 18  28 38 00 00 00 00 00 00  |5Y0844/.(8......|
avrdude> quit

avrdude done.  Thank you.
stefanrueger commented 11 months ago

. Currently, the serial number can not be read using Avrdude.

PR #1510 provides one way for reading the serial number that works with a number of programmers (eg, usbtiny or usbasp), but it will need a couple more PRs to extend the gamut of programmers that can read sigrow (if possible). So I suggest to close this issue once PR #1510 is merged (and feel lucky if we make progress with some more programmers),