RK3588如何搭建preempt_rt+ethercat

张开发
2026/4/10 4:02:55 15 分钟阅读
RK3588如何搭建preempt_rt+ethercat
说明使用的RK3588的分支版本是linux-6.1-stan-rkr6 内核版本是6.1.99 文件系统是Debian GNU/Linux 12 把瑞芯微的SDK更新到linux-6.1-stan-rkr6这个版本即可适配preemrt的ethercat的源码是RK已经适配过的直接拿来使用即可。 RK的SDK的doc也有ethercat相关的文档。编译preemrt的内核前面要先把preemrt的内核补丁打好看RK的文档即可。编译ethercat通用的驱动编译编译出来可以正常使用说明编译的环境大致没问题。 其中编译步骤试过两种一种是交叉编译一种是RK3588直接编译。用交叉编译命令如下# ethcat_igh我放到了SDK的根目录方便编译 SDK_DIR/home/yangx/linux2/yangx/RK3588/IAC-RK3588-MB-kernel-6.1/ TOOLS_PATH$SDK_DIR/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/ CROSS_PATH$TOOLS_PATH/bin export PATH$TOOLS_PATH:$CROSS_PATH:$PATH export CROSS_COMPILEaarch64-none-linux-gnu- export ARCHarm64 KERNEL_SRC/home/yangx/linux2/yangx/RK3588/IAC-RK3588-MB-kernel-6.1/kernel/ ./bootstrap ./configure --prefix/home/yangx/linux2/yangx/RK3588/IAC-RK3588-MB-kernel-6.1/ethercat_igh/build/ --hostaarch64-none-linux-gnu --with-linux-dir${KERNEL_SRC} --enable-8139toono --enable-stmmacyes --enable-genericno --enable-wildcardsyes # 编译驱动 make ARCHarm64 modules #编译应用工具和ethercat库 make ARCHarm64RK3588直接编译用U盘把ethercat_igh文件夹直接拷贝到板子的根目录编译命令如下:./bootstrap ./configure --with-linux-dir/usr/src/linux-headers-6.1-rockchip --disable-8139too --enable-genericno --enable-stmmacyes --disable-e1000e --enable-kernel --disable-hrtimer --disable-eoe --prefix/opt/etherlab make modules make make install两种方式都能编译成功。 编译通用驱动是这个两个参数--enable-genericyes --enable-stmmacno 实际调试的时候是先加载通用的驱动使用ethercat的命令都是正常的然后再重新编译stmmac的驱动进行调试。修改内核把设备树的gmac0的compatible修改为snps,dwmac-5.00.a0板子加载ethercat驱动和使用的步骤# 把内核源码编译的 pcs_xpcs.ko phylink.ko 放到/lib/modules/6.1.99-rt36/文件夹 insmod phylink.ko insmod pcs_xpcs.ko # 设置为eth0的MAC地址 insmod ec_master.ko main_devices32:d4:b5:f9:e3:d5 insmod ec_stmmac.ko实际测试的时候Ethercat模块是EL1008EL2008网线直连RK3588和ethercat模块1ms周期10us的抖动延时。

更多文章