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 support for GPT partition tables #406

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PetteriAimonen
Copy link

Especially Mac OS X Disk Utility formats SD cards as GPT partition table by default.
This pull request adds support in SdFat to access these SD cards also.

Separated partition table reading into a new file and
added GPT partition table support.

Removed check for MBR partition boot being 0x00 / 0x80.
Some systems use other values here if the partition is
marked as bootable.
@greiman
Copy link
Owner

greiman commented Dec 7, 2022

I probably won't add this since I have a policy of only supporting the official SD Association format.

@PetteriAimonen
Copy link
Author

Hmm, ok. The newest SDUC format does use GPT officially also, but I guess there are other things that prevent it from working currently.

@greiman
Copy link
Owner

greiman commented Dec 7, 2022

The official format specifies a single layout for a given size card and manufactures arrange flash, buffing and algorithms according to this layout.

Buffering for FAT areas is different form data areas. Management of flash record units, fragmentation, and wear leveling is based on this layout.

You should not use a PC, Mac, Linux, or other method to format SD cards. Use the official SD formatter.

@PetteriAimonen
Copy link
Author

Yeah, I can agree with that. Though I guess even the existing support for partitions 2-4 goes beyond the SD card official spec?

If you feel like SdFat is better off without this, feel free to close this pull request.

I'll just figure out a way to do it out-of-tree. I see that SdFat 2.2.0 added the volStart parameter that makes this quite easy. For now, trying to get users to format SD cards correctly is harder for us than just adding support for the GPT format :)

@greiman
Copy link
Owner

greiman commented Dec 7, 2022

I guess even the existing support for partitions 2-4 goes beyond the SD card official spec.

SD cards have a single partition and almost every field from Medium Identifier to Cluster Size is specified for a given SD size.

The first 32,768 sectors must only contain the Master Boot Record and Partition Table. This is for reliability so this area will never need rewrite for wear leveling. So most of the first 16 MiB is not used.

The exFAT Up-case Table is totally specified.

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.

2 participants