BeagleBone AI UART 4 setup using device tree overlays

I am trying to get UART 4 on the BBAI to show up as a /dev/ttyO4 object through device tree overlays. I have so far not been able to get this working.
This is what I have done so far:

  1. Flash an SD card with the latest Debian TIDL image
  2. Plug in the SD card and boot the board (without touching the power button)
  3. I then ran several commands to update the board.
    a. sudo apt update
    b. sudo apt upgrade –y
    c. sudo apt install dosfstools initramfs-tools rsync u-boot-tools
    d. sudo apt install bb-u-boot-am57xx-evm
    I found somewhere on this forum that the stock linux kernel 4.14 is not new enough for device tree overlays.
    I then upgraded the BBAI linux kernel using these steps:
  4. cd /opt/scripts
  5. sudo tools/update_kernel.sh –lts-4_19-kernel
  6. sudo reboot now
    I then started work on getting an overlay working.
    This is what I did to create my BBAI_UART4.dtbo
  7. I copied the dts file from here:
    a. /opt/source/bb.org-overlays/src/arm/BB-UART4-00A0.dts
  8. I then modified the file to look like this:
    a.
/*
 * Copyright (C) 2013 CircuitCo
 *
 * Comes from here:
 * /opt/source/bb.org-overlays/src/arm/BB-UART4-00A0.dts
 *
 * Compile like this on the BBAI:
 * dtc -O dtb -o BBAI_UART4_00A0.dtbo -b 0 -@ BBAI_UART4_00A0.dts
 *
 * Virtual cape for UART4 on connector pins P9.13 P9.11
 * BBAI has UART 4 on pins P8.31 for RX and P8.32 for TX
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/dts-v1/;
/plugin/;

/ {
        /* compatible = "ti,beaglebone", "ti,beaglebone-ai"; */
        compatible = "beagleboard.org,am5729-beagleboneai", "ti,am5728", "ti,dra742", "ti,dra74", "ti,dra7";

        /* identification - matches the name of this dts file. */
        part-number = "BBAI_UART4";
        version = "00A0";

        /* state the resources this cape uses */
        exclusive-use =
                /* the pin header uses */
                "P8.32",        /* uart4_txd */
                "P8.31",        /* uart4_rxd */
                /* the hardware ip uses */
                "uart4";

        fragment@0 {
                target = <&am57xx_pinmux>;
                __overlay__ {
                        bb_uart4_pins: pinmux_bb_uart4_pins {
                                pinctrl-single,pins = <
                                        0x173C 0x04     /* gpmc_wait0.uart4_rxd was (0x070) -> now (0x173C) | MODE6 (0x26) -> now mode 4 (0x04) */
                                        0x1740 0x04     /* gpmc_wpn.uart4_txd   was (0x074) -> now (0x1740) | MODE6 (0x06) -> now mode 4 (0x04) */
                                >;
                        };
                };
        };

        fragment@1 {
                target = <&uart5>;      /* really uart4 */
                __overlay__ {
                        status = "okay";
                        pinctrl-names = "default";
                        pinctrl-0 = <&bb_uart4_pins>;
                };
        };
};
  1. I then compiled this file with this command:
    a. dtc -W no-unit_address_vs_reg -O dtb -o BBAI_UART4.dtbo -b 0 -@ BBAI_UART4.dts
  2. I then copied this file over to /lib/firmware
  3. I then edited the uEnv.txt file under /boot by adding these 2 lines at the bottom:
    a. enable_uboot_overlays=1
    b. dtb_overlay=/lib/firmware/BBAI_UART4.dtbo
  4. I then rebooted the BBAi
    After these steps, I still did not see a device like /dev/ttyO4.
    I then tried editing the device tree itself. These are the steps I followed:
  5. cd
  6. cp /boot/dtbs/4.19.94-ti-r73/am5729-beagleboneai.dtb .
  7. dtbs am5729-beagleboneai.dtb > am5729-beagleboneai-custom.dts
  8. Using nano, edit the section where serial@48066000 {} contains “uart5” (it maps to uart4)
    a. The line “ status = “disabled”;” needs to become “status = “okay”;”
  9. After that change, create a new device tree binary with:
    a. dtc -O dtb -o am5729-beagleboneai.dtb am5729-beagleboneai-custom.dts
  10. Overwrite the old device tree file with this command:
  11. sudo mv am5729-beagleboneai.dtb /boot/dtbs/4.19.94-ti-r73/am5729-beagleboneai.dtb
  12. sudo reboot now
    After running these steps, the file /dev/ttyO4 shows up. The problem is that the pins are not correctly configured as can be seen with the show-pins.pl script under /opt/scripts/device/bone
    This is the output of looking for Uart4:
    ./show-pins.pl | grep “P8.31”
    P8.31a 133 C8 e fast rx down gpio8_14 ocp@44000000/P8_31_pinmux (pinmux_P8_31_default_pin)
    P8.31b 207 G16 f fast Driver off ocp@44000000/P8_31_pinmux (pinmux_P8_31_default_pin)
    debian@beaglebone:/opt/scripts/device/bone$ ./show-pins.pl | grep “P8.32”
    P8.32a 134 C7 e fast rx down gpio8_15 ocp@44000000/P8_32_pinmux (pinmux_P8_32_default_pin)
    P8.32b 208 D17 f fast Driver off ocp@44000000/P8_32_pinmux (pinmux_P8_32_default_pin)

I am not sure what to do to get the uart 4 peripheral to turn on as well as set the pin pad mux to where uart 4 is exposed. What do I have to do to get the device tree overlay to work properly without modifying the device tree itself? I also read that uboot needs to be configured properly to load the device tree overlay. Is uboot relevant to this question? What process should I follow to properly configure uart 4 using a device tree overlay?

Here is the output of the /opt/scripts/tools/version.sh script:

sudo ./version.sh
[sudo] password for debian:
git:/opt/scripts/:[674bb55e34e94e3837f4f55790c7d1a52c9e149f]
model:[BeagleBoard.org_BeagleBone_AI]
dogtag:[BeagleBoard.org Debian Buster IoT TIDL Image 2020-04-06]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot SPL 2019.07-rc4-00001-g607b5b738b (Jul 06 2019 - 21:01:15 -0500)]:[location: dd MBR]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot SPL 2019.07-rc4-00001-g607b5b738b (Jul 06 2019 - 21:01:15 -0500)]:[location: dd MBR]
UBOOT: Booted Device-Tree:[am5729-beagleboneai.dts]
kernel:[4.19.94-ti-r73]
nodejs:[v10.24.0]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[dtb_overlay=/lib/firmware/BBAI_UART4.dtbo]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20210821.0-0~buster+20210821]
pkg:[bb-customizations]:[1.20220325.0-0~buster+20220325]
pkg:[bb-usb-gadgets]:[1.20220316.1-0~buster+20220316]
pkg:[bb-wl18xx-firmware]:[1.20211222.2-0~buster+20211222]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.5-git20200715.0-0~buster+20200716]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyS0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 rng_core.default_quality=100 quiet]
dmesg | grep remote
[ 15.190658] remoteproc remoteproc0: 58820000.ipu is available
[ 15.220758] remoteproc remoteproc1: 55020000.ipu is available
[ 15.236827] remoteproc remoteproc2: 40800000.dsp is available
[ 15.241983] remoteproc remoteproc3: 41000000.dsp is available
[ 15.356692] remoteproc remoteproc0: powering up 58820000.ipu
[ 15.356739] remoteproc remoteproc0: Booting fw image dra7-ipu1-fw.xem4, size 7051536
[ 15.356888] Modules linked in: omap_remoteproc virtio_rpmsg_bus remoteproc virtio virtio_ring usb_f_ncm usb_f_mass_storage usb_f_rndis u_ether libcomposite uio_pdrv_genirq uio cmemk(O) gpio_pisosr usbhid
[ 15.357802] [] (iommu_attach_device) from [] (rproc_boot+0x380/0x6ec [remoteproc])
[ 15.357926] [] (rproc_boot [remoteproc]) from [] (rproc_auto_boot_callback+0x20/0x2c [remoteproc])
[ 15.357998] [] (rproc_auto_boot_callback [remoteproc]) from [] (request_firmware_work_func+0x60/0x9c)
[ 15.377124] Modules linked in: omap_remoteproc virtio_rpmsg_bus remoteproc virtio virtio_ring usb_f_ncm usb_f_mass_storage usb_f_rndis u_ether libcomposite uio_pdrv_genirq uio cmemk(O) gpio_pisosr usbhid
[ 15.671921] [] (iommu_attach_device) from [] (rproc_boot+0x380/0x6ec [remoteproc])
[ 15.681407] [] (rproc_boot [remoteproc]) from [] (rproc_auto_boot_callback+0x20/0x2c [remoteproc])
[ 15.692254] [] (rproc_auto_boot_callback [remoteproc]) from [] (request_firmware_work_func+0x60/0x9c)
[ 15.833136] remoteproc remoteproc1: powering up 55020000.ipu
[ 15.841266] remoteproc remoteproc1: Booting fw image dra7-ipu2-fw.xem4, size 3751356
[ 16.365287] remoteproc remoteproc2: powering up 40800000.dsp
[ 16.378314] remoteproc remoteproc2: Booting fw image dra7-dsp1-fw.xe66, size 21014532
[ 16.394221] remoteproc remoteproc3: powering up 41000000.dsp
[ 16.425103] remoteproc remoteproc3: Booting fw image dra7-dsp2-fw.xe66, size 21014532
[ 16.595323] remoteproc remoteproc1: registered virtio0 (type 7)
[ 16.613123] remoteproc remoteproc1: remote processor 55020000.ipu is now up
[ 16.701317] remoteproc remoteproc3: registered virtio1 (type 7)
[ 16.707410] remoteproc remoteproc3: remote processor 41000000.dsp is now up
[ 16.769256] remoteproc remoteproc2: registered virtio2 (type 7)
[ 16.775377] remoteproc remoteproc2: remote processor 40800000.dsp is now up
[ 45.152898] remoteproc remoteproc4: 4b234000.pru is available
[ 45.224623] remoteproc remoteproc5: 4b238000.pru is available
[ 45.264537] remoteproc remoteproc6: 4b2b4000.pru is available
[ 45.292815] remoteproc remoteproc7: 4b2b8000.pru is available
dmesg | grep pru
[ 38.711202] pruss_uio_shmem 4b200000.pruss_shmem: Allocating gdev
[ 38.757475] pruss_uio_shmem 4b200000.pruss_shmem: Allocating info
[ 38.764344] pruss_uio_shmem 4b200000.pruss_shmem: Requesting resource
[ 38.837267] pruss_uio_shmem 4b200000.pruss_shmem: Mapping resource
[ 38.892605] pruss_uio_shmem 4b200000.pruss_shmem: Registering with uio driver
[ 39.018231] pruss_uio_shmem 4b200000.pruss_shmem: Saving platform data
[ 39.074100] pruss_uio_shmem 4b280000.pruss_shmem: Allocating gdev
[ 39.105150] pruss_uio_shmem 4b280000.pruss_shmem: Allocating info
[ 39.145370] pruss_uio_shmem 4b280000.pruss_shmem: Requesting resource
[ 39.243259] pruss_uio_shmem 4b280000.pruss_shmem: Mapping resource
[ 39.310698] pruss_uio_shmem 4b280000.pruss_shmem: Registering with uio driver
[ 39.421418] pruss_uio_shmem 4b280000.pruss_shmem: Saving platform data
[ 45.152898] remoteproc remoteproc4: 4b234000.pru is available
[ 45.193363] pru-rproc 4b234000.pru: PRU rproc node pru@4b234000 probed successfully
[ 45.224623] remoteproc remoteproc5: 4b238000.pru is available
[ 45.238641] pru-rproc 4b238000.pru: PRU rproc node pru@4b238000 probed successfully
[ 45.264537] remoteproc remoteproc6: 4b2b4000.pru is available
[ 45.280220] pru-rproc 4b2b4000.pru: PRU rproc node pru@4b2b4000 probed successfully
[ 45.292815] remoteproc remoteproc7: 4b2b8000.pru is available
[ 45.299535] pru-rproc 4b2b8000.pru: PRU rproc node pru@4b2b8000 probed successfully
dmesg | grep pinctrl-single
[ 1.009820] pinctrl-single 4a003400.pinmux: 282 pins, size 1128
dmesg | grep gpio-of-helper
[ 1.021819] gpio-of-helper 44000000.ocp:cape-universal: ready
lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 17ef:608c Lenovo
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

Here are some URLs that I referenced to come up with these steps:

https://deepaklorkhatri.me/GSoC2020_BeagleBoard.org/

1 Like

The solution was to re-clone the repository located here:

/opt/source/dtb-4.19-ti

Then checkout the 4.19 overlays branch

create a new device tree file that inherits the base am5729 bbai device tree file. It should only modify pins in the mid pad mux related to uart.

then compile the device tree file using the provided makefile and pass the path to the new device tree file.

The compiled device tree file then needs to get placed under the
/boot/dtbs/ 4.19 . 94 -ti-r73/
directory.
Then the /boot/uEnv.txt file must be told to use the new device tree file with the “dtb=” flag. This is a relative path, don’t specify absolute paths. (specify the .dtb file)

reboot
you are good to go