fix(dsk,firstInit,build): let the system boot all the way to the desktop
Four independent blockers sat between "the image boots UTSM" and "the desktop
comes up". Each one wedged the boot on its own; all four are fixed here and the
tree now reaches "[desktop] desktop ready" under QEMU/OVMF
(evidence: .build_tmp/d2.log).
1. FirstInit made networking a hard gate (CODE/firstInit/main.c)
The setup wizard always showed the network page, and on a machine with no
wireless device the only exit was Save - pressing Connect raised NET-E01.
Networking is not a precondition for entering the system, so a wizard that
cannot be completed without it is a plain design defect.
- No wireless device detected -> skip the network page entirely (the
g_no_wireless_device flag already existed but was only logged).
- With a device present, add a Skip button (draw + mouse hit-box + keyboard
Enter), mirroring "I don't have internet" on Windows.
- Connect keeps its zero-fallback NET-E01 panic: the unimplemented path is
still honest, it just no longer holds the user hostage.
2. ESP cluster size left no room in the root directory
(CODE/linux/pack_system_image.sh)
With the cluster size left to mkfs it chose 1 sector, i.e. 16 directory
entries per cluster. The ESP root ends up holding exactly 16 entries
(DESHABBOOT/EFI/LIMINE/BOOT/DRIVER/SYSTEM/USER/NVVARS plus one long-name
entry each), and the root chain is a single cluster - so on first boot the
DSK could never write USER.CONF.
Pin -s 4 (2KiB, 64 entries): it clears the FAT32 65525 lower bound and the
0xFFF5 boundary that -s 8 lands on at this 256MiB size, and leaves 48 free
entries. The alternatives were measured, not guessed (see the comment).
3. DSK could not grow the root directory (CODE/dsk/main.c)
fat32_write_root_file returned -4 "no free dir entry" whenever the scan of
the root chain came up empty. A FAT filesystem is supposed to extend the
directory chain, so allocate a cluster, link it at the current tail, write
the entry there and commit the FAT. Fixing only (2) would have papered over
this: any real disk whose root fills up would still fail the same way.
4. Nothing generated the CJK bitmap font packs (build.ps1)
The desktop loads system/font/simhei_16.dbf and panics DESK-E04 FONT PACK
MISSING without it. The .dbf files are generated from simhei.ttf by
CODE/font/mkfont.py and are gitignored, but no build step ever invoked it -
same class of bug as the previously untracked .drv binaries. Generate
simhei_16.dbf / simhei_24.dbf in build.ps1 (with the existing WSL python3
fallback for Pillow), rebuilding only when the TTF is newer than the pack.
docs/STATUS.md updated to match: FirstInit wizard and the D3 named API export
table move to done, and the FAT32 / ESP cluster size / CJK font pack entries
are added or corrected. D3 was already fully implemented (table, lookup,
selftest with positive and negative cases, TST-E21..E24 instrumentation) -
only the status row was stale.
Verified boot chain (QEMU/OVMF, dev variant):
BdsDxe -> Limine -> UTSM -> DKM 17/17 -> DSK -> FirstInit (network page
skipped) -> USER.CONF written -> login (password accepted) -> desktop:
"[zhfont] dbf loaded (16px ok)" ... "[desktop] desktop ready"
This commit is contained in:
@@ -167,17 +167,25 @@ if [[ -z "$p1" || -z "$p2" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 簇大小交给 mkfs.vfat 自动选择。
|
||||
# ESP 的簇大小必须显式指定为 4 个扇区(2KiB),不能交给 mkfs 自动选。
|
||||
#
|
||||
# 历史坑一:这里曾经强制 -s 8(4KiB 簇)。256MiB 的 ESP 恰好被算成 65535
|
||||
# 个簇(FAT32 的 0xFFF5 边界),该几何下 OVMF(EDK2 FatPkg) 拒挂该卷 ——
|
||||
# 现象是 BdsDxe "Not Found",Shell 里分区只显示 BLKn、没有对应 FS。
|
||||
# 对照实验:sidecar(CODE/linux/make_sata_sidecar.sh)用不带 -s 的
|
||||
# mkfs.vfat 就一切正常,所以这里也不再手工指定簇大小。
|
||||
# 历史坑一(OVMF 挂不上):曾经写死 -s 8(4KiB 簇)。256MiB 的 ESP 在该几何下
|
||||
# 恰好得到 65535 个簇 —— 正是 FAT32 的 0xFFF5 边界 —— OVMF(EDK2 FatPkg) 拒挂
|
||||
# 该卷,现象是 BdsDxe "Not Found",Shell 里分区只有 BLKn 没有 FS。
|
||||
#
|
||||
# 历史坑二:不要加 -f 1。UEFI 规范建议 ESP 用单 FAT 表,但实测 OVMF 对
|
||||
# nfat=1/2 都能挂,加 -f 1 并不能解决上面的问题,反而偏离 sidecar 的行为。
|
||||
mkfs.vfat -F 32 -n DESHABBOOT "$p1" >/dev/null
|
||||
# 历史坑二(根目录写满):修坑一时改成不指定 -s 交给 mkfs 自动选,它给出
|
||||
# spc=1(512B/簇)。根目录每簇只能放 16 个目录项,而打包进 ESP 根目录的内容
|
||||
# (DESHABBOOT/EFI/LIMINE/BOOT/DRIVER/SYSTEM/USER/NVVARS + 它们的 LFN 项)
|
||||
# 正好 16 项,根目录链又只有单簇 —— 于是 DSK 首次启动写 USER.CONF 时必然
|
||||
# 拿到 "no free dir entry"(-4)→ FS-E02 panic,系统进不去。
|
||||
#
|
||||
# 256MiB ESP 各档簇大小的安全性(每档都算过):
|
||||
# spc=1 16 项/簇 524288 簇 根目录一簇就满(坑二)
|
||||
# spc=4 64 项/簇 131072 簇 ✅ 远离 FAT32 下限 65525 与 0xFFF5 边界
|
||||
# spc=8 128 项/簇 65536 簇 ❌ 落在 65535 边界(坑一)
|
||||
# spc=16 256 项/簇 32768 簇 ❌ 低于 FAT32 下限 65525
|
||||
# 所以固定 -s 4:既让根目录有 64 项余量,又不碰任何边界。
|
||||
mkfs.vfat -F 32 -s 4 -n DESHABBOOT "$p1" >/dev/null
|
||||
# DSK 内嵌 ext4 读写驱动支持范围:4K block / 256B inode / extent 树,
|
||||
# 不支持 journal、metadata_csum、64bit(遇到即 panic FS-E28)——
|
||||
# 因此这里必须显式关闭这三个 feature。
|
||||
|
||||
Reference in New Issue
Block a user