BeagleBone Black overlays

463 views
Skip to first unread message

John Morris

unread,
Mar 3, 2018, 11:59:44 PM3/3/18
to Machinekit
I'm having a heck of a time getting overlays working on the BBB with
RCN's 2018-02 MK image. I'm weak on the concepts to begin with, and
here's what I've done.

With the stock `/boot/uEnv.txt`, most pins aren't already assigned to
any cape:

machinekit@beaglebone:~$ config-pin P9.18 lo
P9_18 pinmux file not found!
Pin has no cape: P9_18
machinekit@beaglebone:~$ ls -d /sys/devices/platform/ocp/ocp:P*
/sys/devices/platform/ocp/ocp:P9_19_pinmux
/sys/devices/platform/ocp/ocp:P9_20_pinmux

Trying to load the universal cape with `config-pin overlay
cape-universal` dumps a huge list of errors to the console and kernel
oopses on the 4.14 kernel. On the 4.4 kernel, the pins seem to appear
in `/sys/devices/platform/ocp/ocp:P*`, but `config-pin P9.18 lo` says
"WARNING: GPIO pin not exported, cannot set direction or value!". So I
don't do that.

Instead, I compile and install a .dts file with just the wanted pins,
and add the line
`uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo` to
`/boot/uEnv.txt`. This doesn't seem to assign any pins, but I'm unclear
whether it's a bad file or something else.


https://github.com/zultron/autoclave_control/blob/master/etc/bb_autoclave.dts

Compiling produces no unexpected errors:

> machinekit@beaglebone:~$ sudo dtc -O dtb -o /lib/firmware/bb_autoclave-00A0.dtbo -b 0 -@ etc/bb_autoclave.dts
> /lib/firmware/bb_autoclave-00A0.dtbo: Warning (unit_address_vs_reg): Node /fragment@0 has a unit name, but no reg property


Maybe this is meaningful; the Linux 4.14 version:

> machinekit@beaglebone:~$ sudo /opt/scripts/tools/version.sh
> git:/opt/scripts/:[ad016da40de5805f1a6f981cbb6c454b1a7f244b]
> eeprom:[A335BNLT0A5A1513BBBK3416]
> model:[TI_AM335x_BeagleBone_Black]
> dogtag:[Machinekit Debian Image 2018-02-04]
> bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.01-00002-g9aa111a004]
> bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2015.01-00001-gb2412df]
> kernel:[4.14.16-ti-rt-r30]
> uboot_overlay_options:[enable_uboot_overlays=1]
> uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo]
> uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
> uboot_overlay_options:[enable_uboot_cape_universal=1]
> pkg:[bb-cape-overlays]:[4.4.20180126.0-0rcnee0~stretch+20180126]
> pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee2~stretch+20180104]
> pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]
> groups: �‘debian�’: no such user
> groups:[]
> dmesg | grep pinctrl-single
> [ 1.409569] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
> dmesg | grep gpio-of-helper
> [ 1.411448] gpio-of-helper ocp:cape-universal: ready
> END

The Linux 4.4 version, slightly different:

> root@beaglebone:/home/machinekit# sudo /opt/scripts/tools/version.sh
> [...]
> kernel:[4.4.113-ti-rt-r147]
> [...]
> dmesg | grep gpio-of-helper
> [ 1.511377] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0
> [ 1.511589] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1
> [ 1.511604] gpio-of-helper ocp:cape-universal: ready
> END

So who knows what dumb thing I'm missing? Thanks!

John

Charles Steinkuehler

unread,
Mar 4, 2018, 9:07:28 AM3/4/18
to machi...@googlegroups.com
On 3/3/2018 10:59 PM, John Morris wrote:
>
> Instead, I compile and install a .dts file with just the wanted pins,
> and add the line
> `uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo` to
> `/boot/uEnv.txt`.  This doesn't seem to assign any pins, but I'm
> unclear whether it's a bad file or something else.
>
> https://github.com/zultron/autoclave_control/blob/master/etc/bb_autoclave.dts

That snippit of a device tree overlay is incomplete. I suggest you
start with one of the unviersal overlays and chop out everything you
don't need. Alternately, add some more stuff to your minimal overlay
file. Using your first pin (P9_18) as an example:

You first need to define some pin mux settings (note you only need to
define the ones you want to use):

target = <&am33xx_pinmux>;

https://github.com/cdsteinkuehler/beaglebone-universal-io/blob/master/cape-universal-00A0.dts#L479-L495

...then you can setup the pinmux helper:

target = <&ocp>;
compatible = "bone-pinmux-helper";

https://github.com/cdsteinkuehler/beaglebone-universal-io/blob/master/cape-universal-00A0.dts#L1040-L1052

These two bits are the "magic" that lets you play with pinmux settings
from user space. To change the default pin settings, either edit the
default value directly (ie: P9_18_default_pin) or change the first
entry in the pinmux-helper stanza, ie:

// pinctrl-0 = <&P9_18_default_pin>;
pinctrl-0 = <&P9_18_gpio_pd_pin>;

Finally, export the gpio pins, this is what makes them visible in
sysfs and is basically the same as:
"cat $pin > /sys/class/gpio/export":

target = <&ocp>;
compatible = "gpio-of-helper";

https://github.com/cdsteinkuehler/beaglebone-universal-io/blob/master/cape-universal-00A0.dts#L1408-L1413

Or as mentioned previously, if you don't need to mess with the pinmux
settings you can just export the GPIO pins you need via the sysfs
interface.

--
Charles Steinkuehler
cha...@steinkuehler.net

Robert Nelson

unread,
Mar 5, 2018, 1:31:46 AM3/5/18
to John Morris, Machinekit
Hi John,
Your old eMMC is blocking U-Boot Overlays:

sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10


>> kernel:[4.14.16-ti-rt-r30]
>> uboot_overlay_options:[enable_uboot_overlays=1]
>>
>> uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo]
>> uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
>> uboot_overlay_options:[enable_uboot_cape_universal=1]

I'm in a middle of a rewrite to enable cape-universal in this
situation, currently your selection of
"uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo" is blocking
cape-univesal:

Step 1: Upgrade to this bootloader:

sudo /opt/scripts/tools/developers/update_bootloader.sh --beta

Step 2: Install this kernel: (haven't backported the changes to
v4.14.x/v4.9.x/v4.4.x yet)

sudo /opt/scripts/tools/update_kernel.sh --bone-channel --exp

Step 3: in your overlay add a new fragment@0 section like this, but
with the pins your "bb_autoclave" uses:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-BONE-4D4C-01-00A1.dts#L16-L53


>> pkg:[bb-cape-overlays]:[4.4.20180126.0-0rcnee0~stretch+20180126]
>> pkg:[bb-wl18xx-firmware]:[1.20170829-0rcnee2~stretch+20180104]
>> pkg:[firmware-ti-connectivity]:[20170823-1rcnee0~stretch+20170830]
>> groups: �‘debian�’: no such user

opps, i need to check for machinekit too..

>> groups:[]
>> dmesg | grep pinctrl-single
>> [ 1.409569] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800
>> size 568
>> dmesg | grep gpio-of-helper
>> [ 1.411448] gpio-of-helper ocp:cape-universal: ready
>> END
>
>
> The Linux 4.4 version, slightly different:
>
>> root@beaglebone:/home/machinekit# sudo /opt/scripts/tools/version.sh
>> [...]
>> kernel:[4.4.113-ti-rt-r147]
>> [...]
>> dmesg | grep gpio-of-helper
>> [ 1.511377] gpio-of-helper ocp:cape-universal: Allocated GPIO id=0
>> [ 1.511589] gpio-of-helper ocp:cape-universal: Allocated GPIO id=1
>> [ 1.511604] gpio-of-helper ocp:cape-universal: ready
>> END
>
>
> So who knows what dumb thing I'm missing? Thanks!
>
> John
>
> --
> website: http://www.machinekit.io blog: http://blog.machinekit.io github:
> https://github.com/machinekit
> --- You received this message because you are subscribed to the Google
> Groups "Machinekit" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to machinekit+...@googlegroups.com.
> Visit this group at https://groups.google.com/group/machinekit.
> For more options, visit https://groups.google.com/d/optout.



--
Robert Nelson
https://rcn-ee.com/

John Morris

unread,
Mar 6, 2018, 1:34:32 PM3/6/18
to Machinekit, Robert Nelson


On 03/05/2018 12:31 AM, Robert Nelson wrote:
> [...]
>
> Your old eMMC is blocking U-Boot Overlays:
>
> sudo dd if=/dev/zero of=/dev/mmcblk1 bs=1M count=10
>
> [...]
>
> I'm in a middle of a rewrite to enable cape-universal in this
> situation, currently your selection of
> "uboot_overlay_addr0=/lib/firmware/bb_autoclave-00A0.dtbo" is blocking
> cape-univesal:
>
> Step 1: Upgrade to this bootloader:
>
> sudo /opt/scripts/tools/developers/update_bootloader.sh --beta
>
> Step 2: Install this kernel: (haven't backported the changes to
> v4.14.x/v4.9.x/v4.4.x yet)
>
> sudo /opt/scripts/tools/update_kernel.sh --bone-channel --exp

Performing these steps seems to have unblocked the universal cape, as
you said, and now `/sys/devices/platform/ocp/ocp:P*_*_pinmux` have
reappeared without needing my custom .dts file at all. Great!

Even better, the USB WiFi adapter (that worked fine on the BB white)
that hadn't been working is now happy again. Before, it wouldn't come
up after boot, and had to be unplugged and replugged in order to start
working.

Only thing missing is the RT_PREEMPT patch. For my application it may
not be necessary, since autoclave control timings aren't critical.

> Step 3: in your overlay add a new fragment@0 section like this, but
> with the pins your "bb_autoclave" uses:
>
> https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-BONE-4D4C-01-00A1.dts#L16-L53

I still haven't managed to get my overlay working. Charles's
suggestions to add the pinmux configuration and this suggestion to free
the pins caused errors. I probably made a mistake following y'all's
directions. I'm happy to go back and troubleshoot if it helps anyone,
but right now with the pins in the default state, it's all good.

Thank you!

John
Reply all
Reply to author
Forward
0 new messages