BBGW GPIO not found

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.

Hi

Can you share your dockerfile?

Another way to give access to hardware is through the devices keyword as mentioned in the Interact with hardware docs - can you try this?

If that works, but the privileged mode approach doesn’t work - that would give us useful debug info.

adding device keywords did not help.

this is the dockerfile for one of the containers:

FROM balenalib/%%BALENA_MACHINE_NAME%%-debian-node:10

COPY empty_file tmp*/qemu-arm-stati[c] /usr/bin/

RUN install_packages avahi-utils libavahi-compat-libdnssd-dev curl git build-essential dialog libnss-mdns python xsltproc 

RUN mkdir -p /root/demo-app
WORKDIR /root/demo-app

COPY . .
RUN npm install
RUN npm run build

RUN mkdir -p /root/.demo-app
COPY v360.svg /root/.demo-app/logo.svg

EXPOSE 3000
ENV IS_IN_DOCKER true
ENV demo-app_DISABLE_SERVER_UPDATES true
ENV demo-app_NODE_CONFIG_DIR /data/
ENV UDEV=on


COPY scripts/start.sh .
CMD ["bash", "start.sh"]
ENTRYPOINT /root/demo-app/bin/demo-app-server --securityenabled

this is my docker-template:

version: '2.1'
networks: {}
volumes:
  resin-data: {}
services:
  demo-app:
    container_name: demo-app
    build: ./demo-app-server-node
    restart: always
    network_mode: host
    volumes:
      - 'resin-data:/data'
    privileged: true
    labels:
      io.balena.features.dbus: '1'
      io.balena.features.balena-api: '1'
      io.balena.features.supervisor-api: '1'
      io.balena.features.sysfs: '1'
    ports:
      - "80:3000"
    devices:
      - "/dev:/dev"
    cap_add:
      - NET_ADMIN
      - SYS_RAWIO
    environment:
      DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/host/run/dbus/system_bus_socket"
  wifi-connect:
    build: ./wifi-connect
    network_mode: "host"
    privileged: true
    labels:
      io.balena.features.dbus: '1'
    devices:
      - "/dev/i2c-1:/dev/i2c-1"
    cap_add:
      - NET_ADMIN
      - SYS_RAWIO
    environment:
      DBUS_SYSTEM_BUS_ADDRESS: "unix:path=/host/run/dbus/system_bus_socket"

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

Hey there!

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/

Thanks

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
root@e66614e:~# ls -l /sys/devices/platform/ocp/ocp\:P8_09_pinmux/
total 0
lrwxrwxrwx 1 root root    0 Apr  2 16:01 driver -> ../../../../bus/platform/drivers/bone-pinmux-helper
-rw-r--r-- 1 root root 4096 Apr  2 16:01 driver_override
-r--r--r-- 1 root root 4096 Apr  2 16:01 modalias
lrwxrwxrwx 1 root root    0 Apr  2 16:01 of_node -> ../../../../firmware/devicetree/base/ocp/P8_09_pinmux
drwxr-xr-x 2 root root    0 Apr  2 16:01 power
-rw-r--r-- 1 root root 4096 Apr  2 15:56 state
lrwxrwxrwx 1 root root    0 Jan  1  2000 subsystem -> ../../../../bus/platform
-rw-r--r-- 1 root root 4096 Jan  1  2000 uevent

The overly basically initialised the RTC chip, now I’ve also added the parts to declare P8_09 and P8_19 My-Custom-Overlay-00A0.dts.log (3.0 KB)

@jkridner Just curious, have you ever seen this situation before, by chance?

I’ve now updated to balenaOS 2.73.1+rev2 but still the issue remains :exploding_head:

Hi Claude,

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.

BTW, you can do that with something like:

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";
        };
    };
};
1 Like

Thanks for the info @jkridner – I appreciate it greatly!

@fencer, have a look at Jason’s remarks above. :slight_smile:

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):

debug: [uboot_base_dtb_univ=am335x-bonegreen-wireless-uboot-univ.dtb] ...
uboot_overlays: [uboot_base_dtb=am335x-bonegreen-wireless-uboot-univ.dtb] ...
debug: unable to find [am335x-bonegreen-wireless-uboot-univ.dtb] 

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.

Hello! Just wanted to ping regarding this issue. Were you able to verify your results regarding pin state?

Yes that has solved my issue. Would you like me to submit a PR for this?

@fencer it would be great if you can do that! Thanks for following up so far!

Hey @fencer Just wondered if you’d had chance to create that PR? No worries if not. Cheers!

my first PR #270 created :slight_smile:

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.