下载代码 在Ubuntu上执行
1 git clone git@github.com:Ethereal-O/OHPLC_ARKTS.git -b control_plane control_plane
在Windows上执行
1 2 git clone git@github.com:Ethereal-O/OHPLC_ARKTS.git -b go go git clone git@github.com:Ethereal-O/OHPLC_ARKTS.git -b frontends frontends
编译EtherCAT 在Ubuntu上执行。进入control-plane目录beremiz_optimize下的EthercatMasterX目录
下载必要环境
1 2 3 4 5 6 sudo apt install automake libtool net-tools gcc-aarch64-linux-gnu g++-aarch64-linux-gnu make pkg-config sudo rm -rf ethercat git clone https://gitlab.com/etherlab.org/ethercat.git cd ethercat git checkout stable-1.5 ./bootstrap
交叉编译
1 2 3 ./configure --enable-cycles --enable-hrtimer --enable-8139too=no --disable-eoe CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ --host=aarch64-linux make clean make all modules
复制并打包EthercatMasterX/ethercat/lib/.libs下的所有文件
1 tar cvf Ethercat.tar -C ./beremiz_optimize/EthercatMasterX/ethercat/lib/.libs .
编译Soem 在Ubuntu上执行。进入control-plane目录beremiz_optimize下的SoemX目录
原理。其先导入setup.sh中的环境变量,以决定其是否进行交叉编译。因此,要修改setup.sh,使其可以找到我们的编译器。EtherCAT主站SOEM在TI AM335x上的移植
1 2 3 4 5 6 7 8 9 10 11 12 diff Soem/setup.sh SoemX/setup.sh 28a29,31 > bq3568hm) > export CROSS_GCC=aarch64-linux-gnu > ;; 54c57,58 < export GCC_PATH=${COMPILERS:-/opt/rt-tools/compilers}/$CROSS_GCC --- > > export GCC_PATH=${COMPILERS:-/usr} 61d64 <
1 2 3 4 5 6 7 8 9 10 11 diff Soem/make/app.mk SoemX/make/app.mk 26c26,27 < ifeq ($(ARCH),linux) --- > > ifeq ($(BSP),linux) 37c38,39 < $(SILENT)$(CC) $(LDFLAGS) $(LD_PATHS) $(OBJDIR)/*.o -o $@ $(LIBS) --- > > $(SILENT)$(CC) $(LD_PATHS) $(OBJDIR)/*.o -o $@ $(LIBS)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 cat SoemX/make/compilers/aarch64-linux-gnu-gcc.mk # Prefix of the cross-compiler CROSS_GCC := aarch64-linux-gnu # Common settings include $(PRJ_ROOT)/make/compilers/gcc.mk # Machine settings -include $(PRJ_ROOT)/make/compilers/$(ARCH).mk # Default machine settings MACHINE ?= -mthumb-interwork -mlittle-endian -mthumb # # CFLAGS += $(MACHINE) -fshort-wchar # LDFLAGS += $(MACHINE) -Wl,--no-wchar-size-warning
交叉编译
1 2 source ./setup.sh bq3568hm linux make all
打包/lib/bq3568hm下文件
1 tar cvf Soem.tar -C ./beremiz_optimize/SoemX/lib/bq3568hm .
编译Modbus 在Ubuntu上执行。进入control-plane目录beremiz_optimize下的ModbusX目录。 修改MakeFile中的CC,改为aarch64-linux-gnu-gcc。直接make。
编译PLC 在Ubuntu上执行。进入control-plane目录beremiz_optimize下的PLC/projects/RACK1_SoemX/build目录
修改makefile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 diff ./RACK1_Soem/build/Makefile ./RACK1_SoemX/build/Makefile 3,4c3,4 < CC := gcc < # CC := aarch64-linux-gnu-gcc --- > > CC := aarch64-linux-gnu-gcc 9,15c9,15 < ethercat_master_include := $(beremizDir)/EthercatMaster/ethercat/include < soem_include := ${beremizDir}/Soem/soem < nicdrv_include := ${beremizDir}/Soem/oshw/linux < modbus_include := ${beremizDir}/Modbus < ethercat_master_lib := $(beremizDir)/EthercatMaster/ethercat/lib/.libs < soem_lib := ${beremizDir}/Soem/lib/linux < modbus_lib := $(beremizDir)/Modbus --- > ethercat_master_include := $(beremizDir)/EthercatMasterX/ethercat/include > soem_include := ${beremizDir} /SoemX/soem > nicdrv_include := ${beremizDir} /SoemX/oshw/linux > modbus_include := ${beremizDir} /ModbusX > ethercat_master_lib := $(beremizDir)/EthercatMasterX/ethercat/lib/.libs > soem_lib := ${beremizDir} /SoemX/lib/bq3568hm > modbus_lib := $(beremizDir)/ModbusX
交叉编译
打包glibc 在Ubuntu上执行
1 tar cvf libc.tar -C /usr/aarch64-linux-gnu/lib .
此时得到四个文件,分别为Ethercat.tar,Soem.tar,libc.tar和RACK1_Soem。
关闭SELinux 在Windows上执行
查看状态
1 2 3 .\hdc.exe list targets .\hdc.exe shell mount -o rw,remount / .\hdc.exe shell cat /etc/selinux/config
永久关闭
1 2 3 .\hdc.exe list targets .\hdc.exe shell mount -o rw,remount / .\hdc.exe shell sed -i s
安装包 在Windows上执行 将上述三个压缩包发送至设备,解压,复制到/usr/lib下
1 2 3 4 5 6 7 8 9 .\hdc.exe list targets .\hdc.exe shell mount -o rw,remount / .\hdc.exe shell mkdir -p /data /data /beremiz/dependency/lib .\hdc.exe file send .\Ethercat.tar /data /data /beremiz/dependency/lib/Ethercat.tar .\hdc.exe file send .\Soem.tar /data /data /beremiz/dependency/lib/Soem.tar .\hdc.exe file send .\libc.tar /data /data /beremiz/dependency/lib/libc.tar .\hdc.exe file send .\RACK1_Soem /data /data /beremiz/RACK1_Soem .\hdc.exe shell chmod 777 /data /data /beremiz/RACK1_Soem .\hdc.exe shell
1 2 3 4 5 6 7 8 cd /data/data/beremiz/dependency/lib mkdir Ethercat && mkdir Soem && mkdir libc tar xvf Ethercat.tar -C Ethercat tar xvf Soem.tar -C Soem tar xvf libc.tar -C libc cp ./Ethercat/*so* /lib/ -d cp ./Soem/*so* /lib/ -d cp ./libc/*so* /lib/ -d
安装管理程序 在Windows上执行,进入go目录。
1 2 3 4 5 6 7 8 9 10 11 go env -w CGO_ENABLED=0 go env -w GOARCH=arm64 go env -w GOOS=linux go build -o supershell .\supershell.go .\hdc.exe shell mount -o remount,rw / .\hdc.exe shell mkdir -p /data /data /supershell .\hdc.exe file send .\supershell /system/bin/supershell .\hdc.exe file send .\cfg\supershell.cfg /system/etc/init/supershell.cfg .\hdc.exe file send .\cfg\background.sh /data /data /supershell/background.sh .\hdc.exe shell chmod 777 /system/bin/supershell .\hdc.exe shell reboot
清除设置的go env,直接将文件C:\Users\Ethereal\AppData\Roaming\go\env
清空。
编译前端 在Windows上打开deveco,编译执行前端。
(已经不需要)注意api版本编译10,兼容9。
其他常用命令 1 2 3 4 5 6 7 .\hdc.exe shell power-shell wakeup .\hdc.exe shell power-shell setmode 602 .\hdc.exe shell power-shell suspend .\hdc.exe shell mount -o remount,rw / .\hdc.exe shell dmesg .\hdc.exe shell ps -A .\hdc.exe shell netstat
参考 实验室EtherCAT文档
EtherCAT主站SOEM在TI AM335x上的移植
查看SELinux状态及关闭SELinux