From 72124d7edfb43dc2f003f18c6ad372bb7f655330 Mon Sep 17 00:00:00 2001 From: Matt Madison Date: Wed, 14 Dec 2022 14:12:23 -0800 Subject: [PATCH] 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 --- .../tegra-flash-reboot/reboot-recovery.c | 16 ++++++++++++++ .../initrdscripts/tegra-flash-reboot_1.0.bb | 21 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 recipes-core/initrdscripts/tegra-flash-reboot/reboot-recovery.c create mode 100644 recipes-core/initrdscripts/tegra-flash-reboot_1.0.bb diff --git a/recipes-core/initrdscripts/tegra-flash-reboot/reboot-recovery.c b/recipes-core/initrdscripts/tegra-flash-reboot/reboot-recovery.c new file mode 100644 index 00000000..9ff670ba --- /dev/null +++ b/recipes-core/initrdscripts/tegra-flash-reboot/reboot-recovery.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: MIT */ +#include +#include +#include + +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"); +} diff --git a/recipes-core/initrdscripts/tegra-flash-reboot_1.0.bb b/recipes-core/initrdscripts/tegra-flash-reboot_1.0.bb new file mode 100644 index 00000000..d48c9fae --- /dev/null +++ b/recipes-core/initrdscripts/tegra-flash-reboot_1.0.bb @@ -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}"