Skip to content

Commit

Permalink
Patch toolchain arm-rpi-4.9.3-linux-gnueabihf
Browse files Browse the repository at this point in the history
  • Loading branch information
vok1980 committed May 19, 2017
1 parent d820ab9 commit 6e49d7e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

15 comments on commit 6e49d7e

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, just tried to use the toolchain but on trying cmake I ran into the following issue.

CMake Error at /home/jdas/Desktop/cmake-3.8.1-Linux-x86_64/share/cmake-3.8/Modules/CMakeTestCCompiler.cmake:51 (message):
The C compiler
"/home/jdas/DasPiZW/XTools-49Fix/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"
is not able to compile a simple test program.

It fails with the following output:

Change Dir: /home/jdas/DasPiZW/OpenCV/OpenCV_Basic-493_build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_26018/fast"

/usr/bin/make -f CMakeFiles/cmTC_26018.dir/build.make
CMakeFiles/cmTC_26018.dir/build

make[1]: Entering directory
'/home/jdas/DasPiZW/OpenCV/OpenCV_Basic-493_build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_26018.dir/testCCompiler.c.o

/home/jdas/DasPiZW/XTools-49Fix/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
-Wl,-rpath-link,/home/jdas/DasPiZW/SysRoot/opt/vc/lib
-Wl,-rpath-link,/home/jdas/DasPiZW/SysRoot/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/jdas/DasPiZW/SysRoot/usr/lib/arm-linux-gnueabihf
-Wl,-rpath-link,/home/jdas/DasPiZW/SysRoot/usr/local/lib -o
CMakeFiles/cmTC_26018.dir/testCCompiler.c.o -c
/home/jdas/DasPiZW/OpenCV/OpenCV_Basic-493_build/CMakeFiles/CMakeTmp/testCCompiler.c

!!!!!!!! Set correct RPI_SYSROOT env variable

CMakeFiles/cmTC_26018.dir/build.make:65: recipe for target
'CMakeFiles/cmTC_26018.dir/testCCompiler.c.o' failed

make[1]: *** [CMakeFiles/cmTC_26018.dir/testCCompiler.c.o] Error 1

make[1]: Leaving directory
'/home/jdas/DasPiZW/OpenCV/OpenCV_Basic-493_build/CMakeFiles/CMakeTmp'

Makefile:126: recipe for target 'cmTC_26018/fast' failed

make: *** [cmTC_26018/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)

Configuring incomplete, errors occurred!

I did make sure to set the RPI_SYSROOT to my Pi Sysroot on the Ubuntu host. But that didn't seem to solve the issue.

What am I doing wrong? Would you like me to add the .cmake file as well?

Thanks

@vok1980
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at


Seems like your RPI_SYSROOT not set, does not exists or is not a directory.

@Demonbots
Copy link

@Demonbots Demonbots commented on 6e49d7e May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your note.

I have already added RPI_SYSROOT variable in my toolchain's cmake file. I've added the cmake file below.

SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_SYSTEM_VERSION 1)

SET(DEVROOT $ENV{HOME}/DasPiZW)
SET(PIROOT ${DEVROOT}/SysRoot)
SET(RPI_SYSROOT ${DEVROOT}/SysRoot)
SET(PITOOLS ${DEVROOT}/XTools)

SET(TOOLROOT ${PITOOLS}/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf)

##specify the cross compiler
SET(CMAKE_C_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLROOT}/bin/arm-linux-gnueabihf-g++)

SET(CMAKE_SYSROOT ${PIROOT})
SET(CMAKE_FIND_ROOT_PATH ${PIROOT})

##search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
##for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(FLAGS "-Wl,-rpath-link,${PIROOT}/opt/vc/lib -Wl,-rpath-link,${PIROOT}/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,${PIROOT}/usr/local/lib")

UNSET(CMAKE_C_FLAGS CACHE)
UNSET(CMAKE_CXX_FLAGS CACHE)

SET(CMAKE_CXX_FLAGS ${FLAGS} CACHE STRING "" FORCE)
SET(CMAKE_C_FLAGS ${FLAGS} CACHE STRING "" FORCE)

In addition to this I had previously also tried to compile using gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf and gcc-linaro-4.9-2015.02-3-x86_64_arm-linux-gnueabihf. However, in both these cases the executable resulted in a segmentation fault when run on the Pi Zero (running Jessie).

I am sure I am missing something here to do with configuration, as when I compile the same program with a 4.8 compiler it can run on the pi without any issues.

Any help would be appreciated. Thank you in advance for your time.

@vok1980
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this segmentation fault happen at std::thread?

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I have not got remote debugging set up on my Pi. Would you happen to have any tips on how I can set it up? I'm sorry that part I have never done before.

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, unfortunately the gdb didn't return what I was hoping for. Instead the error log is as below..

Starting program: /home/jdas/DasPiZW/OpenCV/HW_Build/HW
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading /lib/ld-2.19.so from remote target...
Reading /lib/.debug/ld-2.19.so from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libarmmem.so from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 from remote target...
Reading /lib/arm-linux-gnueabihf/libgcc_s.so.1 from remote target...
Reading /lib/arm-linux-gnueabihf/libc.so.6 from remote target...
Reading /lib/arm-linux-gnueabihf/libm.so.6 from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.20 from remote target...
Reading /usr/lib/arm-linux-gnueabihf/.debug/libstdc++.so.6.0.20 from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libgcc_s.so.1 from remote target...
Reading /lib/arm-linux-gnueabihf/libc-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libc-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/libm-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libm-2.19.so from remote target...

Program received signal SIGSEGV, Segmentation fault.
0x000108d2 in frame_dummy ()
(gdb)

What do you make of this? I am a bit lost how to proceed. I think that this is something to do with the linaro toolchain with gcc493.

@vok1980
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backtrace

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I missed something with the logs?
Also any suggestions on how I can add RPI_SYSROOT?

@Demonbots
Copy link

@Demonbots Demonbots commented on 6e49d7e May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there, I ran the program with gdb and backtrace. The output isn't very helpful for my debug. Pasting below.

I did note one point though - earlier the seg fault at frame_dummy (), but this latest run isn't quite sure of the function anymore.

If you can provide any insights it'd be really great.

(gdb) run
Starting program: /home/jdas/DasPiZW/OpenCV/HW_Build/HW49
Reading /lib/ld-linux-armhf.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading /lib/ld-2.19.so from remote target...
Reading /lib/.debug/ld-2.19.so from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libarmmem.so from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 from remote target...
Reading /lib/arm-linux-gnueabihf/libm.so.6 from remote target...
Reading /lib/arm-linux-gnueabihf/libgcc_s.so.1 from remote target...
Reading /lib/arm-linux-gnueabihf/libc.so.6 from remote target...
Reading /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.20 from remote target...
Reading /usr/lib/arm-linux-gnueabihf/.debug/libstdc++.so.6.0.20 from remote target...
Reading /lib/arm-linux-gnueabihf/libm-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libm-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libgcc_s.so.1 from remote target...
Reading /lib/arm-linux-gnueabihf/libc-2.19.so from remote target...
Reading /lib/arm-linux-gnueabihf/.debug/libc-2.19.so from remote target...

Program received signal SIGSEGV, Segmentation fault.
0x0005f7c2 in ?? ()
(gdb) bt
#0 0x0005f7c2 in ?? ()
raspberrypi#1 0x0001060e in _start () at ../ports/sysdeps/arm/start.S:113
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thanks

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vok1980 - could I please request your guidance on how I can get RPI_SYSROOT added to my build variables? As I had mentioned I had already added it to my toolchain's .cmake file. Is there anywhere else that you think I should add this?

Since this morning I've also tried g++-arm-linux-gnueabihf with gcc 6.3 as well and unfortunately, this too returns the same problem with Segmentation Fault when I run the Hello World executable on Pi. So I am really out of options unfortunately and not sure how to proceed.

Any help is appreciated.

Thanks

@vok1980
Copy link
Owner Author

@vok1980 vok1980 commented on 6e49d7e Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Demonbots I'v got some runtime problems with this toolchain. Now I an using ubuntu's packets gcc-5-arm-linux-gnueabihf & g++-5-arm-linux-gnueabihf and it works good for me on my RPi3b with Jessie.
Just don't forget to copy /usr/arm-linux-gnueabihf/lib/libstdc++* to lib path of your application on device, and check ldd <application>, that it uses it.

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @vok1980 for the guidance. I'll try it out. Couple of things I want to check please.

  1. My PiZeroW is ARMv6 whereas the Pi3 is ARMv8, so do you think the toolchain will be okay for v6?
  2. To install would I have to apt-get the packages separately or is there a single toolchain that has both the packages? The reason I ask is I'm trying to figure out how to let my .cmake file know where to look for the binaries for toolchain.

Many thanks.

@vok1980
Copy link
Owner Author

@vok1980 vok1980 commented on 6e49d7e Jun 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Demonbots

  1. I'm using -march=armv8-a compilation flag. I suppose, that in your case something like -march=armv6 or -march=armv6zk should be used. I'm not sure about it, you'd better to check it somewhere on RPi's forums.
  2. sudo apt-get install gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf. After that you can use arm-linux-gnueabihf-gcc-5 & arm-linux-gnueabihf-g++-5 as gcc & g++ for arm cross-compilation.

I did not try it with cmake, but I think that it will be enough to:

  • Set CC=arm-linux-gnueabihf-gcc-5
  • Set CXX=arm-linux-gnueabihf-g++-5
  • Add arch specific compiler flags like -march, but I don't remember how to do it with cmake. You can try flags it uses by default, maybe it will be ok.

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vok1980 for the awesome tips. I'll give it a go and let you know if it works.

Final question (and apologies for the basic question) when I do apt-get install for the toolchain, where on my system does it install. I'll use that location in the .cmake file as the path of the toolchain.

Thanks in advance.

@Demonbots
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vok1980 - Unfortunately using the toolchain you recommended did not work. It fails trying to compile the hello world program saying that Thumb-1 Hard-Float VFB ABI is not implemented. I've pasted the command and the resulting error below.

$ arm-linux-gnueabihf-g++-5 -march=armv6z ../HW/Hello_World.cpp -o HW
In file included from /usr/arm-linux-gnueabihf/include/c++/5/ios:39:0,
from /usr/arm-linux-gnueabihf/include/c++/5/ostream:38,
from /usr/arm-linux-gnueabihf/include/c++/5/iostream:39,
from ../HW/Hello_World.cpp:9:
/usr/arm-linux-gnueabihf/include/c++/5/exception: In constructor ‘std::exception::exception()’:
/usr/arm-linux-gnueabihf/include/c++/5/exception:63:39: sorry, unimplemented: Thumb-1 hard-float VFP ABI
exception() _GLIBCXX_USE_NOEXCEPT { }

Is there another switch/parameter I can use. Looks like I am really stuck with my ARMv6 as no cross compilers are there for the V6, they are all V7 and up. :(

Suggestions?

Please sign in to comment.