Many TLAs: MTP MSC FS SD SDFat LittleFS UsbMSCFat to work with each other 8)

@KurtE
I added:
Code:
  m_dev->syncDevice();
and found something interesting. If I formatted part 0 in Teensy and then checked with Windows it formatted. Then I plugged it back into Teensy and formatted part 1 and put it back in Windows and both drives registered as fine.

Wondering if something is not not updating. Maybe have to re-begin drive or do a reset?
 
We may have cross posted... Have you tried resetting checksum=0 at start of format?

Definitely cross - posted. Never even thought about that since checksum was always recalculated from what I saw. Something so simple causing the whole problem!

Anyway just tried it and it worked!
 
Definitely cross - posted. Never even thought about that since checksum was always recalculated from what I saw. Something so simple causing the whole problem!

Anyway just tried it and it worked!
Once I verbally said (actually typed), that it works on the first partition I tried it on, but not second... A ding went off...

So looked for anything that was either initialized in the class or if there were any static variables.... And saw the one being defined in header file.

Then looked for places that referenced it and most all of them looked like: checksum = exFatChecksum(checksum, secBuf);

What I did not check is to see if we have any reliance on any other not explicitly initialized variables that the compiler probably zeroed. but so far it worked.

But at least I learned a few things like:

Code:
    uint8_t *bpb_area = (uint8_t*)malloc(512*24); 
    if (!bpb_area) {
      Serial.println("Unable to allocate dump memory");
      return;
    }
    // Lets just read in the top 24 sectors;
    uint8_t *sector_buffer = bpb_area;
    for (uint32_t i = 0; i < 24; i++) {
      partVol.blockDevice()->readSector(sector+i, sector_buffer);
      sector_buffer += 512;
    }
works, but if you replace malloc with EXTMEM_Malloc then I did not get any data back!
 
@KurtE
Glad you found it - didn't have much hair left and was pulling out what I had left since it looked like it should have worked.

Agree with you. Even though it took a while I learned a lot about exFAT and even a bit on FAT32.

Meant to ask - does setVolumeLabel work with exFAT yet? Never added that to the lib.
 
I know the feeling about pulling out hair! :D Why is it that the bugs are always in the last place you look ;)

Volume name... It was? Have not tried it in awhile (few days).

Did you want to push up a fix? Or try adding Volume name?
 
Going to try Volume name and if it works will push up the changes. With the other issue didn't worry about. Want to clean up dbg_pring as well.
 
@KurtE
Just pushed the fix for ExFatFormatted that you identified :). Also added the setVolumeLabel code. Checked it out again and it worked:
Code:
Cards up to 2 GiB (GiB = 2^30 bytes) will be formated FAT16.
Cards larger than 2 GiB and up to 32 GiB will be formatted
FAT32. Cards larger than 32 GiB will be formatted exFAT.

Waiting up to 5 seconds for USB drive 1
Initialize USB drive...UsbBase::mscBegin called 20004360 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
USB drive 1 is present.

msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
exFAT:	1,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,2048,123049984
exFAT:	2,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,123052032,118972416
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
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002804, 2)
PFsVolume::begin(20002804, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002804, 3)
PFsVolume::begin(20002804, 3)
Partition 2 valid:0
PFsVolume::begin USBmscInterface(20002804, 4)
PFsVolume::begin(20002804, 4)
Partition 3 valid:0
0:>> ExFat: Volume name:(exFATv1) Partition Total Size:62998446080 Used:47185920 time us: 44750
    Free Clusters: API: 480280 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 1
1:>> ExFat: Volume name:(exFATv2) Partition Total Size:60910731264 Used:45613056 time us: 44250
    Free Clusters: API: 464364 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
done...
Enter 0, 1 , 2, or 3 for Partition or Enter to Bypass
Initialize USB drive...UsbBase::mscBegin called 20004360 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
USB drive 1 is present.
PFsVolume::begin(20002804, 1)
Partition 0 valid:1
ExFatFormatter - WIP
0
    m_relativeSectors:2048
    m_totalSectors:123049984
Writing Partition Boot Sector
Write eight Extended Boot Sectors
Write OEM Parameter Sector and reserved sector
Write Boot CheckSum Sector
Writing exFAT .................................
Write cluster two, bitmap
Writing upcase table
Writing root
Format done
Press any key to run again
Initialize USB drive...UsbBase::mscBegin called 20004360 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
USB drive 1 is present.

msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
exFAT:	1,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,2048,123049984
exFAT:	2,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,123052032,118972416
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
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002804, 2)
PFsVolume::begin(20002804, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002804, 3)
PFsVolume::begin(20002804, 3)
Partition 2 valid:0
PFsVolume::begin USBmscInterface(20002804, 4)
PFsVolume::begin(20002804, 4)
Partition 3 valid:0
0:>> ExFat: Volume name:(exFATv1) Partition Total Size:62998446080 Used:47185920 time us: 45750
    Free Clusters: API: 480280 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 1
1:>> ExFat: Volume name:(exFATv2) Partition Total Size:60910731264 Used:45613056 time us: 44250
    Free Clusters: API: 464364 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
done...
Enter 0, 1 , 2, or 3 for Partition or Enter to Bypass
Initialize USB drive...UsbBase::mscBegin called 20004360 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
USB drive 1 is present.
PFsVolume::begin(20002804, 2)
Partition 1 valid:1
ExFatFormatter - WIP
1
    m_relativeSectors:123052032
    m_totalSectors:118972416
Writing Partition Boot Sector
Write eight Extended Boot Sectors
Write OEM Parameter Sector and reserved sector
Write Boot CheckSum Sector
Writing exFAT .................................
Write cluster two, bitmap
Writing upcase table
Writing root
Format done
Press any key to run again
Initialize USB drive...UsbBase::mscBegin called 20004360 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
USB drive 1 is present.

msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
exFAT:	1,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,2048,123049984
exFAT:	2,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,123052032,118972416
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
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002804, 2)
PFsVolume::begin(20002804, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002804, 3)
PFsVolume::begin(20002804, 3)
Partition 2 valid:0
PFsVolume::begin USBmscInterface(20002804, 4)
PFsVolume::begin(20002804, 4)
Partition 3 valid:0
0:>> ExFat: Volume name:(exFATv1) Partition Total Size:62998446080 Used:47185920 time us: 45750
    Free Clusters: API: 480280 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
1:>> ExFat: Volume name:(exFATv2) Partition Total Size:60910731264 Used:45613056 time us: 44250
    Free Clusters: API: 464364 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
done...
Enter 0, 1 , 2, or 3 for Partition or Enter to Bypass
 
@KurtE
I just tried MTP with 3 different drives:
1. 64GB thumb drive with 2 exFAT partition. MTP recognized the 2 partitions and reformatted successfully.
2. 32GB SD Adapter with sd card. Failed to start:
Code:
MTP_test
SDIO Storage 0 254 sdio failed or missing
SD Storage 1 10 sd1 failed or missing
sd_addFilesystem: 0 20006f78 RAM1 20002dd0 20006f78
RAM Storage 0 RAM1 199936 512
sd_addFilesystem: 1 20007040 RAM2 20002dd0 20007040
RAM Storage 1 RAM2 3999744 4096

Initializing USB MSC drives...
USB Drive Inserted[/B]
3. SSD with 2 FAT32 partitions. Worked but wouldn't suggest formatting a large SSD from MTP - takes way way too long. 14GB partition took about 5-10 minutes. But it worked>
Code:
CMD: 100f(FORMAT_STORE)l: 20 T:b : 40001 0
 MTPD::formatStore called post:0
Format Callback: user_token:1 store: 3 p2:0 post:0 
RESP:2001(RSP:OK)l: 20 T:b : 40001 0
 MTPD::formatStore called post:1
*** Start Interval Timer ***
Format Callback: user_token:1 store: 3 p2:0 post:1 
CMD: 1005(GET_STORAGE_INFO)l: 16 T:c : 40001
RESP:2019(RSP:DEVICE_BUSY)l: 16 T:c : 40001
1
Volume name:(NEW VOLUME)
PFsFatFormatter::format................
Sector Count: 29634560, Sectors/MB: 2048
Partition Capacity (MB): 14470
Fat Type: 32
    m_dataStart:204834816
    m_sectorsPerCluster:64
    m_relativeSectors:204802048
    m_sectorsPerFat: 14455

 MAKEFAT32
    m_sectorCount: 29634560
    m_dataStart: 204834816
    m_sectorsPerCluster: 64
    nc: 64371360
    m_fatSize: 14455
m_fatSize: 14455
partType: 12, fatStart: 204805906, totalSectors: 29634560
Writing FAT CMD: 1007(GET_OBJECT_HANDLES)l: 24 T:d : 10001 0 ffffffff
RESP:2019(RSP:DEVICE_BUSY)l: 24 T:d : 10001 0 ffffffff
................................
###PFsVolume::freeClusterCount: FT:32
    m_sectorsPerCluster:64
    m_sectorsPerClusterShift:6
    m_rootDirEntryCount:0
    m_sectorsPerFat:14455
    m_dataStartSector:204834816
    m_fatStartSector:204805906
    m_rootDirStart:2
    m_bytesPerSector:512
free clusters after format: 462527
PFsVolume::begin(2000971c, 2)
###PFsVolume::freeClusterCount: FT:32
    m_sectorsPerCluster:64
    m_sectorsPerClusterShift:6
    m_rootDirEntryCount:0
    m_sectorsPerFat:14455
    m_dataStartSector:204834816
    m_fatStartSector:204805906
    m_rootDirStart:2
    m_bytesPerSector:512
free clusters after begin on partVol: 462527
Format Done
*** end Interval Timer ***
 
Just check if it is recognized using MSCFormatter and it is so must be something in MTP:
Code:
USB drive 1 is present.

msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT32:	1,0,0x20,0x21,0x0,0xC,0xFE,0xFF,0xFF,2048,31275008
exFAT:	2,0,0xFE,0xFF,0xFF,0x7,0xFE,0xFF,0xFF,31277056,31275008
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
PFsVolume::begin USBmscInterface(20002804, 1)
PFsVolume::begin(20002804, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002804, 2)
PFsVolume::begin(20002804, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002804, 3)
PFsVolume::begin(20002804, 3)
Partition 2 valid:0
PFsVolume::begin USBmscInterface(20002804, 4)
PFsVolume::begin(20002804, 4)
Partition 3 valid:0
0:>> Fat32: Volume name:(V1)###PFsVolume::freeClusterCount: FT:32
    m_sectorsPerCluster:16
    m_sectorsPerClusterShift:4
    m_rootDirEntryCount:0
    m_sectorsPerFat:15256
    m_dataStartSector:34816
    m_fatStartSector:4304
    m_rootDirStart:2
    m_bytesPerSector:512
 Partition Total Size:15996026880 Used:32768 time us: 953998
    Free Clusters: API: 1952636 by CB:1952636 time us: 953992
    Free Clusters: Info: 1952639 time us: 1867
1:>> ExFat: Volume name:(v2) Partition Total Size:16009658368 Used:229376 time us: 91749
    Free Clusters: API: 488569 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
done...
 
Good question, there are lots of things we can work on, that I know we can break!

Would still be a good thing to get some feedback on some of the lower level things, things like: Testing... Looks like you have a jump on this.

What things we can add/change/break in the FS.h

Things like: Should add the ability to retrieve the files dates and times as part of MTP/MSC/... SD stuff now supports it.
Can/should we propagate up some LittleFS funcctions like the Quick format/ ...

Speaking of those functions, Maybe those functions, like bool lowLevelFormat(char progressChar=0);

Should have another optional parameter: Print& print=Serial... As maybe we don't want it to go to Serial. Maybe MTP app with LCD display may want to intercept those characters and update some status bar area...

Maybe extend my Storage Callback class to include maybe being called when new files are added/deleted on the host, such that maybe we need to update something.... Or we are monitoring something...

Also try to see if there are ways to do things with MTP that I keep missing.

Example: Is there some way for a device (like us) to tell the host) that we would like them to display something? For example right now the Format code returns more or less immediate, might be nice if we could later say that the format was actually completed.

Also testing on MAC and Linux.
 
@KurtE
Now that we are talking I have to check to see what the is being done to duplicate:
Code:
         "E - erase the card and skip formatting.\n"
         "F - erase and then format the card. (recommended)\n"
         "Q - quick format the card without erase.\n"

We also have to decide if we want to enforce formatting to the recommended format type based on partition size. <2Gb FAT16, 2-32GB FAT32 and >32 exFAT.
 
Yep lots of good questions... Question is again how to allow users to choose those options.

As for choosing the right one by the size... For me especially if not SD card, I would probably tend to retain what the user originally formatted it as... But again that is just me.

With SD Cards, My impression from the SDFat Issues I raised and then closed. Supposedly at least some of the manufactures do something about optimizing their SD to work with the specific sizes, like maybe something like special area of storage for the FAT tables... Not really sure. But again all bets are off if the user actually does something like use an SD Card for an RPI, which then creates multiple partitions.

Also Probably wont be easy to get him to take in any PRs to support extended partitions. My guess is it would not be hard. Probably a little work in the begin code, and probably the starting sector numbers have to be based both by the offset to where the extended partition begins, and then where the partition begins within the extended partition.

Also probably won't be able to support several plug in hard disks, as some of them (like the one I tried) probably uses a GPT format instead of an MBR format... Not sure what work it is to support those.


I was able to get the SD inserted in USB driver to come up...

Not overly eloquent yet but...
Code:
bool mbrDmp(msController *pdrv) {
  MbrSector_t mbr;
  // bool valid = true;
  [COLOR="#FF0000"]UsbFs msc;
  if (!msc.begin(pdrv)) return false;[/COLOR]
The calls below in the dmp function were hanging as device maybe was not ready yet.
So hait it begin an msc object and then it comes up...

Probably it for tonight. Reading SciFi...
 
Side note: I think it would be interesting and maybe useful to cleanup the example sketches.

Like maybe multiple files that split up some of the different storage types.

Also maybe a simple TFT display sketch that works with MTP... Not sure which display. Wish it was bigger than ILI9341, but that is the one PRJC sells. But could be fun for example to have an RA8875 display, where maybe we have list of the storages. where the user can select ones it it shows information on a volume. Maybe having simple way then to choose format choices and then allow you to click to start format.
Also allow you to walk down into directories... Maybe allow you to do somethings with some of the files, like delete one, or create directory...

This would then help to flesh out things like how to get notifications, like when the user maybe deletes files on the PC, that is shown in the current list.... Maybe have an area that if new jpg file shows up it changes the background...
 
Side note: I think it would be interesting and maybe useful to cleanup the example sketches.

Like maybe multiple files that split up some of the different storage types.

Also maybe a simple TFT display sketch that works with MTP... Not sure which display. Wish it was bigger than ILI9341, but that is the one PRJC sells. But could be fun for example to have an RA8875 display, where maybe we have list of the storages. where the user can select ones it it shows information on a volume. Maybe having simple way then to choose format choices and then allow you to click to start format.
Also allow you to walk down into directories... Maybe allow you to do somethings with some of the files, like delete one, or create directory...

This would then help to flesh out things like how to get notifications, like when the user maybe deletes files on the PC, that is shown in the current list.... Maybe have an area that if new jpg file shows up it changes the background...

Kinda like what I had with the T3.6, T4.0 and T4.1. A file manager, a modified version of the Kilo editor and STBasic all modified for use with the original RA8876_Lite driver I used. With all of the changes made to RA8876_t3 it will require a BIG rewrite. The file manager was representative of the a Norton or MC file manager but very basic. It had two panes that worked with a very basic dialog interface and the mouse or keyboard could be used.

Some examples:

T4_fm1.jpg

T4_fm4.jpg

fm_error_msg.jpg

T4_fm_rename.jpg

T$_mkdir.jpg

Sorry for the picture quality but I think you can see what I was able to do with the Teensy's. The T4.1 has allowed bigger multi file copy's due to more available memory.

This was based on uSDFS and FatFS. With the T3.6 I had a POSIX style OS working that would allow using the newlib/libc calls to work with stdin, stdout, stderr etc... using the weak defines of _open(), _close(),_read(), write()...

It basically was a wrapper for the POSIX file system to FatFS methods. It worked well for being a kluge:)

Ok, I'm done...
 
@wwatson Looks like fun. Maybe more work than we would want to do. But would be interesting.

@wwatson and @mjs513 @WMXZ @paulstoffregen ...
Another question to ask, is do we think we have enough of this stuff extended and stable enough to merge it from my branches back into the master ones.
This includes USBHost - to allow for the reads with callbacks.
the MSC project, with lots of stuff.
Also in the end does it make sense to have the PFsVolume... code in this library or another one?

MTP - I have had an outstanding PR for awhile again not sure best way to handle this library.

But again a more generic question is Should PJRC fork a version of MTP/MSC.. which hopefully goes into Teensduino release, which maybe isolate our changes from the originals, in case there is conflicting needs. That is such that we (I) don't do something stupid and break the good work of the originator, especially for the usage cases that the original code was developed for?
 
@All,

I ran into a problem when formatting a 128G Thumb drive with MSCFormatter. If I create all four partitions and format them as ExFat partitions with Linux and then check the first entry of the Fat I see this:

Code:
F8FFFFFFFFFFFFFF030000000400000005000000FFFFFFFFFFFFFFFFFFFFFFFF

And the integrity info shows this:

Code:
  Primary: EXFATP1 (/dev/sdf1), 29.8 GB [exFAT]
    General
      Name..............................EXFATP1 (/dev/sdf1)
      Type..............................Primary
      Active Partition..................No
      File System.......................exFAT
      RAID Type

    Partition Geometry
      First Sector......................2048
      Offset............................2048
      Segment...........................0
      Bytes per Sector..................512
      Total Sectors.....................62500864

    Volume: EXFATP1 (/dev/sdf1), 29.8 GB [exFAT]
      Volume General
        Volume name.....................EXFATP1
        Mount point.....................Not mounted
        Volume type.....................Volume
        File system.....................exFAT
        Serial number...................3B9B-000
        GUID name......................./dev/sdf1
        Status..........................Ready
        Scanned.........................No

      Volume integrity info
        Overall integrity status........[COLOR="#00FF00"]Excellent[/COLOR]
        Primary Boot Sector.............Valid
        Copy of Boot Sector.............Valid
        Primary Boot Sector matches a CopyValid
        Primary FAT Table...............Valid
        Root Folder.....................[COLOR="#00FF00"]Valid[/COLOR]
        Primary Boot Sector partially matches a CopyValid

      Volume capacity
        Total size......................29.8 GB (32,000,442,368 bytes)

      Volume Geometry
        First sector....................2048
        Total sectors...................62500864
        Bytes per sector................512
        Cluster size....................32768 bytes
        Get max file size...............128 PB (144,115,187,673,202,688 bytes)

But if I format the first ExFat partition using the MSCFormatter I get this as the first Fat entry:

Code:
F8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000

And the integrity check shows this:

Code:
  Primary: EXFATP1 (/dev/sdf1), 29.8 GB [exFAT]
    General
      Name..............................EXFATP1 (/dev/sdf1)
      Type..............................Primary
      Active Partition..................No
      File System.......................exFAT
      RAID Type

    Partition Geometry
      First Sector......................2048
      Offset............................2048
      Segment...........................0
      Bytes per Sector..................512
      Total Sectors.....................62500864

    Volume: EXFATP1 (/dev/sdf1), 29.8 GB [exFAT]
      Volume General
        Volume name.....................EXFATP1
        Mount point.....................Not mounted
        Volume type.....................Volume
        File system.....................exFAT
        Serial number...................3B9B-000
        GUID name......................./dev/sdf1
        Status..........................Ready
        Scanned.........................No

      Volume integrity info
        Overall integrity status........[COLOR="#FF0000"]Very Bad[/COLOR]
        Primary Boot Sector.............Valid
        Copy of Boot Sector.............Valid
        Primary Boot Sector matches a CopyValid
        Primary FAT Table...............Valid
        Root Folder.....................[COLOR="#FF0000"]Invalid[/COLOR]
        Primary Boot Sector partially matches a CopyValid

      Volume capacity
        Total size......................29.8 GB (32,000,442,368 bytes)

      Volume Geometry
        First sector....................2048
        Total sectors...................62500864
        Bytes per sector................512
        Cluster size....................32768 bytes
        Get max file size...............128 PB (144,115,187,673,202,688 bytes)

The first partition will not mount but the other three will. Then if I copy the first Fat entry of the second good partition to the first Fat entry of the first partition, the first partition will mount successfully.
This only happens when all four partitions are formatted and used. If I just create three or less partitions and format then format first partition with MSCFormatter they all mount successfully. I wonder if this is also a problem with four partitions being formatted as ExFat with Windows?

Anyway, just a heads up:)
 
Last edited:
@wwatson
Sorry for the delay but just got back to the computer. I've primarily been working with 2 64GB partitions on my 128GB thumb drive and haven;t seen any issues. But I've just formatted to have 4 exFat partitions and will test. You sure the first partition didn't fail formatting - I got caugth on that once or twice.
 
@KurtE - @wwatson
Something strange is happening again.

1. When I formatated a 128GB thumb drive and created 4 exFAT volumes the first volume failed to format, it hit the bitmapsize limit. Then I created 3 exFAT volumes about 30GB each and 1 FAT then MSC failed:
Code:
Cards up to 2 GiB (GiB = 2^30 bytes) will be formated FAT16.
Cards larger than 2 GiB and up to 32 GiB will be formatted
FAT32. Cards larger than 32 GiB will be formatted exFAT.

Waiting up to 5 seconds for USB drive 1
Initialize USB drive...UsbBase::mscBegin called 200045c0 1 1
    After usbDriveBegin
PFsVolume::begin USBmscInterface(20002a6c, 1)
PFsVolume::begin(20002a6c, 1)
USB drive 1 is present.

msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
exFAT:	1,0,0x20,0x21,0x0,0x7,0xFE,0xFF,0xFF,2048,67983360
exFAT:	2,0,0xFE,0xFF,0xFF,0x7,0xFE,0xFF,0xFF,67985408,67952640
exFAT:	3,0,0xFE,0xFF,0xFF,0x7,0xFE,0xFF,0xFF,135938048,68390912
FAT32:	4,0,0xFE,0xFF,0xFF,0xC,0xFE,0xFF,0xFF,204328960,37693504
PFsVolume::begin USBmscInterface(20002a6c, 1)
PFsVolume::begin(20002a6c, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 2)
PFsVolume::begin(20002a6c, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 3)
PFsVolume::begin(20002a6c, 3)
Partition 2 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 4)
PFsVolume::begin(20002a6c, 4)
Partition 3 valid:1
0:>> ExFat: Volume name:(v1) Partition Total Size:34804334592 Used:786432 time us: 24752
    Free Clusters: API: 265530 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
1:>> ExFat: Volume name:(v2) Partition Total Size:34788605952 Used:786432 time us: 24877
    Free Clusters: API: 265410 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
2:>> ExFat: Volume name:(v3) Partition Total Size:35013001216 Used:786432 time us: 25249
    Free Clusters: API: 267122 by CB:0 time us: 0
    Free Clusters: Info: 4294967295 time us: 0
3:>> Fat32: Volume name:(FAT32)###PFsVolume::freeClusterCount: FT:32
    m_sectorsPerCluster:32
    m_sectorsPerClusterShift:5
    m_rootDirEntryCount:0
    m_sectorsPerFat:9197
    m_dataStartSector:204353536
    m_fatStartSector:204335142
    m_rootDirStart:2
    m_bytesPerSector:512

2. Creating 4 FAT32 volumes it hangs on the first FAT32:
Code:
msc # Partition Table
	part,boot,bgnCHS[3],type,endCHS[3],start,length
FAT32:	1,0,0x20,0x21,0x0,0xB,0xFE,0xFF,0xFF,2048,62203904
FAT32:	2,0,0xFE,0xFF,0xFF,0xC,0xFE,0xFF,0xFF,62205952,61116416
FAT32:	3,0,0xFE,0xFF,0xFF,0xC,0xFE,0xFF,0xFF,123322368,59017216
FAT32:	4,0,0xFE,0xFF,0xFF,0xC,0xFE,0xFF,0xFF,182339584,59684864
PFsVolume::begin USBmscInterface(20002a6c, 1)
PFsVolume::begin(20002a6c, 1)
Partition 0 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 2)
PFsVolume::begin(20002a6c, 2)
Partition 1 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 3)
PFsVolume::begin(20002a6c, 3)
Partition 2 valid:1
PFsVolume::begin USBmscInterface(20002a6c, 4)
PFsVolume::begin(20002a6c, 4)
Partition 3 valid:1
0:>> Fat32: Volume name:(v1)###PFsVolume::freeClusterCount: FT:32
    m_sectorsPerCluster:32
    m_sectorsPerClusterShift:5
    m_rootDirEntryCount:0
    m_sectorsPerFat:15180
    m_dataStartSector:32440
    m_fatStartSector:2080
    m_rootDirStart:2
    m_bytesPerSector:512
 
@wwatson
Sorry for the delay but just got back to the computer. I've primarily been working with 2 64GB partitions on my 128GB thumb drive and haven;t seen any issues. But I've just formatted to have 4 exFat partitions and will test. You sure the first partition didn't fail formatting - I got caugth on that once or twice.

Me too. I was also working with two partitions. The failure is consistent. Tried several times and got the same result. It only happens when creating four partitions with Linux. After I do that Linux is happy and so is the Teensy. Then I format the first partition with the Teensy and MSCFormatter as ExFat, I plug it back into Linux and the first partition will not mount. The other three partitions will mount and be accessible. The only difference I could find as you saw in the previous post was was the first entry in the Fat of the first partition. There was extra info in the first Fat entries when all four partitions are used . That is when I copied the first entry of the second partitions Fat (with the to extra info) to the first entry of the first partitions Fat. Then the first partition would mount as well as the other three. I am not sure if this is a Linux ExFat format thing or if it is the same with Windows. I don't have Windows so I can't check for that and that is why I hoping others with Windows could check it out.

Just for reference:
Code:
F8FFFFFFFFFFFFFF[COLOR="#00FF00"]030000000400000005000000FFFFFFFFFFFFFFFFFFFFFFFF[/COLOR]
Works with four ExFat partitions.
Code:
F8FFFFFFFFFFFFFF[COLOR="#FF0000"]FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000[/COLOR]
Fails on any partition of the four ExFat partitions formatted by MSCFormatter.

I think there might be more to formatting the Fat with ExFat but ran out of time this weekend to purse it:(
 
Last edited:
@mjs513 @KurtE - Guess more to be done. Going to have to break down and get Windows to test with. Probably will grab a used laptop from work and set it up for WIN10. I have not tried four partitions of FAT32 yet. Will be interesting to check it out with Linux and see if I get the same results as you did Mike.

Have to feed the family now and catch a wink:( Why is it so hard to walk away from all of this fun:)
 
@wwatson
Addicting isn't it :)

Anyway seems mixing FAT32 partitions and exFAT partitions is a hangup if the FAT32 partition doesn't come before exFAT partition? - with 4 FAT32 partitions - no problem.

At least what I am running in a problem with is when formatting as exFAT and using default AU;s its a problem if formatting below 32GB.
 
Sorry I have been sort of missing in action today...

Actually playing with the sketch trying to see if it will format drives on SD Cards... I made some progress and passed in a volume for ExFat on SDCard and it errored at the same location you mention here.

Then wondered about SD cards on SPIO so started adding that. Then thought about rearranging the code a little and make a pass through all of the USB devices Sd devices and create a table of PfsVolume objects and then allow the user to call through to the format with mostly just the volume and....

Will see, but my guess probably not before tomorrow.
 
Back
Top