feat(cli): Add support to NVRAM - #519
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 69fa431 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
📁 File Coverage (20 files)
|
brunomenezes
force-pushed
the
feat/cli-add-nvram-support
branch
from
August 18, 2026 18:29
391697a to
9a7432d
Compare
tuler
force-pushed
the
refactor/sdk-update-anvil-state-source
branch
from
September 2, 2026 20:57
edd91c9 to
0a66b6f
Compare
brunomenezes
force-pushed
the
feat/cli-add-nvram-support
branch
from
October 3, 2026 09:18
9a7432d to
2d4fe71
Compare
Base automatically changed from
refactor/sdk-update-anvil-state-source
to
prerelease/v2-alpha
October 3, 2026 12:33
brunomenezes
force-pushed
the
feat/cli-add-nvram-support
branch
from
October 5, 2026 19:38
2d4fe71 to
af62c9f
Compare
brunomenezes
marked this pull request as ready for review
October 5, 2026 19:44
tuler
approved these changes
Oct 5, 2026
tuler
approved these changes
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds NVRAM support to the CLI, declared in
cartesi.tomland translated into cartesi-machine's--nvramoption. Rebased ontoprerelease/v2-alpha, so the emulator 0.21.0 and rollups-node2.0.0-alpha.13groundwork from #529 is already in place — this PR no longer carries a merge blocker or a temporary commit.An NVRAM is a raw range of bytes exposed to the guest as a
/dev/uio*device. Unlike a flash drive it has no filesystem, no mount point and no page cache between the guest and the memory range, so writes are visible to the emulator immediately with no flush before snapshotting. That makes it the primitive for an application that wants a fixed region of bytes it canmmap()and persist across advance states.Features
[nvrams]incartesi.toml. Optional — a config without it emits no new flags and runs no new build steps. Each table needssizeorfilename(or both, which must agree exactly); sizes must be a multiple of 4Ki, at most 8 nvrams are supported, and labels cannot collide with drive labels since both share the DTB/aliasesnamespace. All validated at parse time, so a bad config fails before anything is built.Only the nvrams that need a backing image get built. A
sharedone is allocated zero-filled in.cartesi/; afilenameone is copied there, leaving the source untouched. A pristine nvram produces no artifact at all, since the emulator fills the range itself.The emulator version requirement is now enforced. feat(cli): cli changes to align with rollups-node [upcoming changes] #529 moved
requiredVersionto^0.21.0, but nothing read it at runtime anddoctornever checked the emulator.buildandshellnow verify before booting anddoctorreports it alongside the Docker checks, so a stale install givescartesi-machine 0.20.0 found, but ^0.21.0 is requiredinstead of a rawunrecognized option --nvram=...lua traceback. The check deliberately does not block when the version cannot be determined, since that also happens with Docker down or the binary missing.Fixes
forceDockeroption, rebuilding the options object and dropping it, so it reported the host binary's version instead of the SDK image's. This is why the existing assertion incartesi-machine.test.tspassed for anyone with a matching local install and failed in CI. Thecwdit needs for the Docker volume mount was also unset.Refactoring
bootMachineinto a purebuildMachineArgs, so the generated flags are unit-testable without spawning a machine.assertSupported(found), separating the decision from the subprocess that discovers it — testable directly, with no module mocking.Verification
Full suite — unit and integration — against the released
0.12.0-alpha.43images with no environment overrides: 235 pass / 1 skip / 0 fail across 19 files. The base measures 184/1/0, so this adds 51 tests and keeps it green; the skip is pre-existing (docker.test.tssqfs drive).tscreports no errors undersrc/.The nvram boot test runs rather than skips — it is gated on the emulator supporting
--nvram, andalpha.43does. It builds a throwaway application declaring a pristineinputand a sharedoutput, then asserts that only the nvrams needing an image get one, that the guest exposes one/dev/uio*per nvram, that labels resolve incartesi.tomlorder, and thatwritemmap/readmmapround-trips and reaches the host'soutput.raw— the assertion that actually provesshared.Version gate checked both ways:
cartesi doctorreports✔ Cartesi Machine 0.21.0, and a project pinned tosdk = "cartesi/sdk:0.12.0-alpha.41"(emulator 0.20.0) fails withUnsupportedVersionErrorrather than reaching the emulator.