Skip to content
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

oofatfs: enable use of random volume IDs #7410

Merged
merged 1 commit into from Jan 4, 2023

Conversation

jepler
Copy link
Member

@jepler jepler commented Jan 3, 2023

This is a speculative fix for #7409 if the underlying cause is the deterministic volume ID. However, not all boards have working urandom (samd21 at least does not) so a couple of fallbacks are attempted when it fails. Note that the final fallback to the monotonic time is not great but probably has at least a few bits of randomness in it so it's better than nothing.

I verified that on a pico_w, each storage.erase_filesystem() gives a distinct 32-bit volume ID (pico_w's urandom can never fail)

Note that this doesn't change the unique ID of an existing CIRCUITPY, only when storage.erase_filesystem() is called or when the drive is first initialized on a fresh device.

This may help address adafruit#7409 if the underlying cause is the deterministic
volume ID. However, not all boards have working urandom (samd21
at least does not) so a couple of fallbacks are attempted when it fails.

I verified that on a pico_w, each `storage.erase_filesystem()` gives
a distinct 32-bit volume ID (pico_w's urandom can never fail)
@dhalbert
Copy link
Collaborator

dhalbert commented Jan 4, 2023

Another fairly changeable number I looked at (by experiment) is microcontroller.cpu.temperature, if available, and microcontroller.cpu.voltage (if actually measured). The degree of precision on these varies: on SAMD21, temperature has only a few digits, but voltage has more. On RP2040, temperature has more, but there is no dynamic voltage measurement. However, both of these have a true UID so the point for them is moot.

@anecdata
Copy link
Member

anecdata commented Jan 4, 2023

storage.erase_filesystem() with unique volume_uuid fixes #7409. 🎉 Thanks @jepler!!

@Neradoc
Copy link

Neradoc commented Jan 4, 2023

This also fixes the long standing elusive issue with the Finder opening a file from the wrong board even before Ventura. (I tested it with nuking 2 picos and could see that the volume_uuid was the same before the PR and different after).
I wrote a few notes on that bug, but it seems that there isn't an open issue.

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.

Nice find! This makes total sense to me!

@dhalbert dhalbert merged commit 4d33cf4 into adafruit:main Jan 4, 2023
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.

None yet

5 participants