Using UART0 and UART5 on Expansion headers P8 and P9

I am new to the Beaglebone Black. I am running Debian GNU/Linux 10

I want to use all the available serial ports on a Cape.

I have configured the pins as follow:
config-pin p9.17 uart
config-pin p9.18 uart
stty -F /dev/ttyO0 sane

config-pin p9.24 uart
config-pin p9.26 uart
stty -F /dev/ttyO1 sane

config-pin p9.21 uart
config-pin p9.22 uart
stty -F /dev/ttyO2 sane

config-pin p9.11 uart
config-pin p9.13 uart
stty -F /dev/ttyO4 sane

config-pin p8.37 uart
config-pin p8.38 uart
stty -F /dev/ttyO5 sane

Using a simple CPP app I can use UARTs 1,2,4 successfully.
UART3 has no Rxd so I am ignoring this.

But UART 5 and UART 1 do not work.

Reading back the port configuration I get the following:
debian@beaglebone:~$ config-pin -q p9.17
Current mode for P9_17 is: default
debian@beaglebone:~$ config-pin -q p9.18
Current mode for P9_18 is: default
debian@beaglebone:~$ config-pin -q p9.24
Current mode for P9_24 is: uart
debian@beaglebone:~$ config-pin -q p9.26
Current mode for P9_26 is: uart
debian@beaglebone:~$ config-pin -q p9.21
Current mode for P9_21 is: uart
debian@beaglebone:~$ config-pin -q p9.22
Current mode for P9_22 is: uart
debian@beaglebone:~$ config-pin -q p9.11
Current mode for P9_11 is: uart
debian@beaglebone:~$ config-pin -q p9.13
Current mode for P9_13 is: uart
debian@beaglebone:~$ config-pin -q p8.37
ERROR: open() for /sys/devices/platform/ocp/ocp:P8_37_pinmux/state failed, No such file or directory
debian@beaglebone:~$ config-pin -q p8.38
ERROR: open() for /sys/devices/platform/ocp/ocp:P8_38_pinmux/state failed, No such file or directory
debian@beaglebone:~$

I understand UART0 is use on J1 as a debug feature. Is there any way to disable this so I can use it on P9 pins 17 and 18? If so, can your please provide instruction on how to do this.

UART5 does not have the configuration files or directory for P8_37 or P8_38. Can you help with instructions on how to get this working.

I note I am not the only one to ask these questions but have not seen any helpful answers.

Sorry, wrong sub-system, P9_17/P9_18 are a uart (pr1_uart0), but for PRU1, not the Cortex-A8…

Disable HDMI for those pins (P8_37 or P8_38) : Beagleboard:BeagleBoneBlack Debian - eLinux.org

Regards,

1 Like

Hi Robert
Thanks for your response.
Disabling HDMI worked and I now have UART5 working on P8 37 & 38.
Thanks for you help.
Best regards

Hi again Robert

Perhaps I was a bit hasty in my last reply. Your instructions worked perfectly to enable UART5 but I can’t find a reference which informs which device functions use which expansion header pins and need to be disabled to enable other functions to be assigned.

I can now Tx and Rx on UARTs 1, 2, 4, 5 which is great, but I can’t assign RTS or CTS handshaking to UARTS 1, 3 & 5 which I think should be possible according to the table in section 7.1 Expansion Connectors of the BBB Reference manual.

When I map them as UART eg
config-pin p8.32 uart
They query back as default
config-pin -q p8.32
Current mode for P8_32 is: default

Can you please advise where I can find this information?
Ultimately I am wanting to use RTS to drive Tx-Enable on an RS-485 driver in a CPP app. There seems to be lots of historic questions on the forum around this but I can’t find a simple answer.

I also want to assign some pins as GPIO.

I feel like I am missing some important documentation if you could give me a steer.

Thanks

So RTS/CTS has been a mess since we switched from the omap-serial.c driver to the 8250_omap.c driver:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/omap-serial.c?h=v5.16-rc4

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/serial/8250/8250_omap.c?h=v5.16-rc4

The omap-serial is specific to the device, whereas the 8250_omap uses a generic 8250 library shared with other devices…

Where as serial-omap just handled the RTS/CTS as long as the pin’s where specified, for 8250_omap we need to add a few device tree options:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/serial/8250_omap.yaml

aka add, cts-gpios/rts-gpios defines…

        cts-gpios = <&gpioX Y GPIO_ACTIVE_LOW>;
        rts-gpios = <&gpioX Z GPIO_ACTIVE_LOW>;

Regards,

1 Like

Hi Robert

Thanks for your response, but I am not clear what it means. Sorry if I am being a bit needy but can you help me with this.

Please confirm / correct my understanding as follows.

The first link is the original omap-serial.c driver, so I don’t need to do anything with this.

The 3rd link is a configuration file which I need to edit as follows to assign rts and cts port pins etc
eg for UART1 P9 pin 19 and P9 pin 20

    cts-gpios = <&gpio9 19 GPIO_ACTIVE_LOW>;

    rts-gpios = <&gpio9 20 GPIO_ACTIVE_HIGH>;

Note I want RTS to be active high for RS-485 Tx Enable.

Questions:
Under what section do these extra entries need to go? eg in “properties” say under the following block?

rts-gpios: true
cts-gpios: true
dtr-gpios: true
dsr-gpios: true
rng-gpios: true
dcd-gpios: true
rs485-rts-delay: true
rs485-rts-active-low: true
rs485-rx-during-tx: true
rs485-rts-active-high: true
linux,rs485-enabled-at-boot-time: true
rts-gpio: true
power-domains: true
clock-frequency: true
current-speed: true
overrun-throttle-ms: true

How do I configure it to use RTS for RS-485 Tx Enable (active high) vs RS-232 Request to send - flow control (active low). The above block seems relevant but I am not clear on a few points - please see my comments over some lines.

rts-gpios: true // init the following GPIOS all high for all UARTS on startup?
cts-gpios: true
dtr-gpios: true
dsr-gpios: true
rng-gpios: true
dcd-gpios: true
rs485-rts-delay: true // does this assert RTS before we start sending or keep RTS asserted after last byte sent? I guess the recommended setting is true?
rs485-rts-active-low: true // This would not make sense for RS-485 and conficts with 2 lines down?
rs485-rx-during-tx: true // for half duplex I would want to set this to false, but my app would not try to send while receiving. Does this control Rx-Enable on my RS-485 driver somehow? eg nother GPIO?
rs485-rts-active-high: true // I need this for Tx-Enable on my RS-485 driver
linux,rs485-enabled-at-boot-time: true // to ensure the RS-485 driver is not asseting Tx-Enable to my driver and the RS-485 bus?
rts-gpio: true
power-domains: true
clock-frequency: true
current-speed: true
overrun-throttle-ms: true

Also the above parameters do not specify which UART. If I want some UARTs for RS-232 full duplex with RTS/CTS flow control and other RS-485 half-duplex with RTS driving Tx-Enable, how do I specify this? I guess the above could just be defaults on startup and they can be changed to what I need when my app Opens the com port? Please advise?

For RS-485, will the 8250 omap serial driver (when configured correctly for RS-485), automatically drive RTS high when transmitting and low afterwards, or must I still do this in software.

The second link is the 8250 omap-serial.c driver, but I am not sure what I need to do with this. Was this just for reference and will it read the contents of the 8250_omap.yaml when it runs, or do I need to rebuild it. Is this part of the Kernel and does the entire Kernel needs to be rebuilt. I have never built a Linux Kernel and am not familiar with the process.

Regards
Michael