Reduce attributes on FAT file system with Mac OS#21
Conversation
Local Test Results (Mac, MATLAB R2025b)Tested the Result: Key FindingAfter This is a macOS security attribute that cannot be removed by Test Output
RecommendationThe current cleanup approach on The real question remains: does removing |
|
If removing attributes doesn't work, we should avoid creating SD cards with Mac for now. There will always be the attributes files on the Mac generated FAT32 card and they still be temporally interleaved with the pattern files. The "recommendation" doesn't make sense in our context. Keeping the attribute files or keeping them does not make a difference is the file access is based on the index of the FAT entry. Once the file name based access on the teensy is fast enough, it also won't matter what other files are on the card, so removing the attribute files will also be unnecessary. I suggest closing this PR and using Windows or Linux to create the SD cards. |
|
One thing that could work: on Mac (and only there) create pattern files names that are in the 6.3 name format. Then the attribute files will follow the 8.3 format. Together the pattern file and the associated attribute file might occupy as much space in the FAT index as the long form file names generated in Linux and windows. But this makes a bad workaround (avoiding file names since that broke directories with more that 50 pattern files) worse. Instead I suggest to focus on getting the file name based access to work in the teensy with the state machine running. |
Even that might not work, depending on the Mac implementation: "." cannot be part of a short filename entry, which means the attribute files might always occupy a "long" entry (see page 33 and following at https://cscie92.dce.harvard.edu/fall2025/slides/FAT32%20File%20Structure.pdf) |
|
Claude thought about this some more and found one potential solution! I will test tomorrow: macOS AppleDouble ( On macOS, every file copied to a FAT32 SD card gets a companion Prevention approaches tested (ALL FAILED):
The Cleanup approach that works:
Updated Still needs: G4.1 controller lab test with a Mac-prepared card to confirm Frank's hypothesis that only |
|
From the documentation I found it looks like If you could merge the attributes on your internal drive before copying the files (basically replacing my And we already confirmed this (also for windows and Linux hidden directories and files):
|
|
What could work: run the current code from [1] https://fatsort.sourceforge.io/, probably available through homebrew |
Lab Test Results (Mar 5)Tested two Mac-prepared SD cards on the G4.1 controller — both failed: Test 1:
|
| Method | Purpose | Result |
|---|---|---|
xattr -c before copy (PR #21) |
Prevent ._* files |
❌ com.apple.provenance is kernel-level, persists |
COPYFILE_DISABLE=1 cp |
Prevent ._* files |
❌ Still creates ._* |
cp -X |
Prevent ._* files |
❌ Still creates ._* |
cat source > dest |
Prevent ._* files |
❌ Still creates ._* |
dd if=source of=dest |
Prevent ._* files |
❌ Still creates ._* |
ditto --norsrc |
Prevent ._* files |
❌ Still creates ._* |
Python shutil.copy |
Prevent ._* files |
❌ Still creates ._* |
dot_clean -m post-copy |
Remove ._* files |
✅ Removes files, but ❌ controller still fails |
dot_clean -m + fatsort |
Remove ._* + compact FAT32 dir |
✅ Clean dirIndex, but ❌ controller still fails |
Conclusion
The G4.1 controller failure with Mac-prepared cards goes beyond ._* files and FAT32 dirIndex ordering. Something else about macOS-formatted FAT32 is incompatible with the firmware — possibly .Spotlight-V100 (which macOS locks and cannot be deleted while mounted), or differences in how macOS newfs_msdos creates the FAT32 filesystem compared to Windows format.
Recommendation: Close this PR. Use Windows or Linux for SD card creation. Long-term fix: Teensy firmware with filename-based pattern access.
SD cards generated with Mac OS seem to fail with the index based access to files. This is due to the
._*files generated by Mac OS to keep file attributes. This code remove attributes from the*.patfiles before writing to FAT32. Potentially this avoids the._*.patfiles being generated on the SD card.This PR need thorough testing before considering at merge to
main.