Setting pin mode with PocketBeagle2

I am getting started with the PocketBeagle2. I have used the Black and Black Wireless units for several years under Debian Buster. I’m used to setting the pin mode with config-pin but this does not appear to be part of the distr for the PocketBeagle2 and I tried sudo apt update but that did not get config-pin. Is there a new way to set pin modes? I want to confirm that I can set the pins I’m planning to use to the modes that I expect before finishing a custom board layout. I’ve been burned by the documentation not being exactly right before! (We all make mistakes.)

The PocketBeagle is booted with Debian Trixie IOT Image 2025-09-05.
version, uName etc don’t work so I’m not able to give more details at this time.

Set the pins in an overlay, take a look at examples with the pocketbeagle2 prefix

Thanks. Not quite as handy as config-pin but I can do it!

I wrote this DTS to just configure the IO I need. It compiles and I put it in /lib/firmware and edited uEnv.txt to load it on boot and rebooted but I don’t think it’s loading. (There wasn’t a uEnv.txt in /boot so I had to create it.)

The IOs don’t appear in the file system.

I do not work with device tree overlays very often so I’m sure I’m missing something and will greatly appreciate any and all help on this!

/dts-v1/;
/plugin/;

/ {
    compatible = "beagle,am62-pocketbeagle2", "ti,am625";
    model = "PocketBeagle2 APS1 IO Cape";

    chosen {
        overlays {
            PB2-APS1-IO = "2025-11-11 10:15";
        };
    };
};

&main_pmx0 {
    i2c3_pins: i2c3-pins {
        pinctrl-single,pins = <
            0x01d0 0x00030002 /* P2.09 I2C3_SCL: input, pull-up, mux=2 */
            0x01d4 0x00030002 /* P2.11 I2C3_SDA: input, pull-up, mux=2 */
        >;
    };

    can0_pins: can0-pins {
        pinctrl-single,pins = <
            0x01d8 0x00000000 /* P2.05 MCAN0_TX: output, mux=0 */
            0x01dc 0x00010000 /* P2.07 MCAN0_RX: input, mux=0 */
        >;
    };

    gpio_pins: gpio-pins {
        pinctrl-single,pins = <
            0x00b8 0x00000007 /* P2.02 GPIO0_45: output, mux=7 */
            0x00bc 0x00000007 /* P2.04 GPIO0_46: output, mux=7 */
            0x00c0 0x00030007 /* P2.06 GPIO0_47: input, pull-up, mux=7 */
        >;
    };
};

&main_i2c3 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c3_pins>;
    status = "okay";
};

&main_mcan0 {
    pinctrl-names = "default";
    pinctrl-0 = <&can0_pins>;
    status = "okay";
};

&main_gpio0 {
    status = "okay";
};

&cbass_main {
    leds {
        compatible = "gpio-leds";
        pinctrl-names = "default";
        pinctrl-0 = <&gpio_pins>;

        led_p2_02 {
            label = "p2.02";
            gpios = <&main_gpio0 45 0>;
            default-state = "off";
        };

        led_p2_04 {
            label = "p2.04";
            gpios = <&main_gpio0 46 0>;
            default-state = "off";
        };
    };

    switch {
        compatible = "gpio-keys";
        pinctrl-names = "default";
        pinctrl-0 = <&gpio_pins>;

        button {
            label = "P2.06 Switch";
            gpios = <&main_gpio0 47 1>;
            linux,code = <0x100>;
            debounce-interval = <50>;
        };
    };
};

Here is uEnv.txt

enable_uboot_overlays=1
uboot_overlay_addr0=PB2-APS1-IO.dtbo

overlays are loaded by /boot/firmware/extlinux.conf in the fat32 partition.. overlays are stored in /boot/firmware/overlays/

by default:

label microSD (default)
    kernel /Image.gz
    append console=ttyS2,115200n8 earlycon=ns16550a,mmio32,0x02860000 root=/dev/mmcblk1p3 ro rootfstype=ext4 fsck.repair=yes resume=/dev/mmcblk1p2 rootwait net.ifnames=0
    fdtdir /
    #fdtoverlays /overlays/<file>.dtbo
    #initrd /initrd.img

this option is selected..

you’d have to modify:

From:

    #fdtoverlays /overlays/<file>.dtbo

to:

    fdtoverlays /overlays/PB2-APS1-IO.dtbo

Regards,

@RobertCNelson Thank you! I am getting there!! I got the overlay to load and I can flip P2_02 and P2_04 on and off and I can bring up CAN0 and see all three I2C buses using i2cdetect.

But I am trying to also define an input switch using GPIO0_47 on P2.06 and it is not coming up. Here is the section in by dts file. The output gpio’s are working but the input is not.

gpio_pins: gpio-pins {
pinctrl-single,pins = <
0x00b8 0x00000007 /* P2.02 GPIO0_45: output, mux=7 /
0x00bc 0x00000007 /
P2.04 GPIO0_46: output, mux=7 /
0x00c0 0x00030007 /
P2.06 GPIO0_47: input, pull-up, mux=7 */

;
}

&cbass_main {
leds {
compatible = “gpio-leds”;
pinctrl-names = “default”;
pinctrl-0 = <&gpio_pins>;

    led_p2_02 {
        label = "p2.02";
        gpios = <&main_gpio0 45 0>;
        default-state = "off";
    };

    led_p2_04 {
        label = "p2.04";
        gpios = <&main_gpio0 46 0>;
        default-state = "off";
    };
};

switch {
    compatible = "gpio-keys";
    pinctrl-names = "default";
    pinctrl-0 = <&gpio_pins>;

    button {
        label = "P2.06 Switch";
        gpios = <&main_gpio0 47 1>;
        linux,code = <0x100>;
        debounce-interval = <50>;
    };
};

The logs from dmesg -Hw have this warning. I don’t understand why it’s trying to configure 46 when I think I am clearly defining it for 47.

[ +0.000530] pinctrl-single f4000.pinctrl: pin PIN46 already requested by bus@f0000:leds; cannot claim for bus@f0000:switch
[ +0.000015] pinctrl-single f4000.pinctrl: error -EINVAL: pin-46 (bus@f0000:switch)
[ +0.000010] pinctrl-single f4000.pinctrl: error -EINVAL: could not request pin 46 (PIN46) from group gpio-pins on device pinctrl-single
[ +0.000010] gpio-keys bus@f0000:switch: Error applying setting, reverse things back

Your tripping over two nodes linking to one.., just split them into two labels… and update your reference pinctrl-0

    gpio_out_pins: gpio-out-pins {
        pinctrl-single,pins = <
            0x00b8 0x00000007 /* P2.02 GPIO0_45: output, mux=7 */
            0x00bc 0x00000007 /* P2.04 GPIO0_46: output, mux=7 */
        >;
    };
    gpio_in_pins: gpio-in-pins {
        pinctrl-single,pins = <
            0x00c0 0x00030007 /* P2.06 GPIO0_47: input, pull-up, mux=7 */
        >;
    };

My LEDS are still configured as outputs and the errors in dmseg are gone but I don’t see ‘switch’ in the tree. Is there anything wrong with this syntax?

&cbass_main {
leds {
compatible = “gpio-leds”;
pinctrl-names = “default”;
pinctrl-0 = <&gpio_out_pins>;

    led_p2_02 {
        label = "p2.02";
        gpios = <&main_gpio0 45 0>;
        default-state = "off";
    };

    led_p2_04 {
        label = "p2.04";
        gpios = <&main_gpio0 46 0>;
        default-state = "off";
    };
};

switch {
    compatible = "gpio-keys";
    pinctrl-names = "default";
    pinctrl-0 = <&gpio_in_pins>;

    button {
        label = "P2.06 Switch";
        gpios = <&main_gpio0 47 1>;
        linux,code = <0x100>;
        debounce-interval = <50>;
    };
};

};

you should see it via:

evtest /dev/input/event1

evtest is not in the distribution and I cannot get to the internet from the PocketBeagle2 using the USB tether to my Windows 11 PC. So apt update can’t get to deb.debian.org

This has to be the single most frustrating thing about using Beagles!

(Excuse the rant please.)

Enable internet connection sharing, then on the PB2, run sudo dhpclient usb0

Regards

Ok. So I had to take a little break but I’m back on this and no success so far.

If I enable ICS I lose connected to the PB2 over the Windows 11 wifi. ( I’m assuming I need to enable ICS on the network connection that has internet access. I think that’s what I have always done with the Black and Black Wireless)

So once I lose connection, I can’t execute sudo dhclient usb0 (assuming you meant dhclient and not dhpclient because dhpclient doesn’t exist)

Now, if I don’t enable ICS and connect to the PB2 and execute sudo dhclient usb0 I eventually get “Cannot find device “ubs0”

FYI this is running Debian Trixie IOT Imaged 2025-09-05

Thought I added this package to later builds… Index of /rootfs/debian-arm64-13-iot-v6.12-ti/2025-11-26