tegra-flash-reboot: add recipe

to provide a small utility to reboot into recovery mode,
which can't be done with busybox's reboot command.

Signed-off-by: Matt Madison <matt@madison.systems>
This commit is contained in:
Matt Madison
2022-12-14 14:12:23 -08:00
committed by Matt Madison
parent 1523415228
commit 72124d7edf
2 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: MIT */
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/syscall.h>
static inline int sys_reboot(const void *arg) {
return (int) syscall(SYS_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_RESTART2, arg);
}
int
main (int argc, char *argv[])
{
if (argc > 1)
return sys_reboot(argv[1]);
return sys_reboot("forced-recovery");
}

View File

@@ -0,0 +1,21 @@
DESCRIPTION = "Utility to force reboot into recovery mode"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://reboot-recovery.c"
COMPATIBLE_MACHINE = "(tegra)"
S = "${WORKDIR}"
B = "${WORKDIR}/build"
do_compile() {
$CC $CFLAGS $LDFLAGS -o ${B}/reboot-recovery ${S}/reboot-recovery.c
}
do_install() {
install -d ${D}${bindir}
install -m 0755 ${B}/reboot-recovery ${D}${bindir}/
}
PACKAGE_ARCH = "${TEGRA_PKGARCH}"