米尔Remi Pi 实时系统与EtherCAT移植

2024年04月30日 18:44    发布者:swiftman
1.概述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等外设接口,在工业、医疗、电力等行业都得到广泛的应用。2.实时内核设计
[*]实时补丁我们选择RT-Preempt来实现

RT补丁可以从RT官网下载5.10.83对应的补丁
[*]把补丁放到自己的工作目录下,然后解压,如图2-1:

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


图2-1. 内核源码
[*]进入到内核源码打补丁,如图2-2:

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

图2-2. 打实时补丁
[*]编译内核源码

hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ /opt/remi-sdk/environment-setup-aarch64-poky-linux
hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ make ARCH=arm64 mys_g2lx_defconfig
hjx@myir-server:~/renesas/04_Sources/myir-renesas-linux$ make ARCH=arm64 Image dtbs   -j16



2.2. 其他影响性能的配置3.实时性测试
[*]空载测试

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


图3-1.空载测试
[*]CPU&内存满载

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


[*]增加压力

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

图3-2.满载测试表3-1.数据信息4.1. 下载EtherCAT IGH源码https://gitlab.com/etherlab.org/ethercat/-/tree/stable-1.5?ref_type=heads图4-1. 下载源码
[*]解压EtherCAT源码

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



[*]加载sdk环境变量

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


编译通过会对应生成ethercat-stable-1.5/devices/ec_generic.ko和ethercat-stable-1.5/master/ec_master.ko安装成功后前面指定/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output目录下有编译生成的各种用户空间的文件。hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ make install
Making install in include
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'/
usr/bin/install -c -m 644 ecrt.h ectty.h '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/output/include'
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
Making install in script
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'
Making install in init.d
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make: Nothing to be done for 'install-exec-am'
............
..........
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make: Nothing to be done for 'install-exec-am'.
make: Nothing to be done for 'install-data-am'.
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
4.4. 将EtharCAT相关文件打包至此IGH交叉编译完成,下面是在对应arm目标板上的操作。将上面制作好的output.tar.bz2传到开发板上,然后解压出来。root@myir-remi-1g:~# tar -xvf output.tar.bz2output/
output/
etc/output/
etc/ethercat.conf
output/etc/init.d/
output/etc/init.d/ethercat
output/etc/sysconfig/
output/etc/sysconfig/ethercat
output/sbin/
output/sbin/ethercatctl
output/include/
output/include/ectty.h
output/include/ecrt.h
output/modules/
output/modules/ec_master.ko
output/modules/ec_generic.ko
output/share/
output/share/bash-completion/
output/share/bash-completion/completions/
output/share/bash-completion/completions/ethercat
output/bin/
output/bin/ethercat
output/lib/
output/lib/libethercat.so
output/lib/pkgconfig/
output/lib/pkgconfig/libethercat.pc
output/lib/libethercat.so.1.2.0
output/lib/cmake/
output/lib/cmake/ethercat/
output/lib/cmake/ethercat/ethercat-config.cmake
output/lib/libethercat.a
output/lib/libethercat.la
output/lib/libethercat.so.1
将output目录下各文件目录的内容复制到板子根文件系统根目录下相应目录下,例如:cp bin/ethercat /bin/(include目录不用复制)root@myir-remi-1g:~/output# ls
bin etc  include  lib  modules  sbin  share
root@myir-remi-1g:~/output# cp bin/ethercat /bin/
root@myir-remi-1g:~/output# cp etc/ethercat.conf /etc/
root@myir-remi-1g:~/output# cp etc/init.d/*  /etc/init.d
root@myir-remi-1g:~/output# cp -r etc/sysconfig/ /etc/
root@myir-remi-1g:~/output# cp  lib/libethercat.* /lib64/
root@myir-remi-1g:~/output# cp -r lib/pkgconfig /lib64/
root@myir-remi-1g:~/output# cp modules/ec_master.ko /lib/modules/5.10.83-cip1-yocto-standard/
root@myir-remi-1g:~/output# cp sbin/ethercatctl  /sbin/
4.6. 启动EtherCAT4.6.2. 启动EtherCATroot@myir-remi-1g:~# /etc/init.d/ethercat start
Starting EtherCAT master 1.5.2 done

至此所有步骤完成。
米尔瑞米派 Remi Pi瑞萨第一款MPU生态板卡,兼容树莓派扩展模块采用瑞萨RZ/G2L工业级处理器,便于企业客户产品开发;Remi Pi兼容树莓派所有配件,方便产品原型搭建和创新应用;更多的工业接口,兼顾开发、学习和实际应用;软件系统丰富,支持Debian/Ubuntu/Linux等。