In case of the need of a hard real time operating system in addition to a Linux OS, here it is described howto do that. Additionally the EtherCat library SOEM is also parrt of the system.
Unfortunately the Raspberry Pi OS does not support a precompiled PREEMPT_RT patched kernel for armhf in their repositories. It is described here roughly how to do the task.