Skip to content

OpenOCD scripts/ directory no longer in search path — release archives may fail at first flash #8

@nedseb

Description

@nedseb

Severity: High — likely breaks any first-flash on a fresh release archive that doesn't have a system OpenOCD installed.

The release archives ship the XPack OpenOCD scripts directory at <install>/scripts/ (release.yaml:42 does mv xpack-openocd-0.12.0-4/openocd/scripts/ linux/). All our .cfg files reference standard scripts via source [find ...], e.g. configs/f1x-unlock.cfg:1 does:

source [find interface/stlink.cfg]

The find directive only resolves through OpenOCD's search path. The original code passed -s scripts (relative path) so that linux/scripts/ became searchable when the binary was launched from linux/. In commit fe30049 (cleanup of "leftovers from review") I removed that argument, thinking it was unused. It wasn't.

Without -s <path-to-scripts>, the bundled OpenOCD has to fall back to its compiled-in install prefix, which doesn't match the layout the release archive produces (bin/ and scripts/ both flattened next to the executable instead of bin/../share/openocd/scripts/).

Fix

In src/open_ocd_task.rs:111-133, restore an extra -s argument pointing at <exe_dir>/scripts when that directory exists:

let scripts_folder = dirs::get_exe_dir()?.join("scripts");
// only push -s scripts_folder if scripts_folder.exists()

Use absolute paths (-s of the joined PathBuf) rather than the bare relative "scripts" so it works regardless of the user's CWD.

Repro

  1. Download the latest xpack-bundled release archive (easy_flash_daplink-vX-xpack-ubuntu-XX.04.zip).
  2. Unzip into a fresh directory.
  3. Run the binary, attempt the DapLink flow.
  4. Expected: OpenOCD reports Can't find interface/stlink.cfg (or similar) and the unlock step fails.

Spotted in post-merge review.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions