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
63 changes: 60 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
python:
name: Python syntax and parser smoke
name: Python syntax, parser, uploader, and package smoke
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -16,16 +16,64 @@ jobs:
python-version: '3.12'
- name: Compile GUI module
run: python -m py_compile gui/portable_avr_control_studio.py
- name: Parser smoke tests
- name: Parser and uploader smoke tests
run: |
python - <<'PY'
from gui.portable_avr_control_studio import parse_serial_line
from pathlib import Path
from tempfile import TemporaryDirectory
from gui.portable_avr_control_studio import (
UploadValidationError,
parse_serial_line,
validate_upload_request,
)

assert parse_serial_line('OK,PING\n').kind == 'OK'
assert parse_serial_line('ERR,BAD,message\n').kind == 'ERR'
assert parse_serial_line('CONFIG,DEVICE_NAME=Unit,SENSOR_VREF_MV=5000\n').fields['SENSOR_VREF_MV'] == '5000'
assert parse_serial_line('STATUS,SENSOR_RAW=512,SENSOR_MV=2502\n').fields['SENSOR_MV'] == '2502'
assert parse_serial_line('DATA,INFO,protocol=2\n').fields['PROTOCOL'] == '2'
assert parse_serial_line('garbage\n').malformed

with TemporaryDirectory() as temp:
root = Path(temp)
firmware = root / 'PortableAVRControlStudio.ino.hex'
firmware.write_text(':00000001FF\n', encoding='utf-8')
tools = root / 'tools' / 'avrdude'
tools.mkdir(parents=True)
(tools / 'avrdude.exe').write_text('dummy uploader', encoding='utf-8')
(tools / 'avrdude.conf').write_text('dummy config', encoding='utf-8')
(root / 'firmware.ino').write_text('raw source is unsupported in app', encoding='utf-8')

cmd, tool, returned_firmware = validate_upload_request('COM7', str(firmware), root, path_env='')
assert tool.source == 'bundled'
assert returned_firmware == firmware
assert cmd == [
str(tools / 'avrdude.exe'),
'-C', str(tools / 'avrdude.conf'),
'-v', '-patmega328p', '-carduino',
'-P', 'COM7', '-b115200', '-D',
f'-Uflash:w:{firmware}:i',
]

for port, hex_path, expected in (
('', str(firmware), 'COM port'),
('COM7', str(root / 'missing.hex'), 'existing prepared .hex'),
('COM7', str(root / 'firmware.ino'), 'must end with .hex'),
):
try:
validate_upload_request(port, hex_path, root, path_env='')
except UploadValidationError as exc:
assert expected in str(exc)
else:
raise AssertionError(f'expected validation failure for {expected}')

(tools / 'avrdude.exe').unlink()
try:
validate_upload_request('COM7', str(firmware), root, path_env='')
except UploadValidationError as exc:
assert 'avrdude was not found' in str(exc)
else:
raise AssertionError('expected missing avrdude validation failure')
PY

- name: Compile release assembly script
Expand All @@ -38,6 +86,7 @@ jobs:
cleanup() {
rm -rf \
release/artifacts/windows/PortableAVRControlStudio.exe \
release/artifacts/windows/tools/avrdude \
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip
Expand All @@ -46,6 +95,10 @@ jobs:

printf 'dummy exe for CI release assembly smoke test\n' > release/artifacts/windows/PortableAVRControlStudio.exe
printf ':00000001FF\n' > release/artifacts/firmware/PortableAVRControlStudio.ino.hex
mkdir -p release/artifacts/windows/tools/avrdude
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

python release/scripts/assemble_customer_package.py

Expand All @@ -59,9 +112,13 @@ jobs:
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/docs/product_spec.md
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/docs/testing.md
test -f release/customer_package/PortableAVRControlStudio-customer-handoff/docs/profiles/arduino_uno_avr.json
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

git check-ignore \
release/artifacts/windows/PortableAVRControlStudio.exe \
release/artifacts/windows/tools/avrdude/avrdude.exe \
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip
Expand Down
68 changes: 62 additions & 6 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
- name: Install Windows packaging dependencies
run: py -m pip install --upgrade pyinstaller pyserial

- name: Install Arduino CLI
uses: arduino/setup-arduino-cli@v2

- name: Install Arduino AVR core for bundled uploader
shell: pwsh
run: |
arduino-cli core update-index
arduino-cli core install arduino:avr

- name: Build Windows EXE
run: powershell -ExecutionPolicy Bypass -File .\release\scripts\build_windows_exe.ps1

Expand All @@ -31,11 +40,54 @@ jobs:
}
Get-Item $exe | Select-Object FullName,Length,LastWriteTime

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

$candidates = @(
Join-Path $env:LOCALAPPDATA 'Arduino15\packages\arduino\tools\avrdude'
)
$toolRoot = $candidates | Where-Object { Test-Path $_ -PathType Container } | Select-Object -First 1
if (-not $toolRoot) {
throw 'Could not locate Arduino AVR avrdude tool root after installing arduino:avr.'
}

$versionRoot = Get-ChildItem $toolRoot -Directory | Sort-Object LastWriteTime -Descending | Select-Object -First 1
if (-not $versionRoot) {
throw "Could not locate an avrdude version directory under $toolRoot."
}

$bin = Join-Path $versionRoot.FullName 'bin'
$conf = Join-Path $versionRoot.FullName 'etc\avrdude.conf'
$exe = Join-Path $bin 'avrdude.exe'
if (-not (Test-Path $exe -PathType Leaf)) {
throw "Could not locate avrdude.exe at $exe."
}
if (-not (Test-Path $conf -PathType Leaf)) {
throw "Could not locate avrdude.conf at $conf."
}

Copy-Item -Path (Join-Path $bin '*') -Destination $stage -Recurse -Force
Copy-Item -Path $conf -Destination (Join-Path $stage 'avrdude.conf') -Force

if (-not (Test-Path (Join-Path $stage 'avrdude.exe') -PathType Leaf)) {
throw 'Staged uploader is missing avrdude.exe.'
}
if (-not (Test-Path (Join-Path $stage 'avrdude.conf') -PathType Leaf)) {
throw 'Staged uploader is missing avrdude.conf.'
}
Get-ChildItem $stage | Select-Object FullName,Length,LastWriteTime

- name: Upload Windows EXE artifact
uses: actions/upload-artifact@v4
with:
name: portable-avr-control-studio-windows-exe
path: release/artifacts/windows/PortableAVRControlStudio.exe
path: |
release/artifacts/windows/PortableAVRControlStudio.exe
release/artifacts/windows/tools/avrdude/**
if-no-files-found: error

uno-firmware-hex:
Expand Down Expand Up @@ -100,6 +152,8 @@ jobs:
run: |
set -euo pipefail
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/firmware/PortableAVRControlStudio.ino.hex

- name: Assemble customer ZIP
Expand All @@ -115,11 +169,13 @@ jobs:
run: |
set -euo pipefail
mkdir -p release/artifacts/checksums
sha256sum \
release/artifacts/windows/PortableAVRControlStudio.exe \
release/artifacts/firmware/PortableAVRControlStudio.ino.hex \
release/customer_package/PortableAVRControlStudio-customer-handoff.zip \
> release/artifacts/checksums/SHA256SUMS.txt
{
sha256sum \
release/artifacts/windows/PortableAVRControlStudio.exe \
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
} > release/artifacts/checksums/SHA256SUMS.txt
cat release/artifacts/checksums/SHA256SUMS.txt

- name: Upload customer ZIP artifact
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Hardware profiles in `docs/profiles/` document expected wiring, output polarity,

## Firmware upload status

The Firmware tab supports selecting prepared `.hex` firmware artifacts as a placeholder handoff workflow. It must not be presented as a fully validated production uploader until the uploader, target MCU flags, COM-port behavior, hardware profile, and firmware artifact have been packaged and tested together.
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.

## Firmware compile checks

Expand Down Expand Up @@ -131,7 +131,7 @@ 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`. Keep upload as a maintainer/developer prepared-artifact workflow unless an uploader such as `avrdude` is bundled, configured, and tested with the exact target hardware and COM-port procedure.
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.

## Draft status and hardware-test limitation

Expand Down
7 changes: 5 additions & 2 deletions docs/PACKAGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ The script copies these items into `release/customer_package/PortableAVRControlS
6. `docs\product_spec.md`
7. `docs\testing.md`
8. `docs\profiles\arduino_uno_avr.json`
9. `release/artifacts/windows/tools/avrdude/` staged as `tools/avrdude/`

The firmware upload tab is a placeholder workflow for prepared `.hex` artifacts. A production package should bundle and test the selected uploader, target MCU flags, COM-port behavior, and profile-specific firmware before presenting upload as a one-click customer feature.
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.


## Arduino Uno firmware HEX artifact
Expand All @@ -70,7 +73,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 a controlled upload process; do not describe the package as a tested one-click production uploader unless the uploader is bundled and validated with the final board and profile.
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.

## Developer customer ZIP checklist

Expand Down
9 changes: 6 additions & 3 deletions docs/customer_handoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ A prepared customer ZIP should contain:

- `PortableAVRControlStudio.exe` — Windows desktop app.
- `PortableAVRControlStudio.ino.hex` — prepared Arduino Uno firmware artifact, if firmware delivery is included.
- `tools/avrdude/` — bundled Windows uploader files used by the Firmware tab when included in the release package.
- `docs/` — protocol, product settings, testing notes, and hardware profile documents.
- `docs/profiles/arduino_uno_avr.json` — the default documented wiring/profile for Arduino Uno.

If the ZIP does not include an uploader tool such as `avrdude` plus tested upload settings, treat the `.hex` file as a prepared firmware artifact for a developer or maintainer to upload. Do not assume the app provides validated one-click production firmware upload.
The Firmware tab can upload the prepared `.hex` file when the package includes `tools/avrdude/` or when `avrdude` is available on `PATH`. It does not compile raw source code and upload success is not physical hardware validation.

## How to run the Windows app

Expand All @@ -25,7 +26,7 @@ The app can be opened without an Arduino connected. Use demo mode for training o

## How to connect the Arduino Uno

1. Use an Arduino Uno or compatible ATmega328P AVR board that matches the documented hardware profile.
1. Use an Arduino Uno / ATmega328P AVR board that matches the documented hardware profile.
2. Connect the Arduino Uno to the Windows PC with a USB cable that supports data, not a charge-only cable.
3. Wait for Windows to finish installing or assigning the USB serial driver.
4. Open Windows Device Manager if needed and check **Ports (COM & LPT)** for the assigned COM port, such as `COM3` or `COM7`.
Expand Down Expand Up @@ -93,7 +94,9 @@ EEPROM persistence still requires validation on the target physical board before

## Firmware artifact and upload boundary

The release package may include `PortableAVRControlStudio.ino.hex` at the customer package root as a prepared Arduino Uno firmware artifact. This repository documents how to build the artifact, but firmware upload should remain a maintainer/developer workflow unless the customer package also includes a tested uploader, exact command flags, target MCU settings, and COM-port procedure.
The release package may include `PortableAVRControlStudio.ino.hex` at the customer package root as a prepared Arduino Uno / ATmega328P AVR firmware artifact. Customers do not paste raw code into the app, and the app does not compile raw `.ino` source code. Customer-provided source code must be reviewed and compiled into a `.hex` artifact before it is selected in the app.

When the customer package includes `tools/avrdude/`, the Firmware tab can upload a prepared `.hex` file to an Arduino Uno using the bundled uploader, or a configured `avrdude` on `PATH` if bundled files are missing. Upload requires an Arduino Uno, a USB data cable, the correct COM port, and a compatible Arduino bootloader. Upload success only means the firmware transfer command completed; it is not physical hardware validation of wiring, relay loads, sensors, power, or enclosure safety.

## What still requires physical hardware validation

Expand Down
26 changes: 24 additions & 2 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,35 @@ GitHub Actions runs `.github/workflows/checks.yml` with:
```bash
python -m py_compile gui/portable_avr_control_studio.py
python - <<'PY'
from gui.portable_avr_control_studio import parse_serial_line
from pathlib import Path
from tempfile import TemporaryDirectory
from gui.portable_avr_control_studio import UploadValidationError, parse_serial_line, validate_upload_request
assert parse_serial_line('OK,PING\n').kind == 'OK'
assert parse_serial_line('ERR,BAD,message\n').kind == 'ERR'
assert parse_serial_line('CONFIG,DEVICE_NAME=Unit,SENSOR_VREF_MV=5000\n').fields['SENSOR_VREF_MV'] == '5000'
assert parse_serial_line('STATUS,SENSOR_RAW=512,SENSOR_MV=2502\n').fields['SENSOR_MV'] == '2502'
assert parse_serial_line('DATA,INFO,protocol=2\n').fields['PROTOCOL'] == '2'
assert parse_serial_line('garbage\n').malformed

with TemporaryDirectory() as temp:
root = Path(temp)
firmware = root / 'PortableAVRControlStudio.ino.hex'
firmware.write_text(':00000001FF\n', encoding='utf-8')
tools = root / 'tools' / 'avrdude'
tools.mkdir(parents=True)
(tools / 'avrdude.exe').write_text('dummy uploader', encoding='utf-8')
(tools / 'avrdude.conf').write_text('dummy config', encoding='utf-8')
cmd, tool, returned_firmware = validate_upload_request('COM7', str(firmware), root, path_env='')
assert tool.source == 'bundled'
assert returned_firmware == firmware
assert '-patmega328p' in cmd and '-carduino' in cmd
for port, hex_path in (('', str(firmware)), ('COM7', str(root / 'missing.hex'))):
try:
validate_upload_request(port, hex_path, root, path_env='')
except UploadValidationError:
pass
else:
raise AssertionError('expected firmware upload validation failure')
PY
```

Expand All @@ -30,7 +52,7 @@ If Arduino CLI or network setup is unavailable in an execution environment, run
## Local checks

```bash
python -m py_compile gui/portable_avr_control_studio.py
python -m py_compile gui/portable_avr_control_studio.py release/scripts/assemble_customer_package.py
python - <<'PY'
from gui.portable_avr_control_studio import parse_serial_line
assert parse_serial_line('OK,PING\n').kind == 'OK'
Expand Down
Loading
Loading