machinekit / machinekit-hal

Universal framework for machine control based on Hardware Abstraction Layer principle
https://www.machinekit.io
Other
109 stars 63 forks source link

processor does not support `ldrexh r2,[r1]' and other operations in ARM mode #366

Open ebo opened 2 years ago

ebo commented 2 years ago

With a clean Bullseye build on a RPi-3B I get dozens of errors while running "cmake --build ./build" which produce errors which are variations on the following:

/tmp/ccur4T6u.s:1341: Error: selected processor does not support `ldrexh r2,[r1]' in ARM mode machinekit-hal

Does machinekit-hal require running on an RPi-4 as well as requiring Bullseye? I could never get it to build cleanly under Buster.

ebo commented 2 years ago

It is not working on a clean Bullseye RPi-4 either. Here is the full error list:

[ 14%] Building C object src/libraries/runtime/CMakeFiles/runtime_module.dir/src/rtapi.c.o /tmp/ccCvFFzL.s: Assembler messages: /tmp/ccCvFFzL.s:1341: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1341: Error: selected processor does not supportstrexheq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1390: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1390: Error: selected processor does not supportstrexheq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1437: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1437: Error: selected processor does not supportstrexbeq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1486: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1486: Error: selected processor does not supportstrexbeq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1533: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1533: Error: selected processor does not supportstrexheq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1582: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1582: Error: selected processor does not supportstrexheq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1629: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1629: Error: selected processor does not supportstrexbeq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1678: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1678: Error: selected processor does not supportstrexbeq r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1869: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1869: Error: selected processor does not supportstrexh r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1907: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1907: Error: selected processor does not supportstrexb r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1945: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1945: Error: selected processor does not supportstrexh r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:1983: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:1983: Error: selected processor does not supportstrexb r3,r0,[r1]' in ARM mode /tmp/ccCvFFzL.s:2562: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2562: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2596: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2596: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2630: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2630: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2664: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2664: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2698: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2698: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2732: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2732: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2766: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2766: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2800: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2800: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2834: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2834: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2868: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2868: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2902: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2902: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2936: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2936: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2970: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:2970: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3004: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3004: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3038: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3038: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3072: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3072: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3829: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3829: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3866: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3866: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3903: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3903: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3940: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3940: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3977: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:3977: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4014: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4014: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4051: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4051: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4088: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4088: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4125: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4125: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4162: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4162: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4199: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4199: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4236: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4236: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4273: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4273: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4310: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4310: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4347: Error: selected processor does not support ldrexh r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4347: Error: selected processor does not supportstrexh r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4384: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4384: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4421: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4421: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4458: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4458: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4495: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4495: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4532: Error: selected processor does not support ldrexb r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4532: Error: selected processor does not supportstrexb r3,r2,[r1]' in ARM mode /tmp/ccCvFFzL.s:4727: Error: selected processor does not support ldrexh r1,[r0]' in ARM mode /tmp/ccCvFFzL.s:4727: Error: selected processor does not supportstrexh r3,r2,[r0]' in ARM mode /tmp/ccCvFFzL.s:4769: Error: selected processor does not support ldrexb r1,[r0]' in ARM mode /tmp/ccCvFFzL.s:4769: Error: selected processor does not supportstrexb r3,r2,[r0]' in ARM mode /tmp/ccCvFFzL.s:4811: Error: selected processor does not support ldrexh r1,[r0]' in ARM mode /tmp/ccCvFFzL.s:4811: Error: selected processor does not supportstrexh r3,r2,[r0]' in ARM mode /tmp/ccCvFFzL.s:4853: Error: selected processor does not support ldrexb r1,[r0]' in ARM mode /tmp/ccCvFFzL.s:4853: Error: selected processor does not supportstrexb r3,r2,[r0]' in ARM mode gmake[2]: [src/libraries/runtime/CMakeFiles/runtime_module.dir/build.make:76: src/libraries/runtime/CMakeFiles/runtime_module.dir/src/rtapi.c.o] Error 1 gmake[1]: [CMakeFiles/Makefile2:9729: src/libraries/runtime/CMakeFiles/runtime_module.dir/all] Error 2 gmake: *** [Makefile:166: all] Error 2

ebo commented 2 years ago

I've even tried to downgrade GCC to 9.3 and rebuild. I still get the same errors.

The only clue I have about how to fix this error is adding '-march=armv7-a' to CFLAGS as seen here: http://lkml.iu.edu/hypermail/linux/kernel/1409.3/02963.html

Looking at CMakeLists.txt, there does not appear to be a line to set CMAKE_C_FLAGS, but there is for DEBUG, RELEASE, and RELWITHDEBINFO.

ebo commented 2 years ago

Adding CMAKE_C_FLAGS and CMAKE_CXX_FLAGS to CMakeLists.txt:

set(CMAKE_C_FLAGS "-g -O0 -march=armv7-a" ) set(CMAKE_CXX_FLAGS "-g -O0 -march=armv7-a")

as well as adding '-march=armv7-a' to all the other FLAGS definitions:

set(CMAKE_C_FLAGS_DEBUG "-g -O0 -march=armv7-a" ) set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -march=armv7-a") set(CMAKE_C_FLAGS_RELEASE "-O0 -march=armv7-a") set(CMAKE_CXX_FLAGS_RELEASE "-O0 -march=armv7-a") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O0 -march=armv7-a") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O0 -march=armv7-a")

got this build through. Once this is added to CMakeLists.txt, this bug will probably be solved.

ebo commented 2 years ago

ok. Last night I forked machinekit-hal in prep to make the changes and submit a PR. Starting from a clean Bullseye build I find that I do need the '-march=armv7-a' to build on an RPi-4 with the current cmake configuration. To get it to work for myself I simply added it in where the FLAGS were set, but this is not the proper way to support other architectures. I may need som help getting this worked in as it has been years since I have written cmake files.

Also, to check if the current build system requires anything from cmake-3.22+, I temporarily lowered that to 3.18 (the current stable release distributed by everyone). It in fact does seem to require 3.22. I'll check again to make sure oce I get everything built through.

BTW, part of my PR will be build documentation updates.