journal 2026-05-04

P68 AtomVM port — first implementation pass (scaffolding only)

p68atomvmbeamerlangbare-metalscaffoldingpartial

Follow-up to the AtomVM research session. This is the first code pass — directory layout, runtime glue, platform shim, build flow. Nothing has been built or run end-to-end. The point of this session was to commit a project skeleton with real source files that map onto AtomVM’s actual platform interface, so the next session is just “make cmake happy” instead of “decide where every file goes.”

What landed

projects/68_atomvm_port/ now has:

What does not work yet

PASS / FAIL / NOT RUN labels:

stepstatus
Directory + file layoutPASS
runtime/, port/, app/ source writtenPASS
vendor-fetch (clones AtomVM at pinned commit)NOT RUN
libatomvm-build (cmake + ninja)NOT RUN
beam (erlc hello.erl)NOT RUN — no erlc on this devshell
packbeamNOT RUN
Bare-metal ELF linkNOT RUN
Boot blob assemblyNOT RUN
Sim shows AtomVM banner over UARTNOT RUN

The test/Makefile is written under the assumption that:

Neither is true on this nix devshell yet. flake.nix will need pkgs.pkgsCross.riscv64-embedded.buildPackages.gcc, pkgs.cmake, pkgs.ninja, and pkgs.erlang added — left as a TODO for the user / next session.

The thing I expect to bite us first

The cmake invocation. AtomVM’s main CMakeLists.txt and its platform CMakeLists for rp2 jointly force a bunch of HAVE_* feature flags off (mkfifo, getcwd, pread, pwrite, ftruncate, …) because newlib declares them but doesn’t implement them. Our test/Makefile cmake invocation does not force any of those. First config pass will likely fail with “feature test compiled but won’t link.” We’ll need to mirror the rp2 forcing list, or factor it into a CMake toolchain file.

Second-most-likely problem: the riscv32-unknown-elf triple. nixpkgs pkgsCross.riscv64-embedded builds a riscv64-none-elf- prefix, not riscv64-elf-; our P43 Makefile uses riscv64-elf-gcc which works on this host because of an mise-installed toolchain. Need to verify and standardize.

Decision items not made yet

Next session

In rough order:

  1. Update flake.nix to add pkgs.erlang and the bare-metal RV32 newlib toolchain. Re-run make check-tools. Update 00_environment/TOOLCHAIN_REPORT.md.
  2. make vendor-fetch && make libatomvm-config. Capture cmake output. Iterate on HAVE_* feature flags until configure succeeds.
  3. make libatomvm-build. Capture link errors against newlib; the rp2 platform’s special-cases should be a guide.
  4. make beam && make packbeam. Confirm the magic bytes match what avmpack_is_valid expects.
  5. Try make all. Expect undefined refs at link time, fix in port/p68_sys.c or port/p68_libc.c.
  6. make verilator-run. First UART line should be the AtomVM banner. If we get to “Found startup beam: hello” we’ve already won.

What just happened?

Wrote a project skeleton that’s the right shape for the next session to push on. The platform shim mirrors AtomVM’s rp2/sys.c function-by-function, with everything that depends on Pico SDK or multi-hart hardware replaced by a stub or our chip’s MMIO. None of it compiles yet — the AtomVM source tree isn’t checked out, the toolchain isn’t in the devshell, and we haven’t tried cmake. But the layout is committed, so the next pass is a debugging exercise on a known-shape problem instead of a design exercise.