Skip to content

Instantly share code, notes, and snippets.

@terasakisatoshi
Created October 9, 2020 08:40
Show Gist options
  • Save terasakisatoshi/8a95eb8b676a29ad3f5fe4a717ff3254 to your computer and use it in GitHub Desktop.
Save terasakisatoshi/8a95eb8b676a29ad3f5fe4a717ff3254 to your computer and use it in GitHub Desktop.
Script to Build Julia locally for RaspberryPi4
#! /bin/bash
# Usage:
# 1. Copy this file to your raspberry pi e.g. /home/pi
# 2. Run this file `bash build_locally.sh`
# 3. Tested on Raspberry Pi4 with 4 or 8 GB
sudo apt-get update && sudo apt-get install -y \
build-essential libatomic1 python gfortran perl wget m4 cmake pkg-config \
nghttp2 libmbedtls-dev \
git
JL_VERSION=master
JL_BUILD_DIR=build-julia-${JL_VERSION}
# get JL_COMMIT_HASH via `git rev-parse --short HEAD`
JL_COMMIT_HASH=8987f7ac6d
JL_BUILD_DIR=build-julia-${JL_VERSION}-${JL_COMMIT_HASH}
git clone https://github.com/JuliaLang/julia.git $JL_BUILD_DIR && \
cd ${JL_BUILD_DIR} && git checkout ${JL_COMMIT_HASH} && cd ..
cat > ${JL_BUILD_DIR}/Make.user << EOF
CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0
prefix=/home/pi/julia-${JL_VERSION}-${JL_COMMIT_HASH}
USE_BINARYBUILDER=0
LDFLAGS=-latomic
CFLAGS += "-mfpu=neon-vfpv4"
CXXFLAGS += "-mfpu=neon-vfpv4"
MARCH="armv7-a"
JULIA_CPU_TARGET="armv7-a\;armv7-a,neon\;armv7-a,neon,vfp4"
USE_SYSTEM_NGHTTP2=1
USE_SYSTEM_MBEDTLS=1
EOF
cd ${JL_BUILD_DIR} && make -j `nproc` && sudo make install && cd ..
@terasakisatoshi
Copy link
Author

Hi Greg, thank you for your feedback!

I'm a big fan of JuliaLang and I would love to get it working on my Raspberry Pi
Good to know!!! I hope you can make it.

Maybe our script build_locally.sh is too old in 2021 😭 . BTW have you tried https://gist.github.com/terasakisatoshi/8a95eb8b676a29ad3f5fe4a717ff3254#gistcomment-3696889 ?

or build julia on current master ?

we do not have to set USE_BINARYBUILDER=0, which makes rpi4 build julia from scratch including its dependencies.

Here is what I did note that lines including # are comment

# try it on your Raspberry Pi
$ git clone https://github.com/JuliaLang/julia.git
$ cd julia
$ git checkout  d29126a43e
# `git rev-parse HEAD` should be
# d29126a43ee289fc5ab8fcb3dc0e03f514605950
# create `Make.user` as follows
MARCH=armv7-a
LDFLAGS=-latomic
# then, just do it
$ cat Make.user
MARCH=armv7-a
LDFLAGS=-latomic
$ julia -j4 
$ ./julia # good luck.

image

@terasakisatoshi
Copy link
Author

@GregMc, how is it going ?

@GregMc
Copy link

GregMc commented Apr 20, 2021

Hi Terasakisatoshi ,

You haven't heard from me - because I haven't managed to get a version of Julia later than 1.0.6 onto my RaspberryPi4. I have tried 'Make' and 'Build' and both get stuck at different stages. Basically I don't know enough about the process to make informed decisions. For example - Once a 'make' fails - do I need to delete the destination directory and re-run it with different settings - Or is there more screwed up elsewhere that once it has failed - only I new Raspbian Image will restore the situation. It is those sorts of questions that I am grabbling with at the moment.

Thanks for your help and interest.

cheers

Greg, Liverpool

@terasakisatoshi
Copy link
Author

Have you seen jlcross project ?

https://github.com/Julia-Embedded/jlcross

@GregMc
Copy link

GregMc commented Apr 22, 2021

Thanks Terasakisatoshi , I've had a look and it looks very interesting - I haven't yet had a chance to try any of the stuff.

Once a 'make' or a 'build' fails - where can I restart the process from - Am I having to reflash a SD Card every time, OR can I just delete the directories I can see - and try again. I think that's my biggest problem.

Cheers for your help

Greg, Liverpool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment