llama.cpp on a jailbroken PS5: run any GGUF model natively on the console, starting with Qwen 3.8
Fleet worker in every build, a PC's GPU as a worker, own launch payload (#53)
Mert Cobanov3e4a71a509c3
diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.ymlindex 8934aa3..554cd39 100644--- a/.github/workflows/native-build.yml+++ b/.github/workflows/native-build.yml@@ -30,13 +30,8 @@ jobs:build/model_plan_testps5-title:- name: Full PS5 title cross-build and static package checks (${{ matrix.variant }})+ name: Full PS5 title cross-build and static package checksruns-on: ubuntu-24.04- strategy:- fail-fast: false- matrix:- # fleet: PS5LM_FLEET=1, the RPC worker build released as ps5lm-app-fleet (docs/FLEET.md)- variant: [default, fleet]timeout-minutes: 45container:# Official Debian image; trixie supplies compatible LLVM19/SPIRV host tools.@@ -49,7 +44,6 @@ jobs:DEBIAN_FRONTEND: noninteractiveBUILD_JOBS: '2'LLVM_CONFIG: /usr/bin/llvm-config-19- PS5LM_FLEET: ${{ matrix.variant == 'fleet' && '1' || '0' }}steps:- name: Public cross-build prerequisitesrun: |@@ -75,7 +69,7 @@ jobs:- name: State the full-build validation boundaryif: always()run: |- echo "## Native PS5 title cross-build (${{ matrix.variant }})" >> "$GITHUB_STEP_SUMMARY"+ echo "## Native PS5 title cross-build" >> "$GITHUB_STEP_SUMMARY"echo 'Builds the pinned public SDK/runtime, patched RADV, UI and app title; checks ELF/FSELF structure.' >> "$GITHUB_STEP_SUMMARY"echo 'Build tools and checksum-verified public SDK/driver dependencies download; no model or proprietary firmware is needed.' >> "$GITHUB_STEP_SUMMARY"echo 'This is static cross-build validation, not console boot, Vulkan execution, PS5 emulation or model inference.' >> "$GITHUB_STEP_SUMMARY"diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5ba68da..6a0729d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,22 @@ Versions follow [semver](https://semver.org). The app's version is set in`v<version>` and ships `ps5lm-app-v<version>.zip` (see `scripts/release-app.sh`).v0.1.x are the upstream payload releases by cobanov.+## [Unreleased]++### Changed+- **The fleet worker is part of the app.** There is no separate fleet build or+ `ps5lm-app-fleet` zip any more: every PS5LM can be a fleet worker, and stays the normal app+ unless `/data/PS5LM/fleet-worker.txt` asks for one, as before. `PS5LM_FLEET` is gone from+ `scripts/build-app.sh`, and CI builds one title again.++### Added+- **A PC's GPU as a fleet worker.** `PS5LM_FLEET_GPU=metal` (or `cuda`, `vulkan`)+ `scripts/build-fleet-host.sh` adds that backend, so `ggml-rpc-server -d MTL0` serves the PC's+ GPU next to the consoles. The default host build stays CPU only.+- `scripts/ps5lm-app.sh launch` works again, with PS5LM's own launcher payload+ (`ps5/app/launch_app.c`, built by `build-app.sh`) instead of the removed+ ps5-homebrew-dev-protocol.+## [0.10.0] - 2026-11-01### Addeddiff --git a/README.md b/README.mdindex fb7d6e0..127cf37 100644--- a/README.md+++ b/README.md@@ -174,10 +174,10 @@ ggml-vulkan on [PS5_Vulkan](https://github.com/mihawk-99/PS5_Vulkan)'s RADV, bui[Fleet](docs/FLEET.md) splits one dense `llama`/`qwen2` GGUF across severalconsoles over llama.cpp's RPC, controlled by one PC: one model across theirmemory, not a copy on each, so a model too large for one PS5 can run on two or-more. The PC can add its CPU as another worker. It is a separate build of the app, released as-`ps5lm-app-fleet-vX.Y.Z.zip` next to the normal zip; the normal app has no RPC-code. Two-worker CPU inference is tested in CI, the fleet title cross-builds-there, and a PS5 worker has served a model together with a PC, but it is+more. The PC can add its CPU or GPU as another worker. The worker is part of the+app and starts only when `/data/PS5LM/fleet-worker.txt` asks for it (v0.10.0 had+it in a separate `ps5lm-app-fleet` zip). Two-worker CPU inference is tested in+CI, and a PS5 worker has served a model together with a PC, but it is**experimental**: Qwen 3.8's `qwen35` layout is not admitted bythis first planner yet, and RPC has no authentication, so it belongs on anisolated network you trust. See [validation and limits](docs/FLEET-VALIDATION.md).diff --git a/docs/BUILDING.md b/docs/BUILDING.mdindex 4f00eea..c9db942 100644--- a/docs/BUILDING.md+++ b/docs/BUILDING.md@@ -91,8 +91,9 @@ PS5_HOST=<console IP> scripts/ps5lm-app.sh screenshot out.bmp```- The app closes itself on request (`/data/PS5LM/quit`), so nothing is killed while it draws.- Launching uses ps5-homebrew-dev-protocol's launch payload, cloned into `.deps/src`. A title started- any other way without a user (shsrv's `launch`) is ended by the system after about 20 seconds.+ Launching sends `build/app-ps5/launch-PPSA99575.elf` (`ps5/app/launch_app.c`, built by+ `build-app.sh`) to elfldr; it starts the title for the foreground user with `sceLncUtilLaunchApp`.+ A title started without a user (shsrv's `launch`) is ended by the system after about 20 seconds.- `/data/PS5LM/app-args.txt` (one argument a line) overrides the planner. `/data/PS5LM/env.txt` (one`NAME=value` a line) sets `RADV_`, `MESA_`, `ACO_`, `GGML_` and `LLAMA_` switches before the GPU opens.- The artwork comes from SVG: `scripts/render-artwork.sh` renders the icon and the home screendiff --git a/docs/CI.md b/docs/CI.mdindex c0d53e7..3ab5e70 100644--- a/docs/CI.md+++ b/docs/CI.md@@ -9,9 +9,8 @@ are cancelled. There are two independent jobs:GGUF `model_plan_test.cpp`, and regressions for dashboard compiler job limitsand propagation of failed background compilers. No submodule or model downloadis needed for these checks.-- **Full PS5 title cross-build** (45-minute limit, two compiler jobs), once for- each build variant: `default`, and `fleet` with `PS5LM_FLEET=1` (the RPC worker- build, [FLEET.md](FLEET.md)). Each bootstraps the public SDK, reproduces+- **Full PS5 title cross-build** (45-minute limit, two compiler jobs), with the+ fleet RPC worker in it ([FLEET.md](FLEET.md)). It bootstraps the public SDK, reproducesclean-room `libc.prx`, builds patched RADV and llama-server/native dashboard,packages the title folder, and inspects its ELF/FSELF structure and integrity.It does not execute the resulting title.diff --git a/docs/FLEET-VALIDATION.md b/docs/FLEET-VALIDATION.mdindex ec5e859..953b4b0 100644--- a/docs/FLEET-VALIDATION.md+++ b/docs/FLEET-VALIDATION.md@@ -1,9 +1,10 @@# Fleet validation — 2026-10-21–22> A record of the original validation. Since then the RPC patches moved to-> `patches/fleet/` and the worker to the `PS5LM_FLEET=1` build, and+> `patches/fleet/`, the worker became part of every app build (from v0.11.0;+> v0.10.0 had a separate `PS5LM_FLEET=1` build), and> `scripts/test-fleet-native.sh` and `test-fleet-title.sh` were folded into-> `PS5LM_FLEET=1 scripts/test-native-build.sh` ([FLEET.md](FLEET.md)).+> `scripts/test-native-build.sh` ([FLEET.md](FLEET.md)).## Resultdiff --git a/docs/FLEET.md b/docs/FLEET.mdindex eb67c2e..d38dde5 100644--- a/docs/FLEET.md+++ b/docs/FLEET.md@@ -1,38 +1,39 @@# Experimental fleet: one model, several PS5 workers-**Status: host controller and an opt-in PS5 worker in a separate fleet build of-the title; CPU RPC inference and the fleet title's cross-build are tested in CI.-On hardware, one PS5 worker has served one model together with a Linux CPU-worker (2026-11-01, below); more consoles at once are not validated by the-maintainers.** This is not a performance claim. The default-PS5LM title has no RPC code; releases ship the fleet build as its own zip,-`ps5lm-app-fleet-vX.Y.Z.zip`.+**Status: host controller, and a PS5 worker that is part of the app and starts+only when you opt in; CPU RPC inference and the title's cross-build are tested+in CI. On hardware, one PS5 worker has served one model together with a Linux+CPU worker (2026-11-01, below); more consoles at once are not validated by the+maintainers.** This is not a performance claim. Up to v0.10.0 the worker was a+separate build, `ps5lm-app-fleet-v0.10.0.zip`; from v0.11.0 every PS5LM has it.What it is for: a model that does not fit in one console's memory runs acrossseveral, each holding a run of its layers. Every token passes through everyworker over the network, so it is not faster than one console; it makes larger-models possible. Workers are PS5s; a PC can also join with its CPU (the host-build has no GPU backend, so a PC's GPU cannot be a worker yet).+models possible. Workers are PS5s; a PC can join too, with its CPU or, with a+GPU host build (`PS5LM_FLEET_GPU`), its GPU.## Quick start-1. **On each PS5:** install `ps5lm-app-fleet-vX.Y.Z.zip` from the- [releases](https://github.com/cobanov/PS5LM/releases) like the normal app,- then put `/data/PS5LM/fleet-worker.txt` on it over FTP: the console's own IP+1. **On each PS5:** PS5LM v0.11.0 or later (for v0.10.0, its+ `ps5lm-app-fleet-v0.10.0.zip` from the+ [releases](https://github.com/cobanov/PS5LM/releases)), then put `/data/PS5LM/fleet-worker.txt` on it over FTP: the console's own IPand a port below 40000, then the acknowledgement line([Configure workers](#configure-workers-only-after-building-and-validating-the-title)).Start PS5LM: it shows the worker screen instead of the dashboard.2. **On a Linux or macOS PC on the same network:** `git submodule update --init--depth 1 third_party/llama.cpp`, then `scripts/build-fleet-host.sh`- ([Host](#host-cpu--rpc)).+ ([Host](#host-cpu--rpc)). To add the PC's GPU as a worker, build with+ `PS5LM_FLEET_GPU=metal` (or `cuda`, `vulkan`) and start+ `build/fleet-host/bin/ggml-rpc-server -H <PC IP> -p 30053 -d MTL0`+ (`CUDA0`, `Vulkan0`), then list it as one more node.3. **Nodes:** copy `fleet/nodes.example.json` and list each console's`IP:port` with its memory budget.4. **Plan, then serve:** `python3 -m fleet plan --model model.gguf --nodesnodes.json` shows which layers go where; `python3 -m fleet serve ...--ack-insecure-rpc` starts one llama-server on `127.0.0.1:8081` of the PC([Plan and serve](#plan-and-serve-from-the-controller)).-5. **Back to normal:** delete `fleet-worker.txt` and restart PS5LM, or install- the normal zip again.+5. **Back to normal:** delete `fleet-worker.txt` and restart PS5LM.Dense `llama` and `qwen2` GGUFs only; Qwen 3.5/3.8 (`qwen35`) is refused. RPChas no authentication: keep workers on a network you trust. On macOS, the app@@ -136,12 +137,14 @@ scripts/build-fleet-host.sh```The host script applies the repository's numbered llama.cpp patches and-`patches/fleet`, disables-GPU backends and RDMA, and builds the RPC tools plus the upstream multi-server-regression. It does not fetch model weights or start a listener. Set `CMAKE`,+`patches/fleet`, disables RDMA, and builds the RPC tools plus the upstream+multi-server regression. It is CPU only unless `PS5LM_FLEET_GPU` is `metal`,+`cuda` or `vulkan`; then `ggml-rpc-server -d MTL0` (`CUDA0`, `Vulkan0`) serves+that GPU as a worker. The controller always names its RPC devices explicitly,+so a GPU in the host build is used only through a worker you start and list. It does not fetch model weights or start a listener. Set `CMAKE`,`NINJA` or `CMAKE_BUILD_PARALLEL_LEVEL` for local tool locations/resources.-### PS5 worker title — the fleet build+### PS5 worker — part of the appFollow [BUILDING.md](BUILDING.md) to prepare PS5_Vulkan, its pinned PS5_Mesa andPS5_PayloadSDK forks, patched RADV, native packaging tool, `libc.prx` and the@@ -149,22 +152,19 @@ checksum-pinned ps5-opengl SDK. Then:```shgit submodule update --init --depth 1-PS5LM_FLEET=1 scripts/build-app.sh+scripts/build-app.sh```-`PS5LM_FLEET=1` is what makes it the fleet build: llama.cpp with `GGML_RPC=ON`-(`GGML_RPC_RDMA=OFF`) and `patches/fleet` on top of the numbered patches, and-the title with `fleet_worker.cpp` and the worker's startup mode in `main.cpp`.-Without it, `scripts/build-app.sh` builds the default title with none of that,-and takes `patches/fleet` back out of the llama.cpp checkout if a fleet build-left it there. Both variants have the same title ID, so installing one replaces-the other; settings and models in `/data/PS5LM` stay. `scripts/release-app.sh`-names the zip after the variant the last build made.--CI builds both variants on every pull request: `native-build.yml` runs-`scripts/test-native-build.sh` once as is and once with `PS5LM_FLEET=1`, each-with the structural ELF/FSELF checks ([CI.md](CI.md)). That proves the fleet-title links, not that it boots, that its Vulkan results are right, or that a+Every build has the worker: llama.cpp with `GGML_RPC=ON` (`GGML_RPC_RDMA=OFF`)+and `patches/fleet` on top of the numbered patches, and the title with+`fleet_worker.cpp` and the worker's startup mode in `main.cpp`. It stays idle,+with no listener, unless `/data/PS5LM/fleet-worker.txt` exists. Up to v0.10.0+this was a separate `PS5LM_FLEET=1` build and zip.++CI builds the title on every pull request (`native-build.yml`,+`scripts/test-native-build.sh`, with the structural ELF/FSELF checks,+[CI.md](CI.md)). That proves the worker links, not that it boots, that its+Vulkan results are right, or that areal multi-console run works. QEMU is not a substitute: its[x86 system models](https://www.qemu.org/docs/master/system/target-i386.html)and [Linux/BSD user modes](https://www.qemu.org/docs/master/user/main.html)@@ -177,6 +177,12 @@ with blocks 0–22 on the PS5 and block 23 plus the output on the PC, andanswered a chat request correctly. This run found the 40000 port limit below;the worker writes its own and ggml's messages to `/data/PS5LM/app.log`.+The same day, with the worker in the normal app (this build) and a Mac's GPU:+`ggml-rpc-server -d MTL0` from a `PS5LM_FLEET_GPU=metal` host build on an Apple+M-series Mac, the controller on the Linux PC. Blocks 0–22 on the PS5, block 23+and the output on the Mac's GPU; it answered correctly at 13 tokens/s (7.4 with+the PC's CPU in that place). One small model, so not a performance figure.+## Configure workers (only after building and validating the title)On each console, explicitly create `/data/PS5LM/fleet-worker.txt` containingdiff --git a/ps5/app/launch_app.c b/ps5/app/launch_app.cnew file mode 100644index 0000000..bc2cb63--- /dev/null+++ b/ps5/app/launch_app.c@@ -0,0 +1,41 @@+/* A payload that starts an installed title, for scripts/ps5lm-app.sh launch:+ * elfldr runs it, it asks the system to launch TITLE_ID for the foreground+ * user and exits. elfldr passes no arguments, so the title ID is built in+ * (scripts/build-app.sh makes build/app-ps5/launch-<TITLE_ID>.elf).+ *+ * SPDX-License-Identifier: GPL-3.0-or-later */+#include <stdint.h>+#include <stdio.h>+#include <string.h>++#ifndef TITLE_ID+#error "build with -DTITLE_ID=\"PPSA99575\""+#endif++typedef struct {+ uint32_t sz;+ uint32_t user_id;+ uint32_t app_opt;+ uint64_t crash_report;+ uint32_t check_flag;+} LncAppParam;++int sceUserServiceInitialize(void *);+int sceUserServiceGetForegroundUser(int *);+int sceLncUtilLaunchApp(const char *, const char **, LncAppParam *);++int main(void) {+ int user = -1;+ sceUserServiceInitialize(0);+ if (sceUserServiceGetForegroundUser(&user) != 0) {+ puts("launch-app: no foreground user");+ return 1;+ }+ LncAppParam param;+ memset(¶m, 0, sizeof param);+ param.sz = sizeof param;+ param.user_id = (uint32_t) user;+ int rc = sceLncUtilLaunchApp(TITLE_ID, NULL, ¶m);+ printf("launch-app: %s -> 0x%08x\n", TITLE_ID, (unsigned) rc);+ return rc < 0;+}diff --git a/ps5/app/main.cpp b/ps5/app/main.cppindex 5f2fe19..de4897e 100644--- a/ps5/app/main.cpp+++ b/ps5/app/main.cpp@@ -41,9 +41,7 @@#include "dashboard.hpp"#include "fetch.hpp"-#if PS5LM_FLEET // the fleet build only: PS5LM_FLEET=1 scripts/build-app.sh#include "fleet_worker.hpp"-#endif#include "market.hpp"#include "display.hpp"#include "ggml-backend.h"@@ -110,9 +108,7 @@ constexpr const char * kEnv = "/data/PS5LM/env.txt"; // driver and ggmlconstexpr const char * kTextOnly = "/data/PS5LM/text-only"; // the last load's projector failed: load without it onceconstexpr const char * kQuit = "/data/PS5LM/quit";constexpr const char * kSettings = "/data/PS5LM/settings.json";-#if PS5LM_FLEETconstexpr const char * kFleetWorker = "/data/PS5LM/fleet-worker.txt";-#endifconstexpr const char * kScratch = "/data/PS5LM/scratch";// The file tools only: a title cannot start processes (no shell command).constexpr const char * kTools = "read_file,write_file,edit_file,file_glob_search,grep_search,get_info";@@ -713,7 +709,6 @@ int main(int, char **) {}sceSystemServiceHideSplashScreen();-#if PS5LM_FLEET// Fleet is a mutually exclusive startup mode, not another local model.// In particular, do not start StatsCollector (its HTTP probes), model// auto-load, downloads, or controller/file commands that could restart or@@ -777,7 +772,6 @@ int main(int, char **) {}}}-#endifStatsCollector stats;stats.start(kPort);diff --git a/scripts/build-app.sh b/scripts/build-app.shindex 0a16059..32c3d17 100755--- a/scripts/build-app.sh+++ b/scripts/build-app.sh@@ -10,8 +10,6 @@## scripts/build-app.sh configure, build and package# PS5LM_PREBUILT_UI=OFF ... omit the optional downloaded browser UI-# PS5LM_FLEET=1 ... the fleet build: adds ggml's RPC backend,-# patches/fleet and the RPC worker (docs/FLEET.md)# CMAKE_BUILD_PARALLEL_LEVEL also bounds the native dashboard compilers.set -euo pipefail@@ -29,8 +27,6 @@ headers="$root/.deps/ps5-vk-headers"glsdk=${PS5_OPENGL_SDK:-$(bash "$root/third_party/ps5-homebrew-ui/tools/fetch-opengl-sdk.sh")}sce_sys="$root/ps5/app/sce_sys"param="$sce_sys/param.json"-fleet=${PS5LM_FLEET:-0}-[[ $fleet == 0 || $fleet == 1 ]] || { echo "build-app: PS5LM_FLEET must be 0 or 1" >&2; exit 2; }for f in "$archive" "$tool" "$vk/runtime/libc.prx" "$sdk/bin/prospero-lld" "$glsdk/lib/libPS5OpenGL.a"; do[ -e "$f" ] || { echo "build-app: missing $f" >&2; exit 2; }@@ -62,24 +58,12 @@ set(SPIRV-Headers_FOUND TRUE)EOFfi-# The PS5 changes to llama.cpp (patches/), as scripts/build-llama.sh applies them.-# patches/fleet goes on top only for a fleet build; a default build after a fleet-# one takes it back out first, last patch first.-fleet_patches=("$root"/patches/fleet/*.patch)-if [[ $fleet == 0 ]]; then- for (( i = ${#fleet_patches[@]} - 1; i >= 0; i-- )); do- p=${fleet_patches[i]}- if git -C "$llama" apply --reverse --check "$p" 2>/dev/null; then git -C "$llama" apply --reverse "$p"; fi- done-fi-for p in "$root"/patches/*.patch; do+# The PS5 changes to llama.cpp (patches/), as scripts/build-llama.sh applies them,+# then patches/fleet for the RPC worker (docs/FLEET.md), the same set the fleet+# host build applies.+for p in "$root"/patches/*.patch "$root"/patches/fleet/*.patch; dogit -C "$llama" apply --reverse --check "$p" 2>/dev/null || git -C "$llama" apply "$p"done-if [[ $fleet == 1 ]]; then- for p in "${fleet_patches[@]}"; do- git -C "$llama" apply --reverse --check "$p" 2>/dev/null || git -C "$llama" apply "$p"- done-fi# ftpsrv (drakmor's 1.16-ng-stable), PS5LM's copy: a payload the app sends to# elfldr when no ftpsrv answers (connect_ftp_writer in ps5/app/ftp_writer.hpp).@@ -104,7 +88,7 @@ cmake -S "$llama" -B "$out/llama" -G Ninja \-DCMAKE_C_FLAGS="$flags" -DCMAKE_CXX_FLAGS="$cxxflags" \-DBUILD_SHARED_LIBS=OFF -DGGML_BACKEND_DL=OFF -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=OFF \-DGGML_AVX=ON -DGGML_AVX2=ON -DGGML_FMA=ON -DGGML_F16C=ON -DGGML_BMI2=ON -DGGML_AVX512=OFF \- -DGGML_OPENMP=OFF -DGGML_CCACHE=OFF -DGGML_VULKAN=ON -DGGML_RPC="$([[ $fleet == 1 ]] && echo ON || echo OFF)" -DGGML_RPC_RDMA=OFF \+ -DGGML_OPENMP=OFF -DGGML_CCACHE=OFF -DGGML_VULKAN=ON -DGGML_RPC=ON -DGGML_RPC_RDMA=OFF \-DVulkan_INCLUDE_DIR="$headers/include" -DVulkan_LIBRARY="$archive" \-DVulkan_GLSLC_EXECUTABLE="$(command -v glslc)" -DSPIRV-Headers_DIR="$headers/cmake" \-DMATH_LIBRARY=SceLibcInternal \@@ -120,15 +104,11 @@ obj="$out/obj"mkdir -p "$obj" "$out/stubs"cxx() { "$root/ps5/app/ps5cxx" -std=c++17 -O2 -ffunction-sections -fdata-sections "$@"; }cxx -std=c++20 -fexceptions -fcxx-exceptions -frtti -I "$headers/include" -I "$llama/ggml/include" -I "$root/third_party/ps5-homebrew-ui/src" \- -I "$glsdk/include" -DGL_GLEXT_PROTOTYPES=1 -DPS5LM_FLEET="$fleet" \+ -I "$glsdk/include" -DGL_GLEXT_PROTOTYPES=1 \-c "$root/ps5/app/main.cpp" -o "$obj/main.o"cxx -fexceptions -fcxx-exceptions -c "$root/ps5/app/model_plan.cpp" -o "$obj/model_plan.o"-fleet_objects=()-if [[ $fleet == 1 ]]; then- cxx -fexceptions -fcxx-exceptions -I "$llama/ggml/include" \- -c "$root/ps5/app/fleet_worker.cpp" -o "$obj/fleet_worker.o"- fleet_objects=("$obj/fleet_worker.o")-fi+cxx -fexceptions -fcxx-exceptions -I "$llama/ggml/include" \+ -c "$root/ps5/app/fleet_worker.cpp" -o "$obj/fleet_worker.o"cxx -std=c++20 -fexceptions -fcxx-exceptions -I "$llama/vendor" -c "$root/ps5/app/settings.cpp" -o "$obj/settings.o"cxx -std=c++20 -fexceptions -fcxx-exceptions -c "$root/ps5/app/fetch.cpp" -o "$obj/fetch.o"cxx -std=c++20 -fexceptions -fcxx-exceptions -I "$llama/vendor" -c "$root/ps5/app/market.cpp" -o "$obj/market.o"@@ -232,7 +212,7 @@ mapfile -t libs < <(find "$out/llama" -name '*.a' | sort)"$sdk/bin/prospero-lld" "${radv_linker_script[@]}" --eh-frame-hdr "${radv_link_flags[@]}" \--version-script "$vk/tooling/native/app-symbols.map" --exclude-libs=ALL \-e _start -o "$out/llvm-pie.elf" \- "$obj/app_crt.o" "$obj/app_cpp_runtime.o" "$obj/main.o" "$obj/display.o" "$obj/model_plan.o" "${fleet_objects[@]}" "$obj/settings.o" "$obj/fetch.o" "$obj/market.o" "$obj/ftp_writer.o" "$obj/activity.o" "$obj/sha256.o" "$obj/dashboard.o" "$obj/stats.o" \+ "$obj/app_crt.o" "$obj/app_cpp_runtime.o" "$obj/main.o" "$obj/display.o" "$obj/model_plan.o" "$obj/fleet_worker.o" "$obj/settings.o" "$obj/fetch.o" "$obj/market.o" "$obj/ftp_writer.o" "$obj/activity.o" "$obj/sha256.o" "$obj/dashboard.o" "$obj/stats.o" \--start-group "${libs[@]}" "$obj/libps5lm_kit.a" "$obj/libps5app_compat.a" "$out/gl/libps5lm_gl.a" --end-group \"$out/stubs/libSceAgc.so" "$out/stubs/libSceAgcDriver.so" \"${radv_link_inputs[@]}" \@@ -243,6 +223,9 @@ mapfile -t libs < <(find "$out/llama" -name '*.a' | sort)--companion-sdk 0x08050001 --file-name eboot.elftitle_id=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["titleId"])' "$param")+# The payload scripts/ps5lm-app.sh launch sends to elfldr to start the title.+PS5_PAYLOAD_SDK="$sdk" "$sdk/bin/prospero-clang" -Wall -Werror -O2 -DTITLE_ID="\"$title_id\"" \+ -o "$out/launch-$title_id.elf" "$root/ps5/app/launch_app.c" -lSceSystemService -lSceUserServiceapp="$out/title/$title_id"rm -rf -- "$app"mkdir -p "$app/sce_sys" "$app/sce_module"@@ -292,6 +275,4 @@ printf '%s\n' "ftpsrv by John Törnblom and drakmor, GPL-3.0-or-later: https://g"with PS5LM's patches/ftpsrv/0001-loopback-only-for-ps5lm.patch: 127.0.0.1:2123 only, as ps5lm-ftpsrv." \> "$app/payloads/ps5lm-ftpsrv-NOTICE.txt""$tool" self --inspect --file "$app/eboot.bin" > /dev/null-# release-app.sh names the zip after the variant this build made.-if [[ $fleet == 1 ]]; then echo fleet; else echo default; fi > "$out/variant"-echo "build-app: $app ($(stat -c %s "$app/eboot.bin") bytes, $(cat "$out/variant"))"+echo "build-app: $app ($(stat -c %s "$app/eboot.bin") bytes)"diff --git a/scripts/build-fleet-host.sh b/scripts/build-fleet-host.shindex 7d8b4e5..95db589 100755--- a/scripts/build-fleet-host.sh+++ b/scripts/build-fleet-host.sh@@ -1,11 +1,16 @@#!/usr/bin/env bash-# Build the CPU-only host/controller and localhost RPC test workers.+# Build the host/controller and RPC workers: CPU only by default.+# PS5LM_FLEET_GPU=metal|cuda|vulkan adds that GPU backend, so ggml-rpc-server can+# serve this PC's GPU as a worker next to the consoles (docs/FLEET.md).set -euo pipefailroot="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"llama="$root/third_party/llama.cpp"out="${PS5LM_FLEET_BUILD:-$root/build/fleet-host}"cmake_bin="${CMAKE:-cmake}"ninja_bin="${NINJA:-ninja}"+gpu=${PS5LM_FLEET_GPU:-none}+case $gpu in none|metal|cuda|vulkan) ;; *) echo "build-fleet-host: PS5LM_FLEET_GPU must be none, metal, cuda or vulkan" >&2; exit 2 ;; esac+on() { [ "$gpu" = "$1" ] && echo ON || echo OFF; }for tool in "$cmake_bin" "$ninja_bin" python3 git; docommand -v "$tool" >/dev/null || { echo "build-fleet-host: missing $tool" >&2; exit 2; }done@@ -19,8 +24,8 @@ if [ "$actual" != "$expected" ]; thenecho "build-fleet-host: llama.cpp revision $actual differs from pinned $expected" >&2exit 2fi-# Keep the same patch set on the controller and the fleet title (PS5LM_FLEET=1-# scripts/build-app.sh), with no protocol fork.+# Keep the same patch set on the controller and the PS5 title (scripts/build-app.sh+# applies patches/fleet too), with no protocol fork.for patch in "$root"/patches/*.patch "$root"/patches/fleet/*.patch; dogit -C "$llama" apply --reverse --check "$patch" 2>/dev/null || git -C "$llama" apply "$patch"done@@ -35,14 +40,14 @@ fi-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF \-DGGML_RPC=ON -DGGML_RPC_RDMA=OFF -DGGML_BACKEND_DL=OFF \-DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=OFF \- -DGGML_CUDA=OFF -DGGML_VULKAN=OFF -DGGML_METAL=OFF \+ -DGGML_CUDA="$(on cuda)" -DGGML_VULKAN="$(on vulkan)" -DGGML_METAL="$(on metal)" \-DGGML_OPENMP=OFF -DGGML_CCACHE=OFF \-DLLAMA_OPENSSL=OFF -DLLAMA_BUILD_COMMON=ON -DLLAMA_BUILD_TESTS=ON \-DLLAMA_BUILD_EXAMPLES=OFF -DLLAMA_BUILD_TOOLS=ON -DLLAMA_BUILD_SERVER=ON \-DLLAMA_BUILD_APP=OFF -DLLAMA_BUILD_UI=OFF -DLLAMA_USE_PREBUILT_UI=OFF"$cmake_bin" --build "$out" --parallel "${CMAKE_BUILD_PARALLEL_LEVEL:-2}" \--target llama-server llama-cli ggml-rpc-server test-rpc-multi-server-python3 - "$out" "$actual" "$(git -C "$root" rev-parse HEAD)" "$root" <<'PY_MANIFEST'+python3 - "$out" "$actual" "$(git -C "$root" rev-parse HEAD)" "$root" "$gpu" <<'PY_MANIFEST'import hashlibimport jsonfrom pathlib import Path@@ -54,7 +59,7 @@ out = Path(sys.argv[1]).resolve()"binary": str(out / "bin/llama-server"),"server_sha256": hashlib.sha256((out / "bin/llama-server").read_bytes()).hexdigest(),"rpc_binary": str(out / "bin/ggml-rpc-server"),- "backends": ["CPU", "RPC"],+ "backends": ["CPU", "RPC"] + ([] if sys.argv[5] == "none" else [sys.argv[5].upper()]),"applied_patches": {str(p.relative_to(Path(sys.argv[4]) / "patches")): hashlib.sha256(p.read_bytes()).hexdigest()for p in sorted((Path(sys.argv[4]) / "patches").glob("*.patch"))+ sorted((Path(sys.argv[4]) / "patches/fleet").glob("*.patch"))},diff --git a/scripts/ps5lm-app.sh b/scripts/ps5lm-app.shindex b0f08e2..c31d9ef 100755--- a/scripts/ps5lm-app.sh+++ b/scripts/ps5lm-app.sh@@ -3,7 +3,7 @@## scripts/ps5lm-app.sh close ask the running app to end itself, and wait# scripts/ps5lm-app.sh deploy upload build/app-ps5/title/<TITLE_ID>-# scripts/ps5lm-app.sh launch start it (ps5-homebrew-dev-protocol's launch payload)+# scripts/ps5lm-app.sh launch start it (build/app-ps5/launch-<TITLE_ID>.elf, from build-app.sh)# scripts/ps5lm-app.sh cycle close, deploy, launch# scripts/ps5lm-app.sh screenshot [file] what the TV shows, as a BMP# scripts/ps5lm-app.sh load <model path> switch the model, as the library does@@ -23,7 +23,6 @@ host=${PS5_HOST:?set PS5_HOST to the console IP}ftp="ftp://$host:${PS5_FTP_PORT:-2121}"title=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["titleId"])' "$root/ps5/app/sce_sys/param.json")app="$root/build/app-ps5/title/$title"-protocol=${PS5_PROTOCOL:-$root/.deps/src/ps5-homebrew-dev-protocol}close() {printf 'quit\n' | curl -sS -T - "$ftp/data/PS5LM/quit"@@ -50,12 +49,10 @@ deploy() {}launch() {- # The protocol's script builds the payload; it is sent with socat, as the- # other scripts here do (the script's own sender needs GNU nc's -q).- local tmp=${TMPDIR:-/tmp}- PS5_PAYLOAD_SDK=${PS5_PAYLOAD_SDK:-$root/.deps/ps5-payload-sdk} PS5_CONTROLLER_COMPILE_ONLY=1 \- bash "$protocol/scripts/send-controller.sh" launch "$title" "$host" "${PS5_PORT:-9021}" > /dev/null- socat -u "FILE:$tmp/ps5-homebrew-protocol/launch-$title.elf" "TCP:$host:${PS5_PORT:-9021}"+ # ps5/app/launch_app.c, built next to the app; elfldr runs it, it starts the title.+ local elf="$root/build/app-ps5/launch-$title.elf"+ [ -f "$elf" ] || { echo "ps5lm-app: build it first (scripts/build-app.sh makes $elf)" >&2; exit 1; }+ socat -u "FILE:$elf" "TCP:$host:${PS5_PORT:-9021}"echo "ps5lm-app: launch sent"}diff --git a/scripts/release-app.sh b/scripts/release-app.shindex 7709de5..a92979a 100755--- a/scripts/release-app.sh+++ b/scripts/release-app.sh@@ -1,11 +1,9 @@#!/usr/bin/env bash# Packages the built app for a release: build/release/ps5lm-app-v<version>.zip# holding the app's title folder (PPSA99575), plus its sha256. The version comes from-# ps5/app/version.hpp; the git tag is v<version>. After a fleet build the zip is-# ps5lm-app-fleet-v<version>.zip (docs/FLEET.md).+# ps5/app/version.hpp; the git tag is v<version>.## scripts/build-app.sh && scripts/release-app.sh-# PS5LM_FLEET=1 scripts/build-app.sh && scripts/release-app.sh## SPDX-License-Identifier: GPL-3.0-or-laterset -euo pipefail@@ -15,12 +13,7 @@ version=$(sed -n 's/^#define PS5LM_VERSION "\(.*\)"$/\1/p' "$root/ps5/app/versiotitle=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["titleId"])' "$root/ps5/app/sce_sys/param.json")app="$root/build/app-ps5/title/$title"out="$root/build/release"-variant=$(cat "$root/build/app-ps5/variant" 2>/dev/null || echo default)-case $variant in- default) zip="$out/ps5lm-app-v$version.zip" ;;- fleet) zip="$out/ps5lm-app-fleet-v$version.zip" ;;- *) echo "release-app: unknown build variant '$variant'" >&2; exit 1 ;;-esac+zip="$out/ps5lm-app-v$version.zip"[ -f "$app/eboot.bin" ] || { echo "release-app: build it first (scripts/build-app.sh)" >&2; exit 1; }grep -q "^## \[$version\]" "$root/CHANGELOG.md" || { echo "release-app: CHANGELOG.md has no [$version] entry" >&2; exit 1; }