Quick note: I have been experimenting to better understand why some of my external drives don't work... So I have been experimenting...
Will probably remove some of this, but detected that the SSD drive I tried has a GPT setup instead of MBR... Curious how hard it would be to support simple cases of this.
So I updated the USB_MTP-logger test sketch (MTP_Teensy) to detect when the drive is plugged in and then have the drives call the function to print out their MBR information.
So for one drive I have plugged in I see something like:
Code:
USB Drive: 0 connected
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT32: 1,80,0x0,0x39,0x0,0xB,0xF,0xFC,0xD3,56,15728584
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
addFilesystem: 1 MSC0-FAT32 20008a70
The drive I mentioned that does not work, printed out something like this but the first partition had type 0xee which is not Fat16 or 32 ore exFat so we ignore....
Turns out this is the GPT guard MBR...
SO yesterday I hacked on the mbrDmp method, to print out, and then have been playing to see if I can figure out what it is...
So current output looks like:
Code:
USB Drive: 1 connected
msc # Partition Table
part,boot,bgnCHS[3],type,endCHS[3],start,length
*** GPT Disk not supported ***
GPT guard: 1,0,0x0,0x2,0x0,0xEE,0xFE,0x7F,0x99,1,4294967295
pt_#0: 2,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 3,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
pt_#0: 4,0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0,0
GPT partition header revision: 10000
LBAs current:1 backup:500118191 first:34 last:500118158
Disk GUID:03156F5D-B405-431B-9367-0CF4584D8695Start LBA Array: 2 Count: 128 size:128
Part Type Guid, Unique Guid, First, last, attr, name
0 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, 547BDDC9-1B3A-49A1-858D-BCFBA0FD54BB, 2048, 500117503, 0, Basic data partition
>>> Microsoft Basic Data Partition
EB 76 90 45 58 46 41 54 20 20 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :.v.EXFAT .....................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :................................
00 08 00 00 00 00 00 00 00 28 CF 1D 00 00 00 00 00 08 00 00 00 3C 00 00 00 48 00 00 E0 CE 1D 00 :.........(...........<...H......
05 00 00 00 7A F8 1A 84 00 01 00 00 09 08 01 80 00 00 00 00 00 00 00 00 33 C9 8E D1 8E C1 8E D9 :....z...................3.......
BC D0 7B BD 00 7C 88 16 6F 7C B4 41 BB AA 55 CD 13 72 69 81 FB 55 AA 75 63 F6 C1 01 74 5E FE 06 :..{..|..o|.A..U..ri..U.uc...t^..
02 7C 66 50 B0 65 E8 A6 00 66 58 66 B8 01 00 00 00 8A 0E 6D 7C 66 D3 E0 66 89 46 E8 66 B8 01 00 :.|fP.e...fXf.......m|f..f.F.f...
00 00 8A 0E 6C 7C 66 D3 E0 66 89 46 D8 66 A1 40 7C 66 40 BB 00 7E B9 01 00 66 50 E8 41 00 66 58 :....l|f..f.F.f.@|f@..~...fP.A.fX
66 40 BB 00 80 B9 01 00 E8 34 00 66 50 B0 78 E8 5D 00 66 58 E9 09 01 A0 FC 7D EB 05 A0 FB 7D EB :f@.......4.fP.x.].fX.....}....}.
00 B4 7D 8B F0 AC 98 40 74 0C 48 74 0E B4 0E BB 07 00 CD 10 EB EF A0 FD 7D EB E6 CD 16 CD 19 66 :..}....@t.Ht............}......f
60 66 6A 00 66 50 06 53 66 68 10 00 01 00 B4 42 B2 80 8A 16 6F 7C 8B F4 CD 13 66 58 66 58 66 58 :`fj.fP.Sfh.....B....o|....fXfXfX
66 58 66 61 72 B1 03 5E D8 66 40 49 75 D1 C3 66 60 B4 0E BB 07 00 B9 01 00 CD 10 66 61 C3 42 00 :fXfar..^.f@Iu..f`..........fa.B.
4F 00 4F 00 54 00 4D 00 47 00 52 00 0D 0A 52 65 6D 6F 76 65 20 64 69 73 6B 73 20 6F 72 20 6F 74 :O.O.T.M.G.R...Remove disks or ot
68 65 72 20 6D 65 64 69 61 2E FF 0D 0A 44 69 73 6B 20 65 72 72 6F 72 FF 0D 0A 50 72 65 73 73 20 :her media....Disk error...Press
61 6E 79 20 6B 65 79 20 74 6F 20 72 65 73 74 61 72 74 0D 0A 00 00 00 00 00 00 00 00 00 00 FF FF :any key to restart..............
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF :................................
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 6C 8B 98 55 AA :...........................l..U.
EXFAT:
So I properly detected that the first partition was a GPT Guard and read in the sector 1, slightly verified that it was an GPT header...
Printed out a bit of it... Then cycled through the count of partitions (128 with 4 per sector)...
Then only looked at ones that were not all 0s... Looked for GUID=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
Which stands for: Microsoft Basic Data partition...
I then Read in the first cluster of that partition, which should be a partition boot sector... ... Which I currently dump..
Which so far I detected this case as ExFat (first three bytes as ... and Name: "EXFAT "
Next up maybe playing with seeing how hard to get the ExFat library to like it...
The only place other than format, that I think does anything here is: bool ExFatPartition::init(BlockDevice* dev, uint8_t part) {
And after it verifies MBR it reads in this sector as well, and continues... So may try hacking up version that does some of the steps I just mentioned.
May also be curious at changing this as well, to detect MBR partition types of Extended Partition. If I do, I will probably make an assumption, to only support it in the 4th position and maybe allow partition number > 4...
Let know if anyone wishes to play along and I will push up current changes.