Cannot set pins by overlay

Hello there,
I just got back to my BeagleBone Black and i have no idea why but I just cannot change a pin configuration using overlay nor through export. This is what I am trying to do:

I want to set P8_29 and P8_31 Pins to inputs with a pullup (0x37). here is my overlay:

`
/dts-v1/;
/plugin/;

/{
compatible = “ti,beaglebone”, “ti,beaglebone-black”;
part-number = “BB-AVRDUDE”;
version = “00A0”;

fragment@0 {
target = <&am33xx_pinmux>;

overlay {
ebb_example: BB-AVRDUDE {
pinctrl-single,pins = <
0x0E4 0x37 // P8_29, AVR #RST pin, Input Mode7 pullup
0x0D8 0x37 // P8_31, AVR #HWB pin, Input Mode7 pullup

/* INPUT GPIO(mode7) 0x27 pulldown, 0x37 pullup, 0x?f no pullup/down */

;
};
};
};

fragment@1 {
target = <&ocp>;
overlay {
gpio_helper {
compatible = “gpio-of-helper”;
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&ebb_example>;
};
};
};
};
`

Then I load the DTS and see in the list (last). HDMI is disabled:

`
0: 54:PF—
1: 55:PF—
2: 56:PF—
3: 57:PF—
4: ff:P-O-L Bone-LT-eMMC-2G,00A0,Texas Instrument,BB-BONE-EMMC-2G
5: ff:P-O-- Bone-Black-HDMI,00A0,Texas Instrument,BB-BONELT-HDMI
6: ff:P-O-- Bone-Black-HDMIN,00A0,Texas Instrument,BB-BONELT-HDMIN
7: ff:P-O-L Override Board Name,00A0,Override Manuf,NEOSEC-TINYLCD22
8: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-KEYS
9: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BONE-SPI1-2CS
10: ff:P-O-L Override Board Name,00A0,Override Manuf,am33xx_pwm
11: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-COOLER
12: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-UART5
13: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-BUZZER
14: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-W1
15: ff:P-O-L Override Board Name,00A0,Override Manuf,BB-AVRDUDE

`

Dmesg says it was OK:

`
root@beaglebone:~# dmesg | grep BB-AVRDUDE
[ 151.732517] bone-capemgr bone_capemgr.9: part_number ‘BB-AVRDUDE’, version ‘N/A’
[ 151.732633] bone-capemgr bone_capemgr.9: slot #15: ‘Override Board Name,00A0,Override Manuf,BB-AVRDUDE’
[ 151.732729] bone-capemgr bone_capemgr.9: slot #15: Requesting part number/version based 'BB-AVRDUDE-00A0.dtbo
[ 151.732744] bone-capemgr bone_capemgr.9: slot #15: Requesting firmware ‘BB-AVRDUDE-00A0.dtbo’ for board-name ‘Override Board Name’, version ‘00A0’
[ 151.736445] bone-capemgr bone_capemgr.9: slot #15: dtbo ‘BB-AVRDUDE-00A0.dtbo’ loaded; converting to live tree

`

Then I check the pins and they remain as they were in default:

`
root@beaglebone:~# cat $PINS | grep “pin 57”
pin 57 (44e108e4) 00000027 pinctrl-single
root@beaglebone:~# cat $PINS | grep “pin 54”
pin 54 (44e108d8) 0000002f pinctrl-single

`

Did I forget something? I really cant think of anything. I would really apreciate all help here!

Anyone please?

Hello there,
I just got back to my BeagleBone Black and i have no idea why but I just
cannot change a pin configuration using overlay nor through export. This is
what I am trying to do:

I want to set P8_29 and P8_31 Pins to inputs with a pullup (0x37). here is
my overlay:

<snip overlay stuff>

Then I check the pins and they remain as they were in default:

root@beaglebone:~# cat $PINS | grep "pin 57"
pin 57 (44e108e4) 00000027 pinctrl-single
root@beaglebone:~# cat $PINS | grep "pin 54"
pin 54 (44e108d8) 0000002f pinctrl-single

Did I forget something? I really cant think of anything. I would really
apreciate all help here!

Well, since you're using gpio-of-helper (designed to allow export of
GPIO pins via the device tree instead of using sysfs), but *NOT*
actually defining any GPIO pins, I'm not sure the gpio-of-helper
driver is applying your pinmux settings.

Try adding the GPIO pins you want to the gpio_helper stanza in
fragment 1 and configure them as inputs.

Im.not sure I understand. I am setting the pins in the dts file i pasted. Wrting 0x37 to them to set them as inputs with pullups. I then compile a dtbo, load then load the dtbo. It gets loaded. I check the pins and they are not 0x37. Could you explain again what did you mean exacly? I wanted to simply init the pin with device tree overlay and then manage it with sysfs.

I mean you have pinmux settings, but you're not using the
gpio-of-helper driver to actually export anything, which it what it
was written for. There is a difference between the *PINMUX* is setup
for input and the *GPIO PIN* is setup as an input.

Try adding some actual GPIO entries like these:

https://github.com/beagleboard/devicetree-source/blob/master/arch/arm/boot/dts/BB-GPIOHELP-00A0.dts#L48-L62

I think i get it. I will try this first thing in the morning. Thank you.

I have compiled this dts:
Then added it to slots (it got loaded) and checked the pins. It still doesnt work: Am I still doing something wrong?

Two things to check:

1) The kernel will load any compiled in overlays in preference to
files in /lib/firmware. I don't think there's a BB_AVRDUDE overlay
compiled into the kernel, but you can test by changing the name of
your *.dtbo file to something guaranteed to be unique (or give it a
custom version number) and try to load that instead. That will force
the kernel to look for the file in /lib/firmware.

2) You can crawl through the live device tree (/proc/device-tree/*)
and make sure it's what you're expecting. It's easy to have one typo
or similar that will mess up everything you're trying to do. :slight_smile:

I also dont think that there is a device tree with this name. I will however try you tips at mo day in the morning and let know here. Thank you for help.

@bremenpl

try removing the follwing part in your code:

`
test_input1 {
gpio-name = “test_input1”;
gpio = <&gpio3 23 0x00>; /* gpio4 is gpio3 */
input;
count-rising-edge;
count-falling-edge;
};

test_input2 {
gpio-name = “test_input2”;
gpio = <&gpio1 10 0x00>; /* gpio4 is gpio3 */
input;
count-rising-edge;
count-falling-edge; };

`

and just leave the following part as it is:

`

fragment@1 {
target = <&ocp>;
overlay {
gpio_helper {
compatible = “gpio-of-helper”;
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <&ebb_example>;

};
}; };

`

And if you need some help I can suggest you to try the code generated in this page.

At least you have the chance to check, whether your code is right or not. You can simplify debugging of your code.

Regards

Didnt know about this page, thabk you a lot :).

I discovered that (at least in my ubuntu Linux arm 4.1.13-ti-r36) trying to load and unload overlays on the fly doesn’t work.

I did it many times, in the right way. But you should reboot your system at first and THEN try to load your overlay.

Your changes at the pinmux should be visible now.

I don’t know why one should reboot the system everytime.