diff --git a/README.md b/README.md index b8a9b86..128b018 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,8 @@ Prereqs: Pico SDK + CMake toolchain set up. ### Using `build.py` `build.py` configures CMake, builds the firmware, checks that both output formats -were created, and flashes the ELF with `picotool`. +were created, copies the release artifacts into `firmware/`, and flashes the ELF +with `picotool`. Before running it: @@ -122,6 +123,8 @@ The generated files are: - `build/switch-pico.elf`, which `build.py` passes to `picotool`. - `build/switch-pico.uf2`, which can also be copied to the Pico manually. +- `firmware/switch-pico.elf` and `firmware/switch-pico.uf2`, refreshed from the + corresponding `build/` artifacts after every successful build. To customize the controller grip color while building, pass one of these mutually exclusive options: diff --git a/build.py b/build.py index 5d96461..95c537c 100644 --- a/build.py +++ b/build.py @@ -12,6 +12,9 @@ from pathlib import Path SCRIPT_DIR = Path(__file__).resolve().parent CONFIG_FILE = SCRIPT_DIR / "controller_color_config.h" BUILD_DIR = SCRIPT_DIR / "build" +FIRMWARE_DIR = SCRIPT_DIR / "firmware" +FIRMWARE_ELF_PATH = FIRMWARE_DIR / "switch-pico.elf" +FIRMWARE_UF2_PATH = FIRMWARE_DIR / "switch-pico.uf2" ELF_PATH = Path(os.environ.get("ELF_PATH", BUILD_DIR / "switch-pico.elf")).expanduser() UF2_PATH = Path(os.environ.get("UF2_PATH", BUILD_DIR / "switch-pico.uf2")).expanduser() @@ -126,9 +129,14 @@ def build(): missing = ", ".join(str(path) for path in missing_artifacts) sys.stderr.write(f"Error: Build did not produce required artifact(s): {missing}\n") sys.exit(1) + FIRMWARE_DIR.mkdir(parents=True, exist_ok=True) + shutil.copy2(ELF_PATH, FIRMWARE_ELF_PATH) + shutil.copy2(UF2_PATH, FIRMWARE_UF2_PATH) print(f"Built ELF: {ELF_PATH}") print(f"Built UF2: {UF2_PATH}") + print(f"Copied ELF: {FIRMWARE_ELF_PATH}") + print(f"Copied UF2: {FIRMWARE_UF2_PATH}") def flash(): picotool = resolve_picotool() diff --git a/firmware/switch-pico.elf b/firmware/switch-pico.elf index 2d78548..6d314ee 100755 Binary files a/firmware/switch-pico.elf and b/firmware/switch-pico.elf differ diff --git a/firmware/switch-pico.uf2 b/firmware/switch-pico.uf2 index 4923ff5..113f9a5 100644 Binary files a/firmware/switch-pico.uf2 and b/firmware/switch-pico.uf2 differ