2021-05-27 04:59 AM
Hello on my serdev when i set it up the transmition complete is not set:
stm32-usart 4000f000.serial: transmission complete not set
I configurated my device tree like this:
&usart3 {
compatible = "st,stm32-uart", "st,stm32f7-uart", "st,stm32h7-uart";
pinctrl-names = "default", "sleep", "idle";
pinctrl-0 = <&usart3_pins_b>;
pinctrl-1 = <&usart3_sleep_pins_b>;
pinctrl-2 = <&usart3_idle_pins_b>;
uart-has-rtscts;
status = "okay";
ethernet {
compatible = "st,stm32_usart_net";
local-mac-address = [ A0 B0 C0 D0 E0 F0 ];
current-speed = <38400>;
};
};
So in my system it shows up like this:
/sys/devices/platform/soc/4000f000.serial/serial0/serial0-0
The probe methode of my serdev_device_driver looks like this:
struct stmuart *stm;
u32 speed = 115200;
int ret;
stm = devm_kzalloc(&serdev->dev, sizeof(*stm), GFP_KERNEL);
stm->serdev = serdev;
spin_lock_init(&stm->lock);
INIT_WORK(&stm->tx_work, stmuart_transmit);
serdev_device_set_drvdata(serdev, stm);
serdev_device_set_client_ops(serdev, &stm_serdev_ops);
ret = serdev_device_open(serdev);
if (ret) {
dev_err(&serdev->dev, "Unable to open device\n");
goto free;
}
speed = serdev_device_set_baudrate(serdev, speed);
dev_info(&serdev->dev, "Using baudrate: %u\n", speed);
serdev_device_set_flow_control(serdev, true);
return 0;
My kernel shows me the log when i call the "serdev_device_open" methode. But i can not find something to set options to the serdev_device to avoid it. I looked some other examples and there i also did not find a setting for the device tree. My Kernel is on version 5.4
2021-05-31 01:54 AM
Sorry that i tag you but do you have an idea
@Community member
2021-05-31 07:08 AM
I tried the kernel version 5.10 but the same ressult.
2021-06-01 12:25 PM
I figuret the mistake out and i was able to make a loopback module but now i get this exception:
[33168.807576] ------------[ cut here ]------------
[33168.812054] WARNING: CPU: 0 PID: 1392 at /home/gonzo/projects/SerdevTest/usartHci.c:45 stm_tty_receive+0x4c/0x8c [usartHci]
[33168.823255] Modules linked in: usartHci(OE) cfg80211 snd_soc_cs42l51 snd_soc_hdmi_codec snd_soc_stm32_sai_sub snd_soc_audio_graph_card snd_soc_simple_card_utils snd_soc_stm32_i2s snd_soc_core usb_f_rndis u_ether snd_pcm_dmaengine libcomposite snd_pcm stusb160x typec snd_timer snd stm32_hash stm32_crc32 crypto_engine snd_soc_stm32_sai stm32_cec soundcore sch_fq_codel ipv6 [last unloaded: usartHci]
[33168.858431] CPU: 0 PID: 1392 Comm: kworker/u4:1 Tainted: G W OE 5.10.10 #2
[33168.866254] Hardware name: STM32 (Device Tree Support)
[33168.871406] Workqueue: events_unbound flush_to_ldisc
[33168.876377] [<c0110824>] (unwind_backtrace) from [<c010c4e0>] (show_stack+0x10/0x14)
[33168.884110] [<c010c4e0>] (show_stack) from [<c0b8319c>] (dump_stack+0xb8/0xcc)
[33168.891335] [<c0b8319c>] (dump_stack) from [<c01249c0>] (__warn+0xec/0x104)
[33168.898295] [<c01249c0>] (__warn) from [<c0b7e65c>] (warn_slowpath_fmt+0x64/0xc4)
[33168.905786] [<c0b7e65c>] (warn_slowpath_fmt) from [<bf1360ec>] (stm_tty_receive+0x4c/0x8c [usartHci])
[33168.915014] [<bf1360ec>] (stm_tty_receive [usartHci]) from [<c06b5574>] (ttyport_receive_buf+0x50/0xf4)
[33168.924410] [<c06b5574>] (ttyport_receive_buf) from [<c0693ef4>] (flush_to_ldisc+0x8c/0xe0)
[33168.932765] [<c0693ef4>] (flush_to_ldisc) from [<c0141798>] (process_one_work+0x1dc/0x59c)
[33168.941032] [<c0141798>] (process_one_work) from [<c0141ba4>] (worker_thread+0x4c/0x520)
[33168.949128] [<c0141ba4>] (worker_thread) from [<c014818c>] (kthread+0x144/0x180)
[33168.956526] [<c014818c>] (kthread) from [<c0100148>] (ret_from_fork+0x14/0x2c)
[33168.963741] Exception stack(0xc3e1dfb0 to 0xc3e1dff8)
[33168.968793] dfa0: 00000000 00000000 00000000 00000000
[33168.976976] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[33168.985155] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
[33168.991879] ---[ end trace 29e46253976aa845 ]---
it only pops up when i sent the data when i just print what i recive i get no error,
my loopack looks like this:
static int
stm_tty_receive(struct serdev_device *serdev, const unsigned char *data,
size_t count)
{
struct stmuart *stm = serdev_device_get_drvdata(serdev);
int len;
u8 *pos;
spin_lock(&stm->lock);
WARN_ON(stm->tx_left);
pos = stm->tx_buffer;
len = serdev_device_write_buf(serdev,
data, count);
stm->tx_left = (pos - stm->tx_buffer) - len;
stm->tx_head = stm->tx_buffer + len;
spin_unlock(&stm->lock);
return len;
}
2021-06-01 12:34 PM
The issue was that my device tree was not setup corectly thats why i had this issue before
2021-06-02 02:04 AM
Hi @SAman.1 ,
Sorry to come late in the thread.
Seems you figure out by yourself the issue.
Could you elaborate further "my device tree was not setup correctly" ?
Which node/properties exactly ?
This may help other members and us in ST to better know where was the trap.
Thanks,
Olivier
2021-06-02 06:55 AM
I needed to enable it on the stm32mp151.dtsi and not in the stm32mp15xx-dkx.dtsi.
But i have a new question when enable serdev_device_set_flow_control(serdev, true); it is not sending and the CTS and RTS not get changed. do i need to enable more to get hardware flow control on a serdev.
2021-06-03 02:09 PM
Hi @SAman.1
Maybe this old post can help to setup HW Flow control
https://community.st.com/s/question/0D53W0000037Pi0SAE/how-to-enable-hardware-flow-control-rs485
Olivier
2021-06-03 11:57 PM
Hi I saw that post already but it did not helped me because I wanted to use it from my serial device bus.
2021-06-04 09:11 AM
I am also not able to change my CTS or RTS pin with the serdev_device_set_tiocm methode.