مقایسه کامیت‌‌ها

...
2 کامیت‌ها
مولف SHA1 پیام تاریخ
nearology b452fceb82 ورک فلو bootcmd 2026-11-09 21:01:04 +03:30
nearology 25caf97633 ورک فلو پاک کردن فلش 2026-11-09 20:58:33 +03:30
4فایلهای تغییر یافته به همراه93 افزوده شده و 1 حذف شده
@@ -0,0 +1,28 @@
name: Inspect and Configure Boot Arguments
on:
workflow_dispatch:
inputs:
confirm_squashfs_mtdblock3:
description: 'Confirm RootFS is actually SquashFS on mtdblock3 and set bootargs'
required: false
type: boolean
default: false
jobs:
boot-config:
runs-on: serial-runner
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Inspect boot settings and optionally set verified bootargs
env:
CONFIRM_SQUASHFS_MTDBLOCK3: ${{ inputs.confirm_squashfs_mtdblock3 }}
run: |
if [ "$CONFIRM_SQUASHFS_MTDBLOCK3" = "true" ]; then
/usr/bin/python3 scripts/serial_command.py boot-config --confirm-squashfs-mtdblock3
else
/usr/bin/python3 scripts/serial_command.py boot-config
fi
@@ -0,0 +1,16 @@
name: Erase Entire 32 MiB SPI Flash
on:
workflow_dispatch:
jobs:
flash-erase:
runs-on: serial-runner
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Erase entire flash and verify first 256 bytes
run: |
/usr/bin/python3 scripts/serial_command.py erase
+6
مشاهده پرونده
@@ -0,0 +1,6 @@
The separate `Erase Entire 32 MiB SPI Flash` workflow erases offsets
0x0 through 0x1ffffff, including all firmware and any saved environment.
It requires a successful 32 MiB flash probe, checks the erase/read command
results, and verifies that the first 256 bytes are FF. This sample does
not verify every byte of the flash. No automatic retries are performed.
+43 -1
مشاهده پرونده
@@ -141,12 +141,48 @@ def transfer(cli, firmware, *, dtb=False, kernel=False, rootfs=False, rootfs_siz
print("\nFirmware flash write and full read-back comparison verified.") print("\nFirmware flash write and full read-back comparison verified.")
def erase_flash(cli):
cli.command("sf probe 0:0", r"^SF: Detected .+total 32 MiB\s*$", timeout=20)
cli.command(
"sf erase 0x0 0x2000000",
r"^SF: 33554432 bytes @ 0x0 Erased: OK\s*$", timeout=600,
)
cli.command(
"sf read 0x42800000 0x0 0x100",
r"^SF: 256 bytes @ 0x0 Read: OK\s*$", timeout=20,
)
output = cli.command("md.b 0x42800000 0x100", r"^42800000:")
for offset in range(0, 0x100, 16):
address = f"{0x42800000 + offset:08x}"
rows = re.findall(
r"^" + address + r":((?: [0-9a-fA-F]{2}){16})(?:\s|$)",
output, re.MULTILINE,
)
if len(rows) != 1 or bytes.fromhex(rows[0]) != b"\xff" * 16:
raise RuntimeError("Erase verification failed at " + address)
print("\nFull-flash erase command succeeded; first 256 bytes verified as FF.")
def boot_config(cli, confirmed=False):
cli.command(
"printenv bootcmd bootargs", allow_missing=("bootcmd", "bootargs"),
)
if not confirmed:
print("\nBoot configuration inspected; no changes requested.")
return
bootargs = "console=ttyS0,115200 loglevel=8 root=/dev/mtdblock3 rootfstype=squashfs ro rootwait"
cli.command("setenv bootargs '" + bootargs + "'")
cli.command("printenv bootargs", r"^bootargs=" + re.escape(bootargs) + r"$")
print("\nBootargs verified in RAM; environment not saved and board not rebooted.")
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("mode", choices=("check", "configure", "transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs"), default="check", nargs="?") parser.add_argument("mode", choices=("check", "configure", "transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs", "erase", "boot-config"), default="check", nargs="?")
parser.add_argument("--port", default="/dev/ttyUSB0") parser.add_argument("--port", default="/dev/ttyUSB0")
parser.add_argument("--firmware", type=Path, default=None) parser.add_argument("--firmware", type=Path, default=None)
parser.add_argument("--rootfs-size", type=lambda value: int(value, 0), help="Actual RootFS partition size in bytes (decimal or 0x-prefixed hex)") parser.add_argument("--rootfs-size", type=lambda value: int(value, 0), help="Actual RootFS partition size in bytes (decimal or 0x-prefixed hex)")
parser.add_argument("--confirm-squashfs-mtdblock3", action="store_true", help="Confirm actual RootFS is SquashFS on mtdblock3 and set bootargs")
args = parser.parse_args() args = parser.parse_args()
if args.mode == "transfer-rootfs" and (args.rootfs_size is None or args.rootfs_size < 64): if args.mode == "transfer-rootfs" and (args.rootfs_size is None or args.rootfs_size < 64):
parser.error("--rootfs-size must specify the actual RootFS partition size (at least 64 bytes)") parser.error("--rootfs-size must specify the actual RootFS partition size (at least 64 bytes)")
@@ -163,6 +199,12 @@ def main():
cli.detect() cli.detect()
if args.mode == "check": if args.mode == "check":
return return
if args.mode == "erase":
erase_flash(cli)
return
if args.mode == "boot-config":
boot_config(cli, confirmed=args.confirm_squashfs_mtdblock3)
return
if args.mode in ("transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs"): if args.mode in ("transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs"):
transfer(cli, args.firmware, dtb=args.mode == "transfer-dtb", kernel=args.mode == "transfer-kernel", rootfs=args.mode == "transfer-rootfs", rootfs_size=args.rootfs_size) transfer(cli, args.firmware, dtb=args.mode == "transfer-dtb", kernel=args.mode == "transfer-kernel", rootfs=args.mode == "transfer-rootfs", rootfs_size=args.rootfs_size)
return return