广告

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

实时内核设计n91ednc

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

移植补丁n91ednc

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

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

n91ednc

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

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

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

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

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

图2-2. 打实时补丁n91ednc

编译内核源码n91ednc

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

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

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

更新编译得到的Image即可n91ednc

其他影响性能的配置n91ednc

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

cd /sys/devices/system/cpu/cpufreq/policy0n91ednc

echo userspace > scaling_governorn91ednc

cat scaling_max_freq  > scaling_setspeedn91ednc

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

实时性测试n91ednc

空载测试n91ednc

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

n91ednc

图3-1.空载测试n91ednc

CPU&内存满载n91ednc

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

增加压力n91ednc

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

n91ednc

图3-2.满载测试n91ednc

数据对比:n91ednc

 n91ednc

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

 n91ednc

表4-1.数据信息n91ednc

ethercat IGH移植n91ednc

下载ethercat IGH源码n91ednc

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

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

n91ednc

图4-1. 下载源码n91ednc

解压ethercat源码n91ednc

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

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

加载sdk环境变量n91ednc

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

编译ethercat源码n91ednc

生成configure文件n91ednc

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

+ touch ChangeLogn91ednc

+ mkdir -p m4n91ednc

+ autoreconf -in91ednc

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

configure设置n91ednc

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

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

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

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

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

checking whether build environment is sane... yesn91ednc

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

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

checking for gawk... gawkn91ednc

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

checking whether make supports nested variables... yesn91ednc

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

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

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

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

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

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

..........n91ednc

...............n91ednc

config.status: creating examples/xenomai/Makefilen91ednc

config.status: creating examples/xenomai_posix/Makefilen91ednc

config.status: creating include/Makefilen91ednc

config.status: creating lib/Makefilen91ednc

config.status: creating lib/libethercat.pcn91ednc

config.status: creating master/Kbuildn91ednc

config.status: creating master/Makefilen91ednc

config.status: creating script/Makefilen91ednc

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

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

config.status: creating script/sysconfig/Makefilen91ednc

config.status: creating tool/Makefilen91ednc

config.status: creating tty/Kbuildn91ednc

config.status: creating tty/Makefilen91ednc

config.status: creating config.hn91ednc

config.status: executing depfiles commandsn91ednc

config.status: executing libtool commandsn91ednc

编译源码n91ednc

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

make  all-recursiven91ednc

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

Making all in includen91ednc

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

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

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

Making all in scriptn91ednc

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

Making all in init.dn91ednc

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

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

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

Making all in sysconfign91ednc

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

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

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

......n91ednc

......n91ednc

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

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

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

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

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

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

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

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

编译modulesn91ednc

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

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

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

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

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

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

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

...........n91ednc

............n91ednc

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

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

安装ethercatn91ednc

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

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

Making install in includen91ednc

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

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

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

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

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

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

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

Making install in scriptn91ednc

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

Making install in init.dn91ednc

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

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

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

...........n91ednc

..........n91ednc

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

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

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

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

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

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

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

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

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

将etharcat相关文件打包n91ednc

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

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

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

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

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

bin  etc  include  lib  modules  sbin sharen91ednc

压缩output输出文件n91ednc

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

output/n91ednc

output/etc/n91ednc

output/etc/ethercat.confn91ednc

output/etc/init.d/n91ednc

output/etc/init.d/ethercatn91ednc

output/etc/sysconfig/n91ednc

output/etc/sysconfig/ethercatn91ednc

output/sbin/n91ednc

output/sbin/ethercatctln91ednc

output/include/n91ednc

output/include/ectty.hn91ednc

output/include/ecrt.hn91ednc

output/modules/n91ednc

output/modules/ec_master.kon91ednc

output/modules/ec_generic.kon91ednc

output/share/n91ednc

output/share/bash-completion/n91ednc

output/share/bash-completion/completions/n91ednc

output/share/bash-completion/completions/ethercatn91ednc

output/bin/n91ednc

output/bin/ethercatn91ednc

output/lib/n91ednc

output/lib/libethercat.son91ednc

output/lib/pkgconfig/n91ednc

output/lib/pkgconfig/libethercat.pcn91ednc

output/lib/libethercat.so.1.2.0n91ednc

output/lib/cmake/n91ednc

output/lib/cmake/ethercat/n91ednc

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

output/lib/libethercat.an91ednc

output/lib/libethercat.lan91ednc

output/lib/libethercat.so.1n91ednc

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

output.tar.bz2n91ednc

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

移植ethercat相关库到开发板n91ednc

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

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

output/n91ednc

output/etc/n91ednc

output/etc/ethercat.confn91ednc

output/etc/init.d/n91ednc

output/etc/init.d/ethercatn91ednc

output/etc/sysconfig/n91ednc

output/etc/sysconfig/ethercatn91ednc

output/sbin/n91ednc

output/sbin/ethercatctln91ednc

output/include/n91ednc

output/include/ectty.hn91ednc

output/include/ecrt.hn91ednc

output/modules/n91ednc

output/modules/ec_master.kon91ednc

output/modules/ec_generic.kon91ednc

output/share/n91ednc

output/share/bash-completion/n91ednc

output/share/bash-completion/completions/n91ednc

output/share/bash-completion/completions/ethercatn91ednc

output/bin/n91ednc

output/bin/ethercatn91ednc

output/lib/n91ednc

output/lib/libethercat.son91ednc

output/lib/pkgconfig/n91ednc

output/lib/pkgconfig/libethercat.pcn91ednc

output/lib/libethercat.so.1.2.0n91ednc

output/lib/cmake/n91ednc

output/lib/cmake/ethercat/n91ednc

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

output/lib/libethercat.an91ednc

output/lib/libethercat.lan91ednc

output/lib/libethercat.so.1n91ednc

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

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

bin  etc  include  lib  modules  sbin  sharen91ednc

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

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

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

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

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

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

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

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

启动EtherCATn91ednc

配置主站的MAC地址n91ednc

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

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

启动ethercatn91ednc

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

Starting EtherCAT master 1.5.2  donen91ednc

至此所有步骤完成。n91ednc

米尔瑞米派 Remi Pin91ednc

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

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

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

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

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

n91ednc

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

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

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