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

2024-04-30 23:28

本文主要是介绍瑞米派实时系统与EtherCAT移植-米尔Remi Pi,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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等外设接口,在工业、医疗、电力等行业都得到广泛的应用。

在开发阶段,建议配合核心板配套的评估套件 MYD-YG2L23-8E1D-120-C-REMI来加速开发。评估套件的详细信息请访问:Remi Pi 瑞米派 - 瑞萨第一款MPU生态板卡 - 深圳市米尔电子有限公司

2.实时内核设计

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

2.1. 移植补丁

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

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

  • 把补丁放到自己的工作目录下,然后解压,如图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

更新编译得到的Image即可

2.2. 其他影响性能的配置

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

cd /sys/devices/system/cpu/cpufreq/policy0
echo userspace > scaling_governor
cat scaling_max_freq  > scaling_setspeed

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

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.满载测试

数据对比:

板卡

MYD-YG2LX-REMI

测试时间

120min

指令

cyclictest &stress-ng

空载

平均 8us

最大 24us

满载

平均 13us

最大 136us

表3-1.数据信息

4.EtherCAT IGH移植

4.1. 下载EtherCAT IGH源码

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

Files · stable-1.5 · EtherLab / EtherCAT Master · GitLab

图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

4.2. 编译EtherCAT源码

  • 生成configure文件

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ./bootstrap
+ touch ChangeLog
+ mkdir -p m4
+ autoreconf -i
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'autoconf'.
libtoolize: copying file 'autoconf/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
configure.ac:56: installing 'autoconf/ar-lib'
configure.ac:55: installing 'autoconf/compile'
configure.ac:58: installing 'autoconf/config.guess'
configure.ac:58: installing 'autoconf/config.sub'
configure.ac:42: installing 'autoconf/install-sh'
configure.ac:42: installing 'autoconf/missing'
examples/dc_user/Makefile.am: installing 'autoconf/depcomp'

  • configure设置

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ mkdir  output
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-linux

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

configure: loading site script /opt/remi-sdk/site-config-aarch64-poky-linux
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for aarch64-poky-linux-strip... aarch64-poky-linux-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for a sed that does not truncate output... (cached) sed
checking for aarch64-poky-linux-pkg-config... no
checking for pkg-config... /opt/remi-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether make supports the include directive... yes (GNU style)
..........
...............
config.status: creating examples/xenomai/Makefile
config.status: creating examples/xenomai_posix/Makefile
config.status: creating include/Makefile
config.status: creating lib/Makefile
config.status: creating lib/libethercat.pcconfig.status: creating master/Kbuild
config.status: creating master/Makefileconfig.status: creating script/Makefile
config.status: creating script/init.d/Makefile
config.status: creating script/init.d/ethercat
config.status: creating script/sysconfig/Makefile
config.status: creating tool/Makefile
config.status: creating tty/Kbuild
config.status: creating tty/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

  • 编译源码

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$   make
make all-recursive
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
Making all in include
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
Making all in script
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'
Making all in init.d
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
Making all in sysconfig
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/sysconfig'
......
......
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/user'
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'

  • 编译modules

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  make  modules
make[1]: Entering directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'
CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/mini.o
LD [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples/mini/ec_mini.o
CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/cdev.o
CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/coe_emerg_ring.o
CC [M]  /home/hjx/renesas/04_Sources/ethercat-stable-1.5/master/datagram.o
...........
............
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/myir-renesas-linux'

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

4.3. 安装EtherCAT

安装成功后前面指定/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[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[2]: 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[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/include'
Making install in script
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script'
Making install in init.d
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/script/init.d'
make[3]: Nothing to be done for 'install-exec-am'
............
..........
make[3]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5/examples'
make[1]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Entering directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'
make[1]: Leaving directory '/home/hjx/renesas/04_Sources/ethercat-stable-1.5'

4.4. 将EtharCAT相关文件打包

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

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  mkdir -p output/modules
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  cp devices/ec_generic.ko  output/modules/
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$  cp master/ec_master.ko   output/modules/
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ls output
bin etc  include  lib  modules  sbin share

  • 压缩output输出文件

hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ tar -jcvf output.tar.bz2 
output/  
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
hjx@myir-server:~/renesas/04_Sources/ethercat-stable-1.5$ ls output.tar.bz2
output.tar.bz2

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

4.5. 移植EtherCAT相关库到开发板

将上面制作好的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. 启动EtherCAT

4.6.1. 配置主站的MAC地址

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

4.6.2. 启动EtherCAT

root@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等。

这篇关于瑞米派实时系统与EtherCAT移植-米尔Remi Pi的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/950191

相关文章

OpenCV实现实时颜色检测的示例

《OpenCV实现实时颜色检测的示例》本文主要介绍了OpenCV实现实时颜色检测的示例,通过HSV色彩空间转换和色调范围判断实现红黄绿蓝颜色检测,包含视频捕捉、区域标记、颜色分析等功能,具有一定的参考... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间

基于Python实现一个简单的题库与在线考试系统

《基于Python实现一个简单的题库与在线考试系统》在当今信息化教育时代,在线学习与考试系统已成为教育技术领域的重要组成部分,本文就来介绍一下如何使用Python和PyQt5框架开发一个名为白泽题库系... 目录概述功能特点界面展示系统架构设计类结构图Excel题库填写格式模板题库题目填写格式表核心数据结构

Linux系统中的firewall-offline-cmd详解(收藏版)

《Linux系统中的firewall-offline-cmd详解(收藏版)》firewall-offline-cmd是firewalld的一个命令行工具,专门设计用于在没有运行firewalld服务的... 目录主要用途基本语法选项1. 状态管理2. 区域管理3. 服务管理4. 端口管理5. ICMP 阻断

Windows 系统下 Nginx 的配置步骤详解

《Windows系统下Nginx的配置步骤详解》Nginx是一款功能强大的软件,在互联网领域有广泛应用,简单来说,它就像一个聪明的交通指挥员,能让网站运行得更高效、更稳定,:本文主要介绍W... 目录一、为什么要用 Nginx二、Windows 系统下 Nginx 的配置步骤1. 下载 Nginx2. 解压

如何确定哪些软件是Mac系统自带的? Mac系统内置应用查看技巧

《如何确定哪些软件是Mac系统自带的?Mac系统内置应用查看技巧》如何确定哪些软件是Mac系统自带的?mac系统中有很多自带的应用,想要看看哪些是系统自带,该怎么查看呢?下面我们就来看看Mac系统内... 在MAC电脑上,可以使用以下方法来确定哪些软件是系统自带的:1.应用程序文件夹打开应用程序文件夹

windows系统上如何进行maven安装和配置方式

《windows系统上如何进行maven安装和配置方式》:本文主要介绍windows系统上如何进行maven安装和配置方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不... 目录1. Maven 简介2. maven的下载与安装2.1 下载 Maven2.2 Maven安装2.

使用Python实现Windows系统垃圾清理

《使用Python实现Windows系统垃圾清理》Windows自带的磁盘清理工具功能有限,无法深度清理各类垃圾文件,所以本文为大家介绍了如何使用Python+PyQt5开发一个Windows系统垃圾... 目录一、开发背景与工具概述1.1 为什么需要专业清理工具1.2 工具设计理念二、工具核心功能解析2.

Linux系统之stress-ng测压工具的使用

《Linux系统之stress-ng测压工具的使用》:本文主要介绍Linux系统之stress-ng测压工具的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、理论1.stress工具简介与安装2.语法及参数3.具体安装二、实验1.运行8 cpu, 4 fo

ubuntu20.0.4系统中安装Anaconda的超详细图文教程

《ubuntu20.0.4系统中安装Anaconda的超详细图文教程》:本文主要介绍了在Ubuntu系统中如何下载和安装Anaconda,提供了两种方法,详细内容请阅读本文,希望能对你有所帮助... 本文介绍了在Ubuntu系统中如何下载和安装Anaconda。提供了两种方法,包括通过网页手动下载和使用wg

ubuntu系统使用官方操作命令升级Dify指南

《ubuntu系统使用官方操作命令升级Dify指南》Dify支持自动化执行、日志记录和结果管理,适用于数据处理、模型训练和部署等场景,今天我们就来看看ubuntu系统中使用官方操作命令升级Dify的方... Dify 是一个基于 docker 的工作流管理工具,旨在简化机器学习和数据科学领域的多步骤工作流。