Ultimaker / Cura

3D printer / slicing GUI built on top of the Uranium framework
GNU Lesser General Public License v3.0
6.07k stars 2.06k forks source link

Linux Arm Support #17677

Open castlec opened 9 months ago

castlec commented 9 months ago

Is your feature request related to a problem?

In the past, the community provided arm builds for Cura. Those are now becoming quite outdated. Linux X86 is supported through app image, as are Mac x86 and Mac Arm. With larger SBCs commonly being utilized as desktop devices, Cura on Linux Arm would close a gap in that ecosystem.

Describe the solution you'd like

I'd like Linux/Arm added to the supported platforms.

Describe alternatives you've considered

I've attempted using older builds. The newest build available is 5.3.0 in Fedora. I would be interested in helping to produce the new builds; however, I have not been able to get conan based builds to complete in x86 as I haven't been able to successfully reproduce the build environment.

Affected users and/or printers

anyone using linux on arm. there are arm chromebooks and multiple SBC that are capable of running the software.

Additional information & file uploads

No response

castlec commented 8 months ago

Sharing this for the benefit of others.

I have now managed to run Cura 5.6.0 from source on jammy/armbian/aarch64/rk3588. It required the following.

I have yet to have success with app image packaging. There are multiple reasons for this.

  1. I have no idea what I'm doing
  2. Cura code assumes x86_64 all over the place, even when architecture variables are being utilized.
  3. Like Cura, AppImage itself has no aarch64 package. This means it must be used from another distribution mechanism. The best option for arm right now is pip install appimage-builder. It seems like using the python distribution rather than the .AppImage distribution will meet the needs of the system generically and relieve the CI of some of the funny embedded bashery. Use export APPIMAGEBUILDER_LOCATION in environment to utilize different install location.
  4. AppImage tries to ensure the newest dependencies are available. This breaks on armbian because it doesn't follow their required PEP 440. I'm not sure if this is their requirement or something that's coming in from stdlib but it's broken on armbian nonetheless due to the way armbian denotes origin of packages. . I had to open appimagebuilder/modules/deploy/apt/package.py to fux the version comparisons. A dumb replace of the string ubuntu made this work.
  5. After these changes, I have a package built. It doesn't work though. See 1.

I was hoping to be able to post an appimage build for others to test but that's not going to happen for a while as it stands. Maybe tomorrow's adventures will bring something forward there.

Now that I understand enough of what's going on, I may try to find success with a cross compile. That seems like it's the best way to have arm packages in the existing github actions based CI system. Regardless, distribution needs to be figured out whether it exists as a fork or as a main Cura distribution.

miikasyvanen commented 2 months ago

Hi!

Can you put some details about building cura?

I have tried several times to build cura but failed to get it running. I would like to use 5+ version as now I'm using 4.13...

Thanks, Miika

castlec commented 2 months ago

I'm away from home for the next three weeks so I can't go pull more information for you.

Here's what I can tell you:

I think that's all of it.

If you want to post up a build log, I can have a look at it.

makershopfi commented 2 months ago

Thanks for the quick reply!

I think my biggest problem is installing Qt. I have managed to build Cura but when I run it, it complains about missing Qt packages. Do you remember from where you downloaded the sources and how did you exactly build them? Should it done in venv or just system wide etc.?

castlec commented 2 months ago

Find your dependency version here. https://download.qt.io/archive/qt/

Be sure to read about configuration options. That will help you ensure you're not missing packages. https://doc.qt.io/qt-6/configure-options.html

miikasyvanen commented 2 months ago

Building Cura

Ok, today managed to build Cura 5.7.0 on Orange Pi 5 Pro 16GB board running Ubuntu Jammy (Orange Pi OS version). Here are the steps that I did, some might be unnecessary but these should get build complete and Cura running.

In this build Cura git clone is made in ~/Development so build dir is ~/Development/Cura and Qt6 is installed in /opt/Qt (Online installer needs to run with sudo)

Python and pip version used in build

Install Qt6 binaries with online installer. I used Qt 6.7.0 in this install.

https://www.qt.io/download-qt-installer-oss

At least under additional libraries all should be checked.

Install and configure Conan

pip install conan==1.64
conan config install https://github.com/ultimaker/conan-config.git
conan profile new default --detect --force

In .conan/conan.conf change level-option in [log]-section, this helps to see when build will wait for license input. If not stopped, it stays there waiting forever and consumes all RAM and in the end, your machines is not responsive anymore.

[log]
run_to_output = True        # environment CONAN_LOG_RUN_TO_OUTPUT
run_to_file = False         # environment CONAN_LOG_RUN_TO_FILE
level = 10                # environment CONAN_LOGGING_LEVEL, default is warn
print_run_commands = True   # environment CONAN_PRINT_RUN_COMMANDS

Clone Cura

git clone https://github.com/Ultimaker/Cura.git
cd Cura

Add Qt install path to PATH and set makeflags to compile with all processors to speed up build (optional)

export PATH=/opt/Qt/6.7.0/gcc_arm64/bin:/opt/Qt/6.7.0/gcc_arm64/lib:$PATH
export MAKEFLAGS="-j$(nproc)"

Start build and initialize the Virtual Python Development Environment

conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv

Once build hangs on PyQt6 license checking, stop building with 'Ctrl+C'

Upgrade Pip

~/Development/Cura/venv/bin/python -m pip install --upgrade pip

Install PyQt6

First, remove/comment out all PyQt6 modules except PyQt6 itself and PyQt6-sip from Cura and Uranium requirements.txt files

~/Development/Cura/requirements.txt
find ~/.conan/ -name requirements.txt # I have this at path ~/.conan/data/uranium/5.7.0/_/_/package/e541e632dd3ca870d37dab822cdf6eaa3df15dca/pip_requirements/requirements.txt

Change PyQt6==6.6.0 to PyQt6==6.7.0 and change in both files hash to

    --hash=sha256:3d31b2c59dc378ee26e16586d9469842483588142fc377280aad22aaf2fa6235

Remove possible Qt files from venv

sudo rm -r venv/lib/python3.10/site-packages/PyQt6*

Purge pip cache

~/Development/Cura/venv/bin/pip cache purge

Install PyQt6==6.7.0

~/Development/Cura/venv/bin/pip install PyQt6==6.7.0 --force-reinstall --config-settings --confirm-license= --verbose

Restart conan build

conan install . --build=missing --update -o cura:devtools=True -g VirtualPythonEnv

Activate the Virtual Python Environment

source venv/bin/activate

Run Cura

python cura_app.py
miikasyvanen commented 2 months ago

Building Cura AppImage after building Cura using above instructions

Tested with:

Build Ultimaker-Cura folder with all necessary files for standalone use

cd ~/Development/Cura
pyinstaller venv/conan/UltiMaker-Cura.spec

If you get error message about Qt5 you need to exclude it in 'Analysis' section in the end of UltiMaker-Cura.spec-file

excludes=['PyQt5'],

PyInstaller will create folder 'dist/UltiMaker-Cura' where all files will be. Now you can test if it is working

dist/UltiMaker-Cura/UltiMaker-Cura

Next we need also to add cura.desktop-file and cura-icon.png before building AppImage.

Download appimagetool for aarch64

cd dist/
wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-aarch64.AppImage

Copy cura icon

cp ~/Development/Cura/resources/images/cura-icon.png UltiMaker-Cura/

Create desktop entry

nano UltiMaker-Cura/cura.desktop
[Desktop Entry]
Name=UltiMaker Cura
Name[de]=UltiMaker Cura
GenericName=3D Printing Software
GenericName[de]=3D-Druck-Software
GenericName[nl]=3D-Print Software
Comment=Cura converts 3D models into paths for a 3D printer. It prepares your print for maximum accuracy, minimum printing time and good reliability with many extra features that make your print come out great.
Exec=UltiMaker-Cura %F
Icon=cura-icon
Terminal=false
Type=Application
MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png;text/x-gcode;application/x-amf;application/x-ply;application/x-ctm;model/vnd.collada+xml;model/gltf-binary;model/gltf+json;model/vnd.collada+xml+zip;
Categories=Graphics;
Keywords=3D;Printing;
X-AppImage-Version=5.7.0
Path=
StartupNotify=false

Create AppRun link to point UltiMaker-Cura executable

ln -sf UltiMaker-Cura/UltiMaker-Cura UltiMaker-Cura/AppRun

Build AppImage

ARCH=aarch64 ./appimagetool-aarch64.AppImage UltiMaker-Cura

That's it! Now you can copy/move AppImage to somewhere and use .desktop file to launch AppImage!

Don't forget to change line 'Exec=UltiMaker-Cura %F' in .desktop file to point to your AppImage!