Skip to content

armgit / PS5LM

Public Imported from GitHub
0

llama.cpp on a jailbroken PS5: run any GGUF model natively on the console, starting with Qwen 3.8

v0.3.0: thermals through ps5-exporter, remote presses, checked on the console

Abhirame3682803a681
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69e0730..1a58c72 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,8 @@ v0.1.x are the upstream payload releases by cobanov.
## [Unreleased]
+## [0.3.0] - 2026-10-10
+
### Added
- Pages on L1/R1: Dashboard, Settings and Logs, with tabs in the header.
- Settings page (rail and rows after the kit's Control Room design): load a
@@ -15,8 +17,11 @@ v0.1.x are the upstream payload releases by cobanov.
- Logs page: `app.log` and `llama.log`, scrollable, with an errors-only filter.
- Model details on Cross over the Model tile: every llama-server argument, the
plan, cache and preset; Triangle opens the library.
-- THERMALS tile (SoC and CPU temperature, SoC power), STORAGE tile (free space
- on /data and USB), and the CPU clock.
+- THERMALS tile (SoC and CPU temperature, fan duty), STORAGE tile (free space
+ on /data and USB), and the CPU clock. A title may not read the sensors
+ (`0x80020002`), so the app bundles Marice's ps5-exporter (GPL-3.0, pinned
+ v0.2.0) and sends it to elfldr when it is not running.
+- `scripts/ps5lm-app.sh press <button>`: drive the screens from a PC.
### Changed
- One MEMORY tile replaces MEMORY and GPU MEMORY (the GPU and CPU share one
diff --git a/ps5/app/dashboard.cpp b/ps5/app/dashboard.cpp
index 72499a0..6e98f86 100644
--- a/ps5/app/dashboard.cpp
+++ b/ps5/app/dashboard.cpp
@@ -801,8 +801,12 @@ void Dashboard::draw_content(gfx::DrawList & list, int tile, const Rect & r, flo
const bool known = L.soc_temp > -100;
const float tw = number(list, f, known, "%.0f", L.soc_temp, r.x + kPad, r.y + 118, 60, kInk);
ui::text(list, f.regular, "\xC2\xB0" "C, the SoC", r.x + kPad + tw + 10, r.y + 118, 22, kInk.with_alpha(kMuted));
- if (L.cpu_temp > -100) {
+ if (L.cpu_temp > -100 && L.fan >= 0) {
+ std::snprintf(text, sizeof(text), "CPU %.0f \xC2\xB0" "C \xC2\xB7 fan %.0f%%", L.cpu_temp, L.fan * 100.0f);
+ } else if (L.cpu_temp > -100) {
std::snprintf(text, sizeof(text), "CPU %.0f \xC2\xB0" "C", L.cpu_temp);
+ } else if (!L.sensors_from_exporter) {
+ std::snprintf(text, sizeof(text), "Load ps5-exporter to read them");
} else {
std::snprintf(text, sizeof(text), "No sensor answered");
}
diff --git a/ps5/app/main.cpp b/ps5/app/main.cpp
index c724dcb..0ab4662 100644
--- a/ps5/app/main.cpp
+++ b/ps5/app/main.cpp
@@ -535,7 +535,36 @@ int main(int, char **) {
}
}
feedback.clear();
- dash.update(input, dt, feedback);
+ // A button pressed from the PC (scripts/ps5lm-app.sh press r1), for
+ // testing the screens without a controller in hand.
+ hui::InputFrame in = input;
+ if (n % 20 == 10) {
+ const std::string key = take_request_file("/data/PS5LM/press");
+ const struct {
+ const char * name;
+ hui::Action action;
+ hui::Direction nav;
+ } keys[] = {
+ { "up", hui::Action::up, hui::Direction::up },
+ { "down", hui::Action::down, hui::Direction::down },
+ { "left", hui::Action::left, hui::Direction::left },
+ { "right", hui::Action::right, hui::Direction::right },
+ { "cross", hui::Action::confirm, hui::Direction::none },
+ { "circle", hui::Action::back, hui::Direction::none },
+ { "triangle", hui::Action::north, hui::Direction::none },
+ { "square", hui::Action::west, hui::Direction::none },
+ { "l1", hui::Action::page_prev, hui::Direction::none },
+ { "r1", hui::Action::page_next, hui::Direction::none },
+ };
+ for (const auto & k : keys) {
+ if (key == k.name) {
+ in.connected = true;
+ in.pressed |= hui::action_bit(k.action);
+ in.nav = k.nav;
+ }
+ }
+ }
+ dash.update(in, dt, feedback);
for (const auto & cue : feedback.cues) {
if (!models.settings.sounds) {
break;
diff --git a/ps5/app/stats.cpp b/ps5/app/stats.cpp
index 5b7f3aa..99c4560 100644
--- a/ps5/app/stats.cpp
+++ b/ps5/app/stats.cpp
@@ -123,6 +123,39 @@ double metric(const std::string & text, const char * name) {
return at == std::string::npos ? 0.0 : std::strtod(text.c_str() + at + key.size(), nullptr);
}
+// One sample from Prometheus text by its full name and labels
+// ("ps5_temperature_celsius{sensor=\"cpu\"}"), or `missing`.
+double sample(const std::string & text, const std::string & key, double missing) {
+ const size_t at = text.find("\n" + key + " ");
+ return at == std::string::npos ? missing : std::strtod(text.c_str() + at + key.size() + 2, nullptr);
+}
+
+// Sends a payload to an ELF loader on this console (elfldr, port 9021).
+bool send_payload(const char * path, int port) {
+ FILE * f = std::fopen(path, "rb");
+ if (!f) {
+ return false;
+ }
+ const int fd = socket(AF_INET, SOCK_STREAM, 0);
+ sockaddr_in to = {};
+#ifdef __FreeBSD__
+ to.sin_len = sizeof(to);
+#endif
+ to.sin_family = AF_INET;
+ to.sin_port = htons((uint16_t) port);
+ to.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ bool ok = fd >= 0 && connect(fd, (sockaddr *) &to, sizeof(to)) == 0;
+ char buf[65536];
+ for (size_t n; ok && (n = std::fread(buf, 1, sizeof(buf), f)) > 0;) {
+ ok = send(fd, buf, n, 0) == (ssize_t) n;
+ }
+ std::fclose(f);
+ if (fd >= 0) {
+ close(fd);
+ }
+ return ok;
+}
+
std::string local_address() {
const int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -243,7 +276,39 @@ void StatsCollector::run() {
}
const long hz = sceKernelGetCpuFrequency();
ghz = hz > 0 ? (float) (hz / 1e9) : 0.0f;
+ static bool logged = false; // ponytail: once, to see what a title is allowed to read
+ if (!logged) {
+ logged = true;
+ int t0 = -1000, t1 = -1000;
+ const int r0 = sceKernelGetSocSensorTemperature(0, &t0), r1 = sceKernelGetCpuTemperature(&t1);
+ std::printf("ps5lm-app: sensors: soc rc 0x%x t %d, cpu rc 0x%x t %d, power raw %llu, cpu hz %ld\n", r0, t0,
+ r1, t1, (unsigned long long) raw[0], hz);
+ }
#endif
+ // A title may not read the sensors (0x80020002); a payload may.
+ // Marice/ps5-exporter, when loaded, serves them on port 9100.
+ float fan = -1;
+ bool from_exporter = false;
+ if (soc_t < -100) {
+ std::string p = http_get(9100, "/metrics");
+ // Not running: hand the bundled copy to elfldr, at start and then
+ // once a minute (elfldr may come later).
+ if (p.empty() && (long) (wall - start) % 60 == 1) {
+ const bool sent = send_payload("/app0/payloads/ps5-exporter.elf", 9021);
+ std::printf("ps5lm-app: ps5-exporter not running; %s\n",
+ sent ? "sent the bundled copy to elfldr" : "no elfldr on 9021 to load it");
+ }
+ if (!p.empty()) {
+ from_exporter = true;
+ soc_t = (float) sample(p, "ps5_temperature_celsius{sensor=\"soc0\"}", -1000);
+ cpu_t = (float) sample(p, "ps5_temperature_celsius{sensor=\"cpu\"}", -1000);
+ watts = (float) sample(p, "ps5_soc_power_watts", 0);
+ fan = (float) sample(p, "ps5_fan_duty_ratio", -1);
+ if (ghz <= 0) {
+ ghz = (float) (sample(p, "ps5_cpu_frequency_hertz", 0) / 1e9);
+ }
+ }
+ }
double data_free = 0, data_total = 0, usb_free = 0, usb_total = 0;
space("/data", &data_free, &data_total);
// An empty /mnt/usb0 is a directory of the root filesystem, not a drive.
@@ -258,6 +323,8 @@ void StatsCollector::run() {
live_.cpu_temp = cpu_t;
live_.soc_power_w = watts;
live_.cpu_ghz = ghz;
+ live_.fan = fan;
+ live_.sensors_from_exporter = from_exporter;
if (soc_t > -100) {
push(live_.temp_history, soc_t);
}
diff --git a/ps5/app/stats.hpp b/ps5/app/stats.hpp
index ebcf38c..fd13e60 100644
--- a/ps5/app/stats.hpp
+++ b/ps5/app/stats.hpp
@@ -65,6 +65,8 @@ struct Live {
float cpu_temp = -1000;
float soc_power_w = 0;
float cpu_ghz = 0;
+ float fan = -1; // fan duty 0..1, below 0 when unread
+ bool sensors_from_exporter = false; // read from ps5-exporter, not the kernel
std::vector<float> temp_history; // SoC degrees C per second
// Storage, GiB; usb_total 0 when no drive is mounted.
@@ -109,6 +111,9 @@ class StatsCollector {
// The console's address on the LAN, as the PC sees it ("192.168.1.19"), or
// empty. Asks the routing table through an unconnected UDP socket: nothing is sent.
+// Sends a payload file to an ELF loader on this console; false if none listens.
+bool send_payload(const char * path, int port);
+
std::string local_address();
// A tiny HTTP GET over loopback; returns the body, or empty.
diff --git a/ps5/app/version.hpp b/ps5/app/version.hpp
index f521482..7d0d863 100644
--- a/ps5/app/version.hpp
+++ b/ps5/app/version.hpp
@@ -4,4 +4,4 @@
// The app's version, semver. The one place it is set: scripts read it from
// here (scripts/release-app.sh), and git tags are v<this>. Bump it with an
// entry in CHANGELOG.md.
-#define PS5LM_VERSION "0.2.0"
+#define PS5LM_VERSION "0.3.0"
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index 2fcc38c..00419a1 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -211,5 +211,19 @@ for font in inter-regular inter-semibold montserrat-medium dejavu-sans-mono; do
done
cp "$root/third_party/ps5-homebrew-ui/assets/fonts/"*LICENSE* "$app/assets/fonts/"
cp -r "$root/third_party/ps5-homebrew-ui/assets/audio/sfx" "$app/assets/audio/"
+# ps5-exporter (Marice, GPL-3.0): a title may not read the temperature, fan or
+# SoC power sensors, a payload may. The app sends it to elfldr when it is not
+# running. Pinned by version and hash, downloaded once into .deps.
+exporter="$root/.deps/ps5-exporter-0.2.0.elf"
+exporter_sha=0d19f7a293eeb30178ba562a3712abfdc50f6b6ebbe180ceaad92dc557948ba8
+if [ ! -f "$exporter" ]; then
+ curl -sSfL -o "$exporter.part" https://github.com/Marice/ps5-exporter/releases/download/v0.2.0/ps5-exporter.elf
+ mv "$exporter.part" "$exporter"
+fi
+echo "$exporter_sha $exporter" | sha256sum -c --quiet || { echo "build-app: ps5-exporter hash mismatch" >&2; exit 1; }
+mkdir -p "$app/payloads"
+cp "$exporter" "$app/payloads/ps5-exporter.elf"
+printf '%s\n' "ps5-exporter v0.2.0 by Marice, GPL-3.0-or-later: https://github.com/Marice/ps5-exporter" \
+ "Source: https://github.com/Marice/ps5-exporter/tree/v0.2.0" > "$app/payloads/ps5-exporter-NOTICE.txt"
"$tool" self --inspect --file "$app/eboot.bin" > /dev/null
echo "build-app: $app ($(stat -c %s "$app/eboot.bin") bytes)"
diff --git a/scripts/ps5lm-app.sh b/scripts/ps5lm-app.sh
index 9e7b4da..4b0e453 100755
--- a/scripts/ps5lm-app.sh
+++ b/scripts/ps5lm-app.sh
@@ -8,6 +8,7 @@
# 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
# scripts/ps5lm-app.sh unload unload the model
+# scripts/ps5lm-app.sh press <button> press a button (up, down, cross, l1, r1, ...)
#
# The app is never killed: it polls /data/PS5LM/quit and leaves through
# sceSystemServiceLoadExec("exit"), since killing a title that is rendering
@@ -74,10 +75,11 @@ screenshot() {
case ${1:-} in
load) request load "${2:?model path on the console}" ;;
unload) request unload ;;
+ press) request press "${2:?up|down|left|right|cross|circle|triangle|square|l1|r1}" ;;
screenshot) screenshot "${2:-}" ;;
close) close ;;
deploy) deploy ;;
launch) launch ;;
cycle) close; deploy; launch ;;
- *) echo "usage: $0 close|deploy|launch|cycle|screenshot|load|unload" >&2; exit 2 ;;
+ *) echo "usage: $0 close|deploy|launch|cycle|screenshot|load|unload|press" >&2; exit 2 ;;
esac