> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Flashing firmware

> Program the intended board with a build, capture its boot output, and confirm the new firmware starts.

Ask Inlay to flash after a successful build, in Act or Debug mode. Inlay runs your project's flash command, then captures boot output from the port you name, so you can confirm the new firmware started.

Flashing replaces the firmware on the board and usually resets it. If a debugger session holds the probe, Inlay closes that session before the flash command runs.

## Before you flash

1. Connect and power the intended board and probe.
2. Build firmware for the exact MCU and board revision.
3. Record the flash command, serial port, and baud rate in [INLAY.md](/docs/core-concepts/inlay-md.md) (`flash_command`, `serial_port`, and `serial_baudrate`).
4. Install the flash utility, drivers, and USB permissions on the machine connected to the board.

Inlay runs the command your project already uses, such as `pio run -t upload`, `idf.py flash`, `west flash`, `nrfjprog`, or a J-Link command file. It doesn't supply those utilities or their board configuration.

For an STM32 board with an ST-LINK, the command can use OpenOCD, `st-flash`, or `STM32_Programmer_CLI`, whichever is installed on your `PATH`. For example, with OpenOCD and an STM32F4 target:

```text theme={"theme":"css-variables"}
flash_command = openocd -f interface/stlink.cfg -f target/stm32f4x.cfg -c "program build/app.elf verify reset exit"
```

Replace the target configuration and the ELF path with your board's. See [OpenOCD](/docs/debug-mode/openocd.md) for choosing the interface and target configurations.

## Flash a local board

```text theme={"theme":"css-variables"}
Flash the successful build using the command in INLAY.md. Monitor the
confirmed UART port at 115200 baud and report whether READY appears.
Report programming errors separately from missing boot output.
```

Adjust the port, baud rate, and expected message to your firmware. If you don't name a port, Inlay flashes and reports the command output without capturing boot output.

Inlay asks you to approve the flash command before it runs, unless your [approval settings](/docs/core-concepts/approvals.md) already allow it. Choosing **Allow always** on a flash request also approves later flash requests in the same chat.

While the command runs, Inlay pauses open serial connections in the Monitor and reconnects them afterward. It doesn't reset the target itself: the flash utility's own reset starts the application.

| Setting | Default | What you can change |
| - | - | - |
| Flash command timeout | 5 minutes | Ask for more time, up to 10 minutes. Requests under 1 minute are raised to 1 minute. |
| Boot capture with an expected message | Up to 30 seconds, ending as soon as the message appears | Ask for a different wait. |
| Boot capture without an expected message | 3 seconds | Ask for a longer capture. |
| Capture port | None | A UART or RTT port. ITM ports aren't supported here. |

### Catch the first boot lines

When you give the baud rate, or Inlay already knows it for that port, Inlay opens the port before the flash command runs. Output is captured from the first byte after reset.

Without a known baud rate, Inlay detects it after flashing and starts capturing then, so early lines can be missed. If the port disappears during flashing, Inlay waits about 5 seconds for it to return. An empty log on its own doesn't prove the firmware failed to boot.

### Read the result

Inlay reports programming and boot capture separately:

| Result | What it means | Next step |
| - | - | - |
| Flash failed or timed out | The flash command exited with an error or ran out of time. | Read the command output, fix the cause, and flash again. |
| Flash succeeded, expected message missing | The firmware was loaded, but the message didn't appear in time. | Review the captured output before reflashing. |
| Flash succeeded, capture failed | The firmware was loaded; only reading the port failed. | Ask Inlay to read the port again instead of reflashing. |

For SWO output, flash first and then follow [ITM/SWO](/docs/debug-mode/itm-swo.md).

## Flash through a bench

Use this when the board and probe are attached to another machine set up as a [bench](/docs/integrations/benches.md). You provide a built artifact instead of a flash command, and the bench machine needs probe-rs or OpenOCD installed.

1. [Choose the bench](/docs/integrations/benches.md#use-a-bench-in-a-session) connected to the board for the session.
2. Build the firmware and note the artifact path, such as an ELF, BIN, or HEX file.
3. Ask Inlay to flash it:

```text theme={"theme":"css-variables"}
Flash build/firmware.elf to the confirmed target on the selected bench.
Then read its boot output and report whether the application started.
```

Inlay uploads the artifact to the bench and programs the target there. It picks the flasher from the chip you name, or from the board saved on the bench:

| The target has | Inlay programs it with | How the firmware starts |
| - | - | - |
| A chip name, from your request or the saved board | [probe-rs](/docs/debug-mode/probe-rs.md) | Inlay resets the target after programming. |
| No chip name, but an OpenOCD target and an ST-Link, J-Link, or CMSIS-DAP interface in the bench's [`hardware.toml`](/docs/integrations/benches#describe-the-boards-on-a-bench) | [OpenOCD](/docs/debug-mode/openocd.md), with verify | OpenOCD resets the target after programming. |

* If the bench has several saved boards, name the board or chip you mean.
* If no target can be detected, give the chip name, such as `nRF52832_xxAA`, and Inlay programs it with probe-rs.
* If several probes on the bench can program that chip, Inlay lists them. Name the one to use as `VID:PID:Serial`.
* Programming through a bench times out after 5 minutes.
* An artifact without a selected bench can't be flashed. For a local board, use a flash command.

Serial output stays routed through the bench. Ask Inlay to read the boot output as a separate step, and keep programming success and boot verification as separate checks.

## Program XMOS hardware

Use [XMOS xTAG and xgdb](/docs/debug-mode/xmos-debugging.md) for `.xe` artifacts and XTC Tools setup. Inlay writes the image to boot flash with `xflash`, which replaces the image the board boots from, including a dev kit's factory firmware.

Capturing xSCOPE output after flashing runs the image again from RAM. Use the power-cycle check in that guide to confirm the board boots from flash. [xsim](/docs/debug-mode/xsim.md) reloads the simulator instead of programming a board.

## Prepare an AURIX project

For the supported Windows ADS and iLLD workflow, follow [AURIX ADS and Flasher](/docs/debug-mode/aurix.md). Project setup creates command-line build files. Programming is a separate step that uses AURIX Flasher and the generated HEX file.

## Share a board with other chats

One chat uses a board at a time. If another chat holds it, run `/hardware-queue` to see which one. `/hardware-force-release --confirm` frees the board, but it can interrupt that chat's work.

If another chat flashed the same board after your last flash, Inlay re-runs your last flash command before your next debugger, hardware-script, or serial operation on that board, and tells you it did. If that re-flash fails, the operation doesn't run. Flash the board again yourself, then retry.

## Troubleshoot

* **Wrong or missing artifact:** rebuild for the selected board and use the actual output path.
* **Flash command times out:** check the probe connection, then ask for a longer timeout of up to 10 minutes.
* **Probe busy:** stop conflicting captures or debugger connections, and run `/hardware-queue` to check for another chat.
* **Flash succeeds but the expected message is absent:** check the output transport, baud rate, capture timing, and the flash utility's reset behavior. Ask Inlay to read the port again before reflashing.
* **Port missing after flashing:** USB serial boards can take a moment to reappear. Ask Inlay to read the port again once it's listed.
* **Bench reports no target or several targets:** give the chip name, or name the board you mean.
* **probe-rs or OpenOCD not found on the bench:** install probe-rs or OpenOCD on the bench machine as your normal user, then run `inlay bench verify <name>`.
* **Board no longer detected:** check power, cable, boot mode, and the board's recovery instructions before retrying.

To observe an existing failure without replacing the firmware, start with [Monitor and debug](/docs/debug-mode/overview.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.