Storage Example · Registers

Register Walk: FAT32 Directory

Use the MBR result, read the FAT32 boot sector, compute the root directory LBA, then inspect the first directory sector through the data FIFO.

Start From MBR

The MBR walk found the FAT32 partition at LBA 16384. Read that sector next. It is the FAT32 boot sector, also called the BIOS Parameter Block in older FAT documentation. These raw block reads are debug commands; run debug at the shell if you need a reminder of the register-level tools.

debug
readblk 16384 128

Decoded Boot Sector

bytes_per_sector=512
sectors_per_cluster=1
reserved=32
fats=2
total_sectors=1048572
fat_size=8066
root_cluster=2
fat_lba=16416
data_lba=32548
root_dir_lba=32548

The Formula

fat_lba = partition_lba + reserved_sectors
data_lba = partition_lba + reserved_sectors + fat_count * fat_size
cluster_lba = data_lba + (cluster - 2) * sectors_per_cluster

partition_lba = 16384
root_cluster = 2
root_dir_lba = 32548 + (2 - 2) * 1 = 32548

Read Root Directory

readblk 32548 128

Hardware Result

<DIR> cl=3 size=0 overlays
      cl=8 size=32495 bcm2710-rpi-2-b.dtb
      cl=4 size=1594 LICENCE.broadcom
      cl=206804 size=145 issue.txt
      cl=560208 size=76 config.txt
      cl=72 size=35322 bcm2710-rpi-3-b-plus.dtb
entries_in_first_sector=6

UART Timing Note

The current example uses interrupt-driven UART RX and a 1 ms scheduler tick, so the console can keep full command names responsive while the disk task performs slower reads. Use partitions, disk partitions, dir, and disk dir rather than one-letter disk aliases.