Skip to content
neuralSPOT-X
User guide
HELIA HUB

Lock and sync

Two commands sit under everything else. nsx lock decides what the app depends on and writes it down. nsx sync makes modules/ match what was written down. Keeping them separate is what lets a build be checked without being changed.

nsx configure runs both for you: it locks if there is no nsx.lock, then syncs. You only reach for them directly when you want one without the other, which is most of the time in CI.

Schema 6 records the selected manifest path for each module when its manifest belongs to the locked artifact. To regenerate a schema 5 lock, run nsx lock without a board argument so every target is included. Review the resulting commit SHAs for moving refs.

nsx lock walks the graph from the board’s baseline plus your declared modules, resolves every dependency, and records the result per target board in nsx.lock.

Each module gets a project, a kind, the constraint it was resolved from, and a resolved block. For a git-backed module that block carries the URL, the tag, the exact commit and a content hash of the tree at that commit. The lock also records the NSX version that wrote it and a hash of the nsx.yml it read, which is how drift is detected later.

Five kinds appear, and they differ in where the content comes from:

Kind Source of truth Re-fetched by sync
git A repository at a resolved commit Yes
packaged A source tree shipped inside the NSX package Yes
local An external directory you named with source.path Yes, mirrored
vendored modules/<name>/ in your own repository No
unresolved Last known content, when upstream could not be reached No, hash verified

Because resolution happens per board, two targets on different SoC families can legitimately land on different module sets in the same lock file. The full schema is on the generated nsx.lock reference.

By default a module uses its packaged registry revision. To override a project’s revision in nsx.yml, use the registry override (this applies to its modules):

module_registry:
projects:
nsx-ambiq-sdk:
revision: v5.2.33

SDK 5.2.33 requires neuralspotx 0.9.6 or newer to resolve BSP dependencies, including for built-in boards.

For a module-specific override, use module_registry.modules.<module>.revision. A revision field directly under the app’s top-level modules entries does not set the effective registry revision. Check the resulting constraints in nsx.lock.

revision accepts a tag, branch or full 40-character commit SHA. Git-backed lock entries record exact commits even when their constraints can move:

  • A full commit SHA resolves to itself.
  • A tag records both the tag and its resolved commit. Matching previous tag resolutions can be reused. If upstream moves a tag, an explicit update may change its resolved commit; a committed lock remains the reproducibility anchor.
  • A branch keeps its recorded commit on a plain nsx lock. To advance the branch, use nsx lock --module NAME for one project or nsx lock --update for all projects. Both update forms clear the resolve-ref cache.

Each resolved board lock warns about Git constraints that are neither full SHAs nor recorded tags, grouping modules by project, source and revision. The warning also appears during nsx lock --check; it does not fail the command or imply that a recorded commit has changed. To stabilize future resolution, set an explicit tag or full commit SHA in the registry override above, then review the new lock.

Packaged, local and vendored entries are excluded. In particular, the packaged neuralspotx@main registry self-reference represents bytes from the installed tool, recorded as kind: packaged, rather than a remotely resolved branch. This is based on source kind, not a generic warning exemption for a project name. Unresolved sources retain their separate fallback warnings; they do not have exact commits.

These diagnostics use the neuralspotx logger (stderr in the CLI, suppressed by normal -q filtering). API callers capture them with a logging handler, not the emit= callback. API quiet=True suppresses summaries, not warnings. The separate age-based stale-lock warning and its settings are unchanged.

nsx sync reads nsx.lock and makes modules/ match it. It never writes the lock: if syncing could change what you depend on, the split between the two commands would be pointless.

It is idempotent and cheap on the second run, because it hashes what is already on disk and skips anything that matches. --force re-vendors every fetchable module regardless.

Three flags turn this pair into a build check.

Terminal window
nsx lock --check # report manifest and resolution drift, write nothing
nsx sync --frozen # fail if modules/ differs from the lock; fetch only what is missing
nsx outdated --exit-code # fail if a git module lags its upstream

nsx lock --check does not write the lock or build glue, but can use or populate caches. It checks manifest/content consistency and exits non-zero on drift. Matching previous Git resolutions, including branch SHAs, can be reused: a successful check is not proof that branches match their latest upstream tips. nsx lock --check --update clears the resolve cache and reconsiders previous resolutions without writing the lock/build glue; it reports drift rather than applying it.

nsx sync --frozen refuses to correct. Every form of drift becomes an error naming the module:

Vendored module 'my-sensor' content drifted from lock ...
Local source for 'my-sensor' at /home/you/src/my-sensor has drifted ...
Module 'my-sensor' at modules/my-sensor does not match nsx.lock ...

A module that is missing, as on a fresh clone where modules/ is gitignored, is not drift. --frozen fetches it at the commit in nsx.lock (git modules need network access) and fails if its content hash differs from the lock. The same holds for the cmake/nsx tree that ships with neuralspotx: after upgrading neuralspotx, run nsx lock once before using --frozen.

--frozen is also accepted by configure, build, flash and view, where it applies to the implicit sync those commands would otherwise perform.

To rebuild a qualified commit, check out its app and lock together, then run:

Terminal window
nsx sync --frozen
nsx build --frozen

The sync step verifies the selected board’s sources before the build and restores any missing fetchable modules. Use the tool version recorded in the lock when the packaged CMake files have changed.

To enforce today’s registry defaults as well, run nsx lock --check before those two commands. If a new wheel changes the effective SDK revision from v1 to v2, this check reports drift and exits nonzero without writing the lock. An app that explicitly pins v1 keeps that override. Use nsx lock --check --update to check for movement in upstream Git refs too.

The 1.x compatibility policy protects compatible Git pins across tool upgrades. NSX 0.9.9 already implements these rules. Suppose both boards use a driver from main. Their lock sections record commit A, and upstream has since advanced to B. The app configuration, selected dependency closure, effective registry inputs, and local sources are otherwise unchanged.

Operation after upgrading the tool Outcome
nsx sync --frozen Use verified local content or fetch A from the Git URL recorded in the lock. Verify the content hash and leave the lock untouched. If that origin cannot supply A, identify the recorded source and fail without trying the current registry’s mirror.
nsx lock --check Report drift with a nonzero exit if the wheel changes the effective SDK default. Leave the lock untouched.
nsx lock Keep A and its recorded source identity and content hash for both boards. Preserve unrelated Git pins.
nsx lock --module my-driver Refresh the registry project in each requested target that contains my-driver. Its modules in that target can move to B together. Unrelated compatible Git projects keep their pins.
A full lock fails while preparing the second board Leave the entire previous lock byte-for-byte intact so the developer can retry.

A newer wheel can also change a packaged registry default, such as the SDK revision for the same board. With unchanged app inputs, frozen sync uses the recorded identities or fails verification. Plain lock retains the existing Git pin if it still satisfies the effective inputs. If the new default requires a different revision, plain lock stops before writing, identifies the project and affected boards, and explains how to opt in. A targeted update of a different project also stops before writing if the wheel introduced this conflict in any requested board section where the SDK was unselected. To adopt the new SDK, select a module from its project in each affected target or request a full update with nsx lock --update. To retain the old SDK, pin its previous revision in the app registry. A first lock for a new app uses the new wheel’s defaults.

In 0.9.7, a writable plain nsx lock refreshes floating Git refs even when the app inputs stay the same. Version 0.9.9 preserves compatible pins on a plain lock. An unsupported lock schema still requires regeneration, so review the new pins when replacing an older lock.

Content from a local directory, an app-vendored module, or the CMake files shipped in the wheel has a hash but may have no Git commit to fetch. Frozen sync verifies the materialized bytes against the lock. To adopt changed content, re-lock explicitly and review the diff. Compatible Git pins for unrelated projects are preserved.

Terminal window
nsx outdated # what has moved upstream
nsx lock --update # clear cache and reconsider all resolutions
nsx lock --module nsx-audio # refresh the selected project; implies --update
nsx update # re-resolve and sync in one step

nsx outdated only reports on git-backed modules, because a packaged or vendored module has no upstream tip to compare against. It tells you which modules it skipped and why, and --json gives checked, skipped and outdated_count for a script.

nsx update is lock --update followed by sync. Its preliminary report shows upstream availability for the default target, not a targeted change plan; it may include unselected projects. Three or more outdated modules in that report require confirmation (or --yes), even for a targeted request.

lock --module X and update --module X refresh every Git module belonging to X’s registry project in each applicable target closure. Modules sharing a project share one vendored source directory. Unrelated projects retain matching prior Git commits and tags, including floating branches. Separate projects sharing a URL are not selected together. Conflicting Git commits or mixed Git/unresolved rows sharing one directory are rejected before writing the affected lock section; align revisions, retry unreachable refs, or give separate projects distinct paths.

A writable lock preserves compatible Git pins for unselected projects. New dependencies are resolved, removed dependencies disappear, and local, vendored, and packaged content is rehashed. Explicit source or revision edits in the app’s registry layers apply on the next lock.

If a new wheel changes a packaged default, a plain lock or an unrelated targeted update keeps the qualified Git artifact when it still satisfies that default. If the default would change the artifact or Git source, NSX reports the affected boards and projects and leaves the lock untouched. To adopt the change, select the named module or run nsx lock --update. To keep the previous SDK, pin its source and revision in the app registry. Removing an app override returns that field to packaged defaults and can also require an explicit update. A read-only nsx lock --check still reports effective-input drift.

Closure discovery uses app-local module metadata when available. When a compatible locked Git module is missing, a writable relock acquires its metadata at the recorded commit. If boards have different qualified pins for the same project, NSX reads each board’s metadata from a separate checkout during discovery. If upstream metadata changes, materialize it with sync and run lock again.

Without a usable prior lock there are no resolutions to preserve. Unknown selections fail before lock sections are written. With multiple targets, a selection need only exist in one requested target. If board A uses the selected module and board B uses only a different module from the same project, board B keeps its pin. A board-restricted operation preserves other board sections. NSX writes the combined lock after all requested boards succeed. If a later board fails, the previous lock stays intact. Caches and generated build inputs for earlier boards may already have changed. lock --check --update --module X uses the same selection rules without writing the lock or build glue. On a clean checkout it can read missing Git metadata in temporary directories to report upstream drift. Cache changes are still possible.

In the Python API, lock_app(modules=["X"]) alone does not request an update; pass update=True explicitly. CLI lock --module X implies --update. None or an empty list with update=True requests a full refresh. update_app locks all targets and syncs the default target, retaining its existing shared-source behavior.

Review the diff to nsx.lock before committing an update. It is the only record of what your firmware is built from.

If a module’s remote cannot be reached during a lock, NSX records the module as unresolved and keeps the last known content hash rather than dropping it. The app still builds from what is on disk, and the lock says plainly that the entry was not confirmed against upstream. Re-run nsx lock with network access to resolve it properly.