CMake 汇编程序错误:没有这样的指令

Posted

技术标签:

【中文标题】CMake 汇编程序错误:没有这样的指令【英文标题】:CMake Assembler Errors: No such instruction 【发布时间】:2021-04-08 01:57:29 【问题描述】:

您好,我正在尝试为具有 AM335X ARM Cortex-A8 处理器的 Beaglebone 黑色目标构建 FreeRTOS 应用程序。我正在运行 Windows,但我正在使用运行 linux debian 10 的虚拟机,这是我交叉编译的。 uname -a 提供:

Linux debian 4.19.0-13-amd64 #1 SMP Debian 4.19.160-2 (2020-11-28) x86_64 GNU/Linux

我的项目可以在这里找到: https://github.com/frank2597/FreeRTOS_BBB 当我尝试使用 arm-linux-gnueabihf-gcc 编译时出现各种汇编错误,我用来设置编译器的 cmake 命令可以在我的项目中找到:https://github.com/frank2597/FreeRTOS_BBB/blob/master/AM335X-FreeRTOS-lwip/CMakeLists.txt

我已经使用这个设置为 beaglebone black 交叉编译了一个简单的 hello world 示例,所以我不确定为什么它会在这个 freeRTOS 端口上失败。我应该注意到我基于另一个项目创建了我的 freertos 项目,但我对其进行了简化,因为我认为他将其设置为从 windows 交叉编译(原始项目链接):https://github.com/kryochronic/AM335X-FreeRTOS-lwip

我得到的详细错误如下:

    frank@debian:~/eclipse-workspace/FreeRTOS_Test/build$ make
/usr/bin/cmake -S/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip -B/home/frank/eclipse-workspace/FreeRTOS_Test/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/frank/eclipse-workspace/FreeRTOS_Test/build/CMakeFiles /home/frank/eclipse-workspace/FreeRTOS_Test/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make -f CMakeFiles/src_portable_ported_aws_bufpool.dir/build.make CMakeFiles/src_portable_ported_aws_bufpool.dir/depend
make[2]: Entering directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
cd /home/frank/eclipse-workspace/FreeRTOS_Test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip /home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip /home/frank/eclipse-workspace/FreeRTOS_Test/build /home/frank/eclipse-workspace/FreeRTOS_Test/build /home/frank/eclipse-workspace/FreeRTOS_Test/build/CMakeFiles/src_portable_ported_aws_bufpool.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make -f CMakeFiles/src_portable_ported_aws_bufpool.dir/build.make CMakeFiles/src_portable_ported_aws_bufpool.dir/build
make[2]: Entering directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make[2]: Nothing to be done for 'CMakeFiles/src_portable_ported_aws_bufpool.dir/build'.
make[2]: Leaving directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
[  2%] Built target src_portable_ported_aws_bufpool
make -f CMakeFiles/src_portable_AM335X.dir/build.make CMakeFiles/src_portable_AM335X.dir/depend
make[2]: Entering directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
cd /home/frank/eclipse-workspace/FreeRTOS_Test/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip /home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip /home/frank/eclipse-workspace/FreeRTOS_Test/build /home/frank/eclipse-workspace/FreeRTOS_Test/build /home/frank/eclipse-workspace/FreeRTOS_Test/build/CMakeFiles/src_portable_AM335X.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make -f CMakeFiles/src_portable_AM335X.dir/build.make CMakeFiles/src_portable_AM335X.dir/build
make[2]: Entering directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
[  3%] Building ASM object CMakeFiles/src_portable_AM335X.dir/src/portable/AM335X/ported_amm335x_init.S.o
/usr/bin/cc -DBOOT=MMCSD -DCONSOLE=UARTCONSOLE -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/freertos_kernel/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/FreeRTOS/portable/GCC/ARM_CA8_amm335x -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/include/armv7a -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/include/armv7a/am335x -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/include/hw -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/inc -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/inc -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/inc/config_files -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/app/lwip_app/ports/cpsw/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/portable -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/lwip/ports/cpsw/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/lwip -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/drivers -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/utils -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/platform/beaglebone -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/nandlib -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/nandlib/include -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/system_config/armv7a -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/system_config/armv7a/gcc -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/system_config/armv7a/am335x -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/ti/system_config/armv7a/am335x/gcc -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/netif -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/core -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/core/ipv4 -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/portable/arch -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/api -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/netif -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/lwip -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/lwip/apps -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/lwip/priv -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/lwip/prot -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/posix -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/libraries/3rdparty/lwip/src/include/posix/sys -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/lwip/ports/cpsw/netif -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/freertos_kernel -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/lib/third_party/amazon/freertos_kernel/portable/MemMang -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/ported_aws_bufpool -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/ported_aws_bufpool/inc -I/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/application   -o CMakeFiles/src_portable_AM335X.dir/src/portable/AM335X/ported_amm335x_init.S.o -c /home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S: Assembler messages:
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:77: Error: unknown pseudo-op: `.code'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:92: Error: no such instruction: `ldr r0,=_stack'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:93: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:94: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:95: Error: too many memory references for `sub'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:99: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:100: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:101: Error: too many memory references for `sub'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:105: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:106: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:107: Error: too many memory references for `sub'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:111: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:112: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:113: Error: too many memory references for `sub'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:117: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:118: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:119: Error: too many memory references for `sub'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:124: Error: no such instruction: `msr cpsr_c,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:125: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:133: Error: expecting operand after ','; got nothing
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:134: Error: no such instruction: `mcr p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:135: Error: no such instruction: `isb'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:136: Error: no such instruction: `mrc p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:137: Error: no such instruction: `orr r0,r0,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:138: Error: no such instruction: `mcr p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:143: Error: no such instruction: `mrc p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:144: Error: no such instruction: `orr r1,r1,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:145: Error: no such instruction: `mcr p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:146: Error: expecting operand after ','; got nothing
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:147: Error: no such instruction: `mcr p15,'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:148: Error: expecting operand after ','; got nothing
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:149: Error: no such instruction: `fmxr FPEXC,r0'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:156: Error: no such instruction: `ldr r0,=_bss_start'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:157: Error: no such instruction: `ldr r1,=(_bss_end - 0x04)'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:158: Error: expecting operand after ','; got nothing
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:160: Error: invalid char '[' beginning operand 2 `[r0]'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:161: Error: too many memory references for `cmp'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:162: Error: no such instruction: `ble Loop'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:169: Error: no such instruction: `ldr r10,=start_boot'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:170: Error: too many memory references for `mov'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:171: Error: no such instruction: `bx r10'
/home/frank/eclipse-workspace/FreeRTOS_Test/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S:172: Error: too many memory references for `sub'
make[2]: *** [CMakeFiles/src_portable_AM335X.dir/build.make:144: CMakeFiles/src_portable_AM335X.dir/src/portable/AM335X/ported_amm335x_init.S.o] Error 1
make[2]: Leaving directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make[1]: *** [CMakeFiles/Makefile2:113: CMakeFiles/src_portable_AM335X.dir/all] Error 2
make[1]: Leaving directory '/home/frank/eclipse-workspace/FreeRTOS_Test/build'
make: *** [Makefile:87: all] Error 2

产生这个错误的文件可以在这里找到:https://github.com/frank2597/FreeRTOS_BBB/blob/master/AM335X-FreeRTOS-lwip/src/portable/AM335X/ported_amm335x_init.S

如果您需要其他信息,请告诉我。感谢您对解决此问题的任何帮助,谢谢。

【问题讨论】:

可以看到cmake正在尝试使用/usr/bin/cc来组装文件。那是本机编译器驱动程序,而不是交叉编译器,因此它将尝试将文件解释为 x86 程序集,这显然失败了。您需要说服 cmake 在此处改用 arm-linux-gnueabihf-gcc,但我不太了解 cmake,无法告诉您如何操作。 可能有单独的变量来设置用于 C 编译和汇编的命令,即使它们通常是相同的命令。我敢打赌你已经设置了一个但没有设置另一个,这就是 C 源文件正确使用交叉编译器的原因(以及你的 Hello World 示例工作的原因)但事实并非如此。 这只是先前问题的扩展,很明显正在使用非arm编译器。你不是交叉编译你是本地编译 这很奇怪,我认为我的 CMakeLists.txt 中的 set(CMAKE_C_COMPILER $tools/arm-linux-gnueabihf-gcc) 会改变编译器,但显然它没有这样做。我会调查的 【参考方案1】:
set(CMAKE_C_COMPILER "/path/to/your/c/compiler/executable")
set(CMAKE_CXX_COMPILER "/path/to/your/cpp/compiler/executable")

在*** CMakeLists.txt 中使用 project()enable_language() 命令后,必须在 NOT 之前添加此项

【讨论】:

以上是关于CMake 汇编程序错误:没有这样的指令的主要内容,如果未能解决你的问题,请参考以下文章

CMake 没有正确链接?

UIImage 错误指令

cmake 如何编译成debug版?

CMake项目Boost库错误:boost/config/compiler/gcc.hpp:165:10:致命错误:cstddef:没有这样的文件或目录

没装gcc能用cmake吗?

CMake 错误:CMake 无法找到与“Unix Makefiles”对应的构建程序。 CMAKE_MAKE_PROGRAM 未设置