Skip to content

[WIP] Refactor flashing scripts and add OTA support for Cardputer ADV#29

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-flash-ota-cleanup
Draft

[WIP] Refactor flashing scripts and add OTA support for Cardputer ADV#29
Copilot wants to merge 1 commit intomainfrom
copilot/refactor-flash-ota-cleanup

Conversation

Copy link
Contributor

Copilot AI commented Dec 27, 2025

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.

Original prompt

Create a non-destructive feature branch refactor/flash-ota-cleanup off main and open a pull request that implements reliable flashing scripts, a minimal test firmware, OTA support, and a boot splash for the Cardputer ADV. Do NOT delete or modify existing branches. Keep all changes secure and non-destructive.

Detailed changes to implement in this PR (Cardputer ADV):

  1. platformio.ini
  • Set a safe default upload_speed for the m5stack-cardputer env to 115200.
  • Add an optional environment [env:m5stack-cardputer-fast] that keeps upload_speed = 921600 and otherwise inherits settings.
  • Ensure board remains esp32-s3-devkitc-1 and partition table uses default_16MB.csv (or explicitly include default_16MB.csv if needed).
  • Add comments describing how to enable OTA uploads via espota and how to pass upload_port/password via PlatformIO.
  1. Add reliable esptool flash scripts
  • scripts/flash_esptool.sh (Linux/macOS): argument parsing for PORT, BIN, BAUD; erases flash; writes firmware using esptool for esp32s3; verifies result; exits non-zero on error. Make executable and include usage examples in script header.
  • scripts/flash_esptool.bat (Windows): analogous commands and usage notes.
  1. Add minimal test firmware
  • src/test_blink/main.cpp: initialize M5Unified; display a clear two-state visual indicator "FLASH OK" (on display) toggled every 500ms and print "FLASH OK" to Serial at 115200 for headless verification. Ensure it builds under env m5stack-cardputer.
  1. Add OTA example firmware and device-side web editor
  • src/ota_update/main.cpp: implement Wi‑Fi provisioning options (build flags, data folder, or runtime serial prompt); initialize ArduinoOTA or esp32s3-compatible OTA; show OTA status/progress on Serial and on the display; support espota and an HTTP firmware upload endpoint that writes to the inactive OTA partition and sets ota_pending flag in NVS.
  • Implement safe OTA flow with: write to inactive partition, set ota_pending flag, reboot, short self-test on first boot to confirm image, and automatic/manual rollback (button combo) to previous partition if test fails.
  • src/ota_update/README.md: document how to configure Wi‑Fi credentials, how to use espota (PlatformIO example), how to use the web UI upload, and security recommendations (passwords, signed images optional).
  1. Boot splash (requested text)
  • Add src/boot_splash/main.cpp (or integrate into main) to show the splash text: "HACK THE PLANT!!!" on the M5 display at boot for ~3 seconds and print same message to Serial at 115200. Make the splash string configurable via a header #define (e.g., BOOT_SPLASH_TEXT) and include a comment warning that the text is humorous/test-only.
  1. Partitioning & rollback support
  • Add a partition CSV if current layout doesn't support dual OTA slots; include a default_ota_16MB.csv that has two app slots (ota_0, ota_1) and a littlefs data partition for web editor files and backups. Document partition instructions in README.
  1. README updates
  • Add a new "Build and Flash" section with exact commands: pio run -e m5stack-cardputer, location of .pio/build/.../firmware.bin.
  • Add "Use esptool (recommended if M5 Burner stalls)" with exact erase and write commands for esp32s3.
  • Add "M5 Burner notes" about 115200 default, cable/USB port checks, and M5 Burner stalling behavior.
  • Add "Test firmware" instructions to flash src/test_blink and verify display or serial output.
  • Add "OTA Update" instructions: how to provide Wi‑Fi credentials, how to use PlatformIO espota or the web UI, and how to recover using the rollback button combo or esptool reflash.
  1. CI workflow
  • Add .github/workflows/build-firmware.yml that triggers on push and pull_request to main and refactor/flash-ota-cleanup, builds the m5stack-cardputer env, and uploads .bin and .elf artifacts for download. Keep workflow minimal and do not auto-publish releases.
  1. Branch and PR metadata
  • Create branch refactor/flash-ota-cleanup from main. Do not delete or modify other branches.
  • Open a pull request from refactor/flash-ota-cleanup -> main with a clear PR description listing all changed/added files, testing steps, and next steps for local testing. Do not add assignees.

Testing & verification steps to include in PR description

  • Build: pio run -e m5stack-cardputer
  • Install esptool: python -m pip install esptool
  • Erase: python -m esptool --chip esp32s3 --port /dev/ttyUSB0 --baud 115200 erase_flash
  • Flash: python -m esptool --chip esp32s3 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x1000 .pio/build/m5stack-cardputer/firmware.bin
  • Verify: test firmware displays "FLASH OK" and serial prints at 115200; main firmware shows boot splash "HACK THE PLANT!!!" for ~3s.
  • OTA test: document how to configure Wi‑Fi and use PlatformIO espota or web UI to upload and validate new firmware, and how rollback is triggered manually (button combo) or automatically if self-test fails.

Constraints & security

  • Do not implement backdoors or any capability that bypasses authoriza...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants