BBE Correcting Barometer Missing


Tutorial for BeagleBone Enhanced – Debian Release Images (9.4 – 9.7)

This guide is specific to Debian Release Images (9.4-9.7) in which the Barometer is not being identified in the filesystem for access.

To identify if the board’s device tree is configured incorrectly first we need to examine dmesg:

$ dmesg
[   29.454726] st-press-i2c 0-005c: 0-005c supply vdd not found, using dummy regulator
[   29.454907] st-press-i2c 0-005c: 0-005c supply vddio not found, using dummy regulator
[   29.463637] iio iio:device2: interrupts on the rising edge
[   29.475400] gpio gpiochip1: (gpio): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
[   29.874296] gpio gpiochip1: (gpio): unable to lock HW IRQ 27 for IRQ
[   30.222139] genirq: Failed to request resources for lps331ap-trigger (irq 114) on irqchip 4804c000.gpio
[   30.641187] iio iio:device2: failed to request trigger IRQ.
[   30.974327] st-press-i2c: probe of 0-005c failed with error -22

If you see the reference to;

st-press-i2c: probe of 0-005c failed with error -22

The device tree is configured incorrectly.

Examination of the /sys/bus/iio/devices folder will also show the barometer missing;

debian@beaglebone:$ cd /sys/bus/iio/devices
debian@beaglebone:/sys/bus/iio/devices$ ls -l
total 0
lrwxrwxrwx 1 root root 0 Jan  1  2000 iio:device0 -> ../../../devices/platform/ocp/44e0d000.tscadc/TI-am335x-adc/iio:device0
lrwxrwxrwx 1 root root 0 Sep  2 18:14 iio:device1 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-0068/iio:device1
lrwxrwxrwx 1 root root 0 Sep  2 18:14 trigger0 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-0068/trigger0

Rectifying is fairly straight forward and can be perfomed in the following steps:

1. Change to the device tree source folder

cd /opt/source/dtb-4.14-ti/src/arm/

2. Create a backup of the current dts in case of editing error:

cp am335x-sancloud-bbe.dts am335x-sancloud-bbe.dts.bak

3. Edit the device tree file:

vi am335x-sancloud-bbe.dts

4. Locate and edit the pinmux lines:

	lps3331ap_pins: pinmux_lps3331ap_pins {
		pinctrl-single,pins = <
			0x6C (PIN_INPUT | MUX_MODE7)	/* conf_gpmc_a11.gpio1_27 */
		>;
	};

Change to:

	lps3331ap_pins: pinmux_lps3331ap_pins {
		pinctrl-single,pins = <
			0x68 (PIN_INPUT | MUX_MODE7)	/* conf_gpmc_a10.gpio1_26 */
		>;
	};

5. Locate the interrupt line:

&i2c0 {
	lps331ap: lps331ap@5C {
		compatible = "st,lps331ap";
		st,drdy-int-pin = <1>;
		reg = <0x5C>;
		interrupt-parent = <&gpio1>;
		interrupts = <27 IRQ_TYPE_EDGE_RISING>;
	};

Change to:

&i2c0 {
	lps331ap: lps331ap@5C {
		compatible = "st,lps331ap";
		st,drdy-int-pin = <1>;
		reg = <0x5C>;
		interrupt-parent = <&gpio1>;
		interrupts = <26 IRQ_TYPE_EDGE_RISING>;
	};

6. Save the edited device tree.

7. Compile the edited device tree to create a new binary:

cd /opt/source/dtb-4.14-ti/
make src/arm/am335x-sancloud-bbe.dtb

You should see output similar to:

debian@beaglebone:/opt/source/dtb-4.14-ti$ make src/arm/am335x-sancloud-bbe.dtb
  DTC     src/arm/am335x-sancloud-bbe.dtb

If successful you can then copy the new binary to the boot folder. This requires sudo privileges so the sudo command is used and the password for the debian account used to verify;

8. Copy the new device tree to the boot directory

sudo cp src/arm/am335x-sancloud-bbe.dtb /boot/dtbs/4.14.71-ti-r80/am335x-sancloud-bbe.dtb

If its the first time you have used sudo on the system you will be shown a warning message, enter the debian account password and press enter to proceed:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for debian:

9. Lastly, synchronise the filesystem.

Very important to make sure your changes are flushed from cache onto the physical media.

sync

10. Reboot the system and check dmesg and /sys/bus/iio/devices

debian@beaglebone:$ cd /sys/bus/iio/devices
debian@beaglebone:/sys/bus/iio/devices$ ls -l
total 0
lrwxrwxrwx 1 root root 0 Jan  1  2000 iio:device0 -> ../../../devices/platform/ocp/44e0d000.tscadc/44e0d000.tscadc:adc/iio:device0
lrwxrwxrwx 1 root root 0 Sep  2 18:57 iio:device1 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-0068/iio:device1
lrwxrwxrwx 1 root root 0 Sep  2 18:57 iio:device2 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-005c/iio:device2
lrwxrwxrwx 1 root root 0 Sep  2 18:57 trigger0 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-0068/trigger0
lrwxrwxrwx 1 root root 0 Sep  2 18:57 trigger1 -> ../../../devices/platform/ocp/44e0b000.i2c/i2c-0/0-005c/trigger1