Skip to content

tinyusb: correct SAMD51 serial number extraction #167

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
Aug 26, 2019
Merged

tinyusb: correct SAMD51 serial number extraction #167

merged 1 commit into from
Aug 26, 2019

Conversation

kaysievers
Copy link

TinyUSB does not match the exported serial numbers of the classic USB
stack.

The current code serializes the 32-bit words backwards, and the byte
nibbles are also backwards serialized.

A SAMD51 is exported like:
EFADAF3113347335020202938343E0FF

while it should read:
13FADAFE5337433139202020FF0E3438

TinyUSB does not match the exported serial numbers of the classic USB
stack.

The current code serializes the 32-bit words backwards, and the byte
nibbles are also backwards serialized.

A SAMD51 is exported like:
 EFADAF3113347335020202938343E0FF

while it should read:
  13FADAFE5337433139202020FF0E3438
@ladyada ladyada requested a review from hathach August 24, 2019 23:10
Copy link
Member

@hathach hathach left a comment

Choose a reason for hiding this comment

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

Great thanks again. I am not aware of this backward serial. Copy this serial extraction code from circuitpython :D

@hathach hathach merged commit e33ec1f into adafruit:master Aug 26, 2019
@dhalbert
Copy link

We can fix this in CircuitPython too. I think we were not aware there was a canonical ordering used by others: we were more interested in it just being unique.

@kaysievers
Copy link
Author

Yeah, I don't think there is a strict rule or defined order, it's just bits and using all of them should be universally unique. It's just more common though to start the serialization of bytes with the first word and not the last.

With this change, the USB mass storage bootloader, the Arduino classic USB, the tinyUSB stack all show the same serial number for the same hardware, that's why we synchronized it.

@hathach
Copy link
Member

hathach commented Aug 27, 2019

Oh, I forgot that we need to stay consistent with circuitpython. @dhalbert Let's me know your decision, if you decide not to change cpy, we will probably revert this PR. Although it is not the same as Arduino stack, it is more important to stay consisent with circuitpython

@kaysievers
Copy link
Author

Note, that the code also serialized the individual bytes backwards. 0x0a showed up as "A0". Did python really do the same?

@kaysievers
Copy link
Author

kaysievers commented Aug 27, 2019

Although it is not the same as Arduino stack, it is more important to stay consisent with circuitpython

If all goes well with my tinyusb tests, I would love to have a new firmware version for my MIDI devices switching to it. But if the serial numbers change with with the switch from the Arduino version, they will no longer be recognized as the same devices by the operating system they are connected to, and all the config in the music apps needs to be redone.

@dhalbert
Copy link

@kaysievers The CircuitPython code was copied into this implementation before this fix, so yes, it did.
@hathach I filed an issue in CircuitPython, and can fix it sooner rather than later.

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