首页 > 编程知识 正文

ubuntu20.04更换国内源,ethercat主站与从站

时间:2023-05-04 22:17:33 阅读:148362 作者:3793

在i9 9900k主机上编译的linux内核、xenomai和ethercat igh。 生成的文件如下。

然后,在i5 6600主机上安装编译的内核,并生成和测试ethercat主控器。

这是我编译的上述四个文件。

见文章https://RTT-lwr.readthedocs.io/en/latest/rtpc/xenomai3. html

3359 RTT-lwr.readthedocs.io/en/latest/rtpc/xenomai.html

33559 www.bilibili.com/video/b v1 WG4y1 z7c 2? t=1399

材料linux内核:4.9. 38https://mirrors.edge.kernel.org/pub/Linux/kernel /

xenomai 3.1https://xenomai.org/downloads/xenomai/stable /

ipipe-core-4.9.38-x86-4.patch https://xenomai.org/downloads/ipipe/v3.x/x86 /

Ubuntu http://old-releases.Ubuntu.com/releases /

ethercatigh https://github.com/ribalda/ether cat

某些安装软件包sudo apt-getinstallbuild-essentiallibncurses5- devbisonflexlibssl-devsudoapt-get install kernel-package 以下为$ sudo apt-getinstallbuild-essential git-corelib ncurses5- dev libssl-dev $ sudo apt-getinstallflexbisontexinfozip ERF libsdl-devlibesd0- devlibwxgtk 2.6-dev $ sudo apt-getinstalluboot-mkimage $ sudo apt-get Ubuntu右击终端sudo apt-get t/etc/apt/sources.list///将删除源内容替换为deb http://mirrors.alilirors.precisemainrestricteduniversemultiversedeb 3http://mm precise-securitymainrestricteduniversemultiversedeb http://mirrors.a liyun.com/Ubuntu/precise-updatesmainrestricteduniversemultiversedeb http://mirrors.a liyun.com/Ubuntu/precise-proposedmainrestricteduniversemultiversedeb http://mirrors.a liyun.com/Ubuntu/precise-backportsmainrestricteduniversemultiversede B- src http://mirrors.a liyun.com/Ubuntu/precisemainrestricteduniversemultiversedeb-src http://mirrors.a liyun.com/Ubuntu/precise-securitymainrestricteduniversemultiversedeb-src http://mirrors.a liyun.com/Ubuntu/precise-updatesmainrestricteduniversemultiversedeb-src http://mirrors.a liyun.com/Ubuntu/precise-proposedmainrestricteduniversemultiversedeb-src http://mirrors.a liyun.com/Ubuntu/precise-backportsmainrestestsmaiveststemaivestemarivestivedercterctestorcted/scripts/prepare-kernel.sh-Linux=//Linux-4.9.38--ipipe=/home/VM user/workspace/xenomai-v 3.1

> Processor type and features[ ] Linux guest support ---- [ ] Multi-core scheduler support> Power management and ACPI options[ ] Suspend to RAM and standby [ ] Hibernation (aka 'suspend to disk') > Power management and ACPI options > CPU Frequency scaling[ ] CPU Frequency scaling> Power management and ACPI options > ACPI (Advanced Configuration and Power Interface) Support< > Processor > Power management and ACPI options > CPU Idle [ ] CPU idle PM support > Processor type and features[ ] Transparent Hugepage Support[ ] Contiguous Memory Allocator[ ] Allow for memory compaction[ ] Page migration> Xenomai/cobalt > Sizes and static limits (4096) Number of registry slots (4096) Size of system heap (Kb) (256) Size of private heap (Kb) (256) Size of shared heap (Kb) (512) Maximum number of POSIX timers per process > General setup (-xenomai-3.0.5) Local version - append to kernel release> General setup > Timers subsystem[*] High Resolution Timer Support> Xenomai/cobalt > Drivers > RTnet<M> RTnet, TCP/IP socket interface> Xenomai/cobalt > Drivers > RTnet > Drivers 第三步 编译、安装内核

在i9 9900k上编译内核,生成linux-headers-xxx.deb和linux-image-xxx.deb安装包。

sudo apt install kernel-package//CONCURRENCY_LEVEL=$(nproc) make-kpkg --rootcmd fakeroot --initrd kernel_image kernel_headerssudo CONCURRENCY_LEVEL=$(nproc) make-kpkg --initrd kernel_image kernel_headers

在i5 6600上安装内核、并进行测试。

//安装内核sudo dpkg -i linux-headers-4.1.18-xenomai-3.0.5_4.1.18-xenomai-3.0.5-10.00.Custom_amd64.deb sudo dpkg -i linux-image-4.1.18-xenomai-3.0.5_4.1.18-xenomai-3.0.5-10.00.Custom_amd64.debsudo gedit /etc/default/grubGRUB_CMDLINE_LINUX_DEFAULT="text"#GRUB_HIDDEN_TIMEOUT=0#GRUB_HIDDEN_TIMEOUT_QUIET=truesudo update-grub 卸载安装好的内核dpkg --get-selections|grep linux apt-get remove linux-image-xxxapt-get remove linux-headers-xxx 第四步 编译xenomai 可以在ubuntu系统查看xenomai信息uname -a# Should return Linux waro-rt 4.9.38-xenomai-3.0.5 #2 SMP Wed Sep 20 16:00:12 CEST 2017 x86_64 x86_64 x86_64 GNU/Linuxdmesg | grep Xenomai# [ 1.417024] [Xenomai] scheduling class idle registered.# [ 1.417025] [Xenomai] scheduling class rt registered.# [ 1.417045] [Xenomai] disabling automatic C1E state promotion on Intel processor# [ 1.417055] [Xenomai] SMI-enabled chipset found, but SMI workaround disabled# [ 1.417088] I-pipe: head domain Xenomai registered.# [ 1.417704] [Xenomai] allowing access to group 1234# [ 1.417726] [Xenomai] Cobalt v3.0.5 (Sisyphus's Boulder) [DEBUG]**********************************************cd xenomai-3.1./script/bootstrap //如果没有configure文件则执行此语句./configure --with-core=cobalt --enable-smp --enable-pshared 我执行了这一条./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs --disable-clock-monotonic-rawmake sudo make install //默认安装在/usr/xenomai

xenomai目录包含如下文件

第五步 编译igh ./bootstrap //如果没有configure文件则执行此语句./configure --with-linux-dir=/home/vmuser/workspace/linux-4.9.38 --enable-generic=yes --enable-8139too=yes --enable-e1000=yes --enable-e1000e=yes --enable-r8169=yes --enable-rtdm=yes --enable-cycles=yes --enable-hrtimer=yes --with-xenomai-dir=/usr/xenomai**********************************************igh把编译生成的文件默认安装在了/opt/etherlab目录。通过设置--prefix=/home/vmuser/ethercat-master/output可以把编译生成的文件安装在/home/vmuser/ethercat-master/output目录中。**********************************************makemake modulesmake installsudo make modules_install

我在编译igh的8169网卡驱动(4.9版本)时有报错。
打开ethercat/devices/r8169-4.9-ethercat.c,把339行删掉。
如果用其它版本的驱动,没有报错,就不用删了。


编译完成后,生成如下文件


我将这两部分文件copy到了自建的igh文件夹中。

第六步 将xenomai.tar.gz和igh.tar.gz复制到其他主机

我将编译生成的文件打包成xenomai.tar.gz和igh.tar.gz,然后copy到i5 6600主机进行测试。
我将生成的xenomai.tar.gz文件进行解压,并copy到usr目录。

利用gydgz目录下的latency 工具进行测试

实时效果并不理想,后续再改吧
将igh.tar.gz文件进行解压,并copy到/opt/etherlab目录。

将igh编译生成的驱动文件放到如下位置

接着输入depmod命令。

第七步 ethercat主站配置

这一步参考了igh官方文档的P82页(Installing the Software),文章截图如下:

将/opt/etherlab/etc目录下的sysconfig文件夹copy到/etc目录中,然后修改ethercat文件。



这里主要是对MASTER0_DEVICE="“和DEVICE_MODULES=”"进行了修改。
ln -s /opt/etherlab/etc/init.d/ethercat /etc/init.d 建立软连接
注意ethercat文件中的这部分是否正确

第八步 测试主站

开启主站

# /etc/init.d/ethercat start

重启主站


可以看到主站正常运行,能够扫描到从站的信息。

----------------------------------------------------------------------------------------------

ubuntu14.04解决菜单栏和工具栏消失的方案:

进入图形界面sudo startx重设compiz设置(这一步可以不要)dconf reset -f /org/compiz/重置compiz后,重启Unity:setsid unity(这一步必须要)

添加环境变量

sudo gedit /etc/profile export PATH=$PATH:/usr/xenomai/includesource /etc/profile

cannot open shared object file 问题的解决

# gedit /etc/ld.so.conf添加lib目录include /etc/ld.so.conf.d/*.conf/usr/xenomai/lib/usr/etherlab/lib修改完ld.so.conf之后必须执行/sgydgz/ldconfig -v同步动态库

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。