Storage Example · Registers

Register Walk: MBR Partitions

Before trusting the disk program, read sector zero through the UART register path and decode the four MBR entries by hand.

Goal

This example uses the debug command readblk. It drives the Raspberry Pi eMMC2 path directly: initialize the card, issue CMD17, read the data FIFO, and print all 128 32-bit words from the 512-byte sector. The parser below is mental arithmetic turned into notes; no filesystem code is involved yet.

Command

The normal help output now stays focused on user-facing disk commands. Run debug when you need the raw register and block-read tools used by this walk.

debug
readblk 0 128

Hardware Result

signature=0xAA55
partition 1: boot=0x00 type=0x0C FAT32 LBA first_lba=16384 sectors=1048576
partition 2: boot=0x00 type=0x83 Linux first_lba=1064960 sectors=61268992
partition 3: boot=0x00 type=0x00 empty first_lba=0 sectors=0
partition 4: boot=0x00 type=0x00 empty first_lba=0 sectors=0

Offsets

MBR signature: byte 510 = 0x55, byte 511 = 0xAA
partition table: byte 446
entry size: 16 bytes
entry + 0: boot flag
entry + 4: partition type
entry + 8: first LBA, little-endian u32
entry + 12: sector count, little-endian u32

What This Proves

The card is readable through the low-level path, the first sector is an MBR, and the boot FAT32 partition starts at LBA 16384. The second partition is Linux. That gives the FAT32 example a concrete next sector to read.