FreeCAD and Raspberry Pi 4

I saw that report before. It seems like a dead-end because Raspberry Pi users think it’s a Debian problem, but Debian maintainers think it’s a Raspbian problem, so it’s just finger pointing the other side. It could be a Raspbian issue but I don’t think Raspbian packages are heavily re-packaged as the Debian people think. I think Raspbian basically only adds things regarding to the core of the Raspberry Pi, the BCM2835 chipset, and a few utilities.

The crash seems to happen in libX11, but it seems to be triggered by libCoin, so I think it’s a Coin problem or not? As I understand, the Coin developers don’t really maintain Coin in BitBucket, so who is responsible? I remember somebody here always recommends using FreeCAD’s Coin because upstream doesn’t pay due attention.

#0  0xb3831e74 in XDefaultScreenOfDisplay () from 
/usr/lib/arm-linux-gnueabihf/libX11.so.6
#1  0xb5077ad0 in ?? () from /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#2  0xb5078454 in glxglue_init () from 
/usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#3  0xb50710e0 in cc_glglue_instance () from 
/usr/lib/arm-linux-gnueabihf/libCoin.so.80c

The crash seems to happen in libX11, but it seems to be triggered by libCoin, so I think it’s a Coin problem or not?

https://forum.freecadweb.org/viewtopic.php?f=3&t=37105

As I understand, the Coin developers don’t really maintain Coin in BitBucket

Not? I thought that’s the official repository. Maybe looo knows more.

This is what I’m talking about:

[1] I believe looo is talking about FreeCAD’s repository, https://github.com/FreeCAD/pivy

He’s basically saying, “don’t use the official BitBucket sources, use ours”.

But there’s also the issue of Coin3D leaving BitBucket and migrating to GitHub.

He’s basically saying, “don’t use the official BitBucket sources, use ours”.

But this is only pivy – the Python wrapper of Coin3d – and not Coin3d itself.

When looking at the commit history of Coin3d then something happens: https://bitbucket.org/Coin3D/coin/commits/all

But for pivy not much has happened. The last change was more than a year ago: https://bitbucket.org/Coin3D/pivy/commits/all
However, on the GH fork nothing has happened in the meantime either. So, I guess the official pivy maintainers only merge contributions but don’t actively maintain it.

Some small fixes were added for swig4 and for latest coin. So I think your statement is not really fair. :wink:

Sorry, my bad! I somehow misread the year, i.e. 2018 instead of 2019.

Hehe, to you and Werner, you are talking about a gift of 150 bucks my friend (2x RPI4B4 + heatsinks) :open_mouth: :wink:
For now I’m going to donate some bucks to the FreeCAD project rather :wink: :wink:


Sorry I was busy this last days, I’m still now, no time to compile FreeCAD with degug=ON and so one… However I see the callstack already exist, thanks for the link.


Well, you are right. I hope we will end this kind of endless loop :wink:
endless-circle.png



About this I’m wondering some stuffs… because from start It seems maybe to be an Opengl problem.
And on RPI4 the CPU has changed to BCM2711 (ARM A72)
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md
And more important the GPU changed as well, from Broadcome VidéoCore 4 to VC6. VC6 is brand new, so there is lack of documentation for now…
Documentation exists about VC4:
https://dri.freedesktop.org/docs/drm/gpu/vc4.html


The last time (and the only one) I ran Freecad natively on Raspbian it was Raspbian Stretch, FreeCAD 0.14, on a RPI3B+ with CPU BCM2837(A53) and GPU VidéoCore4.
At that time no graphic acceleration was activated on Raspbian stretch by default, and it was possible to activate opengl drivers (fake_KMS or KMS drivers) in raspi-config menu.
But on RPI4 I guess the beaviour is different. Opengl acceleration is activated by default I guess (not sure), and KMS driver is maybe diferent due to VC6.
Anyway, I should try to disable KMS driver on RPI4 to see if this fixe the crash of FreeCAD. I will tell you.


Well guys, I want not waiste your time with all those links, maybe it’s bullshits, I’m just an end user.
Anyway, I hope the issue is relevant with software rather than drivers :confused:

Thank you for the description. Actually, no, the problem as you describe it, seems to be the “drivers”. I think in general, Coin3D isn’t developed extensively, so it is the same version as before. Since Coin3D is supposed to interact with OpenGL, then yes, maybe the Coin3D developers should in fact look into it. But they are known for not doing much development, basically only host the repository.

Edit: duplicate next , message errased.

Ok, I did few tests.
On RPI4 now remains only 2 graphic drivers:
1: Legacy
2: fake_KMS
So, the full_KMS GL driver doen’t exist anymore for now.
Fake_KMS driver is activated by default on Raspbian buster distro.
I have tested both drivers with glxgears:

  • fake_KMS: glxgears full screen 1920x1080 → 46fps and 3% CPU usage
  • Legacy: glxgears full screen 1920x1080 → 46fps and 77% CPU usage

Unfortunately FreeCAD crashed with both drivers, same error:

Coin warning in cc_glglue_instance(): Error when setting up the GL context. This can happen if there is no current context, or if the context has been set up incorrectly.
Program received signal SIGSEGV, Segmentation fault.
#0  /lib/arm-linux-gnueabihf/libc.so.6(__default_sa_restorer+0) [0xb222a120]

So, maybe now I could try to compile FreeCAD with your previous advices about pivy and FreeCAD’s Coin, and also the advices that Looo told me:

I’m going to try these stuffs, even if I don’t understand very well the perimeter of each third party libreary and how to compile and include them in the whole FreeCAD compilation.
Any advice or script of compilation appreciated to inculde soqt, or Quarter. Or tell me if I’m wrong and feel you free to show me the right way to perform those tests :confused:

OS: Raspbian GNU/Linux 10 (buster) (LXDE/LXDE-pi)
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.19.17651 (Git)
Build type: Unknown
Branch: master
Hash: 16c26cb3b1cd7209ea8efc8cb30b3b18fd80cf95
Python version: 3.7.3
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)

For now I have compiled FreeCAD accordingly to below instructions by following the FreeCAD documentation:

#install raspbian buster 2010-07-10
#update while first start
#reboot

git clone https://github.com/FreeCAD/FreeCAD.git freecad-source

sudo apt install cmake
sudo apt install libtool
sudo apt install swig
sudo apt install libboost-dev libboost-date-time-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-signals-dev libboost-thread-dev
sudo apt install libcoin-dev
sudo apt install libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libopencv-dev libproj-dev libvtk7-dev libx11-dev libxerces-c-dev libzipios++-dev

#Py3 and Qt5
sudo apt install qtbase5-dev qttools5-dev libqt5opengl5-dev libqt5svg5-dev libqt5webkit5-dev libqt5xmlpatterns5-dev libqt5x11extras5-dev libpyside2-dev libshiboken2-dev pyside2-tools python3-dev python3-matplotlib python3-pivy python3-ply python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtsvg python3-pyside2.qtwidgets python3-pyside2uic
sudo apt install libocct*-dev
sudo apt install occt-draw
sudo apt install libsimage-dev
sudo apt install checkinstall

mkdir freecad-build
cd freecad-build

sudo cmake -DBUILD_QT5=ON \
    -DPYTHON_EXECUTABLE=/usr/bin/python3.7 \
    -DPYTHON_INCLUDE_DIR=/usr/include/python3.7m \
    -DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so \
    -DPYTHON_PACKAGES_PATH=/usr/local/lib/python3.7/dist-packages/ \
    ../freecad-source

sudo make -j4

According to this same thread, page 2, you already compiled FreeCAD on the Raspberry Pi 4, so I don’t understand why you are doing it again, or why you would need help again.

sudo cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3.7 ../freecad-source

sudo make -j4

In general you don’t need all the Python variables, just the executable is enough.

Also, you don’t need to run cmake, nor make with sudo. Compilation is not a system operation, it’s creating a program in a directory that you own.

Also, I told you it may be good to have a debug version, so you should have added the debug option to cmake.

cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Debug ../freecad-source
make -j3

You’re totaly right, my bad, my english is not sharp enough sometimes. I meant “The last time I compiled…”.
However I have pasted the code I used to compile last time, in case there is some obvious mistake.
I would avoid to compile again by starting with artificial errors due to my bad.


I had to do that because the path of python 3 wasn’t find by Cmake otherwise.


This is exactly the kind of advices I’m looking for and which is useful to me :slight_smile:
So, do not hesitate to tell me stuffs which seems obvious to you.
Now I have to compile again folowing your advices and those from Looo.

I mean, if you check the CompileOnUnix instructions, there is no sudo in the cmake or make commands.

Exactly, what are you trying to do? Re-compile pivy?

Ok no sudo necessary for Cmake, I will not do it. But the use of sudo was not a problem though, isn’t it?
I’m going to recompile with debug=on as you said. I would like include Freecad’s pivy as well.
I should also check soqt and Quarter as Looo said, but on this point I don’t really get what it is about… I have to learn.
I should also ask to Papy because on french forum he told that he had installed Freecad 0.16 on RPI. I would know more about that.
But now no time, tomorrow I hope.
Thanks for your attention.

Compiling with sudo may be a problem. The generated files may be owned by “root”. So, if later you want to modify them with your normal user “alex”, you may not be able to do it. This is the problem with using sudo. You

I’m going to recompile with debug=on as you said.

You don’t have to do a lot of things. You just have to do this

cmake -DBUILD_QT5=ON -DPYTHON_EXECUTABLE=/usr/bin/python3 -DCMAKE_BUILD_TYPE=Debug ../freecad-source && make -j3



I would like include Freecad’s pivy as well.

Why?

I should also check soqt and Quarter as Looo said, but on this point I don’t really get what it is about… I have to learn.

But why?!

Don’t just follow instructions without knowing what they are about!

I already told you to how to produce a debug version of FreeCAD. Try that first, and then if you need, then you can compile pivy.

Well, this way it could be tested outside of FreeCAD to see if Coin3d works as expected. But Debian should already offer the python3-pivy package that provides all needed files so that there is no point in re-compiling yourself – unless these packages of your Debian version are still broken.

Anyway, here is a Python3 example to check if it also crashes or displays the scene:

import sys

from PySide2.QtWidgets import QApplication

from pivy.coin import SoSeparator
from pivy.coin import SoBaseColor
from pivy.coin import SbColor
from pivy.coin import SoCone

from pivy.quarter import QuarterWidget

app = QApplication(sys.argv)

root = SoSeparator()
col = SoBaseColor()
col.rgb = SbColor(1, 1, 0)
root.addChild(col)
root.addChild(SoCone())

viewer = QuarterWidget()
viewer.setSceneGraph(root)

viewer.setWindowTitle("minimal")
viewer.show()
sys.exit(app.exec_())

Ok, sorry, but I had to do this:

sudo cmake -DBUILD_QT5=ON     -DPYTHON_EXECUTABLE=/usr/bin/python3.7    DCMAKE_BUILD_TYPE=Debug  -DPYTHON_INCLUDE_DIR=/usr/include/python3.7m     -DPYTHON_LIBRARY=/usr/lib/arm-linux-gnueabihf/libpython3.7m.so     -DPYTHON_PACKAGES_PATH=/usr/local/lib/python3.7/dist-packages/     ../freecad-source

(if no sudo and those compiling options I’ve got errors during cmake. Don’t ask me why, if I remember I’ve found those instructions from Freecad compile documentation page. I used it as a workaround to my troubles. I don’t paste errors here, maybe offtopic, but I could if you would).

Then sudo make (otherwise it does not compile):

sudo make -j4

However pi user has usual permission:

pi@raspberrypi:~/freecad-build/bin $ umask -S
u=rwx,g=rx,o=rx

Anyway, after 2 hours compiling:
(OFF TOPIC: For those who are interesting in performance of RPI4:
make -j4 → 100% CPU compiling during 2hours, reaching over 2Go RAM sometimes, 63°C Max with passive heatsink ,no fan, ambient temperature 28°C)

I’ve got the following callstack (similar with the one Werner mentioned above)

pi@raspberrypi:~/freecad-build/bin $ gdb ./FreeCAD
GNU gdb (Raspbian 8.2.1-2) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./FreeCAD...done.
(gdb) run
Starting program: /home/pi/freecad-build/bin/FreeCAD 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
FreeCAD 0.19, Libs: 0.19R17651 (Git)
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2019
  #####                 ####  ###   ####  
  #                    #      # #   #   # 
  #     ##  #### ####  #     #   #  #   # 
  ####  # # #  # #  #  #     #####  #   # 
  #     #   #### ####  #    #     # #   # 
  #     #   #    #     #    #     # #   #  ##  ##  ##
  #     #   #### ####   ### #     # ####   ##  ##  ##

[New Thread 0xae087210 (LWP 23883)]
using qt5ct plugin
[New Thread 0xa7fbe210 (LWP 23884)]
D-Bus global menu: no
[New Thread 0xa1814210 (LWP 23885)]
[New Thread 0xa1013210 (LWP 23886)]
[New Thread 0xa0812210 (LWP 23887)]
D-Bus system tray: no
[New Thread 0x9edff210 (LWP 23888)]
connect failed: No such file or directory
Coin warning in cc_glglue_instance(): Error when setting up the GL context. This can happen if there is no current context, or if the context has been set up incorrectly.

Thread 1 "FreeCAD" received signal SIGSEGV, Segmentation fault.
0xafcbde74 in XDefaultScreenOfDisplay () from /usr/lib/arm-linux-gnueabihf/libX11.so.6
(gdb) bt full
#0  0xafcbde74 in XDefaultScreenOfDisplay () at /usr/lib/arm-linux-gnueabihf/libX11.so.6
#1  0xb3de3ad0 in  () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#2  0xb3de4454 in glxglue_init () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#3  0xb3ddd0e0 in cc_glglue_instance () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#4  0xb3c8e120 in SoGLRenderActionP::isDirectRendering(SoState const*) const () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#5  0xb3c90358 in SoGLRenderActionP::render(SoNode*) () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#6  0xb3c905a0 in SoGLRenderAction::beginTraversal(SoNode*) () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#7  0xb3c8a2fc in SoAction::apply(SoNode*) () at /usr/lib/arm-linux-gnueabihf/libCoin.so.80c
#8  0xb60fa454 in Gui::SoBoxSelectionRenderAction::apply(SoNode*) (this=0xec9270, node=0xe63b28) at /home/pi/freecad-source/src/Gui/SoFCSelectionAction.cpp:1180
        __PRETTY_FUNCTION__ = "virtual void Gui::SoBoxSelectionRenderAction::apply(SoNode*)"
#9  0xb61e2544 in Gui::View3DInventorViewer::renderScene() (this=0xf08700) at /home/pi/freecad-source/src/Gui/View3DInventorViewer.cpp:1744
        vp = {winsize = {vec = {1650, 864}}, vporigin = {vec = {0, 0}}, vpsize = {vec = {1, 1}}, vporigin_s = {vec = {0, 0}}, vpsize_s = {vec = {1650, 864}}, pixperinch = 72}
        origin = {vec = {0, 0}}
        size = {vec = {1650, 864}}
        col = 
              {cspec = QColor::Rgb, ct = {argb = {alpha = 65535, red = 60138, green = 58853, blue = 56540, pad = 0}, ahsv = {alpha = 65535, hue = 60138, saturation = 58853, value = 56540, pad = 0}, acmyk = {alpha = 65535, cyan = 60138, magenta = 58853, yellow = 56540, black = 0}, ahsl = {alpha = 65535, hue = 60138, saturation = 58853, lightness = 56540, pad = 0}, array = {65535, 60138, 58853, 56540, 0}}}
        glra = 0xec9270
        state = 0xed7bd8
#10 0xb61e1e60 in Gui::View3DInventorViewer::actualRedraw() (this=0xf08700) at /home/pi/freecad-source/src/Gui/View3DInventorViewer.cpp:1627
#11 0xb618798c in SIM::Coin3D::Quarter::QuarterWidget::paintEvent(QPaintEvent*) (this=0xf08700, event=0xbeffcf20) at /home/pi/freecad-source/src/Gui/Quarter/QuarterWidget.cpp:922
        w = 0xf07358
        __PRETTY_FUNCTION__ = "virtual void SIM::Coin3D::Quarter::QuarterWidget::paintEvent(QPaintEvent*)"
#12 0xb6190fcc in SIM::Coin3D::Quarter::SoQTQuarterAdaptor::paintEvent(QPaintEvent*) (this=0xf08700, event=0xbeffcf20) at /home/pi/freecad-source/src/Gui/Quarter/SoQTQuarterAdaptor.cpp:717
#13 0xb30fb590 in QWidget::event(QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#14 0xb31a41bc in QFrame::event(QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#15 0xb3401118 in QGraphicsView::viewportEvent(QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#16 0xb6187b5c in SIM::Coin3D::Quarter::QuarterWidget::viewportEvent(QEvent*) (this=0xf08700, event=0xbeffcf20) at /home/pi/freecad-source/src/Gui/Quarter/QuarterWidget.cpp:996
#17 0xb2908090 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Core.so.5
#18 0xb30b8da0 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#19 0xb30c12a8 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/arm-linux-gnueabihf/libQt5Widgets.so.5
#20 0x00f07358 in  ()
(gdb) quit
A debugging session is active.

	Inferior 1 [process 23868] will be killed.

Quit anyway? (y or n) y
pi@raspberrypi:~/freecad-build/bin $

No more to say.. Any comments appreciated. Thanks for attention.

Edit: ambient temperature added about off topic informations

Thank you for the tips Werner, I’ve got a window with the scene:
2019-10-02-000018_1920x1080_scrot.png

It seems ok isn’t it? So now… any idea? :slight_smile:

It seems ok isn’t it? So now… any idea?

Does this Quarter widget show a cone? From your screenshot I cannot see that.