I've got an older rPi 3B+ based system using a matrix keypad via devicetree overlay. I decided it was time to update the OS to the current one and made a new SD card, unfortunately the same config that worked on the old SD is freezing the new one every time i press a key (still works if i swap cards). The culprit is definitely the dto but i can't figure out the problem (taking it out of config.txt stops the crashing) I double checked the dts configuration and decided to make a new one following the available documentation. Unfortunately, the new overlay still causes the system to crash when i press a key.
Things I've tried:
- confirmed all physical connections and used
raspi-gpio get
to confirm gpio pin configuration matches the overlay - checked pins are not being used by something else. I'm using gpio 17,22,23,24 and 27, none of which seem to be used by something else like spi or i2c (couldn't find any reference to anything online and
dpioinfo
has all of them marked as unused without the overlay loaded) - tried using
dmesg | grep -i gpio
anddmesg | grep -i overlay
to check for conflicts but nothing stands out for gpio and overlay produce no results - used
lsinput
to check the overlay is loaded from config.txt
/dev/input/event0 bustype : BUS_HOST vendor : 0x0 product : 0x0 version : 0 name : "MATRIX3x2" bits ev : EV_SYN EV_KEY EV_MSC
- used
dtc -I fs /proc/device-tree
to confirm the dtbo file; looks correct - used
input-events 0
to monitor inputs when i press the keypad. The output didn't provide much info; most of the time it was something like this and the difference is the number of ^[[B messages before the system crashes
13:24:34.320740: EV_MSC MSC_SCAN 1 13:24:34.320740: EV_KEY KEY_DOWN (0x6c) pressed 13:24:34.320740: EV_SYN code=0 value=0 ^[[B
- tried different rPi, SD cards and keypad
Code for DTS:
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target-path = "/";
__overlay__ {
keypad: MATRIX3x2 {
compatible = "gpio-matrix-keypad";
debounce-delay-ms = <25>;
col-scan-delay-us = <50>;
linux,no-autorepeat = "false";
pinctrl-names = "default";
pinctrl-0 = <&keymatrix_pins>;
// Define rows as inputs
row-gpios = <&gpio 27 0 // 1 (input)
&gpio 23 0>; // 2 (input)
// Define columns as outputs
col-gpios = <&gpio 24 1 // 3 (output)
&gpio 17 1 // 4 (output)
&gpio 22 1>; // 5 (output)
linux,keymap = <
0x00000067 // col0 row0 KEY_UP
0x01000001 // col0 row1 KEY_ESC
0x0001006C // col1 row0 KEY_DOWN
0x01010069 // col1 row1 KEY_LEFT
0x0002006A // col2 row0 KEY_RIGHT
0x01020060 // col2 row1 KEY_ENTER
>;
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
keymatrix_pins: keymatrix_pins {
// Only configure row pins as inputs
brcm,pins = <23 27>;
brcm,function = <0>; /* input */
brcm,pull = <1>; /* down */
};
};
};