fix(nixos/upboard): force-load eMMC stack in initrd + align /boot label

First Sintra boot from the freshly-flashed eMMC panicked in stage 1:

  An error occurred in stage 1 of the boot process, which must mount
  the root filesystem on '/mnt-root' and then start stage 2.
  mount: can't find /mnt-root/ in /proc/mounts
  stage 2 init script (/mnt-root/nix/store/...nixos-system-bitspire/init) not found
  Kernel panic - not syncing: Attempted to kill init!

Root cause: the UP Board's eMMC controller is enumerated via ACPI
(sdhci-acpi), but the initrd only had sdhci_pci available. /dev/mmcblk*
nodes never materialised in stage 1, so root-by-label resolution
silently failed and switch_root had nothing to chroot into. Tejo (same
hardware module) appears to have been getting lucky with a different
controller binding, or its eMMC firmware exposes PCI-style SDHCI.

  - Add sdhci-acpi + mmc_block to initrd.availableKernelModules so the
    block device infrastructure is present in the early-boot ramdisk.
  - Force-load both via initrd.kernelModules so they're guaranteed to
    fire before stage 1 init runs — leaving them on availableKernel
    Modules alone relies on udev autoload firing in time, which it
    wasn't.

Also a separate-but-adjacent fix in the same module: /boot was
declared as by-label/boot, but make-disk-image.nix with
partitionTableType="efi" labels the FAT partition "ESP". This was
the FIRST boot failure I hit (manually worked around with
`fatlabel /dev/mmcblk0p1 boot` while in the Alpine live image).
Aligning the declared label with what the image build produces means
future flashes don't need that hand-step. douro.nix already used ESP.

Build verified by `nix eval` on the sintra-installed config — initrd
kernelModules now contains [ "sdhci-acpi" "mmc_block" "dm_mod" ].

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Padreug 2026-05-13 16:47:07 +02:00
commit b7aa10e7fb

View file

@ -24,9 +24,20 @@
"usb_storage"
"sd_mod"
"sdhci_pci"
"sdhci-acpi" # UP Board sintra: eMMC controller is ACPI-enumerated, not PCI
"mmc_block" # creates /dev/mmcblk* block-device nodes
"i915"
];
# Force-load the eMMC stack in stage 1 so root-by-label resolves before
# the kernel hands off to switch_root. Without this, initramfs panics
# with "An error occurred in stage 1 of the boot process" because
# /dev/disk/by-label/nixos never materialises in time.
initrd.kernelModules = [
"sdhci-acpi"
"mmc_block"
];
kernelModules = [
"kvm-intel"
"i2c-dev"
@ -45,14 +56,19 @@
];
};
# Disk layout: GPT with ESP + ext4 root (eMMC on UP Board)
# Disk layout: GPT with ESP + ext4 root (eMMC on UP Board).
# Labels match what make-disk-image.nix with partitionTableType="efi"
# produces — ESP for the FAT partition, nixos for the ext4 root. We
# previously expected `by-label/boot` here and had to manually
# `fatlabel` the partition post-flash; aligning the label avoids
# that hand-step on future re-flashes. (douro.nix already uses ESP.)
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
device = "/dev/disk/by-label/ESP";
fsType = "vfat";
};