Bare-Metal Ada on the ESP32-S3 A step-by-step guide to running Ada on the ESP32-S3 with no ESP-IDF, no FreeRTOS, and no Python.

Step 48 of 56

FAT16: the filesystem a PC can read

Deliberately narrow — read-only, FAT16 only, long filenames supported — because its whole job is being mountable by an operating system you do not control.

Why it exists alongside ext4

ext4 is the better filesystem, but only Linux mounts it. When a device exposes its storage over USB mass storage it appears as a removable drive, and if it is formatted FAT then Windows, macOS and Linux all mount it with no driver and no ceremony: the user drops files on it and the device reads them back.

That single use case sets the whole design.

The deliberate limits

ChoiceReason
Read only The PC writes; the device reads. Nothing here needs to write, so nothing here can corrupt a volume the user cares about.
FAT16 only FAT12 and FAT32 volumes are recognised and rejected rather than misread, so wrongly formatted media fails loudly instead of returning plausible rubbish.
Long filenames (VFAT) Because a user dropping files on a drive will not respect 8.3, and silently mangling their names is not acceptable.

"Recognised and rejected" is the part worth copying as a design habit. A FAT32 volume read as FAT16 does not fail — it returns entries that look like files. Refusing is strictly better than a plausible wrong answer.

Formatting

Fat16.Mkfs is a separate child that lays down an empty volume on blank media. It chooses 4 KB clusters aligned to the NOR erase unit, so the block layer's read-modify-write stays one erase per cluster written — the filesystem's geometry chosen to suit the medium underneath it.

It reads from either an MBR-partitioned disk (what Windows expects on a USB stick) or a bare boot sector at LBA 0, and sits on Block_Dev like everything else, so the same sources run over SPI NOR flash, an SD card, or a file-backed device in the test harness.

Host-verified only. The development harness makes three independent implementations agree about every volume — this code, the host's dosfstools, and a FAT16 writer written from the specification rather than from this source — but the on-device path wants checking on your own hardware.