Commit fbdfa971 authored by jan.koester's avatar jan.koester
Browse files

nas-itx: fenriros.uimg (kernel + initramfs + DTB multi image) for NAND autoboot

The vendor U-Boot 2012.07 rejected the DTB read from NAND; a legacy
multi-file uImage carries the FDT as image 2, so a single nand read of the
kernel partition boots. Default bootargs for the UBI root in /chosen.

Co-Authored-By: default avatarClaude Opus 5.5 <noreply@anthropic.com>
parent 33365c73
Loading
Loading
Loading
Loading
+2 −0
Changes for boards/nas-itx/installer/nas-itx-install.cpp: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -273,6 +273,8 @@ int main(int argc, char** argv) {
        if (!write_raw(*dtb, d) || !write_raw(*ker, k) || !write_ubi(*fs, r)) return 1;
        printf("done. U-Boot: nand read <addr> 0x%llx 0x%llx (kernel), 0x%llx 0x%llx (dtb)\n",
               0x400000ULL, (unsigned long long)k.size(), 0x200000ULL, (unsigned long long)d.size());
        if (k.size() > 31 && k[30] == 4)   // IH_TYPE_MULTI: kernel + initramfs + DTB
            printf("autoboot: setenv bootcmd 'nand read 0x48000000 0x400000 0xf00000; bootm 0x48000000'; saveenv\n");
        return 0;
    }
    fprintf(stderr, "usage: %s survey | install <uImage> <dtb> <rootfs.ubifs> [--force]\n", argv[0]);
+2 −0
Changes for boards/nas-itx/nas-itx.dts: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@

	chosen {
		stdout-path = "serial0:115200n8";
		/* NAND boot; U-Boot replaces it when its env has bootargs */
		bootargs = "console=ttyS0,115200 root=ubi0:rootfs ubi.mtd=fs ubi.allow_mlc=1 rootfstype=ubifs rootflags=uid_r rw";
	};

	/include/ "p1010rdb_32b.dtsi"
+20 −0
Changes for build-cross.sh: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -363,6 +363,25 @@ step_kernel() {
    run kernel dtc -I dts -O dtb -i "$KERNEL_SRC/$KDTS_INC" -o "$OUT/$BOARD.dtb" "$BOARD_DIR/$BOARD.dts"
    cp "$KBUILD/arch/$KARCH/boot/$KIMAGE" "$OUT/$KIMAGE"
    msg "kernel: $(kmake -s kernelrelease 2>/dev/null)  $KIMAGE $(du -h "$OUT/$KIMAGE" | cut -f1)"
    [[ $KIMAGE == uImage ]] && make_boot_image
}

# fenriros.uimg: legacy multi-file uImage kernel + empty initramfs + DTB.
# bootm takes the FDT from image 2, so one 'nand read' of the kernel
# partition boots -- also with old U-Boots (the NAS ITX vendor 2012.07)
make_boot_image() {
    command -v mkimage >/dev/null || die "mkimage (u-boot-tools) missing"
    local hdr load entry tmp="$BUILD/bootimg"
    mkdir -p "$tmp"
    hdr=$(od -An -tx1 -j16 -N8 -v "$OUT/$KIMAGE" | tr -d ' \n')
    load=0x${hdr:0:8} entry=0x${hdr:8:8}
    tail -c +65 "$OUT/$KIMAGE" >"$tmp/kernel.gz"
    # mkimage refuses an empty part (a 0 size would end the list), so the
    # ramdisk is an empty cpio: unpacked into rootfs, no /init, root= mounts
    (cd "$tmp" && : | cpio -o -H newc -R 0:0 --quiet) >"$tmp/empty"
    run kernel mkimage -A "$KARCH" -O linux -T multi -C gzip -a "$load" -e "$entry" \
        -n "FenrirOS $BOARD" -d "$tmp/kernel.gz:$tmp/empty:$OUT/$BOARD.dtb" "$OUT/fenriros.uimg"
    msg "kernel: fenriros.uimg (kernel+dtb, $(du -h "$OUT/fenriros.uimg" | cut -f1))"
}

write_system_config() {
@@ -570,6 +589,7 @@ step_installer() {
    mkdir -p "$ir/root/install"
    cp "$OUT/$BOARD-install" "$ir$PREFIX/sbin/"
    cp "$OUT/$KIMAGE" "$OUT/$BOARD.dtb" "$OUT/rootfs.ubifs" "$ir/root/install/"
    [[ -f $OUT/fenriros.uimg ]] && cp "$OUT/fenriros.uimg" "$ir/root/install/"
    # the root is the initramfs itself: syslite must not remount anything
    msg "installer: initramfs ($(du -sh "$ir" | cut -f1))"
    (cd "$ir" && find . -print0 | cpio --null -o -H newc -R 0:0 --quiet) | zstd -q -19 -T0 >"$OUT/installer.cpio.zst"