Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ jobs:
from pathlib import Path
from tempfile import TemporaryDirectory
from gui.portable_avr_control_studio import (
ARDUINO_CLI_MISSING_MESSAGE,
CUSTOM_SKETCH_PROTOCOL_WARNING,
SketchCompileValidationError,
UploadValidationError,
build_arduino_compile_command,
find_arduino_cli_tool,
parse_serial_line,
prepare_sketch_source,
validate_sketch_compile_request,
validate_upload_request,
)

Expand Down Expand Up @@ -74,6 +81,55 @@ jobs:
assert 'avrdude was not found' in str(exc)
else:
raise AssertionError('expected missing avrdude validation failure')

cli_tools = root / 'tools' / 'arduino-cli'
cli_tools.mkdir(parents=True)
cli_exe = cli_tools / 'arduino-cli.exe'
cli_exe.write_text('dummy compiler', encoding='utf-8')
cli = find_arduino_cli_tool(root, path_env='')
assert cli is not None and cli.source == 'bundled'

workspace = root / 'workspace'
valid_ino = root / 'Blink.ino'
valid_ino.write_text('void setup() {}\nvoid loop() {}\n', encoding='utf-8')
prepared = prepare_sketch_source(str(valid_ino), workspace)
assert prepared.copied_source
assert prepared.sketch_folder.name == 'Blink'
assert (prepared.sketch_folder / 'Blink.ino').is_file()

sketch_folder = root / 'CustomerSketch'
sketch_folder.mkdir()
(sketch_folder / 'CustomerSketch.ino').write_text('void setup() {}\nvoid loop() {}\n', encoding='utf-8')
prepared_folder = prepare_sketch_source(str(sketch_folder), workspace)
assert prepared_folder.sketch_folder == sketch_folder

cmd = build_arduino_compile_command(cli, prepared_folder.sketch_folder, root / 'out')
assert cmd == [str(cli_exe), 'compile', '--fqbn', 'arduino:avr:uno', '--output-dir', str(root / 'out'), str(sketch_folder)]

compile_cmd, compile_tool, compile_prepared = validate_sketch_compile_request(str(sketch_folder), root, workspace, path_env='')
assert compile_tool.source == 'bundled'
assert compile_prepared.sketch_folder == sketch_folder
assert '--fqbn' in compile_cmd and 'arduino:avr:uno' in compile_cmd

bad_source = root / 'not-a-sketch.txt'
bad_source.write_text('nope', encoding='utf-8')
try:
prepare_sketch_source(str(bad_source), workspace)
except SketchCompileValidationError as exc:
assert 'ends with .ino' in str(exc)
else:
raise AssertionError('expected non-.ino source rejection')

cli_exe.unlink()
try:
validate_sketch_compile_request(str(sketch_folder), root, workspace, path_env='')
except SketchCompileValidationError as exc:
assert str(exc) == ARDUINO_CLI_MISSING_MESSAGE
else:
raise AssertionError('expected missing Arduino CLI validation failure')

assert 'Uploading a custom sketch replaces the built-in Portable AVR firmware' in CUSTOM_SKETCH_PROTOCOL_WARNING
assert 'Settings / Status / EEPROM controls only work' in CUSTOM_SKETCH_PROTOCOL_WARNING
PY

- name: Compile release assembly script
Expand All @@ -87,6 +143,7 @@ jobs:
rm -rf \
release/artifacts/windows/PortableAVRControlStudio.exe \
release/artifacts/windows/tools/avrdude \
release/artifacts/windows/tools/arduino-cli \
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip
Expand All @@ -99,6 +156,8 @@ jobs:
printf 'dummy avrdude exe for CI package assembly smoke test\n' > release/artifacts/windows/tools/avrdude/avrdude.exe
printf 'dummy avrdude config for CI package assembly smoke test\n' > release/artifacts/windows/tools/avrdude/avrdude.conf
printf 'dummy support dll for CI package assembly smoke test\n' > release/artifacts/windows/tools/avrdude/libusb0.dll
mkdir -p release/artifacts/windows/tools/arduino-cli
printf 'dummy arduino-cli exe for optional CI package assembly smoke test\n' > release/artifacts/windows/tools/arduino-cli/arduino-cli.exe

python release/scripts/assemble_customer_package.py

Expand All @@ -115,10 +174,12 @@ jobs:
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/tools/avrdude/avrdude.exe
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/tools/avrdude/avrdude.conf
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/tools/avrdude/libusb0.dll
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/tools/arduino-cli/arduino-cli.exe

git check-ignore \
release/artifacts/windows/PortableAVRControlStudio.exe \
release/artifacts/windows/tools/avrdude/avrdude.exe \
release/artifacts/windows/tools/arduino-cli/arduino-cli.exe \
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ jobs:
}
Get-Item $exe | Select-Object FullName,Length,LastWriteTime

- name: Stage Windows Arduino CLI compiler files
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$stage = 'release\artifacts\windows\tools\arduino-cli'
New-Item -ItemType Directory -Force -Path $stage | Out-Null

$command = Get-Command arduino-cli -ErrorAction Stop
$source = $command.Source
if (-not (Test-Path $source -PathType Leaf)) {
throw "Could not locate arduino-cli executable from Get-Command result: $source"
}

$stagedExe = Join-Path $stage 'arduino-cli.exe'
Copy-Item -Path $source -Destination $stagedExe -Force
if (-not (Test-Path $stagedExe -PathType Leaf)) {
throw "Staged Arduino CLI is missing: $stagedExe"
}

Write-Host "Staged Arduino CLI from $source to $stagedExe"
& $stagedExe version
Get-Item $stagedExe | Select-Object FullName,Length,LastWriteTime

- name: Stage Windows avrdude uploader files
shell: pwsh
run: |
Expand Down Expand Up @@ -88,6 +111,7 @@ jobs:
path: |
release/artifacts/windows/PortableAVRControlStudio.exe
release/artifacts/windows/tools/avrdude/**
release/artifacts/windows/tools/arduino-cli/**
if-no-files-found: error

uno-firmware-hex:
Expand Down Expand Up @@ -154,6 +178,7 @@ jobs:
test -f release/artifacts/windows/PortableAVRControlStudio.exe
test -f release/artifacts/windows/tools/avrdude/avrdude.exe
test -f release/artifacts/windows/tools/avrdude/avrdude.conf
test -f release/artifacts/windows/tools/arduino-cli/arduino-cli.exe
test -f release/artifacts/firmware/PortableAVRControlStudio.ino.hex

- name: Assemble customer ZIP
Expand All @@ -163,6 +188,7 @@ jobs:
run: |
set -euo pipefail
test -f release/customer_package/PortableAVRControlStudio-customer-handoff.zip
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/tools/arduino-cli/arduino-cli.exe
ls -la release/customer_package

- name: Generate SHA-256 checksums
Expand All @@ -175,6 +201,7 @@ jobs:
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip
find release/artifacts/windows/tools/avrdude -type f -print0 | sort -z | xargs -0 sha256sum
find release/artifacts/windows/tools/arduino-cli -type f -print0 | sort -z | xargs -0 sha256sum
} > release/artifacts/checksums/SHA256SUMS.txt
cat release/artifacts/checksums/SHA256SUMS.txt

Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ Customer-facing runtime settings are listed in [`docs/product_spec.md`](docs/pro

Hardware profiles in `docs/profiles/` document expected wiring, output polarity, sensor assumptions, and limitations. Hardware profiles do **not** auto-detect unknown hardware. Driver boards, inverted outputs, sensor circuits, or additional peripherals may require both a matching profile and matching firmware changes.

## Firmware upload status
## Firmware upload and sketch compile status

The Firmware tab uploads prepared `.hex` firmware artifacts to Arduino Uno / ATmega328P boards using bundled `tools/avrdude/` files beside the app, or `avrdude` on `PATH` as a fallback. It does not compile raw `.ino` source code inside the app. Upload success only means the `avrdude` firmware transfer command completed; it does not validate physical wiring, relay loads, sensors, power, enclosure safety, or customer hardware installation.
The Firmware tab keeps the prepared `.hex` upload workflow for Arduino Uno / ATmega328P boards using bundled `tools/avrdude/` files beside the app, or `avrdude` on `PATH` as a fallback.

The same tab also includes **Compile Arduino Sketch for Uno** for prepared `.ino` files or Arduino Sketch folders. Sketch compilation is limited to the Arduino Uno / ATmega328P target (`arduino:avr:uno`) and requires Arduino CLI either bundled beside the app under `tools/arduino-cli/` or installed as `arduino-cli` on `PATH`. If Arduino CLI is missing, the app reports: “Arduino CLI was not found. Use a package that includes tools/arduino-cli/ or install Arduino CLI before compiling sketches.”

Sketches that use only Arduino core features are supported directly after Arduino CLI has the `arduino:avr` core available. Sketches that use external libraries require those libraries to already be available to Arduino CLI, or to be installed intentionally by a maintainer/user with Arduino CLI. The app does not automatically repair bad code, guess missing libraries, or install random third-party libraries based on compiler errors. Compiler stdout/stderr is streamed to the Logs tab so missing-library and syntax errors are visible without crashing the GUI.

Uploading a custom sketch replaces the built-in Portable AVR firmware. After uploading a custom sketch, Settings / Status / EEPROM controls only work if that sketch implements the Portable AVR serial protocol. If the custom sketch only prints Serial text, the app may show logs, but Settings and Live Monitor may not work as designed.

Compile success only means Arduino CLI reported a generated HEX. Upload success only means the `avrdude` firmware transfer command completed; neither result validates physical wiring, relay loads, sensors, power, enclosure safety, or customer hardware installation.

## Firmware compile checks

Expand Down Expand Up @@ -131,7 +139,9 @@ arduino-cli core install arduino:avr
arduino-cli compile --fqbn arduino:avr:uno --output-dir release/artifacts/firmware firmware/PortableAVRControlStudio
```

The expected prepared firmware artifact is `release/artifacts/firmware/PortableAVRControlStudio.ino.hex`. Customer-provided source code must be reviewed and compiled into a `.hex` artifact before handoff; customers do not paste raw code into the app. Release packages should include `PortableAVRControlStudio.ino.hex` beside the EXE and `tools/avrdude/` with the Windows uploader files staged by the release workflow.
The expected prepared firmware artifact is `release/artifacts/firmware/PortableAVRControlStudio.ino.hex`. Release packages should include `PortableAVRControlStudio.ino.hex` beside the EXE and `tools/avrdude/` with the Windows uploader files staged by the release workflow.

The official Release Build workflow stages Arduino CLI for Windows under `release/artifacts/windows/tools/arduino-cli/` and the final customer package includes it under `tools/arduino-cli/`. If a custom/manual package does not include `tools/arduino-cli/`, package assembly still succeeds, but compile support falls back to `arduino-cli` installed on the customer PC `PATH`. Do not commit generated EXE, HEX, Arduino CLI tools, avrdude tools, libraries, build folders, or ZIP files.

## Draft status and hardware-test limitation

Expand Down
8 changes: 8 additions & 0 deletions docs/ARDUINO_CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,11 @@ arduino-cli compile --fqbn arduino:avr:nano firmware/PortableAVRControlStudio
The GitHub Actions workflow in `.github/workflows/checks.yml` runs the required Uno compile using `arduino/setup-arduino-cli`. The Nano command is optional documentation only and is not required for merge.

These checks verify that the sketch compiles for the Arduino Uno AVR target. They do not prove relay/buzzer wiring, driver polarity, sensor calibration, EEPROM behavior on a specific board, or physical safety. Do not claim physical hardware testing until it has been performed on the target hardware profile.

## App-based customer sketch compilation

Portable AVR Control Studio can compile prepared `.ino` files or Arduino Sketch folders from the Firmware tab only for Arduino Uno / ATmega328P (`arduino:avr:uno`). The app discovers Arduino CLI under `tools/arduino-cli/` beside the app first, then falls back to `arduino-cli` on `PATH`.

Sketches using only Arduino core features are supported directly after the `arduino:avr` core is available. Sketches using external libraries require those libraries to be installed or otherwise available to Arduino CLI. The app does not automatically repair source code, infer missing libraries, or install random third-party libraries from compiler output.

Uploading a custom sketch replaces the built-in Portable AVR firmware. After uploading a custom sketch, Settings / Status / EEPROM controls only work if that sketch implements the Portable AVR serial protocol. Compile success means Arduino CLI generated a HEX; it is not physical hardware validation.
9 changes: 7 additions & 2 deletions docs/PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ The script copies these items into `release/customer_package/PortableAVRControlS
7. `docs\testing.md`
8. `docs\profiles\arduino_uno_avr.json`
9. `release/artifacts/windows/tools/avrdude/` staged as `tools/avrdude/`
10. `release/artifacts/windows/tools/arduino-cli/` staged as `tools/arduino-cli/` by the official Release Build workflow for customer-side sketch compilation

The assembly script fails if `release/artifacts/windows/tools/avrdude/` does not include `avrdude.exe` and `avrdude.conf`. The release workflow stages those files from the Arduino AVR toolchain and copies required support files from the same Windows `bin` folder. These uploader files are generated release artifacts only and must not be committed to git.

The firmware upload tab uploads prepared `.hex` artifacts to Arduino Uno using bundled or configured `avrdude`. It does not compile raw `.ino` source code. Upload success only means the firmware transfer command completed; it does not validate physical wiring, relay loads, sensors, power, or enclosure safety.
The official Release Build workflow stages `arduino-cli.exe` under `release/artifacts/windows/tools/arduino-cli/` before running `release/scripts/assemble_customer_package.py`, so the normal customer ZIP includes `tools/arduino-cli/arduino-cli.exe`. For custom/manual packages, the assembly script still treats that folder as optional; if it is absent, compile support falls back to `arduino-cli` installed on the customer PC `PATH`.

The firmware tab uploads prepared `.hex` artifacts to Arduino Uno using bundled or configured `avrdude`. It can also compile prepared `.ino` files or Arduino Sketch folders for Arduino Uno / ATmega328P (`arduino:avr:uno`) when Arduino CLI is bundled or on `PATH`. External libraries must already be available to Arduino CLI; the app does not automatically repair source code, guess missing libraries, or install random third-party libraries from compiler output. Compile success only means Arduino CLI generated a HEX, and upload success only means the firmware transfer command completed; neither result validates physical wiring, relay loads, sensors, power, or enclosure safety.

Uploading a custom sketch replaces the built-in Portable AVR firmware. After uploading a custom sketch, Settings / Status / EEPROM controls only work if that sketch implements the Portable AVR serial protocol. If the custom sketch only prints Serial text, the app may show logs, but Settings and Live Monitor may not work as designed.


## Arduino Uno firmware HEX artifact
Expand All @@ -73,7 +78,7 @@ arduino-cli core install arduino:avr
arduino-cli compile --fqbn arduino:avr:uno --output-dir release/artifacts/firmware firmware/PortableAVRControlStudio
```

The expected primary HEX output is `release/artifacts/firmware/PortableAVRControlStudio.ino.hex`. Treat this as a prepared artifact for the app upload workflow. Customer-provided source code must be reviewed and compiled into a `.hex` artifact before customer handoff; the app does not compile raw `.ino` source code.
The expected primary HEX output is `release/artifacts/firmware/PortableAVRControlStudio.ino.hex`. Treat this as a prepared artifact for the app upload workflow. The app's sketch compiler is intended for prepared customer sketches that compile with Arduino CLI for Uno; it is not a substitute for source review or hardware validation.

## Developer customer ZIP checklist

Expand Down
Loading
Loading