From 0124754fea9285d3996124820c468fc2c2031901 Mon Sep 17 00:00:00 2001 From: yangzhenghan Date: Fri, 19 Jan 2024 09:13:34 +0800 Subject: [PATCH] =?UTF-8?q?:typo:=20loongarch64=20=E2=86=92=20la64?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/notes/cross-compiling-acai.md | 8 +- content/posts/build-epics-module-modbus.md | 8 +- ...74\226\350\257\221EPICS\345\222\214IOC.md" | 57 ++++----- ...0\257\221\350\277\220\350\241\214EPICS.md" | 117 ++++++++++++------ 4 files changed, 118 insertions(+), 72 deletions(-) diff --git a/content/notes/cross-compiling-acai.md b/content/notes/cross-compiling-acai.md index d6b4507..bc9c072 100644 --- a/content/notes/cross-compiling-acai.md +++ b/content/notes/cross-compiling-acai.md @@ -24,10 +24,10 @@ EPICS Qt依赖ACAI提供的Channel Access接口。 *这里依旧以龙芯架构为例。* -EPICS base 编译完成后,可以看到`bin`目录下有`linux-loongarch64`、`linux-x86_64`两个目录,`linux-x86_64`目录下比`linux-loongarch64`目录多出了许多`perl`脚本,我们需要把这些脚本复制到龙架构的目录下,下面编译需要用到。 +EPICS base 编译完成后,可以看到`bin`目录下有`linux-la64`、`linux-x86_64`两个目录,`linux-x86_64`目录下比`linux-la64`目录多出了许多`perl`脚本,我们需要把这些脚本复制到龙架构的目录下,下面编译需要用到。 ``` shell -$ cp ./bin/linux-x86_64/*.pl ./bin/linux-loongarch64/ +$ cp ./bin/linux-x86_64/*.pl ./bin/linux-la64/ ``` ## 编译 @@ -41,7 +41,7 @@ cd acai vi configure/RELEASE.local # 修改交叉编译的目标架构,和EPICS base中保持一致 -EPICS_HOST_ARCH=linux-loongarch64 +EPICS_HOST_ARCH=linux-la64 # 修改EPICS_BASE路径,例: EPICS_BASE=/home/ubuntu/loongson/base-7.0.8 @@ -49,4 +49,4 @@ make LD=loongarch64-linux-gnu-ld CC=loongarch64-linux-gnu-gcc CCC=loongarch64-li # 等待编译完成 ``` -编译完成后可以在`lib/linux-loongarch64/`目录下找到`libacai.so`。 +编译完成后可以在`lib/linux-la64/`目录下找到`libacai.so`。 diff --git a/content/posts/build-epics-module-modbus.md b/content/posts/build-epics-module-modbus.md index a01aa24..b01bcc1 100644 --- a/content/posts/build-epics-module-modbus.md +++ b/content/posts/build-epics-module-modbus.md @@ -78,7 +78,7 @@ touch configure/RELEASE.local vi configure/RELEASE.local # 修改成和EPICS Base一样的架构 -EPICS_HOST_ARCH=linux-loongarch64 +EPICS_HOST_ARCH=linux-la64 # EPICS Base路径(示例) EPICS_BASE=/home/ubuntu/loongson/base-7.0.8 # 放置EPICS模块的路径(示例) @@ -98,7 +98,7 @@ touch configure/RELEASE.local vi configure/RELEASE.local # 修改成和EPICS Base一样的架构 -EPICS_HOST_ARCH=linux-loongarch64 +EPICS_HOST_ARCH=linux-la64 # EPICS Base路径(示例) EPICS_BASE=/home/ubuntu/loongson/base-7.0.8 # 放置EPICS模块的路径(示例) @@ -120,7 +120,7 @@ touch configure/RELEASE.local vi configure/RELEASE.local # 修改成和EPICS Base一样的架构 -EPICS_HOST_ARCH=linux-loongarch64 +EPICS_HOST_ARCH=linux-la64 # EPICS Base路径(示例) EPICS_BASE=/home/ubuntu/loongson/base-7.0.8 # 放置EPICS模块的路径(示例) @@ -144,7 +144,7 @@ touch configure/RELEASE.local vi configure/RELEASE.local # 修改成和EPICS Base一样的架构 -EPICS_HOST_ARCH=linux-loongarch64 +EPICS_HOST_ARCH=linux-la64 # EPICS Base路径(示例) EPICS_BASE=/home/ubuntu/loongson/base-7.0.8 # 放置EPICS模块的路径(示例) diff --git "a/content/posts/\344\272\244\345\217\211\347\274\226\350\257\221EPICS\345\222\214IOC.md" "b/content/posts/\344\272\244\345\217\211\347\274\226\350\257\221EPICS\345\222\214IOC.md" index cc33261..ab416ab 100644 --- "a/content/posts/\344\272\244\345\217\211\347\274\226\350\257\221EPICS\345\222\214IOC.md" +++ "b/content/posts/\344\272\244\345\217\211\347\274\226\350\257\221EPICS\345\222\214IOC.md" @@ -1,6 +1,7 @@ --- title: "交叉编译EPICS和IOC" date: 2023-12-12T16:26:35+08:00 +lastmod: 2024-01-18T17:40:26+08:00 draft: false description: Linux交叉编译EPICS tags: ["linux", "EPICS", "龙芯"] @@ -28,13 +29,13 @@ categories: ["EPICS"] 在[龙芯3A5000(loongarch64)上编译运行EPICS](../龙芯3a5000loongarch64上编译运行epics/)中我已经详细讲解了如何在龙架构上编译EPICS,这次,需要在原来对源码修改的基础上,再增加对交叉编译的支持。 -添加`configure/os/CONFIG.linux-x86_64.linux-loongarch64` +添加`configure/os/CONFIG.linux-x86_64.linux-la64` ``` shell -# CONFIG.linux-x86_64.linux-loongarch64 +# CONFIG.linux-x86_64.linux-la64 # # Definitions for linux-x86_64 host - linux-loongarch64 target builds -# Sites may override these in CONFIG_SITE.linux-x86_64.linux-loongarch64 +# Sites may override these in CONFIG_SITE.linux-x86_64.linux-la64 #------------------------------------------------------- VALID_BUILDS = Ioc Command @@ -60,10 +61,10 @@ STATIC_LDLIBS_YES= -Wl,-Bdynamic STATIC_LDLIBS_NO= ``` -添加`configure/os/CONFIG_SITE.linux-x86_64.linux-loongarch64` +添加`configure/os/CONFIG_SITE.linux-x86_64.linux-la64` ``` shell -# CONFIG_SITE.linux-x86_64.linux-loongarch64 +# CONFIG_SITE.linux-x86_64.linux-la64 # # Site specific definitions for linux-x86_64 host - linux-loongarch64 target builds #------------------------------------------------------- @@ -73,7 +74,7 @@ GNU_TARGET = loongarch64-linux-gnu # Set GNU tools install path # Examples is the installation at the APS: -GNU_DIR = /opt/toolchain-loongarch64-linux-gnu-gcc8-host-x86_64-2022-07-18 +GNU_DIR = /opt/loongson-gnu-toolchain-8.3-x86_64-loongarch64-linux-gnu-rc1.2 # If cross-building shared libraries and the paths on the target machine are # different than on the build host, you should uncomment the lines below to @@ -85,13 +86,13 @@ GNU_DIR = /opt/toolchain-loongarch64-linux-gnu-gcc8-host-x86_64-2022-07-18 #PRODDIR_RPATH_LDFLAGS_YES_NO = # However it is usually simpler to set STATIC_BUILD=YES here and not # try to use shared libraries at all when cross-building, like this: -STATIC_BUILD=YES -SHARED_LIBRARIES=NO +#STATIC_BUILD=YES +#SHARED_LIBRARIES=NO # To use libreadline, point this to its install prefix #READLINE_DIR = $(GNU_DIR) -#READLINE_DIR = /tools/cross/linux-x86.linux-arm/readline -# See CONFIG_SITE.Common.linux-arm for other COMMANDLINE_LIBRARY values +#READLINE_DIR = /tools/cross/linux-x86.linux-la64/readline +# See CONFIG_SITE.Common.linux-la64 for other COMMANDLINE_LIBRARY values #COMMANDLINE_LIBRARY = READLINE ``` @@ -108,20 +109,20 @@ SHARED_LIBRARIES=NO 新增`configure/CONFIG_SITE.local`,或者直接修改`configure/CONFIG_SITE`(不推荐)。 ``` shell -CROSS_COMPILER_TARGET_ARCHS=linux-loongarch64 +CROSS_COMPILER_TARGET_ARCHS=linux-la64 ``` 最后,进行编译即可。(确保构建系统上有make和perl,应该都有吧。) ``` shell # 到源码目录下 -$ cd ~/loongson/base-7.0.7 +$ cd ~/loongson/base-7.0.8 $ make -j8 ``` 等待编译完成即可。 -编译完成后,可以看到`bin`和`lib`目录下,都有`linux-loongarch64`、`linux-x86_64`两个目录,其中`linux-loongarch64`目录下就是我们要在开发板上运行的EPICS工具包了。`linux-x86_64`目录下的则是编译生成的本机的EPICS工具包,待会儿我们还会用到。 +编译完成后,可以看到`bin`和`lib`目录下,都有`linux-la64`、`linux-x86_64`两个目录,其中`linux-la64`目录下就是我们要在开发板上运行的EPICS工具包了。`linux-x86_64`目录下的则是编译生成的本机的EPICS工具包,待会儿我们还会用到。 由于开发板的存储空间很小,只有几百兆,所以,我们只能单独将龙架构的内容下载到板子上。 @@ -130,19 +131,19 @@ $ make -j8 ``` base ├─ bin -│ └─ linux-loongarch64 +│ └─ linux-la64 ├─ db ├─ dbd ├─ include (可选) └─ lib - └─ linux-loongarch64 + └─ linux-la64 ``` 将目录中的内容全部打包下载到开发板即可。 ``` shell # 在开发板上运行 -$ cd base/bin/linux-loongarch64 +$ cd base/bin/linux-la64 # 运行软IOC测试 $ ./softIoc epics> @@ -153,7 +154,7 @@ epics> 如下(根据实际情况修改路径): ``` shell -$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/base/lib/linux-loongarch64 +$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/base/lib/linux-la64 ``` > ※ include 目录不是EPICS运行必需的,但如果要基于EPICS进行开发,可能需要用到EPICS的头文件。 @@ -170,13 +171,13 @@ $ cd ~ $ mkdir test $ cd test/ # 替换成自己编译EPICS的目录,注意是使用linux-x86_64目录下的脚本 -$ ~/loongson/base-7.0.7/bin/linux-x86_64/makeBaseApp.pl -t example test -$ ~/loongson/base-7.0.7/bin/linux-x86_64/makeBaseApp.pl -i -t example test +$ ~/loongson/base-7.0.8/bin/linux-x86_64/makeBaseApp.pl -t example test +$ ~/loongson/base-7.0.8/bin/linux-x86_64/makeBaseApp.pl -i -t example test The following target architectures are available in base: - linux-loongarch64 + linux-la64 linux-x86_64 -What architecture do you want to use? linux-loongarch64 +What architecture do you want to use? linux-la64 The following applications are available: test What application should the IOC(s) boot? @@ -184,7 +185,7 @@ The default uses the IOC's name, even if not listed above. Application name? test ``` -**这里唯一多的步骤就是选择目标架构,输入`linux-loongarch64`即可。** +**这里唯一多的步骤就是选择目标架构,输入`linux-la64`即可。** 然后修改编译设置,这里就不用生成动态库了,直接使用静态编译。 @@ -218,7 +219,7 @@ $ make ``` test ├─ bin -│ └─ linux-loongarch64 +│ └─ linux-la64 ├─ db ├─ dbd └─ iocBoot @@ -233,7 +234,7 @@ test epicsEnvSet("IOC","ioctest") epicsEnvSet("TOP","/root/test") epicsEnvSet("EPICS_BASE","/root/base") -epicsEnvSet("EPICS_HOST_ARCH","linux-loongarch64") +epicsEnvSet("EPICS_HOST_ARCH","linux-la64") ``` 最后在开发板上运行IOC。 @@ -245,12 +246,12 @@ $ cd ~/test/iocBoot/ioctest $ chmod +x st.cmd $ ./st.cmd -#!../../bin/linux-loongarch64/test +#!../../bin/linux-la64/test < envPaths epicsEnvSet("IOC","ioctest") epicsEnvSet("TOP","/root/test") epicsEnvSet("EPICS_BASE","/root/base") -epicsEnvSet("EPICS_HOST_ARCH","linux-loongarch64") +epicsEnvSet("EPICS_HOST_ARCH","linux-la64") cd "/root/test" ## Register all support components dbLoadDatabase "dbd/test.dbd" @@ -265,8 +266,8 @@ cd "/root/test/iocBoot/ioctest" iocInit Starting iocInit ############################################################################ -## EPICS R7.0.7 -## Rev. 2023-12-12T14:06+0800 +## EPICS R7.0.8 +## Rev. 2023-12-30T14:06+0800 ## Rev. Date build date/time: ############################################################################ iocRun: All initialization complete diff --git "a/content/posts/\351\276\231\350\212\2573A5000(loongarch64)\344\270\212\347\274\226\350\257\221\350\277\220\350\241\214EPICS.md" "b/content/posts/\351\276\231\350\212\2573A5000(loongarch64)\344\270\212\347\274\226\350\257\221\350\277\220\350\241\214EPICS.md" index 64f6add..8d37657 100644 --- "a/content/posts/\351\276\231\350\212\2573A5000(loongarch64)\344\270\212\347\274\226\350\257\221\350\277\220\350\241\214EPICS.md" +++ "b/content/posts/\351\276\231\350\212\2573A5000(loongarch64)\344\270\212\347\274\226\350\257\221\350\277\220\350\241\214EPICS.md" @@ -1,6 +1,7 @@ --- title: "龙芯3A5000(loongarch64)上编译运行EPICS" date: 2023-02-01T15:51:40+08:00 +lastmod: 2024-01-18T17:40:26+08:00 draft: false description: 在龙芯3A5000(loongarch64)上编译运行EPICS tags: ["linux", "EPICS", "龙芯"] @@ -67,12 +68,12 @@ $ vi ./src/tools/EpicsHostArch.pl 既然识别不了`loongarch64`,那我们就手动添加一行,让它可以识别就行了,即使看不太懂上面的脚本也没关系,看个半懂就行了。 -![Architecture](https://cdn.jsdelivr.net/gh/kira-96/Picture@main/blog/images/2023-02-01_13-32-04.png) +![Architecture](https://cdn.jsdelivr.net/gh/kira-96/Picture@main/blog/images/2024-01-18_16-26-41.png) 我们在如图的光标位置添加一行内容,来让它可以识别`loongarch64`架构。 ``` perl -return 'linux-loongarch64' if m/^loongarch64-linux/; +return 'linux-la64' if m/^loongarch64-linux/; ``` 此时我们再执行一下`make`命令。 @@ -81,98 +82,139 @@ return 'linux-loongarch64' if m/^loongarch64-linux/; 可以看到,现在已经可以识别出`loongarch64-linux`了,报错和在3A4000上编译时也基本一样了。 -> 以下步骤同样适用于在3A4000(mips64)上编译EPICS,只需要将`loongarch64`全部替换为`mips64` +> 以下步骤同样适用于在3A4000(mips64)上编译EPICS,只需要将`la64`全部替换为`mips64` 剩下的报错就是,没有找到对应的编译配置项,我们同样可以仿照已经做了适配的架构来改写,直接按照下面步骤来就可以了。 -1. 添加 CONFIG.Common.linux-loongarch64 +1. 添加 CONFIG.Common.linux-la64 ``` shell $ cd configure/os/ -# 添加 CONFIG.Common.linux-loongarch64 -$ cp CONFIG.Common.linux-aarch64 CONFIG.Common.linux-loongarch64 -$ vi CONFIG.Common.linux-loongarch64 +# 添加 CONFIG.Common.linux-la64 +$ cp CONFIG.Common.linux-aarch64 CONFIG.Common.linux-la64 +$ vi CONFIG.Common.linux-la64 ``` 修改成如下内容: ``` shell -# CONFIG.Common.linux-loongarch64 +# CONFIG.Common.linux-la64 # # Definitions for linux-loongarch64 target builds -# Override these settings in CONFIG_SITE.Common.linux-loongarch64 +# Override these settings in CONFIG_SITE.Common.linux-la64 #------------------------------------------------------- # Include definitions common to all Linux targets include $(CONFIG)/os/CONFIG.Common.linuxCommon -ARCH_CLASS = loongarch64 +ARCH_CLASS = loongarch ``` -2. 添加 CONFIG.linux-loongarch64.Common +2. 添加 CONFIG.linux-la64.Common ``` shell -# 添加 CONFIG.linux-loongarch64.Common -$ cp CONFIG.linux-aarch64.Common CONFIG.linux-loongarch64.Common -$ vi CONFIG.linux-loongarch64.Common +# 添加 CONFIG.linux-la64.Common +$ cp CONFIG.linux-aarch64.Common CONFIG.linux-la64.Common +$ vi CONFIG.linux-la64.Common ``` 修改成如下内容(内容没有变化,可以不修改): ``` shell -# CONFIG.linux-loongarch64.Common +# CONFIG.linux-la64.Common # # Definitions for linux-loongarch64 host builds -# Sites may override these definitions in CONFIG_SITE.linux-loongarch64.Common +# Sites may override these definitions in CONFIG_SITE.linux-la64.Common #------------------------------------------------------- -#Include definitions common to unix hosts +# Include definitions common to unix hosts include $(CONFIG)/os/CONFIG.UnixCommon.Common ``` -3. 添加 CONFIG.linux-loongarch64.linux-loongarch64 +3. 添加 CONFIG.linux-la64.linux-la64 ``` shell -# 添加 CONFIG.linux-loongarch64.linux-loongarch64 -$ cp CONFIG.linux-aarch64.linux-aarch64 CONFIG.linux-loongarch64.linux-loongarch64 -$ vi CONFIG.linux-loongarch64.linux-loongarch64 +# 添加 CONFIG.linux-la64.linux-la64 +$ cp CONFIG.linux-aarch64.linux-aarch64 CONFIG.linux-la64.linux-la64 +$ vi CONFIG.linux-la64.linux-la64 ``` 修改成如下内容(内容没有变化,可以不修改): ``` shell -# CONFIG.linux-loongarch64.linux-loongarch64 +# CONFIG.linux-la64.linux-la64 # # Definitions for native linux-loongarch64 builds -# Override these definitions in CONFIG_SITE.linux-loongarch64.linux-loongarch64 +# Override these definitions in CONFIG_SITE.linux-la64.linux-la64 #------------------------------------------------------- # Include common gnu compiler definitions include $(CONFIG)/CONFIG.gnuCommon ``` -4. 添加 CONFIG_SITE.Common.linux-loongarch64 +4. 添加 CONFIG_SITE.Common.linux-la64 ``` shell -# 添加 CONFIG_SITE.Common.linux-loongarch64 -$ cp CONFIG_SITE.Common.linux-aarch64 CONFIG_SITE.Common.linux-loongarch64 -$ vi CONFIG_SITE.Common.linux-loongarch64 +# 添加 CONFIG_SITE.Common.linux-la64 +$ cp CONFIG_SITE.Common.linux-aarch64 CONFIG_SITE.Common.linux-la64 +$ vi CONFIG_SITE.Common.linux-la64 ``` 内容没有变化,可以不修改。 -5. 添加 CONFIG_SITE.linux-loongarch64.linux-loongarch64 +``` shell +# CONFIG_SITE.Common.linux-la64 +# +# Site Specific definitions for all linux-loongarch64 targets +#------------------------------------------------------- + +# NOTE for SHARED_LIBRARIES: In most cases if this is set to YES the +# shared libraries will be found automatically. However if the .so +# files are installed at a different path to their compile-time path +# then in order to be found at runtime do one of these: +# a) LD_LIBRARY_PATH must include the full absolute pathname to +# $(INSTALL_LOCATION)/lib/$(EPICS_HOST_ARCH) when invoking base +# executables. +# b) Add the runtime path to SHRLIB_DEPLIB_DIRS and PROD_DEPLIB_DIRS, which +# will add the named directory to the list contained in the executables. +# c) Add the runtime path to /etc/ld.so.conf and run ldconfig +# to inform the system of the shared library location. + +# Depending on your version of Linux you'll want one of the following +# lines to enable command-line editing and history in iocsh. If you're +# not sure which, start with the top one and work downwards until the +# build doesn't fail to link the readline library. If none of them work, +# comment them all out to build without readline support. + +# No other libraries needed (recent Fedora, Ubuntu etc.): +#COMMANDLINE_LIBRARY = READLINE + +# Needs -lncurses (RHEL 5 etc.): +#COMMANDLINE_LIBRARY = READLINE_NCURSES + +# Needs -lcurses (older versions) +#COMMANDLINE_LIBRARY = READLINE_CURSES + + +# WARNING: Variables that are set in $(CONFIG)/CONFIG.gnuCommon cannot be +# overridden in this file for native builds, e.g. variables such as +# OPT_CFLAGS_YES, WARN_CFLAGS, SHRLIB_LDFLAGS +# They must be set in CONFIG_SITE.linux-la64.linux-la64 or for +# cross-builds in CONFIG_SITE..linux-la64 instead. +``` + +5. 添加 CONFIG_SITE.linux-la64.linux-la64 ``` shell -# 添加 CONFIG_SITE.linux-loongarch64.linux-loongarch64 -$ cp CONFIG_SITE.linux-aarch64.linux-aarch64 CONFIG_SITE.linux-loongarch64.linux-loongarch64 -$ vi CONFIG_SITE.linux-loongarch64.linux-loongarch64 +# 添加 CONFIG_SITE.linux-la64.linux-la64 +$ cp CONFIG_SITE.linux-aarch64.linux-aarch64 CONFIG_SITE.linux-la64.linux-la64 +$ vi CONFIG_SITE.linux-la64.linux-la64 ``` 修改成如下内容: ``` shell -# CONFIG_SITE.linux-loongarch64.linux-loongarch64 +# CONFIG_SITE.linux-la64.linux-la64 # # Site specific definitions for native linux-loongarch64 builds #------------------------------------------------------- @@ -199,9 +241,9 @@ $ make -j8 接下来就静静等待编译完成。 -编译完后查看编译输出目录`bin/linux-loongarch64/`。 +编译完后查看编译输出目录`bin/linux-la64/`。 -![编译输出目录](https://cdn.jsdelivr.net/gh/kira-96/Picture@main/blog/images/2023-02-01_14-09-04.png) +![编译输出目录](https://cdn.jsdelivr.net/gh/kira-96/Picture@main/blog/images/2024-01-18_16-37-18.png) ## 添加到PATH @@ -220,13 +262,16 @@ $ vi env ``` shell #!/bin/sh # EPICS base shell setup +export EPICS_BASE="/usr/local/epics/base-7.0.7" +export EPICS_HOST_ARCH=linux-la64 + # affix colons on either side of $PATH to simplify matching case ":${PATH}:" in - *:"/usr/local/epics/base-7.0.7/bin/linux-loongarch64":*) + *:"${EPICS_BASE}/bin/${EPICS_HOST_ARCH}":*) ;; *) # Prepending path in case a system-installed epics needs to be overridden - export PATH="/usr/local/epics/base-7.0.7/bin/linux-loongarch64:$PATH" + export PATH="${EPICS_BASE}/bin/${EPICS_HOST_ARCH}:$PATH" ;; esac ```