# Flashing MeshCore Firmware

## Flashing MeshCore Firmware

MeshCore firmware can be installed via the web flasher (easiest), the CLI tool, or OTA (over-the-air) for updates on already-running devices. All methods are covered below.

### Method 1: Web Flasher (Recommended)

The web flasher at **flasher.meshcore.io** requires a Chromium-based browser (Chrome or Edge). Firefox does not support the WebSerial API and will not work.

1. Open **flasher.meshcore.io** in Chrome or Edge.
2. Connect your device via USB. Use a **data-capable** USB cable. Charge-only cables (common with power banks) will not expose the serial port. If the device does not appear, try a different cable first.
3. Hold the BOOT button while plugging in (ESP32 devices) or double-tap the reset button (nRF52 devices) to enter bootloader mode.
4. Select your device type from the dropdown.
5. Select the firmware variant: 
    - **Companion** - pairs with a phone app over BLE or USB
    - **Repeater** - autonomous relay node, no interaction needed
    - **Room Server** - store-and-forward message hub
6. Click **Flash**. The process takes 1 - 2 minutes. Do not disconnect during flashing.
7. After flashing completes, configure the device via the MeshCore app or CLI.

### Method 2: CLI Flashing

The MeshCore CLI tool allows flashing and configuration from a terminal. Useful for bulk deployments or when the web flasher is unavailable.

```
pip install meshcore-cli
```

Connect via serial (USB):

```
meshcore-cli --serial COM3 # Windows
meshcore-cli --serial /dev/ttyUSB0 # Linux/macOS
```

Connect via BLE:

```
meshcore-cli --ble connect
```

Connect via TCP (remote node on same network):

```
meshcore-cli --tcp 192.168.1.100:4403
```

### Method 3: OTA Update (ESP32 devices only)

For devices already running MeshCore firmware, OTA updates avoid needing a USB connection.

1. In the MeshCore app, open the Command Line for your device.
2. Type: `start ota`
3. The device will create a Wi-Fi hotspot named **MeshCore OTA**.
4. Connect your phone or computer to the MeshCore OTA Wi-Fi network.
5. Open a browser and navigate to **http://192.168.4.1/update**
6. Upload the new firmware file (.bin). Wait for the device to reboot.

### Method 4: OTA Update (nRF52 devices)

nRF52-based devices use the Nordic DFU protocol for OTA updates.

1. In the MeshCore app, type `start ota` in the Command Line.
2. Use the **nRF Device Firmware Update** app (available for Android/iOS).
3. Set packet count: 
    - RAK4631: use **10**
    - Heltec T114: use **8**
4. Select the firmware .zip DFU package and transfer.

### Bootloader Entry by Device

<table id="bkmrk-devicemethod-most-es"><thead><tr><th>Device</th><th>Method</th></tr></thead><tbody><tr><td>Most ESP32 devices (V3, V4, T-Beam)</td><td>Hold BOOT button while connecting USB</td></tr><tr><td>nRF52 (T-Echo, RAK WisBlock, Wio series)</td><td>Double-tap reset button quickly</td></tr><tr><td>LilyGo T-Deck variants</td><td>Depress trackball while connecting USB</td></tr><tr><td>Heltec V4</td><td>May need CH340 USB-serial drivers installed first</td></tr></tbody></table>

### Post-Flash Configuration

After flashing, the device needs basic configuration before it will function on the network:

- Set device name (used to identify you in the mesh)
- Set region/frequency (ensure this matches your local regulations - 915 MHz for North America)
- Set TX power (default is usually fine; reduce for indoor testing)
- For Repeater variant: set the repeater name and ensure auto-start is enabled