XCP-Ray: watch and tune your firmware's variables live (x1xcp libraries for PlatformIO)

Hi everyone,

I’d like to share libraries and a free tool I’ve been working on. They let you look inside running firmware: global variables show up as curves in a scope, and parameters can be changed while the program runs, without reflashing. Under the hood it’s XCP, the protocol automotive engineers use to measure and calibrate ECUs.

Libraries

  • x1xcp_serial: Arduino AVR (Nano, Uno, Mega), Raspberry Pi Pico (arduino-pico core) and STM32 (STM32duino), XCP over the USB serial port. Serial.print() keeps working, its text shows up in a console.
  • x1xcp_esp32 and x1xcp_esp8266: XCP on UDP over Wi-Fi.

PlatformIO setup

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = rpipico
board_build.core = earlephilhower
framework = arduino
lib_deps = https://github.com/flmueller/x1xcp-serial.git
build_flags = -g                          ; debug info for the A2L
extra_scripts = post:scripts/x1_a2l.py    ; writes the A2L after every build

The post-build script runs x1-elf2a2l, which reads addresses and types from the DWARF info of the ELF file. A short JSON list picks the variables and adds units, conversions, limits and events, so the A2L always matches the build.

In the sketch it’s a few lines:

#include <x1xcp_serial.h>
static const x1xcp::Event kEvents[] = {{"10ms", 10, false}};

void setup() {
  Serial.begin(115200);
  x1xcp::Config xcp;
  xcp.events = kEvents;
  xcp.eventCount = 1;
  x1xcp::begin(Serial, xcp);
}

void loop() {
  x1xcp::poll();
  // ... your code, then sample the 10 ms values:
  x1xcp::trigger(0);
}

The tool
XCP-Ray runs on Windows and Linux and is free during the public beta: live scopes, value and bar displays, curve and map editors, recordings with MDF4/CSV export, and a Python API. It also talks to real ECUs over CAN, CAN FD, UDP and TCP.

Feedback is very welcome, especially on boards or setups where something doesn’t work yet.