Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#3402 - RUT955: Seriously broken #6573

Open
openwrt-bot opened this issue Oct 23, 2020 · 3 comments
Open

FS#3402 - RUT955: Seriously broken #6573

openwrt-bot opened this issue Oct 23, 2020 · 3 comments
Labels

Comments

@openwrt-bot
Copy link

reinerotto:

RS485 and RS232 (DB9) unusable on my recent RUT955, batch 84.
I want to use RS485 (in worst case, RS232) for modbus comms.

However, my custom built image basically works, incl. mqtt, mwan3, LTE (EC25) etc.
The firmware from TELTONIKA runs without problems.
For strange boot log, pls refere to
https://forum.openwrt.org/t/teltonika-rut955-tainted-kernel-ath1/77335/2

@openwrt-bot
Copy link
Author

dangowrt:

RS-232 is connected via USB needs driver and is available on /dev/ttyACM0.
There is also nothing 'seriously broken' about using the kernel upstream driver for what they call 'ar934x-hs-uart' in Teltonika's firmware. Take a look at the driver and realize that it's basically the same UART as used in earlier Atheros SoCs, just that it wasn't initialized by the bootloader. There is no need to duplicate tons of code for that.

What exactly doesn't work? (I'm sitting next to the device and it does work for me)

@openwrt-bot
Copy link
Author

tophirsch:

RS-232 is working totally fine, just select the correct kmods for usb-serial.

RS-485 is causing some trouble, but I managed to find a fix/workaround.

First there is this kernel trace at boot and whenever I try to open the serial port with picocom:

kern.info kernel: [ 1.619968] 18500000.uart: ttyATH1 at MMIO 0x18500000 (irq = 12, base_baud = 2500000) is a AR933X UART
kern.warn kernel: [ 1.629472] ------------[ cut here ]------------
kern.warn kernel: [ 1.634176] WARNING: CPU: 0 PID: 103 at drivers/gpio/gpiolib.c:3637 gpiod_set_array_value_complex+0x33c/0x42c
kern.warn kernel: [ 1.644220] Modules linked in:
kern.warn kernel: [ 1.647328] CPU: 0 PID: 103 Comm: kworker/0:1 Not tainted 5.4.101 #0
kern.warn kernel: [ 1.653808] Workqueue: events deferred_probe_work_func
kern.warn kernel: [ 1.659013] Stack : 805c2020 802cbd00 00000009 00000002 87d70a80 800b98c0 87e0b3c0 00000000
kern.warn kernel: [ 1.667495] 00000017 87cbc23c 805b3464 87d37ab4 80650000 00000000 87d37a88 2bca0ad8
kern.warn kernel: [ 1.675978] 00000000 00000000 00000000 0000006b 00000063 00000000 645f7072 6f62655f
kern.warn kernel: [ 1.684461] 0000006b 807d0000 00000000 0009f9f0 00000000 00000009 00000000 802cbd00
kern.warn kernel: [ 1.692935] 00000009 00000002 87d70a80 87d37bb0 00000001 8031c12c 00000000 807b0000
kern.warn kernel: [ 1.701410] ...
kern.warn kernel: [ 1.703894] Call Trace:
kern.warn kernel: [ 1.706402] [<80069944>] show_stack+0x30/0x100
kern.warn kernel: [ 1.710919] [<80082624>] __warn+0xc0/0x10c
kern.warn kernel: [ 1.715075] [<800826cc>] warn_slowpath_fmt+0x5c/0xac
kern.warn kernel: [ 1.720109] [<802cbd00>] gpiod_set_array_value_complex+0x33c/0x42c
kern.warn kernel: [ 1.726374] [<802cc088>] gpiod_set_array_value+0x34/0x48
kern.warn kernel: [ 1.731788] [<80322a48>] mctrl_gpio_set+0xc4/0xe8
kern.warn kernel: [ 1.736557] [<80317ab4>] uart_add_one_port+0x3cc/0x534
kern.warn kernel: [ 1.741768] [<80321b84>] ar933x_uart_probe+0x2d8/0x35c
kern.warn kernel: [ 1.746981] [<8032fac8>] platform_drv_probe+0x40/0x94
kern.warn kernel: [ 1.752112] [<8032dc1c>] really_probe+0x104/0x358
kern.warn kernel: [ 1.756886] [<8032bcd4>] bus_for_each_drv+0x70/0xb0
kern.warn kernel: [ 1.761832] [<8032dad4>] __device_attach+0x114/0x150
kern.warn kernel: [ 1.766874] [<8032cc0c>] bus_probe_device+0x9c/0xb8
kern.warn kernel: [ 1.771821] [<8032d1d0>] deferred_probe_work_func+0x7c/0xbc
kern.warn kernel: [ 1.777504] [<80099aa4>] process_one_work+0x220/0x480
kern.warn kernel: [ 1.782627] [<8009a030>] worker_thread+0x32c/0x5c8
kern.warn kernel: [ 1.787502] [<8009ec00>] kthread+0x138/0x140
kern.warn kernel: [ 1.791843] [<80064d98>] ret_from_kernel_thread+0x14/0x1c
kern.warn kernel: [ 1.797325] ---[ end trace 69e1c3c2115ec69e ]---

Commenting the dtr-gpios entry in //target/linux/ath79/dts/ar9344_teltonika_rut955.dts// out, lets the kernel trace disappear and leads to the second problem: the RUT955 is only able to receive data via RS-485, transmission does not work.

This issue can be resolved by modifying the pin muxing in //target/linux/ath79/dts/ar9344_teltonika_rut9xx.dtsi//:
changing:

pmx_uart2: uart2 {
// UART1_DTR on GPIO 0, UART1_RD on GPIO 11, UART1_TD on GPIO 18
pinctrl-single,bits = <0x0 0x0 0xff>,
<0x10 0x4f000000 0xff000000>,
<0x3c 0x000b0000 0x00ff0000>;
};

to:

pmx_uart2: uart2 {
pinctrl-single,bits = <0x00 0x00000000 0x000000ff>,
<0x10 0x004f0000 0x00ff0000>,
<0x3c 0x000b0000 0x00ff0000>;
};

According to the Teltonike SDK the tx pin is 18, but <0x10 0x4f000000 0xff000000> configures GPIO19 at 0x1804003C.
After correcting the value and mask, transmission is working now.

As I'm not that familiar with devicetree, I dont know if commenting out dtr-gpios has no side effects, so be carefull.
If there are no side effects and it could be verified that this fix is working for all RUT955 devices, I could do a PR.

Device used: Teltonika RUT955 (Batch: 102)

@reinerotto
Copy link

Any news here ? I have aRUT955, running 22.03.2, and having trouble to get the built-in RS485 to work. I am building my custom images (from source), and I see quite some differences in target/linux/ath79/dts/ar9344_teltonika_rut955.dts compared to above mentioned patch or https://patchwork.ozlabs.org/project/openwrt/patch/20200212143804.GA519559@makrotopia.org/
Pls, advise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants