Monday, September 9, 2019

Raspbian Buster and Cross Toolchain for Linux and Mac OS 8.3.0

Raspbian Buster is out. It seems it updated gcc from version 6.3.0 (used for Stretch) to gcc version 8.3.0. This is not always needed, but I had a lot of problems in the past related to using an outdated crosscompiler, or the one provided in the raspberry repo: https://github.com/raspberrypi/tools. I therefore built my own toolchain for Stretch, which I provided here, both for Linux and Mac OS.

I did the same for Buster: I built my own toolchain and I built many projects with it, like Qt, ffmpeg etc... Just place the toolchain in /opt/rpi (probably position independent) and you should be done. This toolchain should be 100% compatible with gcc provided by Buster.

Download cross toolchain GCC 6.3.0 for Stretch here.
Download Linux x64 cross toolchain GCC 8.3.0 here.
Download Mac OS cross toolchain GCC 8.3.0 here.

Bye ;-)

23 comments:

  1. hi
    welcome back
    do you will build new Qt version 12 or 13 for raspberry pi

    ReplyDelete
  2. Thank you Luca.
    Just for the others, your toolchain is not position independent, so it have to be placed in /opt/rpi.

    Thanks again.

    ReplyDelete
    Replies
    1. Correct. I tried to create it position independent in the past but it seemed not to work properly on mac.

      Delete
  3. Hello,

    the binaries generated when compiling works on raspberry pi 4 and raspberry pi 3?

    Thanks.
    Good job Luca.

    ReplyDelete
    Replies
    1. You I built for, at least, armv7 and armv8 with this toolchain. So rpi2, rpi3 and rpi4. Didn't try armv6.

      Delete
    2. I used this toolchain to crosscompile Qt5.12.5 for raspberry pi4 with these modules: qtdeclarative qtquickcontrols qtquickcontrols2 qtmultimedia qtsvg qtxmlpatterns qtgraphicaleffects qtwebsockets. It works like a charm!

      Delete
    3. Hi, Mattia. Was you actually able to run pocplayer on RPi4?

      Delete
  4. I use this toolchain t crosscompile Qt5.12.5 for raspberry pi4 on Ubuntu 18.04 and I have this error on compile time:


    /opt/rpi/rpi-gcc-8.3.0/bin/arm-linux-gnueabihf-g++ -c -include .pch/Qt5Core -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=/opt/rpi/buster_enigma/sysroot/ -O3 -std=c++1z -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -D_REENTRANT -fPIC -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_BUILD_CORE_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -I. -Iglobal -I../3rdparty/harfbuzz/src -I../3rdparty/md5 -I../3rdparty/md4 -I../3rdparty/sha3 -I../3rdparty/forkfd -I../3rdparty/tinycbor/src -I../../include -I../../include/QtCore -I../../include/QtCore/5.12.5 -I../../include/QtCore/5.12.5/QtCore -I.moc -I.tracegen -isystem /opt/rpi/buster_enigma/sysroot/usr/include/glib-2.0 -I/opt/rpi/buster_enigma/sysroot/usr/lib/arm-linux-gnueabihf/glib-2.0/include -isystem /opt/rpi/buster_enigma/sysroot/usr/include -I/opt/rpi/buster_enigma/sysroot/opt/vc/include -I../../mkspecs/devices/linux-rasp-pi3-vc4-g++ -o .obj/qlockfile_unix.o io/qlockfile_unix.cpp
    io/qfilesystemengine_unix.cpp: En la función ‘int qt_statx(const char*, statx*)’:
    io/qfilesystemengine_unix.cpp:323:26: error: ‘AT_FDCWD’ no se declaró en este ámbito
    return qt_real_statx(AT_FDCWD, pathname, 0, statxBuffer);

    ReplyDelete
    Replies
    1. AT_FDCWD is defined in fcntl.h in the toolchain.

      Delete
  5. Thank you for your toolchain! It helped me getting started, but unfortunately there were some issues especially with ARMv6 support.

    I created a new repository for a toolchain based on GCC8 and ARMv6 support. Feel free to link it:

    https://github.com/Pro/raspi-toolchain

    ReplyDelete
  6. Thank you for this amazing work.
    I used this toolchain to cross compile POT, QT 5.12.5 and my QT application.
    It is a QT QML project that plays one video.

    It copied qt_driver to mediaservice and I think it is all in the rigth place.
    But my application could not run. It always stop in the problema above.
    I hope maybe someone could read this and give me some light.


    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/video/videonode" ...
    QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/video/videonode/libeglvideonode.so"
    Found metadata in lib /usr/local/qt5pi/plugins/video/videonode/libeglvideonode.so, metadata=
    {
    "IID": "org.qt-project.qt.sgvideonodefactory/5.2",
    "MetaData": {
    "Keys": [
    "egl"
    ]
    },
    "archreq": 0,
    "className": "QSGVideoNodeFactory_EGL",
    "debug": false,
    "version": 330752
    }


    Got keys from plugin meta data ("egl")
    QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/video/videonode" ...
    loaded library "/usr/local/qt5pi/plugins/video/videonode/libeglvideonode.so"
    Requesting control for org.qt-project.qt.videorenderercontrol/5.0...
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/accessiblebridge" ...
    QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/accessiblebridge" ...
    Bus error

    ReplyDelete
    Replies
    1. I forgot to mention that I got a message in dmesg: Unhandled prefetch abort: unknown 1 (0x001)

      Delete
    2. Is a minimal Qt app working properly? Does the app work without multimedia?
      Maybe wrong arch? What is readelf -a saying about /usr/local/qt5pi/plugins/video/videonode/libeglvideonode.so?

      Delete
    3. Thank you for the response.
      I can make a minimal app that works without multimedia.

      Tha readelf gives me:

      Attribute Section: aeabi
      File Attributes
      Tag_CPU_name: "8-A"
      Tag_CPU_arch: v8
      Tag_CPU_arch_profile: Application
      Tag_ARM_ISA_use: Yes
      Tag_THUMB_ISA_use: Thumb-2
      Tag_FP_arch: VFPv2

      when I check a random lib I got

      Attribute Section: aeabi
      File Attributes
      Tag_CPU_name: "6"
      Tag_CPU_arch: v6
      Tag_ARM_ISA_use: Yes
      Tag_THUMB_ISA_use: Thumb-1
      Tag_FP_arch: VFPv2

      Maybe I make a mistake and compile QT as armv8 instead of armv6? I tought it should be armv7. Anyway I will study more about it ..

      Delete
    4. I am using buster built using pi-gen tool.

      Delete
    5. Armv8 is ok then. You'll have to debug deeper. I'd try gdb or strace.

      Delete
    6. I will try going deeper.
      Thank you.

      Delete
    7. Hi @Gabriel
      Did you manage to solve your issue? I got the same issue like you.
      If you have any news, please share
      Thanks
      Kien

      Delete
  7. @Kien, Sorry for the late response.
    I could compile qt 5.12.5 with webengine support using the instructions here.
    https://wiki.qt.io/RaspberryPiWithWebEngine
    But I modify it to use the toolchain provided by Luca.
    One thing that I did to work was change the links to absolute path in arm-linux-gnueaubihf in the rootfs.
    After that I could compile and run POT ok.

    ReplyDelete
  8. My problem now is that WebEngineView component is using almost all cpu in my board. It works but uses 300% of cpu in top. If anyone has some tips I would appreciate

    ReplyDelete