diff --git a/.gitea/workflows/bootcmd.yml b/.gitea/workflows/bootcmd.yml new file mode 100644 index 0000000..1d6f7ff --- /dev/null +++ b/.gitea/workflows/bootcmd.yml @@ -0,0 +1,15 @@ +name: Configure Boot Command for Detected Flash + +on: + workflow_dispatch: + +jobs: + set-bootcmd: + runs-on: serial-runner + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Detect flash, set bootcmd and verify + run: /usr/bin/python3 scripts/serial_command.py set-bootcmd diff --git a/.gitea/workflows/flash-aminpa-V1.5.yml b/.gitea/workflows/flash-aminpa-V1.5.yml index eb8a758..5fc2343 100644 --- a/.gitea/workflows/flash-aminpa-V1.5.yml +++ b/.gitea/workflows/flash-aminpa-V1.5.yml @@ -63,3 +63,6 @@ jobs: - name: Inspect boot configuration run: /usr/bin/python3 scripts/serial_command.py boot-config + + - name: Configure and verify bootcmd for detected flash + run: /usr/bin/python3 scripts/serial_command.py set-bootcmd diff --git a/scripts/serial_command.py b/scripts/serial_command.py index 22f5cd6..8a72515 100644 --- a/scripts/serial_command.py +++ b/scripts/serial_command.py @@ -184,6 +184,20 @@ def erase_flash(cli): print("\nFull-flash erase command succeeded; first 256 bytes verified as FF.") +def set_bootcmd(cli): + capacity = detect_flash(cli) + dtb_offset, dtb_size = LAYOUTS[capacity]["dtb"] + kernel_offset, kernel_size = LAYOUTS[capacity]["kernel"] + bootcmd = ( + f"sf probe 0; sf read 0x41800000 {dtb_offset:#x} {dtb_size:#x}; " + f"sf read 0x42000000 {kernel_offset:#x} {kernel_size:#x}; " + "bootz 0x42000000 - 0x41800000" + ) + cli.command("setenv bootcmd '" + bootcmd + "'") + cli.command("printenv bootcmd", r"^bootcmd=" + re.escape(bootcmd) + r"$") + print("\nDynamic bootcmd verified in RAM; environment not saved and bootcmd not executed.") + + def boot_config(cli, confirmed=False): cli.command( "printenv bootcmd bootargs", allow_missing=("bootcmd", "bootargs"), @@ -199,7 +213,7 @@ def boot_config(cli, confirmed=False): def main(): parser = argparse.ArgumentParser() - parser.add_argument("mode", choices=("check", "configure", "transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs", "erase", "boot-config", "preflight"), default="check", nargs="?") + parser.add_argument("mode", choices=("check", "configure", "transfer", "transfer-dtb", "transfer-kernel", "transfer-rootfs", "erase", "boot-config", "preflight", "set-bootcmd"), default="check", nargs="?") parser.add_argument("--port", default="/dev/ttyUSB0") 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)") @@ -236,6 +250,9 @@ def main(): if args.mode == "boot-config": boot_config(cli, confirmed=args.confirm_squashfs_mtdblock3) return + if args.mode == "set-bootcmd": + set_bootcmd(cli) + return 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) return