Beaglebone cape support

I’m trying to get my Beaglebone (green) to enable ttyS4. I’m running 2.15.1+rev1-dev - the latest download from balenaCloud.

If I try to enable it manually by ‘echo BB-UART4-RS485 > /sys/devices/platform/bone_capemgr/slots’ I get a kernel oops in __of_overlay_create:

[ 265.832538] bone_capemgr bone_capemgr: part_number ‘BB-UART2-RTSCTS’, version ‘N/A’
[ 265.842181] bone_capemgr bone_capemgr: slot #4: override
[ 265.857452] bone_capemgr bone_capemgr: Using override eeprom data at slot 4
[ 265.887764] bone_capemgr bone_capemgr: slot #4: ‘Override Board Name,00A0,Override Manuf,BB-UART2-RTSCTS’
[ 265.907736] Unable to handle kernel NULL pointer dereference at virtual address 0000000c
[ 265.919845] pgd = c7950000
[ 265.922680] [0000000c] *pgd=00000000
[ 265.931816] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[ 265.937176] Modules linked in: ipt_REJECT nf_reject_ipv4 ipt_MASQUERADE nf_nat_masquerade_ipv4 br_netfilter nf_conntrack_netlink nfnetlink xfrm_user xfrm_algo evdev uio_pdrv_genirq uio nls_ascii nls_cp437 sch_fq_codel
[ 265.956643] CPU: 0 PID: 1690 Comm: sh Not tainted 4.14.53+ #2
[ 265.962418] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 265.968540] task: dc799e00 task.stack: c79d0000
[ 265.973120] PC is at __of_overlay_create+0x43c/0xb60
[ 265.978113] LR is at __of_overlay_create+0x448/0xb60
[ 265.983101] pc : [] lr : [] psr: 20070013
[ 265.989397] sp : c79d1d58 ip : c79d5298 fp : c79d1dec

[ 266.216921] [] (__of_overlay_create) from [] (of_overlay_create+0x20/0x24)
[ 266.225595] [] (of_overlay_create) from [] (capemgr_load_slot+0x480/0x5d0)
[ 266.234259] [] (capemgr_load_slot) from [] (slots_store+0x150/0x328)
[ 266.242403] [] (slots_store) from [] (dev_attr_store+0x28/0x34)
[ 266.250110] [] (dev_attr_store) from [] (sysfs_kf_write+0x50/0x54)
[ 266.258074] [] (sysfs_kf_write) from [] (kernfs_fop_write+0xf8/0x1d4)
[ 266.266302] [] (kernfs_fop_write) from [] (__vfs_write+0x28/0x48)
[ 266.274178] [] (__vfs_write) from [] (vfs_write+0xb4/0x1c0)
[ 266.281528] [] (vfs_write) from [] (SyS_write+0x5c/0xbc)
[ 266.288625] [] (SyS_write) from [] (__sys_trace_return+0x0/0x10)
[ 266.296415] Code: e584902c e5843034 e584403c e584a028 (e590500c)
[ 266.478799] —[ end trace b1ba7d0f614b6dcb ]—

Should this work - is this the correct way of enabling it?

Thanks.

1 Like

Hi @sei1,

We are preparing a release for Beaglebone devices where you are able to load device tree overlays from u-boot by adding in uEnv.txt the following content:

enable_uboot_overlays=1
uboot_overlay_addr0=/boot/overlays/BB-UART4-RS485-00A0.dtbo

You can download the 2.29.2+rev3 release from staging dashboard and try it. https://dashboard.balena-staging.io/apps

This release will soon reach production

1 Like

Hi @spanceac,
I’ve just got my Beaglebone back and tried it - the 2.29.2+rev3 appears in the main dashboard now too.
It looks like it’s working, I can see the UART4 appear in the kernel log when it’s booting. I’ll dig out my RS485 cape and test code :smile:
Thanks for your reply.

Hi @sei1,

Please let us know how it went.

Regards!

Hi @spanceac,

Unfortunately it is not working quite yet. Although I can see data on the scope out of UART4-TX, the RTS pin isn’t changing.

Looking in /sys/kernel/debug/pinctrl/44e10800.pinmux

group: pinmux_bb_uart4_rs485_pins
pin 29 (PIN29)
pin 28 (PIN28)
pin 105 (PIN105)

I can see that the RX and TX are set to the UART4 peripheral (0x0e & 0x07) == 6

pin 29 (PIN29) 44e10874 0000000e pinctrl-single
pin 28 (PIN28) 44e10870 0000002e pinctrl-single

But the RTS pin is still assigned to GPIO == 7

pin 105 (PIN105) 44e109a4 00000007 pinctrl-single

Edit - I don't think this hidden observation was relevant

I’ve hidden this bit because I don’t think it is relevant - it looks like the BBG overlay is added after.

Looking through the u-boot output, it looks like it detects that I’m using a BBGreen, but loads uboot_base_dtb_univ = am335x-boneblack-uboot.dtb.

debug: [enable_uboot_overlays=1] …
debug: [enable_uboot_cape_universal=] …
debug: [uboot_base_dtb_univ=am335x-boneblack-uboot.dtb] …
uboot_overlays: [uboot_base_dtb=am335x-boneblack-uboot.dtb] …
uboot_overlays: Switching too: dtb=am335x-boneblack-uboot.dtb …
loading /boot/am335x-boneblack-uboot.dtb …
58048 bytes read in 41 ms (1.3 MiB/s)
uboot_overlays: [fdt_buffer=0x60000] …
uboot_overlays: loading /boot/overlays/M-BB-BBG-00A0.dtbo …
277 bytes read in 148 ms (1000 Bytes/s)
uboot_overlays: loading /boot/overlays/BB-UART4-RS485-00A0.dtbo …
1127 bytes read in 173 ms (5.9 KiB/s)
uboot_overlays: loading /boot/overlays/BB-BONE-eMMC1-01-00A0.dtbo …
1105 bytes read in 91 ms (11.7 KiB/s)
uboot_overlays: loading /boot/overlays/BB-ADC-00A0.dtbo …
695 bytes read in 85 ms (7.8 KiB/s)
uboot_overlays: add [enable_uboot_cape_universal=1] to /boot/uEnv.txt to enable…

Any thoughts?

Thanks.

Hi @sei1,

According to the dts, the RTS gpio is rts-gpio = <&gpio3 19 1>;
https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-UART4-RS485-00A0.dts

That would mean RTS gpio is GPIO3_19 or as Linux sees it: 3*32+19 = gpio115

Regards!

Thanks for that reference @spanceac. Sorry, it’s been a while since I looked in the dts and I guess I was just assuming it would be the UART4_RTS pin.

So I suppose my now problem is that rts-gpio is only used in the omap-serial driver

$ grep -Rl rts-gpio linux
linux/drivers/tty/serial/imx.c
linux/drivers/tty/serial/omap-serial.c
linux/drivers/tty/serial/sirfsoc_uart.c

but the kernel config uses the 8250 driver

$ gunzip -c config.gz | grep “SERIAL_.*OMAP”
CONFIG_SERIAL_8250_OMAP=y
CONFIG_SERIAL_8250_OMAP_TTYO_FIXUP=y
#CONFIG_SERIAL_OMAP is not set

I’ll take a look into rolling my own dtbo to enable the RTS pin instead of that no-longer supported gpio!

Thanks very much for your help :+1:

Good news is I tried the UART2_RTSCTS overlay and I’m getting the expected output in my scope!
Cheers :slight_smile:

1 Like

Glad to hear, cheers for the feedback, @sei1!