← All projects

Latest test build

Build 620 Oct 2026

Newest test build, not an official version.

Universal Firmware, Flashing & App Configuration Guide

This comprehensive guide details the VLight Universal Firmware Architecture, covering ready-to-flash premade builds across all ESP32 microcontrollers, 1-command flashing, zero-touch physical BOOT button pairing, dynamic over-the-air Android App hardware configuration, server logging, and the advanced embedded V SDK for custom firmware development.


Table of Contents

  1. Architecture & Universal Premade Strategy
  2. Supported Hardware Matrix & Pinout Defaults
  3. Flashing Premade Firmware in 1 Command
  4. Physical BOOT Button Pairing Workflow
  5. Configuring Hardware via the Android App
  6. Server Logging & Real-Time Telemetry
  7. Advanced: Custom Firmware Development with V SDK
  8. Emulation & Testing with esp-emulator
  9. Troubleshooting & Hardware Recovery

1. Architecture & Universal Premade Strategy

Historically, configuring smart LED strips required editing source code, recalculating timing parameters, managing complex toolchains (PlatformIO, ESP-IDF, GCC), and recompiling firmware for every unique combination of GPIO pin and LED count.

VLight fundamentally changes this paradigm:

  ┌────────────────────────────────────────────────────────────────────────┐
  │ 1. FLASH ANY ESP32 WITH PREMADE FIRMWARE                              │
  │    ./vlight flash esp32s3 --port /dev/ttyUSB0                          │
  │    (Direct flashing via esptool; no compiler or toolchain needed)      │
  └───────────────────────────────────┬────────────────────────────────────┘
                                      │
                                      ▼
  ┌────────────────────────────────────────────────────────────────────────┐
  │ 2. PAIR TO SERVER VIA PHYSICAL BOOT BUTTON                             │
  │    Press physical BOOT button on board (GPIO 0 / GPIO 9)               │
  │    Node automatically enrolls into VLight Server cluster               │
  └───────────────────────────────────┬────────────────────────────────────┘
                                      │
                                      ▼
  ┌────────────────────────────────────────────────────────────────────────┐
  │ 3. CONFIGURE HARDWARE OVER-THE-AIR VIA ANDROID APP                     │
  │    • Set Data GPIO Pin (e.g. GPIO 18, 21, 4)                           │
  │    • Set Pixel Count (e.g. 60, 144, 300 LEDs)                          │
  │    • Assign Name & Room                                                │
  │    • Tap "Save Configuration to Chip (NVS)"                            │
  └────────────────────────────────────────────────────────────────────────┘

Key Technical Innovations

  1. Dynamic RMT Peripheral Reinitialization: When the GPIO pin or pixel count is updated from the Android App, the firmware frees the previous RMT hardware channel, allocates a new DMA/RMT instance on the specified GPIO, and resizes the in-memory color frame buffer without requiring a physical re-flash.
  2. Non-Volatile Storage (NVS) Persistence: All user settings (data GPIO, LED count, node name, room, and server auth token) are stored in flash memory across power cycles.
  3. Hardware BOOT Button Interrupt: A hardware poll/ISR monitors the physical BOOT strapping pin. When pressed, the node initiates an authenticated mutual HMAC pairing challenge with the VLight Server.

2. Supported Hardware Matrix & Pinout Defaults

Universal premade builds are provided for all major ESP32 chip architectures under firmware/bin/<chip>/:

Target Chip CPU Architecture Cores / Clock Default GPIO Pin Physical BOOT Pin Flash Image Binary Size
ESP32 Xtensa LX6 Dual @ 240MHz GPIO 18 GPIO 0 firmware/bin/esp32/merged.bin ~216 KB
ESP32-S2 Xtensa LX7 Single @ 240MHz GPIO 18 GPIO 0 firmware/bin/esp32s2/merged.bin ~212 KB
ESP32-S3 Xtensa LX7 Dual @ 240MHz GPIO 18 GPIO 0 firmware/bin/esp32s3/merged.bin ~239 KB
ESP32-C3 RISC-V RV32IMC Single @ 160MHz GPIO 18 GPIO 0 firmware/bin/esp32c3/merged.bin ~219 KB
ESP32-C6 RISC-V RV32IMAC Single @ 160MHz GPIO 18 GPIO 9 firmware/bin/esp32c6/merged.bin ~233 KB

Note

All merged flash images contain the secondary bootloader, partition table, and application firmware unified into a single binary, ready to flash starting at memory offset 0x0000.


3. Flashing Premade Firmware in 1 Command

Users and installers do not need to install Python virtual environments, PlatformIO, or GCC compilers. Only esptool is needed (or bundled via ./vlight).

Inspect Available Premade Images

./vlight premade

Output:

=======================================================================================================
                    VLight Universal Premade Firmware Distribution Matrix                              
=======================================================================================================
CHIP      CORE ARCHITECTURE        DEFAULT PIN   BOOT PIN  FLASH SIZE  PREMADE STATUS
-------------------------------------------------------------------------------------------------------
esp32     Xtensa LX6 Dual-Core 240MHz GPIO 18       GPIO 0    4MB/8MB     READY (merged, 216 KB)
esp32s2   Xtensa LX7 Single-Core 240MHz GPIO 18       GPIO 0    4MB/8MB     READY (merged, 212 KB)
esp32s3   Xtensa LX7 Dual-Core 240MHz GPIO 18       GPIO 0    4MB/8MB     READY (merged, 239 KB)
esp32c3   RISC-V RV32IMC Single-Core GPIO 18       GPIO 0    4MB/8MB     READY (merged, 219 KB)
esp32c6   RISC-V RV32IMAC Single-Core GPIO 18       GPIO 9    4MB/8MB     READY (merged, 233 KB)
-------------------------------------------------------------------------------------------------------

Flashing Directly to Hardware

Connect your ESP32 to USB. Flashing works directly out of the box using PlatformIO Core (pio) or esptool:

# 1-command flashing with auto-detection of USB serial port
./vlight flash esp32s3

# Or specify a port explicitly
./vlight flash esp32s3 --port /dev/ttyUSB0

# Works seamlessly with PlatformIO Core CLI (pio) or esptool
./vlight flash esp32

vlight automatically detects connected serial ports (including macOS /dev/cu.* and Linux /dev/ttyUSB*), detects esptool or PlatformIO Core (pio), uploads the merged binary to offset 0x0, and triggers a clean hardware reset:

======================================================================
      Flashing VLight Universal Premade Firmware Image                
======================================================================
Target Chip:  esp32s3
Binary Image: firmware/bin/esp32s3/merged.bin (merged, 239 KB)
Serial Port:  /dev/ttyUSB0 (Baud: 460800)
======================================================================
esptool v5.6.0
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE
Crystal is 40MHz
MAC: dc:54:75:e2:1a:40
Uploading stub...
Running stub...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x0003bfff...
Compressed 244976 bytes to 142103...
Wrote 244976 bytes (142103 compressed) at 0x00000000 in 3.4 seconds...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

[OK] Flash completed successfully!
     1. Device is initialized with default GPIO 18, 60 WS2812B LEDs.
     2. Press the physical BOOT button on the chip to pair with VLight Server.
     3. Open the VLight Android App to customize GPIO Pin and LED Count.

4. Physical BOOT Button Pairing Workflow

Once flashed, the ESP32 powers up, connects to Wi-Fi, and broadcasts its availability.

To prevent unauthorized devices on the local network from joining your lighting network without physical access, VLight uses a physical presence verification protocol:

 ┌───────────────┐                             ┌────────────────┐
 │ ESP32 Device  │                             │ VLight Server  │
 └───────┬───────┘                             └───────┬────────┘
         │                                             │
         │  [User presses physical BOOT button]        │
         │                                             │
         ├────────────────────────────────────────────►│
         │  UDP Beacon: boot_button_pressed=true       │
         │  (Payload: node_id, chip, gpio, leds)       │
         │                                             │
         │                                             │ [Server validates pairing window]
         │                                             │ [Logs colored [PAIRING] event]
         │                                             │ [Generates HMAC-SHA256 Token]
         │                                             │
         │◄────────────────────────────────────────────┤
         │  Enrollment Response (auth_token)           │
         │                                             │
         │  [Saves auth_token to NVS flash]            │
         │  [Visual confirmation pulse: Blue]          │

Pairing Step-by-Step

  1. Ensure the VLight Server is running (./vlight-server serve).
  2. Press the BOOT button on your ESP32 board (held down for ~100ms).
  3. The server immediately catches the presence signal and registers the device.

5. Configuring Hardware via the Android App

Once paired, you never need to touch the firmware code again to adjust hardware parameters.

Changing Settings in the App

  1. Open the VLight Android App.
  2. Select your node from the dashboard.
  3. Scroll to the Hardware & Strip Setup card:
    • GPIO Data Pin: Enter the exact pin your LED strip's data wire is connected to (e.g., 18, 21, 4, 12).
    • LED Pixel Count: Enter the exact number of LEDs on your strip (e.g., 60, 144, 300).
    • Device Name & Room: Name your node (e.g., "Kitchen Counter", "Living Room Desk").
  4. Tap Save Configuration to Chip (NVS).

What Happens Behind the Scenes

  • The Android App issues POST /api/v1/nodes/:id/config with:
    {
      "gpio_pin": 21,
      "led_count": 144,
      "name": "TV Backlight",
      "room": "Living Room"
    }
  • The server updates the SQLite database and sends an update packet to the ESP32.
  • The ESP32:
    1. Writes the new pin and count to NVS flash.
    2. Reconfigures the WS2812B RMT peripheral driver to use the new GPIO pin.
    3. Resizes its memory buffer for 144 pixels.
    4. Emits an emerald green confirmation pulse on the strip.

6. Server Logging & Real-Time Telemetry

The VLight Server coordinator features rich, ANSI-colored logging designed for effortless observability across hundreds of concurrent nodes and client apps:

2026-10-20 21:08:15 [DISCOVERY] Received discovery probe from client at 192.168.1.105:43892
2026-10-20 21:08:15 [CLIENT] Mobile App client queried server status & cluster health
2026-10-20 21:08:15 [NODE] Ingested node beacon: "Light Strip" (ESP32S3, GPIO 18, 60 LEDs) at 192.168.1.150
2026-10-20 21:08:15 [PAIRING] Physical BOOT button pressed on node "Light Strip" (node_f01)! Auto-enrolling into cluster...
2026-10-20 21:08:15 [PAIRING] Node node_f01 authorized with HMAC token. Active session established.
2026-10-20 21:08:22 [CONFIG] Node 'Light Strip' (node_f01) reconfigured: GPIO=21, LEDs=144, Room='Living Room' via Android App
2026-10-20 21:08:30 [LIGHTING] Node 'node_f01' state updated: Power=true, Brightness=220, RGB=(255,140,40), Effect='rainbow' (speed 15) via Mobile Client

Log Tag Legend

Log Tag Color Event Description
[DISCOVERY] Cyan Client UDP broadcast probes & server discovery announcements
[CLIENT] Blue Android App HTTP queries, status checks, and node listings
[NODE] Cyan Periodic UDP health beacons received from lighting nodes
[PAIRING] Green Physical BOOT button presses and mutual authentication events
[CONFIG] Green Hardware reconfiguration (GPIO pin, LED count) saved to NVS
[LIGHTING] Yellow Power, brightness, color, or effect changes dispatched to nodes

7. Advanced: Custom Firmware Development with V SDK

For developers who want to write specialized firmware logic, the VLight Embedded SDK is completely preserved in sdk/.

Writing Custom V Firmware (main.v)

module main

import vlight
import vlight.led

fn on_start(mut ctx vlight.Context) {
    ctx.log("Initializing custom WS2812B node...")
    mut strip := led.WS2812B.new(
        pin: 18
        count: 120
    )
    strip.fill(led.Color{ r: 255, g: 100, b: 20 })
    strip.set_brightness(200)
    strip.show()
    ctx.log("LED strip initialized with custom startup scene.")
}

fn main() {
    mut device := vlight.Device.new(
        name: "Custom Node"
        board: .esp32s3
    )
    device.on_start(on_start)
    device.run()
}

Transpiling and Compiling Custom Builds

# Transpile V to freestanding C99 and compile for ESP32-S3
./vlight build --target esp32s3

# Build for RISC-V ESP32-C3
./vlight build --target esp32c3

8. Emulation & Testing with esp-emulator

VLight integrates natively with Espressif's official esp-emulator (esp-emu), enabling instruction-level firmware testing on your PC without physical hardware.

Running Firmware in the Emulator

./vlight emulate --target esp32c3 --timeout 8s --exit-on "Returned from app_main()"

Automated Emulator Test Suite

Run the automated 5-stage test suite:

./vlight test-firmware

Output:

Running 5 automated emulator test cases...

TEST [1/5] Minimal Node - Full Cold Boot & App Main Completion ... PASS (150 ms)
TEST [2/5] WS2812B Smart LED Strip - Cold Boot & Color Pipeline ... PASS (132 ms)
TEST [3/5] Minimal Node - Fast Bootloader Reset (--skip-rom) ... PASS (128 ms)
TEST [4/5] Execution Tracing & DWARF Line Symbolication ... PASS (161 ms)
TEST [5/5] Timeout & Execution Bounding Enforcement ... PASS (2180 ms)

======================================================================
Test Results: 5 passed, 0 failed (Total: 5)
======================================================================

9. Troubleshooting & Hardware Recovery

1. Chip Not Detected on USB

  • Ensure your USB cable supports data transfer (many cables are charge-only).
  • Check your user permissions on Linux:
    sudo usermod -a -G dialout $USER
  • Identify port: ls -l /dev/ttyUSB* /dev/ttyACM*.

2. Physical BOOT Button Not Triggering Pairing

  • Ensure the server is running: ./vlight-server serve.
  • Hold the BOOT button for at least 100ms.
  • On ESP32-C6 boards, the BOOT pin is GPIO 9 (instead of GPIO 0 on other ESP32s).

3. LEDs Flickering or Incorrect Colors

  • Verify the Color Order in the Android App (WS2812B typically uses GRB, while WS2811 uses RGB).
  • Ensure the Ground (GND) wire of the ESP32 is connected to the Ground of the LED strip's 5V power supply.
  • If using long data wires (> 1 meter), use a 3.3V-to-5V logic level shifter (such as 74AHCT125) on the data GPIO.