Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8162

Interfacing (DSI, CSI, I2C, etc.) • Re: CM4 UART RTS - Unexpected Behaviour

$
0
0
uart3-overlay.dts looks like this:
Looks spot on.
I then edited /boot/firmware/config.txt to edit the lines "dtoverlay=uart3,ctsrts" to "dtoverlay=uart3,ctsrts,rs485" and "dtoverlay=uart4,ctsrts" to "dtoverlay=uart4,ctsrts,rs485". I've rebooted the SBC and the comms lines seem to be working correctly, thank you!

Checking the device tree using "$ dtc -I fs /proc/device-tree", the overrides are shown to have been correctly applied to serial@7e201800 and serial@7e201600, for example as follows:

Code:

serial@7e201600 {arm,primecell-periphid = <0x241011>;pinctrl-names = "default";pinctrl-0 = <0x19>;clock-names = "uartclk\0apb_pclk";interrupts = <0x00 0x79 0x04>;clocks = <0x08 0x13 0x08 0x14>;linux,rs485-enabled-at-boot-time;rs485-rts-delay = <0x00 0x00>;compatible = "arm,pl011\0arm,primecell";status = "okay"; reg = <0x7e201600 0x200>;phandle = <0xc9>;};
I'd be interested in creating a pull request to edit all of the UART overlay files, to help out - would this include UART0, does that one support the RS485 RTS functionality still despite it being a unique UART used for the BLE modem etc? Does any documentation need to be updated too?
It may as well apply to UART0 too. I suspect there are some hardware variants where UART0 isn't routed to BT, so having the RS485 options makes sense if it has RTS exposed.
The README needs to be updated so that all parameters are documented. If you create a PR there is a workflow configured that checks that all parameters are documented appropriately.
I'm still getting used to device tree extensions and overrides, so I have a couple of questions please.
#1: would it be possible to override the dormant rs485-rts-delay under the rs485 fragment? Would it be as simple as adding "rs485_rts_delay = <&rs485>,"rs485-rts-delay";" under __overrides__ and using the correct format to set it under /boot/firmware/config.txt, i.e. "dtoverlay=uart3,ctsrts,rs485,rs485_rts_delay="<1 1>"?
AFAIK You can't assign to both integers in the array, but you can do

Code:

rs485_on_delay = <&rs485>, "rs485-rts-delay:0";rs485_off_delay = <&rs485>, "rs485-rts-delay:4";
The value after the colon configures how many bytes of offset is used, and it is an array of 32bit values (https://elixir.bootlin.com/linux/v6.14. ... re.c#L3599)
#2: how can you use one override to automatically enable one, if this is possible?
One override to enable another? I don't believe that is possible, but you can have multiple actions off the same override and just duplicate them, eg

Code:

rs485 = <0>,"=2";rs485_on_delay = <&rs485>, "rs485-rts-delay:0",                <0>,"=2";rs485_off_delay = <&rs485>, "rs485-rts-delay:4",                <0>,"=2";
so specifying an rs485 delay would automatically enable RS485 mode as well. Generally you wouldn't do that though - keep things simple with one thing doing each operation.
Then again enabling RS485 mode could also enable RTS/CTS muxing, because it's fairly useless without it.

Code:

rs485 = <0>,"=1=2";

Statistics: Posted by 6by9 — Tue Apr 22, 2025 3:40 pm



Viewing all articles
Browse latest Browse all 8162

Trending Articles