ataradov / edbg

Simple utility for programming MCUs and FPGAs though CMSIS-DAP protocol. Works on Linux, MAC and Windows.
BSD 3-Clause "New" or "Revised" License
287 stars 92 forks source link

Print serial number of CM0+ target #91

Closed ooxi closed 4 years ago

ooxi commented 4 years ago

By printing the serial number of the target acted upon enables a lot of use cases like statistical analysis and tracability. The serial number is read from the devices memory using SWD.

Successfully tested on samd21 hardware as well as verified using datasheet of the following targets:

However the targets samr34 as well as samr35 do not seem to support serial number extraction. I wanted to keep the pull request as small as possible, but I can implement a device discrimation if you want in order to not print wrong serial numbers for unsupported devices.

For my usecase it would be very helpful to be able to read the serial number into a file, however I did not find information about a unique device identification for other targets then CM0+.

Sample output:

Debugger: ATMEL EDBG CMSIS-DAP ATML2130021800020377 03.22.01B3 (S)
Clock frequency: 16.0 MHz
Target: SAM D21J18A (Rev D)
Serial number: 41eebbfe 514d3559 34202020 ff0f2a24
Programming.............................................................................. done.
Verification.............................................................................. done.
ataradov commented 4 years ago

I will not merge this. This has nothing to do with programming the part. And by keeping the code small and simple you are able to take it and modify for your needs.

If you need to have serial numbers, it is fine, but there is no need for everyone to have it.

ooxi commented 4 years ago

Well I can see you reasoning, however we also print the target DSU_DID which is not strictly required for programming either.

If you do not reconsider (and you are under no obligation to do so), I will carry this patch in a small fork :-)

ataradov commented 4 years ago

We only print it when the target is not known. DSU_DID is required for ongoing maintenance. It is less relevant now that revision is masked out, but previously situation when a part is not recognized because of a different revision number were common. Printing DSU_DID in this case is more user friendly than just printing "unknown part". We also need to read it anyway, since it is used as part of the part detection method.

ooxi commented 4 years ago

For future reference: patch will be carried in edbg-serial-number.