Add the S21 Pro-class Amlogic A113D/AXG control board to the .afw producer and the CI brick-prevention gate, matching the Zynq-7010 treatment. - ci/afw_boards.py: a113d producer profile (arm64, preserve, buildable). Maps the 7-mtd layout, names nvdata (mtd6) the only image-bearing partition, and stages three images vmlinux.bin/devicetree.dtb/uramdisk.image.gz (arm64-image/fdt/uimage) into it. - ci/afw_manifest.py: validate_a113d enforces exactly those three images, the formats, per-image ceilings, total <= nvdata usable, and that no bootloader/spl/fip/tpl member is present and no non-nvdata partition carries an image. - ci/check-afw.py: the independent checker re-validates the produced bundle (arm64, preserve, no FIP member, three named images with formats/ceilings, total <= nvdata, mtd0-5 carry no image) and knows the arm64 Image magic. - ci/test-afw.py: a113d bundle passes and installs all three into nvdata; non-arm64 kernel, oversize kernel, an added FIP member, and a preserved mtd made to carry an image are each refused. All 37 afw tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qHxYpv7yf7Ah57g4rQ
276 lines
12 KiB
Python
276 lines
12 KiB
Python
# SPDX-License-Identifier: MIT
|
|
"""Board profiles used by the .afw producer and the CI checker.
|
|
|
|
An .afw is valid for exactly one board family. The arch and bootloader policy
|
|
come from this table, never from the caller alone, so a bundle cannot claim a
|
|
board it was not built for. cv1835 and am335x have complete, buildable profiles in this release; the
|
|
other Antminer families are listed so a wrong-board bundle is rejected by name
|
|
instead of being accepted as "unknown".
|
|
"""
|
|
|
|
AM335X_PARTITIONS = [
|
|
{"name": "mtd0", "device": "/dev/mtd0", "offset": 0x0000000, "size": 0x20000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd1", "device": "/dev/mtd1", "offset": 0x0020000, "size": 0x20000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd2", "device": "/dev/mtd2", "offset": 0x0040000, "size": 0x20000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd3", "device": "/dev/mtd3", "offset": 0x0060000, "size": 0x20000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd4", "device": "/dev/mtd4", "offset": 0x0080000, "size": 0x1C0000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd5", "device": "/dev/mtd5", "offset": 0x0240000, "size": 0x20000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd6", "device": "/dev/mtd6", "offset": 0x0260000, "size": 0x20000,
|
|
"secure": False, "boot_critical": True, "write_order": 2, "image": "dtb"},
|
|
{"name": "mtd7", "device": "/dev/mtd7", "offset": 0x0280000, "size": 0x500000,
|
|
"secure": False, "boot_critical": True, "write_order": 3, "image": "kernel"},
|
|
{"name": "mtd8", "device": "/dev/mtd8", "offset": 0x0800000, "size": 0x1400000,
|
|
"secure": False, "boot_critical": True, "write_order": 1, "image": "rootfs"},
|
|
{"name": "mtd9", "device": "/dev/mtd9", "offset": 0x1C00000, "size": 0x200000,
|
|
"secure": True, "boot_critical": False, "write_order": 0, "image": None},
|
|
{"name": "mtd10", "device": "/dev/mtd10", "offset": 0x1E00000, "size": 0x200000,
|
|
"secure": True, "boot_critical": False, "write_order": 0, "image": None},
|
|
{"name": "mtd11", "device": "/dev/mtd11", "offset": 0x2000000, "size": 0x6000000,
|
|
"secure": True, "boot_critical": False, "write_order": 0, "image": None},
|
|
]
|
|
|
|
AM335X_IMAGES = [
|
|
{"name": "kernel", "source": "alkane-am335x.uImage", "role": "kernel",
|
|
"format": "uimage", "partition": "mtd7", "install": True, "exact_bytes": None},
|
|
{"name": "dtb", "source": "am335x-alkane.dtb", "role": "dtb",
|
|
"format": "fdt", "partition": "mtd6", "install": True, "exact_bytes": None},
|
|
{"name": "rootfs", "source": "alkane-am335x-ramdisk.uImage", "role": "rootfs",
|
|
"format": "uimage", "partition": "mtd8", "install": True, "exact_bytes": None},
|
|
]
|
|
|
|
# Tier-3 from-stock variant: same 12-partition NAND map, but mtd4 is written
|
|
# with our non-RSA U-Boot (a legacy uImage the preserved SPL chainloads), so its
|
|
# secure flag is False and it carries the u-boot image at write_order 3; the
|
|
# kernel moves to write_order 4 (U-Boot lands before the kernel). The SPL copies
|
|
# (mtd0-3) and bootenv (mtd5) stay preserved and are never write targets.
|
|
AM335X_STOCK_PARTITIONS = []
|
|
for _p in AM335X_PARTITIONS:
|
|
_q = dict(_p)
|
|
if _q["name"] == "mtd4":
|
|
_q.update(secure=False, write_order=3, image="u-boot")
|
|
elif _q["name"] == "mtd7":
|
|
_q.update(write_order=4)
|
|
AM335X_STOCK_PARTITIONS.append(_q)
|
|
|
|
AM335X_STOCK_IMAGES = [
|
|
{"name": "u-boot", "source": "alkane-am335x-uboot-mtd4.uImage", "role": "bootloader",
|
|
"format": "uimage", "partition": "mtd4", "install": True, "exact_bytes": None},
|
|
] + [dict(_img) for _img in AM335X_IMAGES]
|
|
|
|
BOARDS = {
|
|
"am335x": {
|
|
"arch": "arm",
|
|
"bootloader_policy": "preserve",
|
|
"buildable": True,
|
|
"format_checks": ["uimage", "fdt", "uimage"],
|
|
"partitions": AM335X_PARTITIONS,
|
|
"images": AM335X_IMAGES,
|
|
},
|
|
"am335x-stock": {
|
|
"arch": "arm",
|
|
"bootloader_policy": "include",
|
|
"buildable": True,
|
|
"format_checks": ["uimage", "uimage", "fdt", "uimage"],
|
|
"partitions": AM335X_STOCK_PARTITIONS,
|
|
"images": AM335X_STOCK_IMAGES,
|
|
},
|
|
"cv1835": {
|
|
"arch": "arm64",
|
|
"bootloader_policy": "preserve",
|
|
"buildable": True,
|
|
"format_checks": ["fit", "arm64-image", "fdt", "cpio-gzip"],
|
|
"partitions": [
|
|
{
|
|
"name": "p1",
|
|
"device": "/dev/mmcblk0p1",
|
|
"offset": 0,
|
|
"size": 16 * 1024 * 1024,
|
|
"secure": False,
|
|
"boot_critical": True,
|
|
"write_order": 1,
|
|
"image": "p1",
|
|
},
|
|
{
|
|
"name": "p3",
|
|
"device": "/dev/mmcblk0p3",
|
|
"offset": 0,
|
|
"size": 32 * 1024 * 1024,
|
|
"secure": True,
|
|
"boot_critical": False,
|
|
"write_order": 0,
|
|
"image": None,
|
|
},
|
|
{
|
|
"name": "boot0",
|
|
"device": "/dev/mmcblk0boot0",
|
|
"offset": 0,
|
|
"size": 4 * 1024 * 1024,
|
|
"secure": True,
|
|
"boot_critical": True,
|
|
"write_order": 0,
|
|
"image": None,
|
|
},
|
|
{
|
|
"name": "boot1",
|
|
"device": "/dev/mmcblk0boot1",
|
|
"offset": 0,
|
|
"size": 4 * 1024 * 1024,
|
|
"secure": True,
|
|
"boot_critical": True,
|
|
"write_order": 0,
|
|
"image": None,
|
|
},
|
|
],
|
|
"images": [
|
|
{
|
|
"name": "kernel",
|
|
"source": "Image",
|
|
"role": "kernel",
|
|
"format": "arm64-image",
|
|
"partition": None,
|
|
"install": False,
|
|
"exact_bytes": None,
|
|
},
|
|
{
|
|
"name": "dtb",
|
|
"source": "cv-alkane.dtb",
|
|
"role": "dtb",
|
|
"format": "fdt",
|
|
"partition": None,
|
|
"install": False,
|
|
"exact_bytes": None,
|
|
},
|
|
{
|
|
"name": "rootfs",
|
|
"source": "rootfs.cpio.gz",
|
|
"role": "rootfs",
|
|
"format": "cpio-gzip",
|
|
"partition": None,
|
|
"install": False,
|
|
"exact_bytes": None,
|
|
},
|
|
{
|
|
"name": "p1",
|
|
"source": "alkane-cv1835-p1.fit",
|
|
"role": "boot",
|
|
"format": "fit",
|
|
"partition": "p1",
|
|
"install": True,
|
|
"exact_bytes": 16 * 1024 * 1024,
|
|
},
|
|
],
|
|
},
|
|
# Antminer families that the seven-board release gate still lists. They are
|
|
# known, so a wrong-board bundle is refused by identity, but they do not
|
|
# have a buildable .afw profile in this release.
|
|
"zynq-7010": {
|
|
"arch": "armv7",
|
|
"bootloader_policy": "preserve",
|
|
"buildable": True,
|
|
# kernel (zImage), dtb (FDT), rootfs (gzip cpio ramdisk)
|
|
"format_checks": ["zimage", "fdt", "cpio-gzip"],
|
|
# Both bench Zynq-7010 units (S19, S17) share mtd0 (40 MiB: BOOT.bin +
|
|
# the kernel slot) and mtd1 (32 MiB: ramfs). BOOT.bin (FSBL + FPGA
|
|
# bitstream + stock U-Boot) is PRESERVED - the bundle carries no
|
|
# bootloader member; only the kernel slot in mtd0 and the ramfs in mtd1
|
|
# are our OS. The exact kernel-slot sub-offset is placed by the install
|
|
# method (it differs by unit), so this profile gates image formats and
|
|
# size ceilings, not a fixed offset map.
|
|
"partitions": [
|
|
{"name": "mtd0", "device": "/dev/mtd0", "offset": 0, "size": 0x2800000,
|
|
"secure": False, "boot_critical": True, "write_order": 1, "image": "kernel"},
|
|
{"name": "mtd1", "device": "/dev/mtd1", "offset": 0x2800000, "size": 0x2000000,
|
|
"secure": False, "boot_critical": True, "write_order": 2, "image": "rootfs"},
|
|
],
|
|
"images": [
|
|
{"name": "kernel", "source": "zImage", "role": "kernel",
|
|
"format": "zimage", "partition": "mtd0", "install": True, "exact_bytes": None},
|
|
{"name": "dtb", "source": "zynq-alkane.dtb", "role": "dtb",
|
|
"format": "fdt", "partition": "mtd0", "install": True, "exact_bytes": None},
|
|
{"name": "rootfs", "source": "rootfs.cpio.gz", "role": "rootfs",
|
|
"format": "cpio-gzip", "partition": "mtd1", "install": True, "exact_bytes": None},
|
|
],
|
|
},
|
|
"zynq-s17": {"arch": "armv7", "bootloader_policy": "include", "buildable": False},
|
|
# Amlogic A113D / AXG (S21 Pro-class) control board. arm64. Our OS is staged
|
|
# as FILES in the nvdata UBI volume (mtd6): kernel (arm64 Image), dtb, and a
|
|
# uImage ramdisk. The signed FIP bootloader and the stock boot partition
|
|
# (mtd0-5) are PRESERVED - zero raw writes outside nvdata, so the stock OS in
|
|
# mtd4 stays as a one-setenv fallback. Hence bootloader_policy preserve and no
|
|
# bootloader member.
|
|
"a113d": {
|
|
"arch": "arm64",
|
|
"bootloader_policy": "preserve",
|
|
"buildable": True,
|
|
"format_checks": ["arm64-image", "fdt", "uimage"],
|
|
"partitions": [
|
|
{"name": "mtd0", "device": "/dev/mtd0", "offset": 0x0000000, "size": 0x200000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd1", "device": "/dev/mtd1", "offset": 0x0800000, "size": 0x800000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd2", "device": "/dev/mtd2", "offset": 0x1000000, "size": 0x200000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd3", "device": "/dev/mtd3", "offset": 0x1200000, "size": 0x1000000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd4", "device": "/dev/mtd4", "offset": 0x2200000, "size": 0x2000000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "mtd5", "device": "/dev/mtd5", "offset": 0x4200000, "size": 0x500000,
|
|
"secure": True, "boot_critical": True, "write_order": 0, "image": None},
|
|
{"name": "nvdata", "device": "/dev/mtd6", "offset": 0x4700000, "size": 0xB900000,
|
|
"secure": False, "boot_critical": True, "write_order": 1, "image": "kernel"},
|
|
],
|
|
"images": [
|
|
{"name": "kernel", "source": "vmlinux.bin", "role": "kernel",
|
|
"format": "arm64-image", "partition": "nvdata", "install": True, "exact_bytes": None},
|
|
{"name": "dtb", "source": "devicetree.dtb", "role": "dtb",
|
|
"format": "fdt", "partition": "nvdata", "install": True, "exact_bytes": None},
|
|
{"name": "rootfs", "source": "uramdisk.image.gz", "role": "rootfs",
|
|
"format": "uimage", "partition": "nvdata", "install": True, "exact_bytes": None},
|
|
],
|
|
},
|
|
"a113d-s21pro": {"arch": "arm64", "bootloader_policy": "preserve", "buildable": False},
|
|
"am335x-bb": {"arch": "armv7", "bootloader_policy": "preserve", "buildable": False},
|
|
}
|
|
|
|
SAFE_IMAGE_FORMATS = {
|
|
"fit",
|
|
"arm64-image",
|
|
"zimage",
|
|
"fdt",
|
|
"cpio-gzip",
|
|
"uimage",
|
|
"raw",
|
|
}
|
|
|
|
SAFE_IMAGE_ROLES = {
|
|
"kernel",
|
|
"dtb",
|
|
"rootfs",
|
|
"bootloader",
|
|
"boot",
|
|
"component",
|
|
}
|
|
|
|
|
|
def board(name):
|
|
"""Return the profile for a board family, or raise KeyError."""
|
|
return BOARDS[name]
|
|
|
|
|
|
def known_board(name):
|
|
return name in BOARDS
|
|
|
|
|
|
def expect_arch(name):
|
|
return BOARDS[name]["arch"]
|
|
|
|
|
|
def expect_policy(name):
|
|
return BOARDS[name]["bootloader_policy"]
|