Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

ac-os: set UEFI boot order after OTA flash to fix non-Dell/ThinkPad machines

After writing the kernel to an internal disk, use efibootmgr to create
a "AC Native OS" UEFI boot entry and set it first in the boot order.
This prevents OEM firmwares (HP, Dell, Lenovo) from booting stale
vendor-specific kernel entries instead of our EFI/BOOT/BOOTX64.EFI.

- Mount efivarfs in init for EFI variable access
- Bundle efibootmgr in initramfs build
- Run efibootmgr -c after flash verify succeeds in flash_thread_fn

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+66 -1
+1
fedac/native/initramfs/init
··· 11 11 mount -t tmpfs tmpfs /run 2>/dev/null 12 12 mount -t tracefs tracefs /sys/kernel/tracing 2>/dev/null 13 13 mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null 14 + mount -t efivarfs efivarfs /sys/firmware/efi/efivars 2>/dev/null 14 15 15 16 # Restore baked credentials from initramfs rootfs (before tmpfs hid them) 16 17 # The build bakes Claude creds at /tmp/.claude/ but tmpfs mount hides them.
+2 -1
fedac/native/scripts/build-and-flash.sh
··· 500 500 done 501 501 502 502 # Need basic utilities for shell commands (grep, awk, pgrep, killall, ls, rfkill, curl, etc.) 503 - for util in grep awk sed pgrep killall cat ls head cut rfkill which curl sleep mkdir chmod sfdisk mkfs.vfat; do 503 + # efibootmgr: sets UEFI boot order after OTA flash (prevents stale vendor boot entries) 504 + for util in grep awk sed pgrep killall cat ls head cut rfkill which curl sleep mkdir chmod sfdisk mkfs.vfat efibootmgr; do 504 505 UTIL_PATH="$(command -v "$util" 2>/dev/null || true)" 505 506 if [ -n "$UTIL_PATH" ] && [ -f "$UTIL_PATH" ]; then 506 507 cp "$UTIL_PATH" "${INITRAMFS_DIR}/bin/"
+63
fedac/native/src/js-bindings.c
··· 3081 3081 return NULL; 3082 3082 } 3083 3083 3084 + // Set UEFI boot order so firmware boots our kernel (not a stale vendor entry). 3085 + // Many OEM firmwares (HP, Dell, Lenovo) have hardcoded boot entries pointing at 3086 + // vendor-specific EFI paths. Without updating the boot order, the firmware may 3087 + // boot an old kernel (e.g. from a previous OS install) instead of ours. 3088 + { 3089 + // Mount efivarfs if not already mounted (needed to write UEFI variables) 3090 + struct stat evs; 3091 + if (stat("/sys/firmware/efi/efivars", &evs) == 0) { 3092 + // Try mounting (harmless if already mounted) 3093 + mount("efivarfs", "/sys/firmware/efi/efivars", "efivarfs", 0, NULL); 3094 + 3095 + // Extract disk device from partition path for efibootmgr --disk 3096 + // e.g. /dev/sda1 -> /dev/sda, /dev/nvme0n1p1 -> /dev/nvme0n1 3097 + char disk[64] = "", partnum[8] = ""; 3098 + strncpy(disk, rt->flash_device, sizeof(disk) - 1); 3099 + char *p = disk + strlen(disk) - 1; 3100 + // Walk back past the partition number 3101 + while (p > disk && *p >= '0' && *p <= '9') p--; 3102 + if (p > disk) { 3103 + strncpy(partnum, p + 1, sizeof(partnum) - 1); 3104 + // For NVMe: /dev/nvme0n1p1 -> strip 'p' before part number 3105 + if (*p == 'p' && p > disk && *(p-1) >= '0' && *(p-1) <= '9') 3106 + *p = '\0'; 3107 + else 3108 + *(p + 1) = '\0'; 3109 + } 3110 + 3111 + // Use efibootmgr if available (cleanest approach) 3112 + char cmd[512]; 3113 + snprintf(cmd, sizeof(cmd), 3114 + "efibootmgr -c -d %s -p %s -L 'AC Native OS' " 3115 + "-l '\\EFI\\BOOT\\BOOTX64.EFI' 2>&1", 3116 + disk, partnum[0] ? partnum : "1"); 3117 + ac_log("[flash] setting UEFI boot entry: %s", cmd); 3118 + flash_tlog(rt, "efibootmgr: %s %s part=%s", disk, partnum, partnum[0] ? partnum : "1"); 3119 + 3120 + FILE *efip = popen(cmd, "r"); 3121 + if (efip) { 3122 + char buf[256]; 3123 + while (fgets(buf, sizeof(buf), efip)) { 3124 + // Trim newline 3125 + char *nl = strchr(buf, '\n'); 3126 + if (nl) *nl = '\0'; 3127 + ac_log("[flash] efibootmgr: %s", buf); 3128 + flash_tlog(rt, "efi: %s", buf); 3129 + } 3130 + int rc = pclose(efip); 3131 + if (rc == 0) { 3132 + ac_log("[flash] UEFI boot entry created successfully"); 3133 + flash_tlog(rt, "efi_boot=ok"); 3134 + } else { 3135 + ac_log("[flash] efibootmgr exit=%d (boot entry may not be set)", rc); 3136 + flash_tlog(rt, "efi_boot=fail(%d)", rc); 3137 + } 3138 + } else { 3139 + ac_log("[flash] efibootmgr not available — UEFI boot order unchanged"); 3140 + flash_tlog(rt, "efi_boot=no_efibootmgr"); 3141 + } 3142 + } else { 3143 + ac_log("[flash] no EFI variables support — skipping boot order update"); 3144 + } 3145 + } 3146 + 3084 3147 // Remove downloaded file to free /tmp space 3085 3148 unlink(rt->flash_src); 3086 3149 ac_log("[flash] done: %ld bytes written, verified OK", copied);