使用硬件 MF13-00开发板,软件环境 Ubuntu 22.04LTS,Xenomai 3.2.1, Igh 1.6.0-rc1
一、开发板装通用Ubuntu系统
??????? 准备Ubuntu 22.04的U盘启动盘(可在网上搜索如何制作,简单),将启动盘插入,开发板上电,进入开机界面按F7,将启动项调整为U盘,回车。
??????? 随后进入Ubuntu引导安装界面,按照一般笔记本安装ubuntu流程即可,安装教程:安装ubuntu系统
二、安装实时补丁Xenomai
??????? Xenomai需要对内核打补丁,Ubuntu22.04的内核版本为5.15.0。传统的xenomai补丁需要添加对应版本的i-pipe层到内核中,但5.10版本之后就开始用到dovetail ,即官方自己做好的内核源码,选择对应版本 v5.15-dovetail2-rebase?? 下载链接
??????? 下载最新的xenomai源码,版本v3.2.1? 下载链接
????????安装工具
sudo apt update sudo apt-get install gcc git libncurses5-dev make flex bison libssl-dev libelf-dev automake dwarves sudo apt-get install fuse sudo apt install debhelper findutils autotools-dev autoconf libtool pkg-config libltdl-dev
??????? 解压并导入内核
将两个压缩包解压到同一目录下,后进入内核源码中,将xenomai导入待编译的内核中
cd /linux-dovetail-v5.10.76-dovetail3 sudo ../xenomai-v3.2.1/scripts/prepare-kernel.sh --arch=x86_64
??????? 配置内核
sudo make menuconfig
????????配置内核参数如下:
* General setup
? --> Local version - append to kernel release: (-xenomai)//此处用以区分内核版本
--> Timers subsystem
? ---> High Resolution Timer Support [*](默认)
?* Pocessor type and features
? --> Processor family
? ---> Core 2/newer Xeon
--> Multi-core scheduler support [](关闭)
* Xenomai/cobalt
? --> Sizes and static limits
? ---> Number of registry slots (512 --> 4096)
? ---> Size of system heap (Kb) (4096 --> 4096)
? ---> Size of private heap (Kb) (256 --> 256)
? ---> Size of shared heap (Kb) (256 --> 256)
? ---> Maximum number of POSIX timers per process (256 --> 512)
? --> Drivers
? ---> RTnet
? ---> RTnet, TCP/IP socket interface (Enable)
? ----> Drivers
? -----> New intel(R) PRO/1000 PCIe(Gigabit) [M](模块)
? -----> Realtek 8169(Gigabit) [M](模块)
? -----> Loopback [M](默认)
? ----> Add-Ons
? -----> Real-Time Capturing Support [M](模块)
* Power management and ACPI options
? --> CPU Frequency scaling
? ---> CPU Frequency scaling [](关闭)
? --> ACPI (Advanced Configuration and Power Interface) Support
? ---> Processor [](关闭)
? --> CPU Idle
? ---> CPU idle PM support [](关闭)
* Memory Management Options
? ---> Transparent Hugepage Support [](关闭)
? ---> Allow for memory compaction [](关闭)
? ---> Contiguous Memory Allocation [](关闭)
---> Page Migration [](关闭)
?* Device Drivers
--> Unisys visorbus driver [](关闭)
* Xenomai/cobalt
? --> Drivers
---> Real-time IPC drivers [*] (双击空格选定为*)(可选)
---> RTIPC protocol family <M>(默认)
---> XDDP cross-domain datagram protocol [*](默认)
---> IDDP intra-domain datagram protocol [*](默认)
---> Number of IDDP communication ports (32) (默认)
---> Buffer protocol [*](默认)
---> Number of BUFP communication ports (32) (默认)
??????? 编译内核映像
sudo scripts/config --disable SYSTEM_TRUSTED_KEYS
sudo scripts/config --disable SYSTEM_REVOCATION_KEYS
sudo scripts/config --disable CONFIG_DEBUG_INFO_BTF?
sudo make bzImage -j4??????? //-j* 进行多核编译加快进度(和处理器数量挂钩)
sudo make modules -j4
sudo make INSTALL_MOD_STRIP=1 modules_install -j4
??????? 安装
拷贝.config文件到/boot文件夹下,并重命名为尾缀同配置参数时相同。
sudo cp .config? /boot
sudo mv /boot/.config?? /boot/config-5.15.0-xenomai
拷贝bzImage到/boot文件夹下,并重命名。
sudo cp /arch/x86_64/boot/bzImage? /boot sudo mv /boot/bzImage?? /boot/vmlinuz-5.15.0-xenomai
拷贝System.map到/boot文件夹下,并重命名。
sudo cp System.map /boot sudo mv /boot/System.map /boot/System.map-5.15.0-xenomai
生成initrd文件
cd /lib/modules/5.15.0-xenomai sudo update-initramfs -c -k 5.15.0-xenomai
????????允许非root用户(由于xenomai实时任务是在linux软实时任务基础上创建的,而linux实时任务的创建需要权限,所以还需要配置用户组允许非root用户运行实时任务。创建用户组xenomai,并将当前非root用户与root用户加入用户组xenomai)
sudo addgroup xenomai --gid 1234 sudo addgroup root xenomai sudo usermod -a -G xenomai $USER
??????? 配置GRUB
sudo gedit? /etc/default/grub
# GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=10
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash xenomai.allowed_group=1234"
??????? 更新GRUB
sudo update-grub
??????? 重启电脑,确认版本号已更新
uname -a
??????? 安装Xenomai库
cd /xenomai-v3.2.1
sudo apt install automake libtool m4 autoconf?
sudo autoreconf -vif
sudo ./scripts/bootstrap sudo ./configure --with-pic --with-core=cobalt --enable-smp --disable-tls --enable-dlopen-libs --disable-clock-monotonic-raw sudo make -j4 sudo make install
??????? 更新环境变量
echo ' ### Xenomai export XENOMAI_ROOT_DIR=/usr/xenomai export XENOMAI_PATH=/usr/xenomai export PATH=$PATH:$XENOMAI_PATH/bin:$XENOMAI_PATH/sbin export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$XENOMAI_PATH/lib/pkgconfig export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$XENOMAI_PATH/lib export OROCOS_TARGET=xenomai ' >> ~/.xenomai_rc
echo 'source ~/.xenomai_rc' >> ~/.bashrc source ~/.bashrc
//追加权限
sudo chmod -R 777 /dev/rtdm/memdev-private sudo chmod -R 777 /dev/rtdm/memdev-shared
??????? 测试
sudo /usr/xenomai/bin/latency
??????? 修复负延迟
sudo -s echo 0>/proc/xenomai/latency sudo /usr/xenomai/bin/latency
//NUM值为“last_best”值*1000
echo NUM>/proc/xenomai/latency?
三、安装Igh
????????源码下载编译
??? git clone http://gitlab.com/etherlab.org/ethercat.git ??? ./bootstrap ??????? #--with-linux-dir是指定安装的linux内核目录 可以打开configure查看详细配置项
??????? #--prefix是指定编译输出文件夹 ??? ./configure? --enable-eoe=no --enable-8139too=no --enable-generic=yes --enable-rtmutex --enable-cycles=yes --enable-hrtimer --with-xenomai-dir=/usr/xenomai ? --prefix=/home/fc/test/pc/ethercat/output ??? make ??? make all modules ??? sudo make modules_install install ??? sudo depmod
??????? 创建链接安装
sudo ln -fs /home/fc/test/pc/ethercat/output/etc/init.d/ethercat /etc/init.d sudo mkdir /etc/sysconfig sudo ln -fs /home/fc/test/pc/ethercat/output/etc/sysconfig/ethercat /etc/sysconfig/ sudo ln -fs /home/fc/test/pc/ethercat/output/bin/ethercat /bin/ sudo -i echo KERNEL==\"EtherCAT[0-9]*\", MODE=\"0664\" > /etc/udev/rules.d/99-EtherCAT.rules
??????? 网络配置
ifconfig #查询有线网卡的MAC地址
sudo gedit /etc/sysconfig/ethercat
在其中添加MASTER0_DEVICE=”网卡地址“
DEVICE_MODULES=”generic”
???启动测试
sudo /etc/init.d/ethercat start|stop|restart
显示...done 成功
参考链接:
https://blog.csdn.net/qq_28882933/article/details/123626659
https://blog.csdn.net/rushlalala/article/details/123371687?spm=1001.2014.3001.5502
|