广告

米尔瑞米派Remi Pi实时系统与Ethercat移植 应用笔记

2024-04-26 米尔 阅读:
Remi Pi采用瑞萨RZ/G2L作为核心处理器,该处理器搭载双核Cortex-A55@1.2GHz+Cortex-M33@200MHz处理器,其内部集成高性能3D加速引擎Mail-G31 GPU(500MHz)和视频处理单元(支持H.264硬件编解码),16位的DDR4-1600 / DDR3L-1333内存控制器、千兆以太网控制器、USB、CAN、SD卡、MIPI-CSI等外设接口,在工业、医疗、电力等行业都得到广泛的应用。

在开发阶段,建议配合核心板配套的评估套件 MYD-YG2L23-8E1D-120-C-REMI来加速开发。评估套件的详细信息请访问:https://www.myir.cn/shows/23/14.htmlXFhednc

实时内核设计XFhednc

实时补丁我们选择RT-Preempt来实现XFhednc

移植补丁XFhednc

RT补丁可以从RT官网下载5.10.83对应的补丁XFhednc

https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.10/older/XFhednc

XFhednc

把补丁放到自己的工作目录下,然后解压,如图2-1:XFhednc

hjx@myir-server:~/renesas/04_Sources$ tar -xvf patches-5.10.83-rt58.tar.gzXFhednc

图2-1. 内核源码解压XFhednc

进入到内核源码打补丁,如图2-2:XFhednc

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ for p in `ls -1 ../patches/*.patch`; do patch -p1 < $p; doneXFhednc

图2-2. 打实时补丁XFhednc

编译内核源码XFhednc

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ /opt/remi-sdk/environment-setup-aarch64-poky-linuxXFhednc

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ make ARCH=arm64 mys_g2lx_defconfigXFhednc

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ make ARCH=arm64 Image dtbs   -j16XFhednc

更新编译得到的Image即可XFhednc

其他影响性能的配置XFhednc

禁用CPU Freq自动调频,并设置主频为最高频率:XFhednc

cd /sys/devices/system/cpu/cpufreq/policy0XFhednc

echo userspace > scaling_governorXFhednc

cat scaling_max_freq  > scaling_setspeedXFhednc

(如不禁用cpufreq调频功能,系统会因动态调频产生极大的偶然延迟)XFhednc

实时性测试XFhednc

空载测试XFhednc

cyclictest -p 99 -t 1 -d 100 -i 1000 -D 24h -m -a -nXFhednc

XFhednc

图3-1.空载测试XFhednc

CPU&内存满载XFhednc

cyclictest -p 99 -t 1 -d 100 -i 1000 -D 24h -m -a -nXFhednc

增加压力XFhednc

stress-ng --cpu 4 --cpu-method all --io 4 --vm 50 -d 5  --fork 4 --timeout 36000s XFhednc

XFhednc

图3-2.满载测试XFhednc

数据对比:XFhednc

 XFhednc

板卡 MYD-YG2LX-REMI
测试时间 120min
指令 cyclictest &stress-ng
空载 平均 8us最大 24us
满载 平均 13us最大 136us

 XFhednc

表4-1.数据信息XFhednc

ethercat IGH移植XFhednc

下载ethercat IGH源码XFhednc

到官网下载1.5版本的ethercat源码,如图4-1:XFhednc

https://gitlab.com/etherlab.org/ethercat/-/tree/stable-1.5?ref_type=headsXFhednc

XFhednc

图4-1. 下载源码XFhednc

解压ethercat源码XFhednc

hjx@myir-server:~/renesas/04_Sources$ tar -xvf ethercat-stable-1.5.tar.bz2XFhednc

hjx@myir-server:~/renesas/04_Sources$ cd ethercat-stable-1.5XFhednc

加载sdk环境变量XFhednc

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ source /opt/remi-sdk/environment-setup-aarch64-poky-linuxXFhednc

编译ethercat源码XFhednc

生成configure文件XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ./bootstrapXFhednc

+ touch ChangeLogXFhednc

+ mkdir -p m4XFhednc

+ autoreconf -iXFhednc

libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'autoconf'.XFhednc

libtoolize: copying file 'autoconf/ltmain.sh'XFhednc

libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.XFhednc

libtoolize: copying file 'm4/libtool.m4'XFhednc

libtoolize: copying file 'm4/ltoptions.m4'XFhednc

libtoolize: copying file 'm4/ltsugar.m4'XFhednc

libtoolize: copying file 'm4/ltversion.m4'XFhednc

libtoolize: copying file 'm4/lt~obsolete.m4'XFhednc

configure.ac:56: installing 'autoconf/ar-lib'XFhednc

configure.ac:55: installing 'autoconf/compile'XFhednc

configure.ac:58: installing 'autoconf/config.guess'XFhednc

configure.ac:58: installing 'autoconf/config.sub'XFhednc

configure.ac:42: installing 'autoconf/install-sh'XFhednc

configure.ac:42: installing 'autoconf/missing'XFhednc

examples/dc_user/Makefile.am: installing 'autoconf/depcomp'XFhednc

configure设置XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ mkdir  outputXFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ./configure --prefix=/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output --with-linux-dir=/home/hjx/renesas/04_Sources/myir-renesas-linux  --enable-8139too=no  --enable-generic=yes   --host=aarch64-poky-linuxXFhednc

(--prefix=/home/hjx/renesas/04_Sources/output 指定输出目录、--with-linux-dir=/home/hjx/renesas/04_Sources/myir-renesas-linux指定内核源码目录)XFhednc

configure: loading site script /opt/remi-sdk/site-config-aarch64-poky-linuxXFhednc

checking for a BSD-compatible install... /usr/bin/install -cXFhednc

checking whether build environment is sane... yesXFhednc

checking for aarch64-poky-linux-strip... aarch64-poky-linux-stripXFhednc

checking for a thread-safe mkdir -p... /bin/mkdir -pXFhednc

checking for gawk... gawkXFhednc

checking whether make sets $(MAKE)... yesXFhednc

checking whether make supports nested variables... yesXFhednc

checking whether make supports nested variables... (cached) yesXFhednc

checking for a sed that does not truncate output... (cached) sedXFhednc

checking for aarch64-poky-linux-pkg-config... noXFhednc

checking for pkg-config... /opt/remi-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-configXFhednc

checking pkg-config is at least version 0.9.0... yesXFhednc

checking whether make supports the include directive... yes (GNU style)XFhednc

..........XFhednc

...............XFhednc

config.status: creating examples/xenomai/MakefileXFhednc

config.status: creating examples/xenomai_posix/MakefileXFhednc

config.status: creating include/MakefileXFhednc

config.status: creating lib/MakefileXFhednc

config.status: creating lib/libethercat.pcXFhednc

config.status: creating master/KbuildXFhednc

config.status: creating master/MakefileXFhednc

config.status: creating script/MakefileXFhednc

config.status: creating script/init.d/MakefileXFhednc

config.status: creating script/init.d/ethercatXFhednc

config.status: creating script/sysconfig/MakefileXFhednc

config.status: creating tool/MakefileXFhednc

config.status: creating tty/KbuildXFhednc

config.status: creating tty/MakefileXFhednc

config.status: creating config.hXFhednc

config.status: executing depfiles commandsXFhednc

config.status: executing libtool commandsXFhednc

编译源码XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$   makeXFhednc

make  all-recursiveXFhednc

make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

Making all in includeXFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

make[2]: Nothing to be done for 'all'.XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

Making all in scriptXFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'XFhednc

Making all in init.dXFhednc

make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'XFhednc

make[3]: Nothing to be done for 'all'.XFhednc

make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'XFhednc

Making all in sysconfigXFhednc

make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'XFhednc

make[3]: Nothing to be done for 'all'.XFhednc

make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'XFhednc

......XFhednc

......XFhednc

make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/user'XFhednc

make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[3]: Nothing to be done for 'all-am'.XFhednc

make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

编译modulesXFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  make  modulesXFhednc

make[1]: Entering directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'XFhednc

  CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/mini.oXFhednc

  LD [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/ec_mini.oXFhednc

  CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/cdev.oXFhednc

  CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/coe_emerg_ring.oXFhednc

  CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/datagram.oXFhednc

...........XFhednc

............XFhednc

make[1]: Leaving directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'XFhednc

编译通过会对应生成ethercat-stable-1.5/devices/ec_generic.ko和ethercat-stable-1.5/master/ec_master.koXFhednc

安装ethercatXFhednc

安装成功后前面指定/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output目录下有编译生成的各种用户空间的文件。XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ make installXFhednc

Making install in includeXFhednc

make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

make[2]: Nothing to be done for 'install-exec-am'.XFhednc

 /bin/mkdir -p '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'XFhednc

 /usr/bin/install -c -m 644 ecrt.h ectty.h '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'XFhednc

Making install in scriptXFhednc

make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'XFhednc

Making install in init.dXFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'XFhednc

make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'XFhednc

make[3]: Nothing to be done for 'install-exec-am'.XFhednc

...........XFhednc

..........XFhednc

make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'XFhednc

make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

make[2]: Nothing to be done for 'install-exec-am'.XFhednc

make[2]: Nothing to be done for 'install-data-am'.XFhednc

make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'XFhednc

将etharcat相关文件打包XFhednc

在/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output目录下创建modules文件夹,并复制ec_generic.ko和ec_master.ko到modules下XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  mkdir -p output/modulesXFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  cp devices/ec_generic.ko  output/modules/XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  cp master/ec_master.ko   output/modules/XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ls outputXFhednc

bin  etc  include  lib  modules  sbin shareXFhednc

压缩output输出文件XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ tar -jcvf output.tar.bz2 output/  XFhednc

output/XFhednc

output/etc/XFhednc

output/etc/ethercat.confXFhednc

output/etc/init.d/XFhednc

output/etc/init.d/ethercatXFhednc

output/etc/sysconfig/XFhednc

output/etc/sysconfig/ethercatXFhednc

output/sbin/XFhednc

output/sbin/ethercatctlXFhednc

output/include/XFhednc

output/include/ectty.hXFhednc

output/include/ecrt.hXFhednc

output/modules/XFhednc

output/modules/ec_master.koXFhednc

output/modules/ec_generic.koXFhednc

output/share/XFhednc

output/share/bash-completion/XFhednc

output/share/bash-completion/completions/XFhednc

output/share/bash-completion/completions/ethercatXFhednc

output/bin/XFhednc

output/bin/ethercatXFhednc

output/lib/XFhednc

output/lib/libethercat.soXFhednc

output/lib/pkgconfig/XFhednc

output/lib/pkgconfig/libethercat.pcXFhednc

output/lib/libethercat.so.1.2.0XFhednc

output/lib/cmake/XFhednc

output/lib/cmake/ethercat/XFhednc

output/lib/cmake/ethercat/ethercat-config.cmakeXFhednc

output/lib/libethercat.aXFhednc

output/lib/libethercat.laXFhednc

output/lib/libethercat.so.1XFhednc

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ls output.tar.bz2XFhednc

output.tar.bz2XFhednc

至此IGH交叉编译完成,下面是在对应arm目标板上的操作。XFhednc

移植ethercat相关库到开发板XFhednc

将上面制作好的output.tar.bz2传到开发板上,然后解压出来。XFhednc

root@myir-remi-1g:~# tar -xvf output.tar.bz2                                             XFhednc

output/XFhednc

output/etc/XFhednc

output/etc/ethercat.confXFhednc

output/etc/init.d/XFhednc

output/etc/init.d/ethercatXFhednc

output/etc/sysconfig/XFhednc

output/etc/sysconfig/ethercatXFhednc

output/sbin/XFhednc

output/sbin/ethercatctlXFhednc

output/include/XFhednc

output/include/ectty.hXFhednc

output/include/ecrt.hXFhednc

output/modules/XFhednc

output/modules/ec_master.koXFhednc

output/modules/ec_generic.koXFhednc

output/share/XFhednc

output/share/bash-completion/XFhednc

output/share/bash-completion/completions/XFhednc

output/share/bash-completion/completions/ethercatXFhednc

output/bin/XFhednc

output/bin/ethercatXFhednc

output/lib/XFhednc

output/lib/libethercat.soXFhednc

output/lib/pkgconfig/XFhednc

output/lib/pkgconfig/libethercat.pcXFhednc

output/lib/libethercat.so.1.2.0XFhednc

output/lib/cmake/XFhednc

output/lib/cmake/ethercat/XFhednc

output/lib/cmake/ethercat/ethercat-config.cmakeXFhednc

output/lib/libethercat.aXFhednc

output/lib/libethercat.laXFhednc

output/lib/libethercat.so.1XFhednc

将output目录下各文件目录的内容复制到板子根文件系统根目录下相应目录下,例如:cp bin/ethercat /bin/(include目录不用复制)XFhednc

root@myir-remi-1g:~/output# lsXFhednc

bin  etc  include  lib  modules  sbin  shareXFhednc

root@myir-remi-1g:~/output# cp bin/ethercat /bin/XFhednc

root@myir-remi-1g:~/output# cp etc/ethercat.conf /etc/XFhednc

root@myir-remi-1g:~/output# cp etc/init.d/*  /etc/init.dXFhednc

root@myir-remi-1g:~/output# cp -r etc/sysconfig/ /etc/XFhednc

root@myir-remi-1g:~/output# cp  lib/libethercat.* /lib64/XFhednc

root@myir-remi-1g:~/output# cp -r lib/pkgconfig /lib64/XFhednc

root@myir-remi-1g:~/output# cp modules/ec_master.ko /lib/modules/5.10.83-cip1-yocto-standard/XFhednc

root@myir-remi-1g:~/output# cp sbin/ethercatctl  /sbin/XFhednc

启动EtherCATXFhednc

配置主站的MAC地址XFhednc

root@myir-remi-1g:~# depmodXFhednc

root@myir-remi-1g:~# modprobe ec_master main_devices=1E:ED:19:27:1A:B3 XFhednc

启动ethercatXFhednc

root@myir-remi-1g:~# /etc/init.d/ethercat startXFhednc

Starting EtherCAT master 1.5.2  doneXFhednc

至此所有步骤完成。XFhednc

米尔瑞米派 Remi PiXFhednc

瑞萨第一款MPU生态板卡,兼容树莓派扩展模块XFhednc

采用瑞萨RZ/G2L工业级处理器,便于企业客户产品开发;XFhednc

Remi Pi兼容树莓派所有配件,方便产品原型搭建和创新应用;XFhednc

更多的工业接口,兼顾开发、学习和实际应用;XFhednc

软件系统丰富,支持Debian/Ubuntu/Linux等。XFhednc

XFhednc

如需了解板卡,您可以通过访问以下米尔电子官网链接:XFhednc

https://www.myir.cn/shows/23/14.html更多关于Remi Pi技术问题讨论请登录米尔官方论坛:https://bbs.myir-tech.com/forum-66-1.htmlXFhednc

责编:Demi
文章来源及版权属于米尔,EDN电子技术设计仅作转载分享,对文中陈述、观点判断保持中立,不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。如有疑问,请联系Demi.xia@aspencore.com
  • 微信扫一扫
    一键转发
  • 最前沿的电子设计资讯
    请关注“电子技术设计微信公众号”
广告
热门推荐
广告
广告
EE直播间
在线研讨会
广告
广告
面包芯语
广告
向右滑动:上一篇 向左滑动:下一篇 我知道了