【干货分享】米尔NXP i.MX 91开发板移植运行IGH EtherCAT主站

描述

本文介绍了如何将IGH EtherCAT主站移植到米尔NXP i.MX 91开发板上并运行。
https://bbs.elecfans.com/jishu_2499768_1_1.html

ethercat

米尔基于NXP i.MX91的核心板及开发板,搭载新一代入门级NXP i.MX91处理器,内核Cortex-A55,主频高达1.4 GHz ;支持 LPDDR4 增强可靠性和平台寿命,支持双千兆以太网和双 USB 端口等丰富外设。
 


一、项目介绍

前面我们介绍了怎么让开发板运行在高实时性的系统环境下,让它满足工业自动化、汽车电子应用要求;米尔NXP i.MX91开发板上面集成了2路RGMII千兆以太网接口,我们可以用它来运行工业以太网通信应用。
 


 

二、IGH EtherCAT移植
 

1. 拉取开源IGH EtherCAT仓库
 

  •  
  •  
  •  

git clone https://gitlab.com/etherlab.org/ethercat.git cd ethercat source ~/myd-lmx91-toolchain/environment-setup-armv8a-poky-linux

2. 配置用户空间程序
 

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

# 运行bootstrap脚本 ./bootstrap  # 配置用户空间程序 ./configure \     --host=aarch64-poky-linux \     --with-linux-dir=/home/hywing/workspace/myir-imx-linux \     --enable-8139too=no \     --enable-e100=no \     --enable-e1000=no \     --enable-e1000e=no \     --enable-igb=no \     --enable-usb=no \     --enable-generic=yes \     --enable-cycles=yes \     --enable-tool=yes \     --enable-script=yes \     --enable-rtdm=no \     --prefix=/usr/local

3. 编译驱动模块
 

  •  
  •  
  •  
  •  
  •  
  •  
  •  

# 编译主驱动模块:ec_generic.ko cd ../master make -C /home/hywing/workspace/myir-imx-linux M=$(pwd) modules
 # 编译通用驱动模块:ec_master.ko cd ../devices make -C /home/hywing/workspace/myir-imx-linux M=$(pwd) modules

4. 安装验证
 

  •  
  •  
  •  
  •  
  •  
  •  

ethercat libethercat.so libethercat.a ec_generic.ko ec_master.ko ethercat.conf


 

三、EtherCAT配置
 

1. 网卡配置 :/etc/ethercat.conf。

  •  
  •  
  •  
  •  
  •  

MASTER0_DEVICE="eth0" MASTER0_BACKUP_DEVICE="eth1" MASTER0_BACKUP="eth1" MASTER0_UPDATE_MS="1" MASTER0_VIRTUAL="no"

2. 装载驱动

  •  
  •  
  •  
  •  
  •  

# 加载主驱动模块 sudo modprobe ec_master  # 加载通用驱动模块 sudo modprobe ec_generic

3. 设置开发板为主站状态

  •  

./ethercat master

4. 获取ESC从站配置信息

ethercat

从站的配置信息跟上面是一致的,说明EtherCAT通信成功了

ethercat


 

四、测试

1. 命令行使能ESC从站LED亮灭。

  •  

while true; do ethercat cstruct 0x7010 0x00 0x00 0x00 0x02; sleep 0.5; ethercat cstruct 0x7010 0x00 0x00 0x00 0x00; sleep 0.5; done;

 

 

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分