Variable addresses for QInsight

Why: QInsight has no A2L. Every variable is addressed by the absolute address of the object in your firmware image (address="0x…", addressExtension="0" in the Comm params), and that address can move with every build. The package ships two tools that read the addresses from the ELF's DWARF debug information and produce a QInsight import file, so that you never type an address by hand.

Requirements: Python 3 and pip install pyelftools; the ELF must contain debug info (-g, which the CubeMX Debug preset has — Release with -g0 does not).

tools/elf_vars_scan.py — one JSON file drives everything

Copy tools/elf_vars.template.json next to your project, e.g. my_firmware.vars.json, and adjust it:

{
  "elf": "build/Debug/my_firmware.elf",
  "folders": [ "Core/Src", "App" ],
  "symbols": [ "uwTick" ],
  "output": {
    "csv": "my_firmware.vars.csv",
    "qinsight": "my_firmware_variables.xml",
    "namespace": "my_ecu"
  },
  "options": { "includeConst": false, "arrays": "matrix", "maxArray": 16, "all": false }
}
KeyMeaning
elfthe firmware image with debug info.
folderssource folders whose variables you want. Absolute paths work anywhere; a relative folder is resolved relative to the JSON file; if it does not exist there (the firmware was built elsewhere), it is matched as a path fragment inside the source paths recorded in the ELF instead — "Core/Src" then finds D:/Projects/MyEcu/Core/Src/main.c wherever the build ran. List as many folders as you need. The sources are not parsed; the folders only select which compile units of the ELF are reported.
symbolsoptional list of variable names to report even though their compile unit is outside folders — e.g. "uwTick", the HAL 1 ms tick, without listing the whole HAL (options.all). Plain global names only.
output.csvtable of every variable: file;scope;name;type;size;address;volatile;collapsed;kind;elemType;elemSize;dim1;dim2 (kind = scalar or matrix, see Arrays, curves and maps).
output.jsonthe same rows as JSON (optional).
output.qinsightthe QInsight import file (the scanner runs elf_vars_to_qinsight.py for you). At least one output is required.
output.namespacewritten into every imported variable (optional).
options.includeConstalso list const data in flash (default false — not measurable or calibratable).
options.arrays"matrix" (default): every numeric 1D/2D array is one row of kind matrix — a value block, curve or map for QInsight, transferred as one XCP block. "expand": the elements one by one as separate scalar variables.
options.maxArraywith arrays = "expand": expand arrays up to N elements; longer ones become one collapsed row name[0..n-1] with collapsed = 1 (default 16, 0 = all). A collapsed row is not imported into QInsight.
options.allignore folders and list every compile unit including HAL and lwIP (default false).

All relative paths are relative to the folder of the JSON file, so the command works from any directory:

python <sdk>/tools/elf_vars_scan.py my_firmware.vars.json

The example ships examples/nucleo_h723zg/nucleo_h723zg.vars.json ("folders": ["app"], ELF of the Debug preset) and the bare-metal example examples/nucleo_h723zg_baremetal/nucleo_h723zg_baremetal.vars.json: build the example, run the scanner on that file and you get the scalar variables of the demo signals with their addresses, e.g. gDemoSignals.channels_[0].value at 0x2400005C in the shipped Debug build (verify against your own build), plus the three matrix objects of demo_map.c.

Names of struct members and array elements are flattened for QInsight (gDemoSignals.channels_[0].value → gDemoSignals_channels_0_value); the original C path, the source file and the address stay in the variable's description: XCP: address="0x2400005C" addressExtension="0". Bit-fields are reported with size 0 and skipped for the import — read the containing integer and use QInsight's Bit Shift / Bit Mask instead.

Arrays, curves and maps (Matrix variables)

QInsight shows a calibration map, curve or value block (ASAP2 MAP / CURVE / VAL_BLK) in its Matrix control and transfers it as one XCP block — with the engine's block mode a 16 × 16 float map is one UPLOAD burst and one DOWNLOAD block per written cell window instead of hundreds of acknowledged packets. The scanner exports every numeric 1D or 2D array as a matrixVariable (options.arrays = "matrix"); the layout QInsight expects is one contiguous block X axis, Y axis, data with the data row-major (data[y][x]).

To get a map with its axes from the scan, name the objects by this convention and keep them contiguous — either members of one packed struct or three consecutive globals:

#pragma pack(push, 1)
typedef struct {
    volatile uint16_t x[16];      /* X axis breakpoints, e.g. rpm            */
    volatile uint8_t  y[16];      /* Y axis breakpoints, e.g. load [%]       */
    volatile float    data[16][16]; /* data[y][x]                            */
} IgnitionMap;
#pragma pack(pop)
IgnitionMap ignitionMap;          /* -> one map "ignitionMap", 1072 B block  */

volatile uint16_t torqueCurve_x[8];   /* or: <name>_x, <name>_y, <name>      */
volatile uint16_t torqueCurve[8];     /* -> one curve "torqueCurve"           */

Rules the converter checks (a violation exports the arrays as separate value blocks and prints a warning): the x axis has as many points as the data has columns, the y axis as many as the data has rows, and x, y and data follow each other in memory without gaps (#pragma pack(1) on the struct; keep 4-byte data such as float at a 4-byte offset — 16 + 16 axis bytes do that). A lone array becomes a value block (a lone 2D array is flattened row-major). Element types are mapped like scalars; the axes may have their own type (dataType on xAxis / yAxis), the data type is the variable's default. The block address in the description is the address of the x axis (of the data when there are no axes); assign the variable to the XCP protocol and copy address / addressExtension exactly like for a scalar. Bind it to a periodic event (polled as a whole block) or to an On Request event (read only when the user presses Read); DAQ and STIM do not carry matrices. The largest matrix QInsight transfers is 64 × 64 × 4 B of data plus axes.

The example (app/src/demo_map.c) ships three such objects: qfwDemoMap (16 × 16 float, axes uint16 / uint8), qfwDemoCurve (8 × uint16) and qfwDemoBigMap (64 × 64 float, the QInsight limit); qfwDemoMapOut is a scalar that depends on their cells, so a Watch Table shows the effect of a written cell at once. The use in QInsight is shown in XCP on TCP on a NUCLEO-H723ZG.

tools/elf_vars_to_qinsight.py

The converter behind output.qinsight; run it by hand only when you want its options: --namespace, --strip-prefix <name> (drop a leading struct name from the flattened names), --keep-underscores, --presentation <ref> (assign a presentation to every variable), --address-extension.

python <sdk>/tools/elf_vars_to_qinsight.py my_firmware.vars.csv -o my_firmware_variables.xml --namespace my_ecu

Three steps in QInsight

  1. Scan after every build (elf_vars_scan.py, above).
  2. Import: Home → Project Configuration → Variables → Import, select the XML. The import skips names that already exist in the project, so a second import after a rebuild does not duplicate anything — but it also does not update addresses. If addresses moved, delete the old variables (or edit their Comm params) first.
  3. Assign each variable to the XCP protocol in Project Configuration and copy address and addressExtension from the description into the Comm params, together with direction and eventRef (see Add a variable).

Important: An imported (or manually created) variable that is not assigned to a protocol has no data source and cannot be bound to a control. You recognise it in the Solution Explorer: the tooltip of the variable says Source: not found and its icon lacks the blue badge that assigned variables carry. The fix is step 3 — assign the variable to the XCP protocol in Project Configuration and fill in the Comm params.

Alternatives without the tools: the linker .map next to the ELF (search the symbol, add the member offset by hand — the example pins the offsets with static_assert), or a debugger (print &gDemoSignals in gdb). Both are what the scanner automates.

Next

Troubleshooting — regenerating a CubeMX project and the symptom table.