Skip to content

esp32s2: Use the device's EUI-48 address as unique ID #3156

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 1 commit into from
Jul 16, 2020

Conversation

jepler
Copy link

@jepler jepler commented Jul 15, 2020

Before this, the uid was referring to uninitialized memory and varied from run to run.

On my hardware, esptool reports

MAC: 7c:df:a1:02:6c:b8

after this change, the USB descriptor says SerialNumber: 7CDFA1026CB8 and microcontroller.cpu.id has

>>> "".join("%02x" % byte for byte in microcontroller.cpu.uid)
'c7fd1a20c68b'

Note that the nibble-swapping between USB and cpu.uid is typical. For instance, an stm32 board has USB SerialNumber
24002500F005D42445632302 but hex-converted microcontroller.cpu.id 420052000f504d4254363220.

On my hardware, esptool reports
    MAC: 7c:df:a1:02:6c:b8
after this change, the USB descriptor says SerialNumber: 7CDFA1026CB8
and microcontroller.cpu.id has
    >>> "".join("%02x" % byte for byte in microcontroller.cpu.uid)
    'c7fd1a20c68b'

Note that the nibble-swapping between USB and cpu.uid is typical.
For instance, an stm32 board has USB SerialNumber
24002500F005D42445632302 but hex-converted microcontroller.cpu.id
420052000f504d4254363220.
@jepler jepler requested a review from tannewt July 15, 2020 16:46
@dhalbert
Copy link
Collaborator

Note #2087, about backwards order of the UID.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you!

@tannewt tannewt merged commit 3610520 into adafruit:main Jul 16, 2020
@jepler jepler deleted the esp32s2-serial-number branch November 3, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants