From cdee2c58381baf70fa916838ac9c9abdc3036af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Fri, 16 Aug 2024 13:04:07 +0200 Subject: [PATCH] Add LED indication for button handling in Yellow's U-Boot (#3536) With #3523 as inspiration, it might be useful to wait for buttons to be released, e.g. in case when they become stuck. Also indicate the button operation (wipe, boot files removal, UMS) has been handled by turning on the yellow LED. --- .../board/raspberrypi/yellow/uboot-boot64.ush | 8 ++++++++ buildroot-external/board/raspberrypi/yellow/uboot.config | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/buildroot-external/board/raspberrypi/yellow/uboot-boot64.ush b/buildroot-external/board/raspberrypi/yellow/uboot-boot64.ush index ef6f06cd9..43097e41f 100644 --- a/buildroot-external/board/raspberrypi/yellow/uboot-boot64.ush +++ b/buildroot-external/board/raspberrypi/yellow/uboot-boot64.ush @@ -23,21 +23,29 @@ test -n "${MACHINE_ID}" || setenv BOOT_CONDITION "systemd.condition-first-boot=t # HassOS bootargs setenv bootargs_hassos "zram.enabled=1 zram.num_devices=3 rootwait systemd.machine_id=${MACHINE_ID} cgroup_enable=memory fsck.repair=yes ${BOOT_CONDITION}" +setenv confirm_reset_handled ' \ + led usr on; \ + echo "Waiting for red button to be released"; + while gpio input GPIO27; do sleep 0.5; done;' + # Red Button pressed? if gpio input GPIO27; then sleep 1 # ... and Blue Button Pressed? if gpio input GPIO26; then echo "Boot wipe has been pressed, deleting boot files to trigger USB boot..." + run confirm_reset_handled fatrm ${devtype} ${devnum}:1 /start4.elf reset fi # Red still pressed? if gpio input GPIO27; then echo "Device wipe button has been pressed, setting wipe flag..." + run confirm_reset_handled setenv bootargs_hassos "${bootargs_hassos} haos.wipe=1" fi elif gpio input GPIO26; then + led usr on ums 0 ${devtype} ${devnum} fi diff --git a/buildroot-external/board/raspberrypi/yellow/uboot.config b/buildroot-external/board/raspberrypi/yellow/uboot.config index f17cc1d0f..e0bb378d5 100644 --- a/buildroot-external/board/raspberrypi/yellow/uboot.config +++ b/buildroot-external/board/raspberrypi/yellow/uboot.config @@ -1 +1,5 @@ CONFIG_CMD_USB_MASS_STORAGE=y + +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_CMD_LED=y