Skip to content

feat: support detached guest continuations - #10

Open
jadehawk wants to merge 1 commit into
Free-Ink:masterfrom
jadehawk:feat/guest-continuation
Open

jadehawk wants to merge 1 commit into
Free-Ink:masterfrom
jadehawk:feat/guest-continuation

Conversation

@jadehawk

@jadehawk jadehawk commented Nov 27, 2026 •

Copy link
Copy Markdown

Why this matters to users

Dessen applications should not be limited to readers with PSRAM just because they need Wi-Fi. A richer application can run successfully on an X3 or X4, yet fail as soon as it tries to pair with a service, retrieve a forecast, or fetch updated data. The application, display buffers, firmware and Wi-Fi/TLS stack all compete for the same internal RAM on these ESP32-C3 devices.

This was observed during actual application development. Simply reducing the guest allocation was not a satisfactory solution: in a controlled earlier build, 72 KiB corrupted dashboard text in the test fixtures, whereas 80 KiB passed the dashboard and pairing suites. Reducing avoidable firmware allocations helped, but did not eliminate the networking problem. CrossPoint PR crosspoint-reader/crosspoint-reader#4596 documents an isolated test with only 896 bytes free and a largest allocatable block of 404 bytes at Wi-Fi initialization.

The following measurements come from physical X3 and X4 tests on November 27, 2026, using an integrated prototype that releases an 83 KiB (84,992-byte) guest and restarts before native transport:

Device Free heap at suspended Wi-Fi start Largest block at Wi-Fi start HTTP result Largest block after Wi-Fi release
X3 115,772 B 106,484 B 200 40,948 B
X4 131,760 B 114,676 B 200 57,332 B

Both devices completed the network request. However, even after Wi-Fi was released, neither largest contiguous block could accommodate the original 84,992-byte guest. Total free memory alone does not tell the whole story; fragmentation matters when restoring the application.

The prototype addresses that by restoring the saved guest after a clean restart. From the user's perspective, the application can continue its original operation instead of crashing, closing, or forcing them to start over. A PSRAM-equipped device generally does not face the same guest-memory constraint.

This PR supplies the generic runtime mechanism needed for that approach: detach a parked guest, then resume it with the completed operation's result. It does not prescribe rebooting, store snapshots, or implement Wi-Fi. The integrated hardware measurements motivate the design; the isolated SDK PR verifies the continuation mechanism with a real guest in host tests. The corresponding firmware integration is still required.

Summary

Allow memory-constrained hosts to release a guest allocation while completing an asynchronous operation and resume the same guest afterward.

  • A host can suspend only at a parked async-call boundary. The runtime records pointer-free execution state, detaches guest RAM and services, and refuses to execute or poll while suspended.
  • A host restores the complete saved guest memory and execution state into a new allocation after placing async results in validated guest output buffers.
  • Resume immediately after the original ECALL with its final result; do not repeat the operation or zero guest memory.
  • Reject incompatible continuation metadata, invalid PC or memory bounds, pending results and restoration over a running guest.
  • The embedding host owns the memory allocation, request transfer/cancellation, persistence, integrity, authorization, app/runtime identity and replay prevention. No storage format, reboot policy or firmware-specific networking is introduced.

Validation

Full upstream make test passed with the pinned FreeInk SDK. A real guest parks on an async request, the host saves its full image, detaches and frees the original allocation, then reconstructs the guest in a fresh host and allocation. The test exercises success and transport failure, invalid metadata, no live overwrite, and verifies the original request is not polled or repeated.

No firmware build or persistence integration is included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant