SD, eMMC & Raw NAND Storage Topologies and UUU Provisioning
Contrast FTL-managed block storage (SD/eMMC boot0 + LBA 2 IVT) against raw SLC NAND (MTD eraseblocks, BBT, UBI/UBIFS) and trace UUU two-stage SDP-to-Fastboot flashing.
What you'll learn
- Contrast
SD/eMMC512-byteLBA+boot0hardware partitions against rawSLC NANDeraseblock, page/OOB,MTD, andUBI/UBIFSgeometry. - Analyze why placing
FAT32orext4directly onto rawNANDfails immediately due to factory bad blocks and missing wear leveling. - Trace
UUUprovisioning scripts fromSDP:Boot ROMDCD+DDR3download intoFB:U-BootFastbootflash commands.
Managed FTL Block Flash Versus Raw SLC NAND Geometry
Embedded i.MX6ULL boards ship in two primary non-volatile storage variants: 8 GiB eMMC (USDHC2) and 512 MiB raw SLC NAND (GPMI), alongside a removable SD slot (USDHC1). Although all three store bits in floating-gate/charge-trap NAND cells under the hood, their software interfaces belong to two completely different worlds!
SD cards and eMMC packages integrate a dedicated controller running a Flash Translation Layer (FTL). Linux sees /dev/mmcblk0 or /dev/mmcblk1 as clean 512-byte sectors (LBA 0..N), so MBR/GPT, FAT32 (/boot), and ext4 (rootfs) work directly once Partition 1 starts at LBA 2048 (1 MiB) above u-boot.imx at 0x400 (LBA 2), or inside eMMC's hardware mmcblk1boot0 partition.
Raw SLC NAND has zero internal controller: the i.MX6ULL GPMI and BCH engines drive raw 2 KiB page writes (+ 64 B OOB ECC), 128 KiB block erases, and Bad Block Tables (BBT) through MTD (/dev/mtd0..N) paired with UBI and UBIFS.
Figure 5.2a. Boot ROM SDP only knows how to initialize DDR3 via DCD and jump to RAM U-Boot; U-Boot Fastboot writes the flash.
mental model: Managed SD/eMMC flash is like checking luggage at an airport desk that hides conveyor routing behind clean claim-tag numbers (LBA), whereas raw SLC NAND hands you the warehouse forklift directly — you must track worn floor bays (BBT) and erase entire shelves (128 KiB PEBs) before stacking a 2 KiB box.
Where it stops working: An internal eMMC FTL handles wear leveling and bad blocks, yet sudden power loss during metadata updates can still corrupt FAT32 or FTL tables without ext4 journaling or read-only squashfs.
definition (UBI (Unsorted Block Images)): A Linux kernel volume-management layer sitting directly above raw MTD flash devices that maps contiguous, bad-block-free Logical Eraseblocks (LEBs) onto Physical Eraseblocks (PEBs), maintaining erase-counter headers across the entire NAND chip and transparently relocating data away from newly failing blocks for UBIFS.
- Step 1. Even a brand-new board with completely erased eMMC/NAND boots U-Boot into DDR3 in < 1 second via SDP.
- Step 2. Storing U-Boot in mmcblk1boot0 isolates bootloader updates from MBR/GPT re-partitioning in user space.
- Step 3. -raw2sparse avoids transferring gigabytes of unallocated ext4 zeros over USB 2.0 High-Speed.
- Step 4. FB: done verifies the final Fastboot ACK before you switch BOOT_MODE=10 to test standalone cold boot.
Figure 5.2b. Keep LBA 2..2047 clear on SD, use boot0 on eMMC, use UBI/UBIFS on raw NAND, and stream via UUU SDP->FB.
eMMC Partition Offsets Versus NAND FCB, MTD, and LEB Sizing
Compare exact byte layouts on both media types so partition math never collides with the Boot ROM! On SD (USDHC1) or eMMC User Area, LBA 0 (0x000..0x1FF) holds the 512-byte MBR; byte 0x400 (LBA 2, 1 KiB offset) holds u-boot.imx (IVT magic 0xD1 followed by DCD and U-Boot binary, ~500..800 KiB); and Partition 1 begins cleanly at LBA 2048 (1 MiB = 0x100000), leaving 1,023 KiB of protected headroom.
On 512 MiB SLC NAND (4,096 PEBs x 128 KiB, 64 pages/block x 2,048 B + 64 B OOB), block 0 cannot simply hold raw u-boot.imx: the Boot ROM expects a Flash Control Block (FCB, written with redundant copies + BCH ECC by kobs-ng or U-Boot bcb) and Discovered Bad Block Table (DBBT). Above U-Boot, DTB, and zImage MTD partitions, UBI subtracts 2 pages (4 KiB: EC + VID headers) from each 128 KiB PEB (LEB = 124 KiB) and reserves ~20 PEBs per 1,024 (2%) for bad-block replacement.
Figure 5.2b. UBI consumes 2 NAND pages (EC + VID headers = 4 KiB on 2 KiB-page SLC NAND) per 128 KiB physical eraseblock.
| Dimension | SD / eMMC (USDHC1/2) | Raw SLC NAND (GPMI) | Operational Consequence |
|---|---|---|---|
| Controller & ECC | Internal FTL MCU handles ECC & wear | Host i.MX6ULL GPMI + BCH hardware ECC | Raw NAND exposes bitflips (-EUCLEAN) and bad blocks to MTD |
| Minimum write / erase | 512 B LBA sector (FTL-managed) | Write 2 KiB page; erase 128 KiB PEB | In-place sector overwrite is physically impossible on raw NAND |
| Bootloader header | IVT at 0x400 (LBA 2 or boot0) | FCB + DBBT in Block 0 + redundant copies | Raw dd of u-boot.imx to /dev/mtd0 fails without FCB ECC! |
| Root filesystem | ext4 or squashfs on /dev/mmcblkXp2 | UBIFS on UBI volume (ubi0:rootfs) | bootargs differ: root=/dev/mmcblk1p2 rootwait vs ubi.mtd=4 root=ubi0:rootfs |
learner@ksa:~/gl-e00/m05-l02$ bat -H 4 -H 13 emmc_nand_provision.uuu File: emmc_nand_provision.uuu uuu_version 1.4.182 # Stage 1: Stream U-Boot (+ IVT/DCD) over USB OTG1 HID SDP into DDR3 RAM SDP: boot -f u-boot-imx6ull-14x14-evk-emmc.imx # Stage 2: RAM U-Boot runs USB Fastboot gadget on OTG1 FB: ucmd setenv fastboot_dev mmc FB: ucmd setenv mmcdev 1 FB: ucmd mmc dev 1 # Program U-Boot into dedicated eMMC boot0 hardware partition & enable boot0 FB: flash bootloader u-boot-imx6ull-14x14-evk-emmc.imx FB: ucmd mmc partconf 1 1 1 0 # Stream full MBR + FAT32 (zImage/dtb) + ext4 rootfs with sparse zero-skipping FB: flash -raw2sparse all core-image-minimal-imx6ull.sdcard FB: Sync FB: done- SDP: talks directly to the i.MX6ULL mask Boot ROM over USB HID to init DDR3 via DCD and boot U-Boot in RAM.
- mmc partconf 1 1 1 0 configures eMMC EXT_CSD[179] so Internal Boot reads boot0 with BOOT_ACK enabled.
uuu(1) / ubiattach(8)(1) GL-E00 Quick Reference uuu(1) / ubiattach(8)(1) SYNOPSIS sudo uuu -lsusb # Verify board enumerates as 15a2:0080 (SE Blank 6ULL) in BOOT_MODE=01 sudo uuu -b emmc_all u-boot.imx rootfs.sdcard sudo uuu emmc_nand_provision.uuu KEY STORAGE COMMANDS (Target Linux / U-Boot) dd if=u-boot.imx of=/dev/sdX bs=1K seek=1 conv=fsync # SD card 1 KiB (0x400) IVT offset ubiformat /dev/mtd4 -f rootfs.ubi # Preserves UBI erase counters (never raw nandwrite over UBI!) ubiattach -p /dev/mtd4 && mount -t ubifs ubi0:rootfs /mnt Kernel Systems Academy Lesson 5.2 uuu(1) / ubiattach(8)(1) GL-E00 quick reference · full manual page: man 1 uuu(1) / ubiattach(8) Verifying LBA Headroom, UBI LEB Overhead, and UUU Ordering in C11
Storage-layout arithmetic bugs wipe partition tables or underestimate UBIFS image limits when mkfs.ubifs -m 2048 -e 126976 -c ... is configured. In verify.c, we validate SD/eMMC IVT (0x400) + u-boot.imx bounds against Partition 1 (LBA 2048), compute exact UBI LEB size (126,976 bytes = 124 KiB) and usable capacity on a 512 MiB SLC NAND chip, and check UUU SDP -> FB transition order.
All geometry math executes deterministically in host C11; actual USB SDP enumeration and GPMI BCH ECC timings belong strictly to physical i.MX6ULL target hardware.
learner@ksa:~/gl-e00/m05-l02$ bat -H 17 -H 28 verify.c File: verify.c #define _POSIX_C_SOURCE 200809L #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> struct nand_ubi_geom { uint32_t total_pebs; uint32_t leb_bytes; uint32_t reserved_bad_pebs; uint32_t usable_lebs; }; static struct nand_ubi_geom calc_ubi_geom(uint32_t mtd_pebs, uint32_t peb_bytes, uint32_t page_bytes) { struct nand_ubi_geom g; g.total_pebs = mtd_pebs; g.leb_bytes = peb_bytes - (2U * page_bytes); /* EC + VID headers = 2 pages on non-subpage SLC */ g.reserved_bad_pebs = (4096U * 20U) / 1024U; /* Per-chip 20/1024 BBT pool charged to UBI */ g.usable_lebs = mtd_pebs - g.reserved_bad_pebs - 4U; /* 2 layout + 2 WL/atomic PEBs */ return g; } static bool validate_uuu_steps(const char **cmds, size_t n) { bool ram_uboot_live = false; for (size_t i = 0U; i < n; i++) { if (strncmp(cmds[i], "SDP: boot", 9U) == 0) ram_uboot_live = true; else if (strncmp(cmds[i], "FB:", 3U) == 0 && !ram_uboot_live) return false; } return ram_uboot_live; } int main(void) { uint32_t ivt_offset = 0x400U; /* LBA 2 = 1024 B */ uint32_t uboot_bytes = 640U * 1024U; /* 640 KiB u-boot.imx */ uint32_t part1_lba = 2048U; /* 1 MiB = 1,048,576 B */ bool sd_safe = (ivt_offset + uboot_bytes) <= (part1_lba * 512U); /* 480 MiB rootfs MTD partition = 3840 PEBs of 128 KiB, 2 KiB page */ struct nand_ubi_geom ubi = calc_ubi_geom(3840U, 131072U, 2048U); const char *good_uuu[] = {"SDP: boot -f u-boot.imx", "FB: ucmd mmc dev 1", "FB: done"}; const char *bad_uuu[] = {"FB: flash bootloader u-boot.imx", "SDP: boot -f u-boot.imx"}; if (!sd_safe || ubi.leb_bytes != 126976U || !validate_uuu_steps(good_uuu, 3U) || validate_uuu_steps(bad_uuu, 2U)) return 1; printf("SD_LAYOUT ivt=0x%x uboot_end=%u part1_start=%u headroom_B=%u\n", ivt_offset, ivt_offset + uboot_bytes, part1_lba * 512U, (part1_lba * 512U) - (ivt_offset + uboot_bytes)); printf("NAND_UBI leb_B=%u bad_rsv_pebs=%u usable_lebs=%u usable_MiB=%.1f\n", ubi.leb_bytes, ubi.reserved_bad_pebs, ubi.usable_lebs, ((double)ubi.usable_lebs * (double)ubi.leb_bytes) / (1024.0 * 1024.0)); printf("UUU_SEQ valid_sdp_then_fb=1 reversed_fb_first_rejected=1\n"); return 0; }- Without subpage writes, UBI places EC and VID headers in 2 separate 2 KiB pages -> LEB = 126,976 B.
- Any FB: Fastboot command fails unless an earlier SDP: boot command already started U-Boot in RAM!
Checking Partition Headroom and mkfs.ubifs Parameters
Notice the 126,976-byte (124 KiB) leb_B figure in NAND_UBI: that exact integer is what you pass to mkfs.ubifs -m 2048 -e 126976 -c 3756 when building a NAND rootfs on your Linux host! Passing 131072 (128 KiB raw PEB size) by mistake produces a UBIFS image that ubiupdatevol immediately rejects at runtime.
Notice also why reserved_bad_pebs equals 80 (20/1024 of the entire 4,096-PEB 512 MiB chip, not just the 3,840-PEB rootfs MTD partition!): Linux kernel UBI sizes its bad-block pool against total chip capacity because factory bad blocks cluster unpredictably.
learner@ksa:~/gl-e00/m05-l02gcc -std=c11 -Wall -Wextra -Werror verify.c -o verifylearner@ksa:~/gl-e00/m05-l02./verifySD_LAYOUT ivt=0x400 uboot_end=656384 part1_start=1048576 headroom_B=392192NAND_UBI leb_B=126976 bad_rsv_pebs=80 usable_lebs=3756 usable_MiB=454.8UUU_SEQ valid_sdp_then_fb=1 reversed_fb_first_rejected=1learner@ksa:~/gl-e00/m05-l02learner@ksa:~/gl-e00/m05-l02strace -e trace=write,exit_group ./verifywrite(1, "SD_LAYOUT ivt=0x400 uboot_end=65"..., 204) = 204exit_group(0) = ?+++ exited with 0 +++Provisioning and Flash-Wear Hazards on eMMC and NAND
Keep your host udev rules from Module 1 updated for both UUU USB IDs (15a2:0080 NXP SDP HID and 0525:a4a5 / 1b67:4fff U-Boot Fastboot gadget) so uuu runs reliably without erratic USB permission drops mid-script when the board re-enumerates between SDP: and FB:!
And when updating an existing UBI partition in the field, always use ubiformat or ubiupdatevol — never flash_erase + raw nandwrite, which wipes EC wear-leveling counters.
UUU Hangs at Waiting for Known USB Device Between SDP and FB:
- Symptom:
SDP: boot -f u-boot.imxreaches100%, thenuuustalls indefinitely waiting forFB:Fastboot enumeration. - Root Cause: Either the flashed
u-boot.imxlacksCONFIG_USB_FUNCTION_FASTBOOT/DCDmatching the board'sDDR3size, OR a Linux VM (VirtualBox/VMware) captured15a2:0080(SDP) but failed to auto-capture the new0525:a4a5(Fastboot) USB VID:PID on re-enumeration! - Fix: Add both NXP
SDP(15a2:0080) andU-BootFastboot(0525:a4a5) USB filters to your VM configuration and/etc/udev/rules.d/.
Forgetting bs=1K seek=1 When Writing u-boot.imx to SD Card:
- Symptom: Running
dd if=u-boot.imx of=/dev/sdbbootsU-Boot, yetlsblkandLinux kernelreport theSDcard'sMBRpartition table is completely gone! - Root Cause: Omitting
seek=1 bs=1K(seek=2 bs=512) writesu-boot.imxat byte0x000(LBA 0), overwriting the512-byteMBRAND placing theIVTat0x000instead of0x400! - Fix: Always include
bs=1K seek=1 conv=fsync(preserving bytes0..1023, includingLBA 0MBR), and verifyPartition 1starts at>= LBA 2048.
Guided Practice
Modify verify.c to test what happens when an oversized U-Boot + environment blob grows to 1,100 KiB while Partition 1 starts at LBA 2048 (1,024 KiB). Does sd_safe catch the 77 KiB overlap into the FAT32 Boot Sector?
Compute the minimum 4 MiB-aligned starting sector (LBA 8192) required to give U-Boot and redundant U-Boot environment sectors (env + env_redund) generous 4 MiB headroom.
Independent Practice
Write a C11 parser parse_mtdparts(const char *spec) for mtdparts=gpmi-nand:4m(boot),8m(kernel),1m(dtb),-(rootfs) on a 512 MiB (524,288 KiB) NAND chip that calculates the exact byte offset and PEB count (128 KiB/PEB) of every partition including the remaining -(rootfs) slice.
Confirm that 4 + 8 + 1 = 13 MiB leaves 499 MiB (3,992 PEBs) for rootfs with zero unaligned PEB remainders.
Verification Checks
Key takeaways
SD(USDHC1) andeMMC(USDHC2) embed an on-chip Flash Translation Layer (FTL) exposing512-byteLBAsectors, withi.MX6ULLIVTplaced at byte0x400(LBA 2) andeMMCproviding dedicatedboot0/boot1hardware partitions.- Raw
SLC NAND(GPMI+BCHECC) exposes physical eraseblocks (128 KiB) and factory/wear bad blocks directly without anFTL, requiringLinux kernelMTD, Bad Block Tables (BBT), andUBI/UBIFSrather thanFAT32/ext4. - With
BOOT_MODE[1:0] = 01,UUUStage 1 (SDP: boot -f u-boot.imx) uses the Boot ROM'sUSB_OTG1HID protocol to executeDCDDDR3init and runU-Bootdirectly in RAM. UUUStage 2 (FB:) speaksUSBFastbootto the RAM-residentU-Bootgadget to partition and programeMMC(boot0+GPT/MBR) orNAND(MTD/UBI) unattended.