Skip to content

PocketMage_SDK and ELF apps - #330

Merged
NellowTCS merged 23 commits into
mainfrom
pocketmage-sdk
Nov 1, 2026
Merged

NellowTCS merged 23 commits into
mainfrom
pocketmage-sdk

Conversation

@NellowTCS

@NellowTCS NellowTCS commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Description

Moves the PocketMage library out of the OS tree into its own SDK (PocketMage_SDK) and replaces the OTA-app model with ELF apps. Apps are built against the SDK and loaded in-process from the SD card. Installing or running one doesn't need a reflash or a reboot.

SDK split

  • lib/PocketMage is gone. The SDK now lives in TalismanDesign/PocketMage_SDK and is pulled in as a submodule at Code/PocketMageOS/lib/PocketMage_SDK.
  • Shared state (vspi/hspi/global_fs/prefs, settings, AppState/KBState, getBatteryVoltage) is now owned by the SDK. include/config.h is removed and globals.h pulls everything from the SDK header.
  • The OTA_APP / OTA_APP_FLAG switch is replaced by PM_TARGET_HOST (the OS) and PM_TARGET_APP (an app). The old OTA_APP: tags in the codebase are renamed to match.
  • i18n generation moved into the SDK (pocketmage_i18n/tools/gen_i18n.py). Catalogs merge in order: SDK base first, then the OS's own src/i18n.

ELF apps (elf_runner.cpp, elf_app_manifest.cpp)

  • An app is a .app.elf packed in a .tar with a <name>_ICON.bin and an optional .elfo overlay. The app loader installs it into one of 4 slots (/apps/slot1–/apps/slot4), tracked in NVS as ELFINFO1–ELFINFO4.
  • runElfApp() relocates the image with esp_elf_relocate_source() through a file-backed elf_source_t, so the whole .app.elf is never held in RAM. The app's main runs in its own task, and the OS loop and E-Ink task stand down while CurrentAppState == ELFAPP.
  • Exiting is just a return from main. The image is unloaded and the OS goes back to HOME without rebooting.
  • If there's a matching .elfo, it's loaded through elf_overlay, and the entry point is redirected through its stub block.
  • An optional app.properties file sets name, version, author and scope. scope limits which pm_* symbols the app can resolve. libc, libstdc++ and ESP-IDF stay reachable no matter the scope. A missing or unreadable manifest falls back to the ELF base name and doesn't block the app.
  • The host exports a curated symbol set (src/ELF_SYMS/esp_all_symbol.cpp), including pocketmage_sdk_version.
  • Legacy OTAINFO* / OTA* NVS keys are cleared when a slot is cleared, so old bin-era installs disappear on upgrade.

Submodules (.gitmodules)

  • lib/PocketMage_SDK → TalismanDesign/PocketMage_SDK
  • lib/elf_loader/esp-iot-solution → TalismanDesign/esp-iot-solution, pinned to pocketmage-pin-1.3.3 (this carries the elf_loader streaming source API)
  • lib/elf_overlay → TalismanDesign/elf_overlay

CI

  • Dropped the OTA_APP build env and its tar packaging step.
  • New example-app job: installs the SDK and the Xtensa toolchain (pinned and checksummed), builds the elf_overlay host tools, then builds and packs the SDK template app and runs pm check on it. It also checks that the ELF is little-endian and that the tar has the .app.elf, .elfo and icon.
  • i18n-check now regenerates from the stored catalogs and checks that the app catalog actually merged into the SDK tables.
  • Firmware and web-flasher workflows read app0 from partitions.csv instead of partitions_4APP.csv.
  • Checkouts use submodules: recursive.

Docs

  • New Docs/docs/guides/elf-apps.md covering building, packaging, installing, and what an app can rely on.
  • CONTRIBUTING.md no longer mentions pio run -e OTA_APP and points to the ELF apps guide.

Breaking changes

  • OTA apps (app.bin in a tar) are no longer supported. Existing installs need to be rebuilt against the SDK as .app.elf.
  • Fresh clones need git submodule update --init --recursive. Nothing builds without the SDK.
  • Anything that included config.h or the old lib/PocketMage headers directly needs to go through the SDK now.

Testing

  • Target: ESP32-S3, built through Arduino-ESP32 3.3.11 / ESP-IDF 5.5.5 (pioarduino 55.03.311)
  • PM_PRODUCTION: TODO
  • PM_BETA (no PSRAM): TODO
  • Installed and ran an ELF app from the loader: TODO
  • Scoped app.properties rejects out-of-scope pm_* symbols: TODO

All 9 CI checks pass (firmware builds for both envs, example-app, i18n-check, docs-build, CodeQL).

@NellowTCS NellowTCS changed the title migrate to separate SDK and ELF apps PocketMage_SDK and ELF apps Oct 31, 2026
@NellowTCS
NellowTCS requested a review from ashtf8 November 1, 2026 01:13
@NellowTCS
NellowTCS merged commit 6a00b7f into main Nov 1, 2026
9 checks passed
@NellowTCS
NellowTCS deleted the pocketmage-sdk branch November 1, 2026 04:06
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