TI5728的igh ethercat master 移植

目前采用的是JN-5728mini开发版。
JN-mini5728_rt_3.3.zip拷贝到本地解压

准备工作:

0.开发环境搭建

参考《Ubuntu开发环境搭建 V1.1.pdf》,《JN-mini5728 软件使用手册 V2.0.pdf》

1.下载ethercat1.5.2

下载ethercat ,找到文件夹对应的ethercat-1.5.2这个版本是针对内核4.0+修改过源码的,如果下载的是官方版本,则参考

https://blog.csdn.net/x356982611/article/details/74584644

做对应修改

#dev->netdev = alloc_netdev(sizeof(ec_eoe_t *), name,NET_NAME_UNKNOWN, ether_setup)
#ret = sock_create_kern(&init_net,PF_PACKET, SOCK_RAW, htons(ETH_P_ETHERCAT),

2.准备目标TI板运行的内核源码,编译通过。

参考《JN-mini5728 软件使用手册 V2.0.pdf》,编译linux4.4内核以及u-boot文件

3.安装或者解压目标TI板相应的交叉编译工具。

参考《JN-mini5728 软件使用手册 V2.0.pdf》,安装SDK 这里用的是3.3版本的

4.主机交叉编译igh

/**************Ubuntu平台下*************/
/*0.更新环境*/
#soucre ~/ti-processor-sdk-linux-rt-am57xx-evm-03.03.00.04/linux-devkit/environment-setup

/*1.解压IGH源码进入目录*/
#tar xjf ethercat-1.5.2.tar.bz2
#cd ethercat-1.5.2/
#mkdir etherlab

/*********以下都是在ethercat-1.5.2/目录进行操作**********/
/*2.配置源码,具体参数对照ethercat-1.5.2.pdf第88页Table 9.1: Configuration options */(注意:等号后面不能有空格)
#./configure --prefix=/home/xxx/Downloads/ethercat-1.5.2/etherlab --with-linux-dir=/home/xxx/ti-processor-sdk-linux-rt-am57xx-evm-03.03.00.04/board-support/linux-rt-4.4.41+gitAUTOINC+968d071ce9-g968d071ce9 --enable-8139too=no --enable-generic=yes CC=arm-linux-gnueabihf-gcc --host=arm-linux-gnueabihf

make中如果出现error: ethercat uses VFP register arguments, ../master/soe_errors.o does not
则touch /master/soe_errors.c

/*3.编译源码*/
#make -j4

/*4.指定交叉编译工具,编译modules*/
#make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
//编译通过会对应生成ethercat-1.5.2/devices/ec_generic.ko和ethercat-1.5.2/master/ec_master.ko

/*5.安装*/
#make install
//make install 会在当前目录下生成 etherlab 文件夹,里面有编译生成的各种用户空间的文件

/*6.在etherlab目录下创建modules文件夹,并复制ec_generic.ko和ec_master.ko到modules下*/
#mkdir -p etherlab/modules
#cp devices/ec_generic.ko etherlab/modules/
#cp master/ec_master.ko etherlab/modules/

/*7.将etherlab文件夹打包*/
#tar -cjf etherlab.tar.bz2 etherlab/

5.烧录SD卡

参考《JN-mini5728 软件使用手册 V2.0.pdf》,把编译好的etherlab文件夹子,放到JN-mini5728_programming_rt_3.3/fs_patch/opt文件夹下,然后烧录。
成功后把sd卡插到板子上。
启动。

6.目标机配置

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

/*1..复制ec_master.ko到/lib/modules/内核版本号/*/
#ln -fs /opt/etherlab/etc/init.d/ethercat /etc/init.d/
#ln -fs /opt/etherlab/bin/ethercat /usr/local/bin/
#mkdir /etc/sysconfig
#ln -fs /opt/etherlab/etc/sysconfig/ethercat /etc/sysconfig/
#echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules
#cp /opt/etherlab/modules/ec_master.ko /lib/modules/4.4-your-kernel-name 
//这里的内核版本是4.4可以通过uname -r 查看
#depmod

/*2.获取板子MAC地址*/
#ifconfig

/*3.配置rules,创建设备号*/
#vi /etc/sysconfig/ethercat
MASTER0_DEVICE=”A0:F6:FD:C2:A2:1A”
DEVICE_MODULES=”generic”

/*4.安装通用网卡驱动*/
#insmod /opt/etherlab/modules/ec_generic.ko

7.目标机运行

/**************至此板子上的配置结束,下面是启动EtherCAT ***************/
通过网线直连ethercat主从站,从站启动完成后,打开主站电源

/*1.启动ethercat*/
#/etc/init.d/ethercat start

/*2.查看*/
#ethercat master
#ethercat slave

/到此移植过程结束***/

你可能感兴趣的:(Ethercat,linux,ubuntu,内核,ethercat)