BBB Debian Bookworm reading S2 after system is already booted

Running a headless system with Debian Bookworm. On the production line, they want to re-image from SD card. After the SD card is removed and the system is booted, they want to press S2 and run something like cylon LEDs to indicate that the updated image is running. The /boot/uEnv.txt has been modified so that these 3 lines aren’t commented out:
disable_uboot_overlay_audio=1
disable_uboot_overlay_video=1
disable_uboot_overlay_wireless=1

show-pins output after boot contains this:
P8.45 / hdmi / sysboot 0 40 fast 0 lcd d0 0-0070 (nxp-hdmi-bonelt-pins)
P8.46 / hdmi / sysboot 1 41 fast 0 lcd d1 0-0070 (nxp-hdmi-bonelt-pins)
P8.43 / hdmi / sysboot 2 42 fast 0 lcd d2 0-0070 (nxp-hdmi-bonelt-pins)
P8.44 / hdmi / sysboot 3 43 fast 0 lcd d3 0-0070 (nxp-hdmi-bonelt-pins)
P8.41 / hdmi / sysboot 4 44 fast 0 lcd d4 0-0070 (nxp-hdmi-bonelt-pins)
P8.42 / hdmi / sysboot 5 45 fast 0 lcd d5 0-0070 (nxp-hdmi-bonelt-pins)
P8.39 / hdmi / sysboot 6 46 fast 0 lcd d6 0-0070 (nxp-hdmi-bonelt-pins)
P8.40 / hdmi / sysboot 7 47 fast 0 lcd d7 0-0070 (nxp-hdmi-bonelt-pins)
P8.37 / hdmi / sysboot 8 48 fast 0 lcd d8 0-0070 (nxp-hdmi-bonelt-pins)
P8.38 / hdmi / sysboot 9 49 fast 0 lcd d9 0-0070 (nxp-hdmi-bonelt-pins)
P8.36 / hdmi / sysboot 10 50 fast 0 lcd d10 0-0070 (nxp-hdmi-bonelt-pins)
P8.34 / hdmi / sysboot 11 51 fast 0 lcd d11 0-0070 (nxp-hdmi-bonelt-pins)
P8.35 / hdmi / sysboot 12 52 fast 0 lcd d12 0-0070 (nxp-hdmi-bonelt-pins)
P8.33 / hdmi / sysboot 13 53 fast 0 lcd d13 0-0070 (nxp-hdmi-bonelt-pins)
P8.31 / hdmi / sysboot 14 54 fast 0 lcd d14 0-0070 (nxp-hdmi-bonelt-pins)
P8.32 / hdmi / sysboot 15 55 fast 0 lcd d15 0-0070 (nxp-hdmi-bonelt-pins)

What else needs to be done to be able to read/monitor when S2 is pressed after boot (preferably from a bash script).

That pin…

gpiofind P8_43 returns nothing. Shouldn’t it return something like gpiochipX Y so that I could do “gpioget gpiochipX Y”

root@BeagleBone:/boot# gpiofind P8_43
root@BeagleBone:/boot#

When I cat /sys/kernel/debug/gpio I see this for P8_43

gpiochip1: GPIOs 544-575, parent: platform/481ac000.gpio, gpio-32-63:
gpio-544 (P9_15B )
gpio-545 (P8_18 )
gpio-546 (P8_7 )
gpio-547 (P8_8 )
gpio-548 (P8_10 )
gpio-549 (P8_9 )
gpio-550 (P8_45 [hdmi] )
gpio-551 (P8_46 [hdmi] )
gpio-552 (P8_43 [hdmi] )
gpio-553 (P8_44 [hdmi] )
gpio-554 (P8_41 [hdmi] )
gpio-555 (P8_42 [hdmi] )
gpio-556 (P8_39 [hdmi] )
gpio-557 (P8_40 [hdmi] )
gpio-558 (P8_37 [hdmi] )
gpio-559 (P8_38 [hdmi] )
gpio-560 (P8_36 [hdmi] )
gpio-561 (P8_34 [hdmi] )
gpio-562 ([rmii1_rxd3] )
gpio-563 ([rmii1_rxd2] )
gpio-564 ([rmii1_rxd1] )
gpio-565 ([rmii1_rxd0] )
gpio-566 (P8_27 [hdmi] )
gpio-567 (P8_29 [hdmi] )
gpio-568 (P8_28 [hdmi] )
gpio-569 (P8_30 [hdmi] )
gpio-570 ([mmc0_dat3] )
gpio-571 ([mmc0_dat2] )
gpio-572 ([mmc0_dat1] )
gpio-573 ([mmc0_dat0] )
gpio-574 ([mmc0_clk] )
gpio-575 ([mmc0_cmd] )

So, shouldn’t gpiofind return “gpiochip1 8” for P8_43?

If I do “gpioget gpiochip1 8” with S2 not pressed, I get a 0. With S2 pressed, that command also returns 0.

you’d have to load an overlay and set that pin as an input..

Regards,

To help anyone else viewing this thread. I got the input working. I modified /boot/uEnv.txt and uncommented this line:
enable_uboot_overlays=1
Added this line:

uboot_overlay_addr4=/boot/dtbs/6.12.40-bone31/overlays/BB-P8_43-GPIO.dtbo

built the .dtbo on the BBB in /tmp using this command:
dtc -O dtb -o BB-P8_43-GPIO.dtbo -b 0 -@ BB-P8_43-GPIO.dts

Copied the resultant .dtbo file to /boot/dtbs/6.12.40-bone31/overlays/BB-P8_43-GPIO.dtbo

Tested it with this one line script:
while true; do printf “chip1/8=%s” “$(gpioget gpiochip1 8 2>/dev/null || echo N/A)”; sleep 0.1; done

Here’s the .dts overlay source I used:

/dts-v1/;
/plugin/;

/ {
compatible = “ti,am335x-bone”, “ti,am335x-bone-black”;

/*
 * This fragment overrides the pinmux for P8_43 (ball: GPMC_A9)
 * and assigns it to mode 7 (GPIO), input.
 *
 * According to BeagleBone pin tables:
 *   P8_43 ? gpmc_a9 ? gpio2_9 ? gpiochip1 line 8 in your gpioinfo
 */

fragment@0 {
    target = <&am33xx_pinmux>;
    __overlay__ {
        pinmux_p8_43_gpio: pinmux_p8_43_gpio {
            pinctrl-single,pins = <
                0x090 0x27
            >;
            /*
             * 0x090 : offset for gpmc_a9 (see AM335x TRM)
             * 0x27  : mode 7 (GPIO) + pullup enabled + input enabled
             *
             * Breakdown of 0x27:
             *   mode 7 ? 0x07
             *   input enable ? (1<<5) = 0x20
             *   pullup enabled (default)
             */
        };
    };
};

fragment@1 {
    target = <&ocp>;
    __overlay__ {
        p8_43_gpio_helper {
            compatible = "bone-pinmux-helper";
            status = "okay";
            pinctrl-names = "default";
            pinctrl-0 = <&pinmux_p8_43_gpio>;
        };
    };
};

};

Hope this helps someone!