Skip to content

Update FatFS to R0.16 via abbrev/fatfs dependency#3583

Closed
hathach wants to merge 1 commit into
masterfrom
fatfs-r0.16
Closed

Update FatFS to R0.16 via abbrev/fatfs dependency#3583
hathach wants to merge 1 commit into
masterfrom
fatfs-r0.16

Conversation

@hathach
Copy link
Copy Markdown
Owner

@hathach hathach commented Apr 2, 2026

Summary

  • Update FatFS from R0.15 to R0.16 using abbrev/fatfs GitHub mirror as a managed dependency via get_deps.py instead of vendoring source files
  • Move TinyUSB custom ffconf.h to examples/host/msc_file_explorer/src/ to keep project-specific settings separate from upstream
  • Remove ~24K lines of vendored FatFS source from git tracking

Based on #3581 by @non-bin. Rebased to current master with CI fixes.

Key changes

  • tools/get_deps.py: Added lib/fatfs to deps_mandatory, pinned to R0.16 (commit 30ca13c6). Added deps_remove_files to delete stock ffconf.h after clone so the example's custom version takes precedence.
  • examples/host/msc_file_explorer/src/ffconf.h: Custom config with TinyUSB-specific settings (FF_CODE_PAGE=437, FF_USE_LFN=1, FF_FS_RPATH=2, FF_VOLUMES=4, FF_FS_NORTC=1)
  • Removed vendored lib/fatfs/ from git

FatFS R0.16 highlights (since R0.15)

  • Fixed FAT32 FsInfo regression that forced full FAT scan on every f_getfree()
  • Fixed f_readdir() infinite loop
  • f_getcwd()/.. now works on exFAT
  • Added FF_FS_CRTIME (created-time timestamp) support

Test plan

  • Build msc_file_explorer for raspberry_pi_pico (CMake)
  • Build msc_file_explorer for mimxrt1064_evk (CMake)
  • Build msc_file_explorer for stm32h743eval (CMake + Make)
  • Build all examples for stm32h743eval
  • Verified FatFS source files match official R0.16 from elm-chan
  • CI

🤖 Generated with Claude Code

- Add lib/fatfs to deps_mandatory in get_deps.py, pinned to R0.16
  (commit 30ca13c6) from github.com/abbrev/fatfs mirror
- Move TinyUSB custom ffconf.h to examples/host/msc_file_explorer/src/
  with project-specific settings: FF_CODE_PAGE=437, FF_USE_LFN=1,
  FF_FS_RPATH=2, FF_VOLUMES=4, FF_FS_NORTC=1
- get_deps.py removes stock ffconf.h after clone to avoid conflict
- Remove vendored fatfs source files from git tracking

FatFS R0.16 includes important fixes since R0.15:
- Fixed FAT32 FsInfo regression (forced full FAT scan on f_getfree)
- Fixed f_readdir infinite loop (from R0.15b)
- f_getcwd/.. now works on exFAT
- Added FF_FS_CRTIME support
Copilot AI review requested due to automatic review settings April 2, 2026 10:47
@hathach hathach closed this Apr 2, 2026
@hathach hathach deleted the fatfs-r0.16 branch April 2, 2026 10:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates TinyUSB’s FatFS integration from vendored R0.15 sources to a managed dependency (abbrev/fatfs) pinned to an R0.16 commit, and relocates TinyUSB’s custom ffconf.h into the msc_file_explorer example so project-specific settings stay out of the upstream mirror.

Changes:

  • Add lib/fatfs as a mandatory dependency in tools/get_deps.py and remove upstream ffconf.h after cloning so the example’s custom config is used.
  • Update the example-specific ffconf.h for the new FatFS revision ID / options.
  • Remove previously vendored FatFS source and documentation files from lib/fatfs/.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/get_deps.py Adds FatFS as a mandatory cloned dependency and deletes upstream ffconf.h post-clone.
examples/host/msc_file_explorer/src/ffconf.h Updates the example’s FatFS configuration to match the newer FatFS revision/options.
lib/fatfs/source/ffsystem.c Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/source/ff.h Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/source/diskio.h Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/source/diskio.c Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/source/00readme.txt Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/source/00history.txt Removed from git tracking (now provided by the dependency mirror).
lib/fatfs/LICENSE.txt Removed from git tracking (now provided by the dependency mirror).
Comments suppressed due to low confidence (3)

examples/host/msc_file_explorer/src/ffconf.h:130

  • Spelling/grammar in this comment block: "requiers" should be "requires", and the sentence "It is recommended to be set 255" should be adjusted (e.g., "recommended to be set to 255"). These are user-facing docs in the config header and were touched in this update.
    examples/host/msc_file_explorer/src/ffconf.h:262
  • Spelling in this comment: "read current time form real-time clock" should be "from real-time clock".
    examples/host/msc_file_explorer/src/ffconf.h:302
  • Spelling in this comment block: "featuer" should be "feature".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/get_deps.py
Comment on lines +341 to +345
if d in deps_remove_files:
for f in deps_remove_files[d]:
fp = p / f
if fp.exists():
fp.unlink()
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new deps_remove_files step assumes p is already an initialized git repo when p.exists() is true. Since lib/fatfs used to be a vendored directory, some worktrees may still have a non-git lib/fatfs/ present (e.g., leftover untracked files), causing git rev-parse HEAD to fail earlier and the script to crash on splitlines()[0]. Consider detecting a missing .git/ (or non-zero rev-parse) and re-initializing/cleaning the directory before continuing.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 2, 2026

Size Difference Report

Because TinyUSB code size varies by port and configuration, the metrics below represent the averaged totals across all example builds.

Note: If there is no change, only one value is shown.

Changes >1% in size

No entries.

Changes <1% in size

No entries.

No changes
file .text .rodata .data .bss size % diff
audio_device.c 2897 0 1260 1627 4518 +0.0%
cdc_device.c 1252 16 1106 684 1935 +0.0%
cdc_host.c 6617 487 15 1498 8327 +0.0%
dcd_ch32_usbfs.c 1473 0 0 2444 3917 +0.0%
dcd_ch32_usbhs.c 1469 0 0 448 1917 +0.0%
dcd_ci_fs.c 1925 0 0 1290 3215 +0.0%
dcd_ci_hs.c 1759 0 0 1344 2538 +0.0%
dcd_da146xx.c 3067 0 0 144 3211 +0.0%
dcd_dwc2.c 4210 25 0 265 4500 +0.0%
dcd_eptri.c 2271 0 0 259 2530 +0.0%
dcd_ft9xx.c 3276 0 0 172 3448 +0.0%
dcd_khci.c 1953 0 0 1290 3243 +0.0%
dcd_lpc17_40.c 1474 0 0 648 1798 +0.0%
dcd_lpc_ip3511.c 1463 0 0 264 1683 +0.0%
dcd_mm32f327x_otg.c 1478 0 0 1290 2768 +0.0%
dcd_msp430x5xx.c 1798 0 0 176 1974 +0.0%
dcd_musb.c 2445 0 0 160 2605 +0.0%
dcd_nrf5x.c 2918 0 0 292 3210 +0.0%
dcd_nuc120.c 1094 0 0 78 1172 +0.0%
dcd_nuc121.c 1168 0 0 101 1269 +0.0%
dcd_nuc505.c 0 0 1531 157 1688 +0.0%
dcd_rp2040.c 838 0 764 655 2257 +0.0%
dcd_rusb2.c 2919 0 0 156 3075 +0.0%
dcd_samd.c 1034 0 0 266 1300 +0.0%
dcd_samg.c 1320 0 0 72 1392 +0.0%
dcd_stm32_fsdev.c 2558 0 0 291 2849 +0.0%
dfu_device.c 777 28 712 140 916 +0.0%
dfu_rt_device.c 157 0 134 0 157 +0.0%
dwc2_common.c 602 30 0 0 618 +0.0%
ecm_rndis_device.c 1037 0 1 2858 3896 +0.0%
ehci.c 2763 0 0 6043 7597 +0.0%
fsdev_common.c 180 0 0 0 180 +0.0%
hcd_ch32_usbfs.c 2485 0 0 498 2983 +0.0%
hcd_ci_hs.c 184 0 0 0 184 +0.0%
hcd_dwc2.c 4994 33 1 513 5540 +0.0%
hcd_khci.c 2442 0 0 449 2891 +0.0%
hcd_musb.c 3073 0 0 157 3230 +0.0%
hcd_pio_usb.c 262 0 240 0 502 +0.0%
hcd_rp2040.c 2000 17 4 321 2342 +0.0%
hcd_rusb2.c 2923 0 0 245 3168 +0.0%
hcd_samd.c 2220 0 0 324 2544 +0.0%
hcd_stm32_fsdev.c 3287 0 1 420 3708 +0.0%
hid_device.c 1125 44 997 119 1244 +0.0%
hid_host.c 1240 0 0 1251 2491 +0.0%
hub.c 1384 8 8 30 1418 +0.0%
midi_device.c 1151 0 1007 623 1772 +0.0%
midi_host.c 1341 7 7 3635 4979 +0.0%
msc_device.c 2525 108 2286 547 3071 +0.0%
msc_host.c 1587 0 0 394 1982 +0.0%
mtp_device.c 1696 22 735 588 2292 +0.0%
ncm_device.c 1538 28 718 5843 7395 +0.0%
ohci.c 1940 0 0 2414 4353 +0.0%
printer_device.c 830 0 706 566 1394 +0.0%
rp2040_usb.c 380 35 615 11 1042 +0.0%
rusb2_common.c 160 0 16 0 176 +0.0%
tusb.c 451 0 383 3 453 +0.0%
tusb_fifo.c 841 0 480 0 836 +0.0%
typec_stm32.c 820 8 2 12 842 +0.0%
usbc.c 420 2 20 166 608 +0.0%
usbd.c 3224 57 88 275 3564 +0.0%
usbd_control.c 538 0 484 79 616 +0.0%
usbh.c 4652 55 99 961 5734 +0.0%
usbtmc_device.c 2196 24 68 316 2544 +0.0%
vendor_device.c 641 0 534 565 1204 +0.0%
video_device.c 4443 5 1235 479 4914 +0.0%
TOTAL 119185 1039 16257 46916 167719 +0.0%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants