bbb - regain control of pin previously used by kernel driver

I’m stuck on trying to regain control of a gpio pin which had previously been taken by a driver at boot time.

This is on a beaglebone black with a 4D display cape. The problematic driver is for the touch panel, and the pin is pin p9.26, which is the touch interrupt pin. I want to use this instead for CAN.

I have disabled the driver using unbind, but then trying to reassign the pin with config-pin, the error is:
ERROR: open() for /sys/devices/platform/ocp/ocp:P9_26_pinmux/state failed, No such file or directory

I dont want to use this driver at all. My userspace driver is working fine without using the interrupt so I’ll just cut the trace on the cape leading to that pin. If I want to use the interrupt at a future time, I can simply reroute it to a different pin.

Possible solutions:

  • Permanently prevent the driver from loading at boot (edt_ft5x06).
  • Edit the dtb to disable the touch configuration. (BB-BONE-4D5C-01-00A1.dtbo)
  • Do something to bring the pin back under the control of the config-pin command.

The only google results I found for disabling a module at boot time are for desktops and don’t seem applicable to the BBB.
Recompiling a .dts to a .dtbo seems to have changed recently an I havn’t found instructions that work for the new way. dtc seems to barf on the #include directive. I did find one article that seemed to suggest that I would need to basicly build a custom kernel, which doesnt seem quite right.

Can anyone offer advice on a best approach, or how to achieve this?

It’s been a while since I did anything with a BBB, but things to check.

It is probably that a DTS overlay is being loaded by uboot for the touchscreen driver. If so you can start by removing this. If you have the serial console connected you should see if this is the case.

If you want to use the pin for CAN you will probably need to set up the pin muxing and will need to make a DTS overlay, or modify the root DTS.

You don’t need to compile a custom kernel for this, but you will probably need the kernel source, hence the failure on the #include. You can just compile the DTS files by doing a ‘make dtbs’ after adding your custom file to the Makefile. You don’t need to compile the kernel.

Why does everyone want to use dtc… just use the makefile in that repo…

make
sudo make install

Regards,

Mostly because the overlays are an undocumented, poorly debuggable, impenetrable mess of files with weird syntax.

Overlays are the automake of the embedded Linux ARM world. Everybody copies a “working” script, changes a few bits, types a few magic commands, and prays to their favorite deity in the hopes that the result will do something useful because they can’t possibly figure it out if it doesn’t.

Big Thank you to Benedict and Robert for pointing me in the right direction. For future reference, here are the steps I took to make this work.

git clone https://github.com/beagleboard/linux.git
cd linux
git checkout 5.10
make omap2plus_defconfig

copy edited .dts into arch/arm/boot/dts/overlays/

make dtbs

copy resulting .dtbo into /lib/firmware/

However there were many hickups and roadblocks along the way. Here are just some:
The git archive is 4Gb - make sure there is room on the SD card.
Downloading the archive choked on the BBB part way through while cross compiling on Ubuntu failed, so I downloaded it on Ubuntu then copied it across to the BBB.
The .dts didn’t exist in the archive, so I copied it from the distribution then updated the Makefile.
One of the headers wasn’t found in the include path, but it did exist elsewhere in the archive, so I just copied it into the expected location.

(Pretty much just as Buzmeg described it … Huge relief when it did finaly work.)

Edit: seems most of the above is unnecessary - see reply below. I could simply have typed make in /opt/source/bb.org-overlays …

As a side note; I had hoped that this might prevent the loading of the ft5x06 driver, as well as preventing the capture of the pin at boot, however the driver does still appear to be loading. I dont appear to need to issue the unbind command to the driver any more, but I think it’s probably dumb not to.

for v5.10.x-ti here is the device tree and overlay source…

we pull that source into our kernel build before every release…

You’ll also find a local copy under /opt/source/dtb-5.10-ti which you can git pull

Edit:

debian@BeagleBone:~$ cd /opt/source/dtb-5.10-ti/
debian@BeagleBone:/opt/source/dtb-5.10-ti$ git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Already up to date.
debian@BeagleBone:/opt/source/dtb-5.10-ti$ make
  DTC     src/arm/am335x-sancloud-bbe-lite.dtb
  DTC     src/arm/am335x-boneblue.dtb
  DTC     src/arm/am335x-sancloud-bbe-extended-wifi-uboot-univ.dtb
  DTC     src/arm/am335x-boneblack.dtb
  DTC     src/arm/am335x-bone.dtb
  DTC     src/arm/am335x-bonegreen-wireless-uboot-univ.dtb
  DTC     src/arm/am335x-sancloud-bbe-uboot.dtb
  DTC     src/arm/am57xx-beagle-x15.dtb
  DTC     src/arm/am335x-boneblack-pps.dtb
  DTC     src/arm/am335x-sancloud-bbe-lite-uboot-univ.dtb
  DTC     src/arm/am335x-boneblack-uboot-univ.dtb
  DTC     src/arm/am5729-beagleboneai.dtb
src/arm/bbai-bone-buses.dtsi:544.8-556.4: Warning (graph_child_address): /ocp/target-module@58000000/dss@0/ports: graph node has single child node 'port', #address-cells/#size-cells are not necessary
src/arm/bbai-bone-buses.dtsi:548.8-555.5: Warning (graph_port): /ocp/target-module@58000000/dss@0/ports/port: graph node unit address error, expected "0"
  DTC     src/arm/am335x-sancloud-bbe.dtb
  DTC     src/arm/am335x-sancloud-bbe-lite-uboot.dtb
  DTC     src/arm/am335x-bonegreen-wireless.dtb
  DTC     src/arm/am335x-boneblack-pruswuart.dtb
  DTC     src/arm/am57xx-beagle-x15-revc.dtb
  DTC     src/arm/am335x-sancloud-bbe-extended-wifi.dtb
  DTC     src/arm/am57xx-beagle-x15-revb1.dtb
  DTC     src/arm/am335x-bonegreen.dtb
  DTC     src/arm/am335x-boneblack-wireless.dtb
  DTC     src/arm/am335x-sancloud-bbe-extended-wifi-uboot.dtb
  DTC     src/arm/omap5-uevm.dtb
  DTC     src/arm/am335x-pocketbeagle.dtb
  DTC     src/arm/am335x-sancloud-bbe-uboot-univ.dtb
  DTC     src/arm/am335x-bone-uboot-univ.dtb
  DTC     src/arm/am335x-osd3358-sm-red.dtb
  DTC     src/arm/am335x-bonegreen-gateway.dtb
  DTC     src/arm/am335x-boneblack-uboot.dtb
  DTC     src/arm/overlays/BB-I2C2-BME680.dtbo
  DTC     src/arm/overlays/M-BB-BBG-00A0.dtbo
  DTC     src/arm/overlays/PB-MIKROBUS-1.dtbo
  DTC     src/arm/overlays/BB-BONE-4D5R-01-00A1.dtbo
  DTC     src/arm/overlays/LED_P8_04.dtbo
  DTC     src/arm/overlays/BONE-ADC.dtbo
  DTC     src/arm/overlays/LED_P8_03.dtbo
  DTC     src/arm/overlays/PB-MIKROBUS-0.dtbo
  DTC     src/arm/overlays/BB-CAPE-DISP-CT4-00A0.dtbo
  DTC     src/arm/overlays/BB-BBBW-WL1835-00A0.dtbo
  DTC     src/arm/overlays/PB-HACKADAY-2021.dtbo
  DTC     src/arm/overlays/BB-ADC-00A0.dtbo
  DTC     src/arm/overlays/BB-NHDMI-TDA998x-00A0.dtbo
  DTC     src/arm/overlays/BB-W1-P9.12-00A0.dtbo
  DTC     src/arm/overlays/BB-BONE-LCD4-01-00A1.dtbo
  DTC     src/arm/overlays/BB-SPIDEV1-00A0.dtbo
  DTC     src/arm/overlays/BB-BBGW-WL1835-00A0.dtbo
  DTC     src/arm/overlays/BBORG_RELAY-00A2.dtbo
  DTC     src/arm/overlays/BBORG_COMMS-00A2.dtbo
  DTC     src/arm/overlays/BB-SPIDEV0-00A0.dtbo
  DTC     src/arm/overlays/BBORG_FAN-A000.dtbo
  DTC     src/arm/overlays/M-BB-BBGG-00A0.dtbo
  DTC     src/arm/overlays/AM335X-PRU-UIO-00A0.dtbo
  DTC     src/arm/overlays/BB-HDMI-TDA998x-00A0.dtbo
  DTC     src/arm/overlays/BB-BONE-eMMC1-01-00A0.dtbo
  DTC     src/arm/overlays/BB-BBGG-WL1835-00A0.dtbo
  DTC     src/arm/overlays/BB-BONE-NH7C-01-A0.dtbo
  DTC     src/arm/overlays/AM57XX-PRU-UIO-00A0.dtbo
src/arm/overlays/AM57XX-PRU-UIO-00A0.dts:25.9-37.3: Warning (interrupts_property): /fragment@2/__overlay__: Missing interrupt-parent
src/arm/overlays/AM57XX-PRU-UIO-00A0.dts:43.9-55.3: Warning (interrupts_property): /fragment@4/__overlay__: Missing interrupt-parent
debian@BeagleBone:/opt/source/dtb-5.10-ti$ sudo make install
[sudo] password for debian: 
# install Device Tree
mkdir -p /boot/dtbs/5.10.131-ti-r49/
cp -v src/arm/*.dtb /boot/dtbs/5.10.131-ti-r49/
'src/arm/am335x-bone-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bone-uboot-univ.dtb'
'src/arm/am335x-bone.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bone.dtb'
'src/arm/am335x-boneblack-pps.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack-pps.dtb'
'src/arm/am335x-boneblack-pruswuart.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack-pruswuart.dtb'
'src/arm/am335x-boneblack-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack-uboot-univ.dtb'
'src/arm/am335x-boneblack-uboot.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack-uboot.dtb'
'src/arm/am335x-boneblack-wireless.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack-wireless.dtb'
'src/arm/am335x-boneblack.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblack.dtb'
'src/arm/am335x-boneblue.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-boneblue.dtb'
'src/arm/am335x-bonegreen-gateway.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bonegreen-gateway.dtb'
'src/arm/am335x-bonegreen-wireless-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bonegreen-wireless-uboot-univ.dtb'
'src/arm/am335x-bonegreen-wireless.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bonegreen-wireless.dtb'
'src/arm/am335x-bonegreen.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-bonegreen.dtb'
'src/arm/am335x-osd3358-sm-red.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-osd3358-sm-red.dtb'
'src/arm/am335x-pocketbeagle.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-pocketbeagle.dtb'
'src/arm/am335x-sancloud-bbe-extended-wifi-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-extended-wifi-uboot-univ.dtb'
'src/arm/am335x-sancloud-bbe-extended-wifi-uboot.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-extended-wifi-uboot.dtb'
'src/arm/am335x-sancloud-bbe-extended-wifi.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-extended-wifi.dtb'
'src/arm/am335x-sancloud-bbe-lite-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-lite-uboot-univ.dtb'
'src/arm/am335x-sancloud-bbe-lite-uboot.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-lite-uboot.dtb'
'src/arm/am335x-sancloud-bbe-lite.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-lite.dtb'
'src/arm/am335x-sancloud-bbe-uboot-univ.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-uboot-univ.dtb'
'src/arm/am335x-sancloud-bbe-uboot.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe-uboot.dtb'
'src/arm/am335x-sancloud-bbe.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am335x-sancloud-bbe.dtb'
'src/arm/am5729-beagleboneai.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am5729-beagleboneai.dtb'
'src/arm/am57xx-beagle-x15-revb1.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am57xx-beagle-x15-revb1.dtb'
'src/arm/am57xx-beagle-x15-revc.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am57xx-beagle-x15-revc.dtb'
'src/arm/am57xx-beagle-x15.dtb' -> '/boot/dtbs/5.10.131-ti-r49/am57xx-beagle-x15.dtb'
'src/arm/omap5-uevm.dtb' -> '/boot/dtbs/5.10.131-ti-r49/omap5-uevm.dtb'
# install DT overlays
mkdir -p /boot/dtbs/5.10.131-ti-r49/overlays/
cp -v src/arm/overlays/*.dtbo /boot/dtbs/5.10.131-ti-r49/overlays
'src/arm/overlays/AM335X-PRU-UIO-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/AM335X-PRU-UIO-00A0.dtbo'
'src/arm/overlays/AM57XX-PRU-UIO-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/AM57XX-PRU-UIO-00A0.dtbo'
'src/arm/overlays/BB-ADC-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-ADC-00A0.dtbo'
'src/arm/overlays/BB-BBBW-WL1835-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BBBW-WL1835-00A0.dtbo'
'src/arm/overlays/BB-BBGG-WL1835-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BBGG-WL1835-00A0.dtbo'
'src/arm/overlays/BB-BBGW-WL1835-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BBGW-WL1835-00A0.dtbo'
'src/arm/overlays/BB-BONE-4D5R-01-00A1.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BONE-4D5R-01-00A1.dtbo'
'src/arm/overlays/BB-BONE-LCD4-01-00A1.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BONE-LCD4-01-00A1.dtbo'
'src/arm/overlays/BB-BONE-NH7C-01-A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BONE-NH7C-01-A0.dtbo'
'src/arm/overlays/BB-BONE-eMMC1-01-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-BONE-eMMC1-01-00A0.dtbo'
'src/arm/overlays/BB-CAPE-DISP-CT4-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-CAPE-DISP-CT4-00A0.dtbo'
'src/arm/overlays/BB-HDMI-TDA998x-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-HDMI-TDA998x-00A0.dtbo'
'src/arm/overlays/BB-I2C2-BME680.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-I2C2-BME680.dtbo'
'src/arm/overlays/BB-NHDMI-TDA998x-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-NHDMI-TDA998x-00A0.dtbo'
'src/arm/overlays/BB-SPIDEV0-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-SPIDEV0-00A0.dtbo'
'src/arm/overlays/BB-SPIDEV1-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-SPIDEV1-00A0.dtbo'
'src/arm/overlays/BB-W1-P9.12-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BB-W1-P9.12-00A0.dtbo'
'src/arm/overlays/BBORG_COMMS-00A2.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BBORG_COMMS-00A2.dtbo'
'src/arm/overlays/BBORG_FAN-A000.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BBORG_FAN-A000.dtbo'
'src/arm/overlays/BBORG_RELAY-00A2.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BBORG_RELAY-00A2.dtbo'
'src/arm/overlays/BONE-ADC.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/BONE-ADC.dtbo'
'src/arm/overlays/LED_P8_03.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/LED_P8_03.dtbo'
'src/arm/overlays/LED_P8_04.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/LED_P8_04.dtbo'
'src/arm/overlays/M-BB-BBG-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/M-BB-BBG-00A0.dtbo'
'src/arm/overlays/M-BB-BBGG-00A0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/M-BB-BBGG-00A0.dtbo'
'src/arm/overlays/PB-HACKADAY-2021.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/PB-HACKADAY-2021.dtbo'
'src/arm/overlays/PB-MIKROBUS-0.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/PB-MIKROBUS-0.dtbo'
'src/arm/overlays/PB-MIKROBUS-1.dtbo' -> '/boot/dtbs/5.10.131-ti-r49/overlays/PB-MIKROBUS-1.dtbo'

Regards,

Looking at the various devicetree files, it appears the edt-ft5x06 driver is included by 2 overlays.

BB-CAPE-DISP-CT4-00A0 and BB-BONE-NH7C-01-A0

Make sure they are not being loaded and that should stop the driver from being loaded.