I’m compiling my own balenaOS however when I try to access the GPIO pins on my BB Green Wireless using johnny-five in nodejs I am getting errors that that the GPIO pin does not exist.
ERROR >> Error: ENOENT: no such file or directory, open ‘/sys/devices/platform/ocp/ocp:P8_09_pinmux/state’
Using image from BB website same code works. I’ve also tried to remove any customisations I made in the OS but does not seem to have helped.
I kind of solved this by including the pins in a custom overlay, however I’m now stuck as the container does not seem to have access to the GPIO pin even tough it’s running in privileged mode.
I’ve now noticed that I am getting this error in console of the OS when connected via serial debug. [47194.041533] bone-pinmux-helper ocp:P8_19_pinmux: Failed to find state gpio
I’ve now noticed that I am getting this error in console of the OS when connected via serial debug. [47194.041533] bone-pinmux-helper ocp:P8_19_pinmux: Failed to find state gpio
When do you see this message please? Is it when booting or when your nodejs script tries to access the GPIO pin
Can you please paste the output of /mnt/boot/uEnv.txt?
I’m suspecting this is an issue with the overlay file. Can you please provide some more details about your custom overlay?
Can you paste the output of ls -l /sys/devices/platform/ocp/ and ls -l /sys/devices/platform/ocp/ocp\:P8_09_pinmux/
This happens every time the nodejs tries to access the pin
/mnt/boot/uEnv.txt:
enable_uboot_overlays=1
uboot_overlay_addr0=/boot/overlays/My-Custom-Overlay-00A0.dtbo
uboot_overlay_addr1=/boot/overlays/BB-CAN0-00A0.dtbo
uboot_overlay_addr2=/boot/overlays/BB-CAN1-00A0.dtbo
uboot_overlay_addr3=/boot/overlays/BB-ADC-00A0.dtbo #added later to try and solve the issue
uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo #added later to try and solve the issue
enable_uboot_cape_universal=1
disable_uboot_overlay_video=1
cmdline=coherent_pool=1M quiet #added later to try and solve the issue
root@e66614e:~# ls -l /sys/devices/platform/ocp/
total 0
drwxr-xr-x 3 root root 0 Jan 1 2000 40300000.ocmcram
drwxr-xr-x 7 root root 0 Jan 1 2000 44c00000.interconnect
drwxr-xr-x 9 root root 0 Jan 1 2000 47400000.usb
drwxr-xr-x 4 root root 0 Jan 1 2000 478102fc.target-module
drwxr-xr-x 4 root root 0 Jan 1 2000 47c00000.interconnect
drwxr-xr-x 7 root root 0 Jan 1 2000 48000000.interconnect
drwxr-xr-x 4 root root 0 Jan 1 2000 49000000.edma
drwxr-xr-x 3 root root 0 Jan 1 2000 49800000.tptc
drwxr-xr-x 3 root root 0 Jan 1 2000 49900000.tptc
drwxr-xr-x 3 root root 0 Jan 1 2000 49a00000.tptc
drwxr-xr-x 4 root root 0 Jan 1 2000 4a000000.interconnect
drwxr-xr-x 4 root root 0 Jan 1 2000 4b144400.interconnect
drwxr-xr-x 3 root root 0 Jan 1 2000 4c000000.emif
drwxr-xr-x 3 root root 0 Jan 1 2000 53100000.sham
drwxr-xr-x 3 root root 0 Jan 1 2000 53500000.aes
-rw-r--r-- 1 root root 4096 Apr 2 16:00 driver_override
-r--r--r-- 1 root root 4096 Apr 2 15:51 modalias
drwxr-xr-x 3 root root 0 Jan 1 2000 ocp:P8_09_pinmux
drwxr-xr-x 3 root root 0 Jan 1 2000 ocp:P8_19_pinmux
drwxr-xr-x 3 root root 0 Jan 1 2000 ocp:cape-universal
drwxr-xr-x 4 root root 0 Jan 1 2000 ocp:target-module@56000000
lrwxrwxrwx 1 root root 0 Apr 2 16:00 of_node -> ../../../firmware/devicetree/base/ocp
drwxr-xr-x 2 root root 0 Apr 2 16:00 power
lrwxrwxrwx 1 root root 0 Jan 1 2000 subsystem -> ../../../bus/platform
-rw-r--r-- 1 root root 4096 Jan 1 2000 uevent
You mentioned that the official BeagleBone image works in this case, can you also share the contents of the /boot/uEnv.txt from that distro? If this is an overlay issue, seeing how it’s configured in that image may help us.
No, but if you become familiar with the bone-pinmux-helper driver operation and look at the log you provided about the “gpio” state not being found, the problem becomes somewhat apparent.
The DT overlay only provides a “default” mode and not a “gpio” mode. The userspace software seems to be trying to set the pinmux into “gpio” mode, which does not exist. I believe “default” may be required and the first mode must be “default” and that is what it is booted into, though I’m not 100% on that. Anyway, add a “gpio” mode and the software will be satisfied it could switch the pinmux into that mode. The actual binary values provided in the DT overlay must match that.
I don’t know what the base DT is, but you might consider setting things up to use the DT that you’d otherwise get loaded in the default images. Of course, if it isn’t broke, don’t fix it.
fragment@5 {
target = <&ocp>;
__overlay__ {
P8_09_pinmux {
compatible = "bone-pinmux-helper";
pinctrl-names = "default", "gpio"; // add "gpio" to the list
pinctrl-0 = <&bb_gpio2_5_pins>;
pinctrl-1 = <&bb_gpio2_5_pins>; // you can use the same settings, as long as they are correct
status = "okay";
};
};
};
Thank you @jkridner ! Overlays are quite new to me. In the meantime I have been comparing the boot process of the official BBGW image with that of BalenaOS and have noticed that I get the below messages (These are the overlays included in UBoot by default):
So I did some extensive googling and found out that the am335x-bonegreen-wireless-uboot-univ overlay references am335x-bonegreen-wireless-common-univ which overlay includes all GPIO and modes available for the BBGW.
I’ve included the overlay by creating a BitBake append file in my Yocto layer and added am335x-bonegreen-wireless-uboot-univ.dtb to the KERNEL_DEVICETREE_beaglebone variable.
When I built and booted using this version the error during boot did not show up and neither did the
previous error (Error: ENOENT: no such file or directory, open ‘/sys/devices/platform/ocp/ocp:P8_09_pinmux/state) however I have not yet verified that the actual pin state was changed.
I’m suspecting that this is a bug in the BalenaOs and should be added in linux-beagleboard_5.4.bb
Will post an update when I test the GPIO physical state.
Thanks @fencer! You’re the best! I’ve linked the PR to this support issue, fyi. I’ll close the support issue for now, but you may get a notification once this makes it’s way to production.