Skip to content

Getting started

Custom firmware for the M5Stack M5PaperS3 (ESP32-S3, 4.7” e-ink, touch), plus a desktop simulator built from the same source. Apps: e-book reader, Home Assistant remote, WhatsApp and mail inbox (read through an encrypted phone companion), agenda, weather, Teletekst, Hacker News, daily games, chess, settings. Built for long battery life and calm, quick e-ink rendering.

Where things stand: STATUS. What is planned: ROADMAP. Why it is built this way: DECISIONS.

Terminal window
brew install sdl2-compat uv
uv tool install --python 3.12 platformio
make shot # builds the simulator, writes out/shot.png
make run # simulator window
make flash # build and flash a connected PaperS3
Terminal window
make sim # build the simulator
make shot # headless render to out/shot.png
make run # simulator window
make fw # build firmware
make flash # flash the device on /dev/cu.usbmodem*
make ota # firmware over Wi-Fi (Settings > Developer > Wireless development on; HOST=address)
# signed with ~/.config/paperos/ota-signing.key (make ota-key creates it; never commit it)
make monitor # device serial log
make device-shot # frame dump from the device over USB to out/device.png (tools/device.py: tap, swipe, log)
make view # live view of the device in a browser: click = tap, hold = long press, drag = swipe
# ARGS=--sim for the simulator, ARGS=--lan for a phone, ARGS=--wifi without USB
make cam-shot # webcam still of the panel to out/cam.png (tools/cam.py; CAMERA=name)
make cam-video # webcam video to out/cam.mp4 (SECONDS=5)
make cam-compare # device-shot + cam-shot + ghosting number per region, out/cam-diff.png
make cam-target # calibration screen on the device + still
make test # host unit tests (tests/unit, doctest)
make ui-test # headless UI scripts (tests/ui/*.script) against golden screenshots
make ui-accept # accept new screenshots as goldens (look at them first)
make gallery # out/gallery.html: every UI test screenshot
make check # sim + test + ui-test + fw: must pass before a change is done

tools/latency.py measures tap-to-driver latency on the device, tools/memory.py internal heap and PSRAM per app.

Secrets live on the SD card in /sd/paperos_config (HA_URL, HA_TOKEN, WIFI_SSID, WIFI_PASSWORD, …; the simulator reads sim-data/sd/paperos_config). The Home app’s dashboard is /sd/paperos/home.json; without one the firmware shows an example house (docs/apps/home.md). Neither is in the repository.

  • The ESP-IDF core is built from source (custom_sdkconfig in platformio.ini, D25): a change there rebuilds it (~5 min). PlatformIO’s own Python needs platformio==6.2.0 (not 6.2.0.post1). After changing custom_sdkconfig or board_build.f_*, delete sdkconfig.papers3 first. Flash and PSRAM run at 120 MHz (soak test >set psram-test N).
  • M5GFX is patched at build time (tools/patch_m5gfx.py, D24). After changing a patch: rm -rf .pio/libdeps/papers3/M5GFX, build, flash, tools/device.py set epd-selftest on, check the log says “identical”.
  • Firmware size (D31): no C++ exceptions, no iostreams. The device build has -fno-exceptions; a standard-library throw is an abort. Never include <sstream>, <iostream>, <fstream>, <regex> or <locale> in code the firmware links (100-160 KB each).
  • Shared code stays platform-free. src/core, src/ui, src/apps, src/hal never include Arduino.h, M5Unified.h, SDL.h or ESP-IDF headers. Only src/platform/* may.
  • Nothing draws to the panel except the DisplayManager. Widgets draw into the canvas and call invalidate(hint) (docs/DISPLAY.md).
  • No animation, no scrolling, no blocking on the UI thread (ctx.async / ctx.http).
  • Colours are pos::Color (uint32_t), only gray(0..15).
  • Every UI change is checked with a screenshot. Panel effects (ghosting, flash, gray levels) are checked with the webcam (tools/cam.py, docs/DISPLAY.md “Camera on the panel”).
  • src/gen/ is generated by tools/gen-assets.sh. Do not edit by hand.
  • Names in code, files and docs are English; text on the panel may be Dutch.

The docs are Markdown in docs/ and are also published as a site with navigation, search and diagrams: https://mattijsf.github.io/m5paper-os/. Good places to start: ARCHITECTURE for how the code fits together, DISPLAY for how the panel is driven, APPS for writing an app, and one spec per app in docs/apps/. The Android companion app is described in android/README.md, its Home Assistant package is ha/paperos_inbox.yaml.

To run the site locally: cd site && npm install && npm run dev (npm run build builds it into site/dist). The pages are generated from the Markdown, so edit docs/, not site/; a new doc goes into site/pages.mjs too.