--- name: flashing description: How to compile and flash sketches to the Arduino Uno Q MCU over SWD using the uno_q_flash tool. Load this whenever the user asks to upload, flash, run, program, or build a sketch on the Uno Q. --- # Flashing the Uno Q MCU Use the **`uno_q_flash`** tool. The MPU programs the MCU's flash directly over SWD (bit-banged GPIO via OpenOCD `linuxgpiod`) — no USB cable, no SSH. ## How to use it - `action = "upload"` + `code` (full `.ino`) — compile then flash. The sketch runs immediately (`reset run`). **This is what you call to make a sketch run.** - `action = "compile"` + `code` — verify it builds, don't flash. - `action = "detect"` — list boards. When the user asks to upload/flash/run a sketch, CALL the tool with `action="upload"`. Do not explain the steps in prose. Always provide the complete sketch (`setup()` + `loop()`). ## Under the hood (for context, not for the user) - Compile: `arduino-cli compile --fqbn arduino:zephyr:unoq --export-binaries`. - Flash: OpenOCD writes the image to the bank-2 partition at **`0x8100000`** (the correct sketch address; `0x80F0000` is reserved and never executes). - Requires on-device `arduino-cli` and `/opt/openocd` with `openocd_gpiod.cfg`. ## If it fails - Compile errors come back in the tool result — fix the sketch and retry. - "OpenOCD not found" → the Zephyr core's OpenOCD isn't installed at `/opt/openocd`. - Remember the 3.3 V rule and that PWM is only D3/D5/D6/D9/D10/D11.