m_dev->syncDevice();
We may have cross posted... Have you tried resetting checksum=0 at start of format?
Once I verbally said (actually typed), that it works on the first partition I tried it on, but not second... A ding went off...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!
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;
}
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
Just pushed the fix for ExFatFormatted that you identified . Also added the setVolumeLabel code. Checked it out again and it worked:
Merged in
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]
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 ***
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...
"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"
bool mbrDmp(msController *pdrv) {
MbrSector_t mbr;
// bool valid = true;
[COLOR="#FF0000"]UsbFs msc;
if (!msc.begin(pdrv)) return false;[/COLOR]
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...
F8FFFFFFFFFFFFFF030000000400000005000000FFFFFFFFFFFFFFFFFFFFFFFF
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)
F8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000
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)
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
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.
F8FFFFFFFFFFFFFF[COLOR="#00FF00"]030000000400000005000000FFFFFFFFFFFFFFFFFFFFFFFF[/COLOR]
F8FFFFFFFFFFFFFF[COLOR="#FF0000"]FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000[/COLOR]