广告

米尔瑞米派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.htmlR0xednc

实时内核设计R0xednc

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

移植补丁R0xednc

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

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

R0xednc

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

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

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

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

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

图2-2. 打实时补丁R0xednc

编译内核源码R0xednc

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

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

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

更新编译得到的Image即可R0xednc

其他影响性能的配置R0xednc

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

cd /sys/devices/system/cpu/cpufreq/policy0R0xednc

echo userspace > scaling_governorR0xednc

cat scaling_max_freq  > scaling_setspeedR0xednc

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

实时性测试R0xednc

空载测试R0xednc

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

R0xednc

图3-1.空载测试R0xednc

CPU&内存满载R0xednc

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

增加压力R0xednc

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

R0xednc

图3-2.满载测试R0xednc

数据对比:R0xednc

 R0xednc

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

 R0xednc

表4-1.数据信息R0xednc

ethercat IGH移植R0xednc

下载ethercat IGH源码R0xednc

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

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

R0xednc

图4-1. 下载源码R0xednc

解压ethercat源码R0xednc

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

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

加载sdk环境变量R0xednc

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

编译ethercat源码R0xednc

生成configure文件R0xednc

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

+ touch ChangeLogR0xednc

+ mkdir -p m4R0xednc

+ autoreconf -iR0xednc

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

configure设置R0xednc

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

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-linuxR0xednc

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

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

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

checking whether build environment is sane... yesR0xednc

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

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

checking for gawk... gawkR0xednc

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

checking whether make supports nested variables... yesR0xednc

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

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

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

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

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

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

..........R0xednc

...............R0xednc

config.status: creating examples/xenomai/MakefileR0xednc

config.status: creating examples/xenomai_posix/MakefileR0xednc

config.status: creating include/MakefileR0xednc

config.status: creating lib/MakefileR0xednc

config.status: creating lib/libethercat.pcR0xednc

config.status: creating master/KbuildR0xednc

config.status: creating master/MakefileR0xednc

config.status: creating script/MakefileR0xednc

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

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

config.status: creating script/sysconfig/MakefileR0xednc

config.status: creating tool/MakefileR0xednc

config.status: creating tty/KbuildR0xednc

config.status: creating tty/MakefileR0xednc

config.status: creating config.hR0xednc

config.status: executing depfiles commandsR0xednc

config.status: executing libtool commandsR0xednc

编译源码R0xednc

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

make  all-recursiveR0xednc

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

Making all in includeR0xednc

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

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

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

Making all in scriptR0xednc

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

Making all in init.dR0xednc

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

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

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

Making all in sysconfigR0xednc

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

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

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

......R0xednc

......R0xednc

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

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

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

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

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

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

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

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

编译modulesR0xednc

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

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

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

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

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

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

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

...........R0xednc

............R0xednc

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

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

安装ethercatR0xednc

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

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

Making install in includeR0xednc

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

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

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

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

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

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

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

Making install in scriptR0xednc

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

Making install in init.dR0xednc

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

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

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

...........R0xednc

..........R0xednc

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

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

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

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

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

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

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

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

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

将etharcat相关文件打包R0xednc

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

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

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

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

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

bin  etc  include  lib  modules  sbin shareR0xednc

压缩output输出文件R0xednc

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

output/R0xednc

output/etc/R0xednc

output/etc/ethercat.confR0xednc

output/etc/init.d/R0xednc

output/etc/init.d/ethercatR0xednc

output/etc/sysconfig/R0xednc

output/etc/sysconfig/ethercatR0xednc

output/sbin/R0xednc

output/sbin/ethercatctlR0xednc

output/include/R0xednc

output/include/ectty.hR0xednc

output/include/ecrt.hR0xednc

output/modules/R0xednc

output/modules/ec_master.koR0xednc

output/modules/ec_generic.koR0xednc

output/share/R0xednc

output/share/bash-completion/R0xednc

output/share/bash-completion/completions/R0xednc

output/share/bash-completion/completions/ethercatR0xednc

output/bin/R0xednc

output/bin/ethercatR0xednc

output/lib/R0xednc

output/lib/libethercat.soR0xednc

output/lib/pkgconfig/R0xednc

output/lib/pkgconfig/libethercat.pcR0xednc

output/lib/libethercat.so.1.2.0R0xednc

output/lib/cmake/R0xednc

output/lib/cmake/ethercat/R0xednc

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

output/lib/libethercat.aR0xednc

output/lib/libethercat.laR0xednc

output/lib/libethercat.so.1R0xednc

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

output.tar.bz2R0xednc

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

移植ethercat相关库到开发板R0xednc

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

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

output/R0xednc

output/etc/R0xednc

output/etc/ethercat.confR0xednc

output/etc/init.d/R0xednc

output/etc/init.d/ethercatR0xednc

output/etc/sysconfig/R0xednc

output/etc/sysconfig/ethercatR0xednc

output/sbin/R0xednc

output/sbin/ethercatctlR0xednc

output/include/R0xednc

output/include/ectty.hR0xednc

output/include/ecrt.hR0xednc

output/modules/R0xednc

output/modules/ec_master.koR0xednc

output/modules/ec_generic.koR0xednc

output/share/R0xednc

output/share/bash-completion/R0xednc

output/share/bash-completion/completions/R0xednc

output/share/bash-completion/completions/ethercatR0xednc

output/bin/R0xednc

output/bin/ethercatR0xednc

output/lib/R0xednc

output/lib/libethercat.soR0xednc

output/lib/pkgconfig/R0xednc

output/lib/pkgconfig/libethercat.pcR0xednc

output/lib/libethercat.so.1.2.0R0xednc

output/lib/cmake/R0xednc

output/lib/cmake/ethercat/R0xednc

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

output/lib/libethercat.aR0xednc

output/lib/libethercat.laR0xednc

output/lib/libethercat.so.1R0xednc

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

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

bin  etc  include  lib  modules  sbin  shareR0xednc

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

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

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

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

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

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

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

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

启动EtherCATR0xednc

配置主站的MAC地址R0xednc

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

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

启动ethercatR0xednc

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

Starting EtherCAT master 1.5.2  doneR0xednc

至此所有步骤完成。R0xednc

米尔瑞米派 Remi PiR0xednc

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

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

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

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

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

R0xednc

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

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

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