Install Wolfram Mathematica on Raspberry Pi 4

Disclaimer: I am running Arch Linux ARM. However, as Manjaro is derived from Arch and the community here tends to be more active, I hope you will allow me to post my question.

Dear Manjaro ARM Community,

Im currently trying to install Wolfram Mathematica on my Raspberry Pi 4. All packages and the firmware on my device are up-to-date, and I am running the latest available 64bit RPI kernel:

$ uname -a
Linux alarm 5.15.45-2-rpi-ARCH #1 SMP PREEMPT Wed Jun 8 05:59:13 MDT 2022 aarch64 GNU/Linux

The problem lies in the fact that Mathematica is only available as an armhf binary; this no problem on Raspberry Pi OS, since it includes the necessary multilib libraries, but it is obviously a show stopper on arm64 Arch/Manjaro.

After some research, I decided on a Debian Bullseye armhf chroot as the easiest method to run Mathematica. I set up the environment following the steps below.

Step 1 (Bootstrap, according to this Pine64 forum thread; executed as root):

mkdir /debian-armhf
debootstrap --arch armhf bullseye /debian-armhf
for f in {proc,sys,dev}; do sudo mount --bind /${f} /debian-armhf/${f}; done

Step 2 (Chroot into Debian FS):

chroot /debian-armhf su -

Step 3 (Install wget, download the official Mathematica installer script, and run it):

apt install wget
wget https://wolfr.am/wolfram-engine-raspi-install
chmod +x wolfram-engine-raspi-install && ./wolfram-engine-raspi-install

Step 4 (Install two missing dependencies that are not pulled in automatically):

apt install libatomic1 libgl1

Step 5 (Final step; enable X server access from chroot):

On host system:

xhost +local:

In chroot:

export DISPLAY=:0

When I test the above chroot setup with xclock (part of the x11-apps group in Debian), the program runs as expected. Running mathematica however ends with “Illegal instruction (core dumped)”. Clearly there is something amiss with the binary, but I am not sure how to investigate this problem. Therefore, this is where I would kindly like to ask for your assistance.

And needless to say: if you need any additional information, just let me know!

1 Like

I can understand the desire to run Manjaro but when it comes to Raspberry Pi specific apps - it is most convenient to run the Raspberry Pi OS.

Especially an app like Wolfram which to my knowledge is a paid software and licensed specifically to Raspberry Pi foundation for use with Raspberry Pi OS.

While 64-bit Raspberry Pi OS is available - the recommended OS is still the 32-bit edition and this is what you get when installing using the noobs installer.

So even you have setup a Debian chroot - the chroot still runs atop of a 64-bit Arch kernel and this may be why the app is stalling - the app makes assumptions on the environment which is invalid - the specific instruction is most likely targeting another ABI and fixing such issue is hard if not impossible.

1 Like

For runnig a external architecture inside a arm64 you need to use things like box64, docker or schroot. I don’t know about docker and the pro and cons but first stage to use a schroot is qemu-user-static.
It will be interesting if you schroot piOS because we can test chromium widevine.

Dear linux-aarhus and tartanpion,

Thank you both for your reply.

At least for now, I’d still like to try running Mathematica on Arch/Manjaro. Of course linux-aarhus is right in saying that armhf still is the default flavor of Raspberry Pi OS. However, as Mathematica also runs on the 64bit version of the OS, clearly the kernel (note that we too use the Raspberry Pi kernel on Arch/Manjaro) is no issue so long as the necessary multilib parts are present.
That said, I think my next try will be to debootstrap the arm64 flavor of RPi OS. This should (hopefully) yield kernel-compatible userspace libraries, and should include the required multilib parts.

Regarding tartanpion’s suggestion: As implied in my setup, I really hope to avoid the virtualization route. Since we have the Raspberry Pi OS kernel, and 64bit RPiOS runs 32bit binaries just fine, I still have some hope for the chroot approach.

P.S. Architecture compatibility really shouldn’t be that much of an issue, as for example demonstrated on Kali Linux here.

Let’s us known if it’s working because arch/manjaro is not multiarch contrary to debian (kali) with armf/arm64 package…

I don’t know if it works or not, but you can try using this PKGBUILD. Found it by searching for mathematica aarch64.

https://git.kent-dobias.com/system/PKGBUILDs/wolfram-engine-aarch64/tree/

Dear Strit,

Thanks for the pointer! The PKGBUILD you have shared comes with a corresponding blog post, explaining how to get Mathematica running on the Pinebook Pro. The author’s approach is, in a nutshell, to pacstrap a base armhf Arch install which subsequently serves as the source of armhf libraries required by Mathematica. Conceptually, this “multilib” approach is almost the same as the chroot one.

Due to the convenience of using Arch packages, I will next try to adapt the author’s instructions to the latest version of Mathematica. Should that fail, I will return again to the chroot approach.

In either case, the author points out that the (64bit) kernel must be compiled with CONFIG_ARMV8_DEPRECATED=y for some necessary commands to be available. This is currently not the case for linux-rpi, so I will also have to compile a new kernel.

The overall best solution would be to get Wolfram to release Mathematica for arm64/aarch64 too. And maybe they will, when Raspberry Pi OS goes to 64-bit by default.

Agreed. But until then, I shall use this situation as a pretext to improve my Linux/Arch/ARM skills.

I am confused what you are doing. Our linux-rpi4 kernel has all of those modules enable. Also I hope you are not using the armv6 image mentioned in the post as arch-arm dropped support for it.

ADDED:

I just saw your Disclaimer in the OP.

Success:

I have adapted the steps in this blog post as follows:

  1. Create an armhf “multilib” setup (make sure the folder /armv7h exists, armv7h is the architecture set in /tmp/pacman.conf, and - for the Manjaro community - you point to an ArchLinux ARM mirror):
pacstrap -C /tmp/pacman.conf /armv7h base fontconfig glu libpng pixman portaudio qt5-base
  1. Install the packages armv7h-libs, wolfram-engine-aarch64, and wolframscript-aarch64 (PKGBUILDs are provided here.)

  2. Run mathematica and enjoy your symbolic calculus.

Note: Owing to Darksky’s comment, I have temporarily installed the linux-rpi4 kernel from Manjaro; I plan to build a custom kernel with only CONFIG_ARMV8_DEPRECATED=y enabled soon.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.