Skip to content

feat: add host-mounted SD card support, mirror display to host#715

Draft
ngxson wants to merge 15 commits intocrosspoint-reader:masterfrom
ngxson:xsn/virtual_sdcard
Draft

feat: add host-mounted SD card support, mirror display to host#715
ngxson wants to merge 15 commits intocrosspoint-reader:masterfrom
ngxson:xsn/virtual_sdcard

Conversation

@ngxson
Copy link
Contributor

@ngxson ngxson commented Feb 5, 2026

Summary

This PR is built upon the recently added HAL infrastructure. It aims to help developers to test and debug changes more quickly.

The "emulator" in this context is not a VM (not QEMU, see #500 for why), but more like the -v mounting option on Docker. Currently, it allows to:

  • Use .sdcard directory on host machine (or PC) as a virtual SD card
  • Forward frame buffer to be displayed on host

It requires #656 to work (hence why you see a lot of changes here)

Screen.Recording.2026-02-05.at.23.52.53.mp4

To try this out:

  1. Switch to the emulated pio environment
  2. Compile and upload the firmware
  3. Run python scripts/dev_server.py
  4. You may need to press the Reset button on the device
  5. Once the emulator is up, go to http://127.0.0.1:8090

Known bugs:

  • Not yet tested on windows / linux - only tested on mac
  • File operations are extremely slow compared to a real SD card
  • Sometime, both log and data are using the same Serial object. If 2 tasks (aka 2 threads) trying to use Serial.print at the same time, the emulator can crash. We should implement a proper logger in near future.

TODO:


AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? --> The python script and web UI are vibe-coded. C++ is hand-written.

@osteotek
Copy link
Member

osteotek commented Feb 6, 2026

Can this be used for automated testing, I wonder

@ngxson
Copy link
Contributor Author

ngxson commented Feb 6, 2026

I think this PR lays the foundation of communication between host <--> device, which may enable the development of auto or semi-auto testing tools in the future.

I imagine having a script that automatically compiles the firmware, flash it to the device, prepare a fake .sdcard with some epub/txt/etc inside, then tell the device to open these. The script can then validate the log, the frame buffer and/or the output cache file written to .crosspoint

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.

2 participants