Advice needed on building a device tree overlay

How do I install a single overlay? I’m writing and building a device tree overlay for a RTC chip (a DS1307) on a cape board that we designed. I want to communicate with the chip over the I2C bus no. 2 on a beaglebone black.

I know how to build the overlay using dtc, and I know I must copy the .dtbo file to /lib/firmware. My question is, do I have to run update-initramfs as well, or is it good enough to copy the .dtbo file to /lib/firmware?
Anything else I need to do to install a single .dtbo?

Another question: I see there is an overlay (BB-I2C2-RTC-DS1338.dts) available on https://github.com/RobertCNelson/bb.org-overlays. Maybe this will work for me with my DS1307 chip?

Or I could install all the overlays with sudo apt update; sudo apt install bb-cape-overlays. Is it safe to install all the currently available overlays from Robert Nelson’s site on my system? I have an older version of Ubuntu (16.04.3 LTS from Robert Nelson).

Thanks,
Tim

How do I install a single overlay? I'm writing and building a device tree overlay for a RTC chip (a DS1307) on a cape board that we designed. I want to communicate with the chip over the I2C bus no. 2 on a beaglebone black.

I know how to build the overlay using dtc, and I know I must copy the .dtbo file to /lib/firmware. My question is, do I have to run update-initramfs as well, or is it good enough to copy the .dtbo file to /lib/firmware?
Anything else I need to do to install a single .dtbo?

debian@test-bbb-1:/opt/source/bb.org-overlays$ make
src/arm/BB-I2C2-RTC-DS1338.dtbo
  DTC src/arm/BB-I2C2-RTC-DS1338.dtbo

sudo cp ./src/arm/BB-I2C2-RTC-DS1338.dtbo /lib/firmware/

Another question: I see there is an overlay (BB-I2C2-RTC-DS1338.dts) available on https://github.com/RobertCNelson/bb.org-overlays. Maybe this will work for me with my DS1307 chip?

It should as long as you update these to ds1338 references to DS1307:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-I2C2-RTC-DS1338.dts#L63-L64

Or I could install all the overlays with sudo apt update; sudo apt install bb-cape-overlays. Is it safe to install all the currently available overlays from Robert Nelson's site on my system? I have an older version of Ubuntu (16.04.3 LTS from Robert Nelson).

So this really depends the version of u-boot and kernel that you
currently utilize.

Git Master of bb.org-overlays

https://github.com/beagleboard/bb.org-overlays

Is currently targeting U-Boot Overlays with:

U-Boot v2018.03+
Kernel: v4.4.x -> v4.19.x

So, update-initramfs is no longer required, that was needed for
"Kernel Overlays", as the kernel needed access to the *.dtbo early in
bootup, but we've given up on supporting that. Kernel Overlays are
also no longer even available in anything later then our v4.15.x
kernel branches.

When Debian Buster get's released next spring, bb.org-overlays will
get a new tag, and v4.4.x/v4.9.x support will be no longer guaranteed.
(There's a few "hacks" in there to help support v4.4.x kernel that are
getting in the way of new drivers in mainline)

Regards,

I did the following:

  • I fetched https://github.com/beagleboard/bb.org-overlays
  • copied the file BB-I2C2-RTC-DS1338.dts to BB-I2C2-RTC-DS1307.dts
  • edited BB-I2C2-RTC-DS1307.dts to refer to my DS1307 chip instead of DS1338
  • make src/arm/BB-I2C2-RTC-DS1307.dtbo
  • sudo cp ./src/arm/BB-I2C2-RTC-DS1307.dtbo /lib/firmware/

I added the following lines to /boot/uEnv.txt:
uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/BB-I2C2-RTC-DS1307.dtbo

I rebooted.

After rebooting, dmesg shows this:

bone_capemgr bone_capemgr: Baseboard: ‘A335BNLT,000C,1633BBBG0596’
bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
bone_capemgr bone_capemgr: slot #0: No cape found
bone_capemgr bone_capemgr: slot #1: No cape found
bone_capemgr bone_capemgr: slot #2: No cape found
bone_capemgr bone_capemgr: slot #3: No cape found
bone_capemgr bone_capemgr: initialized OK.

I expected to see BB-UART2-00A0.dtbo in slot #1 and BB-I2C2-RTC-DS1307.dtbo in slot #2.
The overlays are not loaded. What am I doing wrong?

I also expect that loading the overlay BB-I2C2-RTC-DS1307.dtbo will create /dev/rtc1, and also load the module rtc-ds1286.ko. Am I correct in thinking this?

Thanks for your help,
Tim

I forgot to say I have Robert Nelsons Ubuntu 18.04

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

I did the following:

- I fetched https://github.com/beagleboard/bb.org-overlays
- copied the file BB-I2C2-RTC-DS1338.dts to BB-I2C2-RTC-DS1307.dts
- edited BB-I2C2-RTC-DS1307.dts to refer to my DS1307 chip instead of DS1338
- make src/arm/BB-I2C2-RTC-DS1307.dtbo
- sudo cp ./src/arm/BB-I2C2-RTC-DS1307.dtbo /lib/firmware/

I added the following lines to /boot/uEnv.txt:
uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/BB-I2C2-RTC-DS1307.dtbo

I rebooted.

After rebooting, dmesg shows this:
bone_capemgr bone_capemgr: Baseboard: 'A335BNLT,000C,1633BBBG0596'
bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
bone_capemgr bone_capemgr: slot #0: No cape found
bone_capemgr bone_capemgr: slot #1: No cape found
bone_capemgr bone_capemgr: slot #2: No cape found
bone_capemgr bone_capemgr: slot #3: No cape found
bone_capemgr bone_capemgr: initialized OK.

I expected to see BB-UART2-00A0.dtbo in slot #1 and BB-I2C2-RTC-DS1307.dtbo in slot #2.
The overlays are not loaded. What am I doing wrong?

Run this script:

sudo /opt/scripts/tools/version.sh

It'll give us more information for debugging..

I also expect that loading the overlay BB-I2C2-RTC-DS1307.dtbo will create /dev/rtc1, and also load the module rtc-ds1286.ko. Am I correct in thinking this?

Actually we have an alias swap going on... The am335x's un-useful rtc
becomes /dev/rtc1 and the DS1307 becomes /dev/rtc0, thus all the
standard clock programs just work with the external rtc..

And the ds1307 module is usually built in, so you won't see the module
thru lsmod...

Regards,

Robert, here is the output of version.sh.

$ sudo ./version.sh
git:/opt/scripts/:[7f60eba275c0b3d0c1c826d410de25961cc4ed94]

eeprom:[A335BNLT000C1633BBBG0596]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[rcn-ee.net console Ubuntu Image 2018-08-10]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2016.03-00001-gd12d09f]:[location: dd MBR]
kernel:[4.14.62-ti-r69]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/BB-UART2-00A0.dtbo]
uboot_overlay_options:[uboot_overlay_addr1=/lib/firmware/BB-I2C2-RTC-DS1307.dtbo]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-UIO-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.4.20180914.0-0rcnee0~bionic+20180914]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~bionic+20180517]
pkg:[kmod]:[24-1ubuntu3rcnee0~bionic+20180515]
WARNING:pkg:[librobotcontrol]:[NOT_INSTALLED]
groups:[ubuntu : ubuntu adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep admin spi tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet cape_universal=enable]
dmesg | grep pinctrl-single
[ 1.128558] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.129754] gpio-of-helper ocp:cape-universal: ready
END

Actually we have an alias swap going on… The am335x’s un-useful rtc
becomes /dev/rtc1 and the DS1307 becomes /dev/rtc0, thus all the
standard clock programs just work with the external rtc…

I’m glad the DS1307 becomes /etc/rtc0. That makes things easier.

And the ds1307 module is usually built in, so you won’t see the module

thru lsmod…

This is good to know. I was looking at the output of lsmod and wondering why I didn’t see module rtc-ds1307.ko.

I know that the slots file (/sys/devices/platform/bone_capemgr/slots) is now disabled in my kernal (4.14.62-ti-r69).
But I think the bone_capemgr is still enabled.

dmesg shows this:

bone_capemgr bone_capemgr: Baseboard: ‘A335BNLT,000C,1633BBBG0596’
bone_capemgr bone_capemgr: compatible-baseboard=ti,beaglebone-black - #slots=4
bone_capemgr bone_capemgr: slot #0: No cape found
bone_capemgr bone_capemgr: slot #1: No cape found
bone_capemgr bone_capemgr: slot #2: No cape found
bone_capemgr bone_capemgr: slot #3: No cape found
bone_capemgr bone_capemgr: initialized OK.

Should I see BB-UART2-00A0.dtbo in slot #0 and BB-I2C2-RTC-DS1307.dtbo in slot #1?

Or is there another way to tell if the overlays have been loaded?

Thanks for your help,
Tim

The version of U-boot installed in the eMMC is blocking U-Boot
overlays from working properly, just run:

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

and reboot..

Regards,