Each time I download the firmware into an XMEGA I would also like to save the chip's serial number to a batch file so I can keep track of which chips got which version of the firmware.
Is there an easy way to do this?
The serial number on the XMEGA family is stored in the "Production Signature Row" block of memory.
You can read this block of memory over the PDI interface and extract out the 11 bytes that make up the serial number.
On Windows, you can use the ATMEL supplied atprogram
utility to do this inside the same batch file that you use to download the firmware into the flash using the read
command.
Here is an example command to read the serial number bytes using atprogram
and print them as a string of 22 hex digits...
atprogram.exe" --tool avrispmk2 --interface pdi --device atxmega128b3 read --prodsignature --offset 0x08 --size 11 --format hex
(replace the -tool
, --interface
, and --device
arguments to match your situation)
It will print something like...
325931343630ffff18ff0d
To save that value to a file, you can add the --file
parameter...
atprogram.exe --tool avrispmk2 --interface pdi --device atxmega128b3 read --prodsignature --offset 0x08 --size 11 --format hex --file sn.txt
... which results in a file called sn.txt
being created with the serial number on one line.
To build a list of consecutive serial numbers, you can make a batch file that first reads the serial number into a text file, then appends that text file into to a text file that holds the running list.