summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-06-25 15:39:21 +0200
committermetamuffin <metamuffin@disroot.org>2025-06-25 15:39:21 +0200
commit0de1bfc5f4b79ed4cce3078e4abcfa3a47793a59 (patch)
tree473a46b831c494edd75dd30c1ffda41f6a891976
downloadpiboot-0de1bfc5f4b79ed4cce3078e4abcfa3a47793a59.tar
piboot-0de1bfc5f4b79ed4cce3078e4abcfa3a47793a59.tar.bz2
piboot-0de1bfc5f4b79ed4cce3078e4abcfa3a47793a59.tar.zst
initial commit
-rw-r--r--piboot.c58
-rw-r--r--readme.txt10
2 files changed, 68 insertions, 0 deletions
diff --git a/piboot.c b/piboot.c
new file mode 100644
index 0000000..0aa6326
--- /dev/null
+++ b/piboot.c
@@ -0,0 +1,58 @@
+/*
+ piboot
+ Copyright 2025 metamuffin <metamuffin.org>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, version 3 of the License only.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+*/
+#include <errno.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int main(int argc, char **argv) {
+ char *fbpath = "/dev/fb0";
+ if (argc >= 2)
+ fbpath = argv[1];
+ int fd = open(fbpath, O_CLOEXEC | O_WRONLY);
+ if (fd < 0) {
+ fprintf(stderr, "cannot open fb0: %s\n", strerror(errno));
+ return 1;
+ }
+
+ int w = 1920, h = 1080;
+ int sidepad = (w - h) / 2;
+ uint8_t *frame = malloc(w * h * 4);
+ memset(frame, 0, w * h * 4);
+
+ for (int y = 0; y < h; y++)
+ for (int x = 0; x < w; x++) {
+ if (x < sidepad || x >= h + sidepad)
+ continue;
+ int base = (x + y * w) * 4;
+ int u = (x - sidepad) * 256 / h, v = y * 256 / h;
+ frame[base + 0] = v;
+ frame[base + 1] = u;
+ frame[base + 2] = 255 - v;
+ }
+
+ int res = write(fd, frame, w * h * 4);
+ if (res < 0) {
+ fprintf(stderr, "cannot write to fb0: %s\n", strerror(errno));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/readme.txt b/readme.txt
new file mode 100644
index 0000000..3616e29
--- /dev/null
+++ b/readme.txt
@@ -0,0 +1,10 @@
+piboot
+======
+
+Program that displays the test image that is typical for Raspberry Pi's boot via fbdev.
+
+Compilation: `gcc piboot.c`
+Installation: `install -Dm755 a.out /usr/bin/piboot`
+Usage: `piboot` or `piboot /dev/fbX`
+
+License: AGPL-3.0-only