From 54be3a041f66ef104084966d2a1c56364eba9846 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 30 Jun 2026 00:50:17 +0100 Subject: [PATCH] Export RPC + loader internals to apps The public rpc_* and loader_* APIs are already exported by stock firmware (RPC sessions, app data exchange, launch/enqueue/lock/menu); enable them explicitly via EXPORT_ENABLE so they stay on. Add the internal loader header set (loader_i.h, loader_menu.h, loader_queue.h, loader_applications.h) to the SDK so the internal Loader handle and the menu/queue helpers are reachable from apps. rpc_i.h is skipped: it depends on the protobuf headers which are not part of the app SDK. API version -> 87.3; firmware links. --- README.md | 9 +++++++++ build.sh | 31 ++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ecbfcb0..2e7ceb3 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,15 @@ symbol costs one API-table entry. An app can read and modify internal flash directly. **This can brick the device or wipe storage.** Enabled here for research; build with `EXPORT_FLASH=0 ./build.sh` to leave these disabled. +* **RPC + loader internals**: the public `rpc_*` and `loader_*` APIs (RPC + session open/feed/close, app data exchange, launching and enqueuing apps, + lock/unlock, showing the app menu) are already exported by stock firmware and + are the supported way to script the Flipper from a host or launch other apps; + this build enables them explicitly and adds the internal loader headers + (`loader_i.h`, `loader_menu.h`, `loader_queue.h`, `loader_applications.h`) so + the internal loader/menu/queue helpers are reachable too. `rpc_i.h` is not + exported because it depends on the protobuf headers, which are not in the SDK; + the public RPC API covers host scripting. `build.sh` also widens the GAP roles the firmware initialises (`GAP_PERIPHERAL_ROLE | GAP_CENTRAL_ROLE | GAP_OBSERVER_ROLE`) in diff --git a/build.sh b/build.sh index 0fbb2bd..5a12e9c 100755 --- a/build.sh +++ b/build.sh @@ -128,8 +128,37 @@ EXPORT_ENABLE+=' ^furi_hal_flash_ ' fi +# RPC + loader internals: the public rpc_* / loader_* APIs (session open/feed/ +# close, app data exchange, launch/enqueue/lock/menu) are already exported by +# stock firmware; enable them explicitly so they stay on, and add the internal +# loader header set so apps can reach the internal Loader handle and helpers. +EXPORT_ENABLE+=' +^rpc_ +^loader_ +' export EXPORT_ENABLE -if grep -q "^Function,?," "$API_CSV" || ! grep -qE "^Header,\+,.*ble_hci_le\.h" "$API_CSV"; then + +# Add the loader internal headers to the SDK (rpc_i.h is skipped: it pulls the +# protobuf headers, which are not part of the app SDK). +python3 - applications/services/loader/application.fam <<'PY' +import sys +p = sys.argv[1] +s = open(p).read() +want = ''' "loader.h", + "loader_i.h", + "loader_menu.h", + "loader_queue.h", + "loader_applications.h", + "firmware_api/firmware_api.h",''' +have = ''' "loader.h", + "firmware_api/firmware_api.h",''' +if "loader_i.h" not in s: + s = s.replace(have, want, 1) + open(p, "w").write(s) + print(">> patched " + p + ": loader internal headers added to SDK") +PY +if grep -q "^Function,?," "$API_CSV" || ! grep -qE "^Header,\+,.*ble_hci_le\.h" "$API_CSV" \ + || ! grep -qE "^Header,\+,.*loader_i\.h" "$API_CSV"; then # fbt notices the new headers, rewrites the csv with '?' entries and stops. echo ">> syncing API symbol table (expected to stop once)" ./fbt -j"${JOBS:-4}" "${FBT_ARGS[@]}" api_check || true