2020-06-30 11:51 PM
is there a way to tell the kernel (I'm using the Distribution Package) to use a specific pin (not the built-in DE signal) to control the Data Enable of an rs485 transceiver whenever I write something to the related tty?
2020-07-01 07:55 AM
Hello @Mark81 ,
The USARTx_DE signal pins are defined by hw - see pinout table in DS.
If you need to use specific pin, you would have to control the specific gpio pin in your user code and establish necessary timing characteristics of the DE signal.
See https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace
I hope I understood you correctly.
BR,
Milan
2020-07-01 08:43 AM
Exactly. What I wonder is if there's a way to instruct the kernel to handle the pin automatically. I find something in the kernel source code:
https://docs.huihoo.com/doxygen/linux/kernel/3.7/include_2uapi_2linux_2serial_8h_source.html
but it still uses the RTS pin. Perhaps there is a settings to do this with a different gpio.
The problem with manual handling in user space is that I cannot know exactly when the FIFO tx buffer is empty.
I mean, if I `fwrite`, say, 100 bytes to `/dev/ttySTM2` how can I be SURE to change the DE pin just a couple of ms after the last bit of the last byte was sent? Writing a firmware this is a very simple task, but writing a software in user space, without knowing all the stuff between my application and the hw is quite frightening.
2020-07-09 06:51 AM
Hi @Mark81 ,
There's a solution to your issue, see this patch coming from community:
https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=274187
Warning - this patch hasn't been backported, tested and delivered by ST.
Milan
2020-07-09 06:58 AM
Thanks! But I don't understand how to apply these patches.
I searched for `stm32-usart.c` under the whole Distribution-Package and it finds nothing.
2020-07-10 01:39 AM
Hi @Mark81 ,
To update/patch/rebuild the kernel is an advanved topic.
You need to use Developer package - study please information provided in following links:
The see file `stm32-usart.c` in Distribution-Package tou have to first run build using bitbake command. Then you can find it in build_xxxx directory.
Hope this helps
Milan
2020-07-30 12:11 AM
Hi @mleo Did you test that patch on linux-st kernel? I use it on my kernel and doesn't work.
2020-07-31 05:43 AM
Hi @Community member ,
I consulted with an expert - the patch covering rs485 isn't yet mature enough.
Either you can finalize on your own or wait until it's ready.
Best regards,
Milan