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

Add serial numbers for flash drives #398

Open
zwhitchcox opened this issue Jun 14, 2022 · 10 comments
Open

Add serial numbers for flash drives #398

zwhitchcox opened this issue Jun 14, 2022 · 10 comments

Comments

@zwhitchcox
Copy link
Contributor

SD cards and USB flash drives expose a serial number that user's have been requesting. We are currently working on implementing this.

@jellyfish-bot
Copy link

[zwhitchcox] This has attached https://jel.ly.fish/057d4d51-7a26-400b-88e0-6f1e42ad75c5

@lurch
Copy link
Contributor

lurch commented Jun 15, 2022

Duplicate of #309 and others?

@zwhitchcox
Copy link
Contributor Author

zwhitchcox commented Jun 15, 2022

Yes, that's true...working on this right now, so I'll just close it when it's done, as we have users following it right now..thanks again, @lurch

@zwhitchcox
Copy link
Contributor Author

So, it turns out that it's not possible to get the serial number of the SD card with the Etcher Pro hardware. This is due to the way the USB SD card readers work. The SD API is not exposed through the USB interface, but the card reader merely exposes the functionality of a USB mass storage device (UMS) and communicates to the SD card on behalf of the UMS API. The CID registers are not exposed through this UMS interface, and thus we have no way of getting them.

Since the use case for the etcher pro customer was to get these CID numbers from the SD cards, I am dropping this change for now. However, the functionality does work for getting the serial numbers of USB Flash drives, USB SSDs, etc., in general anything that does not have an adapter in between, so this might be useful in the future. If so, I (or whoever) can pick up the changes from the add-serial branch: https://github.com/balena-io-modules/drivelist/tree/add-serial.

@zwhitchcox
Copy link
Contributor Author

Btw, everything is done in the add-serial branch except for getting the serial number on MacOS, which could be implemented using the IORegistry, see https://stackoverflow.com/a/9522904/1742379

@lurch
Copy link
Contributor

lurch commented Jun 20, 2022

Apologies if you already know this, but it is possible to get the SD-card CID numbers if your SD-card-reader is connected over PCIe rather than USB (which it sometimes is on the card-reader built into laptops). And AFAIK the same is true whenever an SD-card shows up as /dev/mmcblkX (e.g. the built-in microSD slot on a Raspberry Pi) instead of /dev/sdX (e.g. a typical USB SD card-reader).

More info at https://www.cameramemoryspeed.com/sd-memory-card-faq/reading-sd-card-cid-serial-psn-internal-numbers/

@zwhitchcox
Copy link
Contributor Author

Yes, I believe 12/16 ports are exposed over the USB interface, and the rest are using PCIe, so we could technically modify the drivers to expose the SD card readers through the PCIe interface as mmc devices, but that would create an inconsistency among the different ports, and for some 4 of the ports you would get the correct serial number for the SD card, but not for the other 12, which I think could be confusing for users and not fully address the use case of the target user.

That being said, I will bring this up internally and see if they think this is a worthwhile change...I will keep this open for now.

@zwhitchcox zwhitchcox reopened this Jun 20, 2022
@lurch
Copy link
Contributor

lurch commented Jun 21, 2022

Yeah, I was coming from the "just in general" viewpoint, rather than from the EtcherPro viewpoint 😉 (I agree that it sounds like having 4 ports working differently to the rest would probably be a bit confusing)

@zwhitchcox
Copy link
Contributor Author

Yes, agreed, it could potentially be useful for other people, so I will come back to this when I have a chance. It's most of the way there anyway.

@Arav1nd2
Copy link

Arav1nd2 commented Dec 31, 2023

@zwhitchcox I went over your branch to get serial number for flash drives. Can you guide me on how to add similar change for mac devices? I am willing to raise a PR (if the team needs one to support this), but a bit lost on where to begin. I want to have that feature for my project for mac devices
Thanks!

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

No branches or pull requests

4 participants