Skip to content

Instantly share code, notes, and snippets.

Created Aug 23, 2016
What would you like to do?
Swift on Pi 3


Install Ubuntu on microSD card

  • Download image from

  • Check Disk Utility for device

  • Unmount card's filesystem, if mounted

  • Copy to card:

    xzcat ubuntu-16.04-preinstalled-server-armhf+raspi3.img.xz | sudo dd bs=32m of=/dev/rdiskN

  • Eject card an put it in your Pi 3

Boot and update Pi 3

  • Boot the pi and log in with user ubuntu, password ubuntu

  • Change the ubuntu password (automatically forced on first log in).

  • Reboot

  • Log in remotely

    • ifconfig -a to get the eth0 address since ubuntu.local didn't work out of the box.
    • ssh ubuntu@ or whatever.
  • Update:

    sudo apt-get update && sudo apt-get upgrade -y reboot

  • At least as of 2016-08-18, at this point the Pi 3 will have non-functioning ethernet due to Suggestion on Swift Pi Slack is to edit /etc/network/interfaces.d/50-cloud-ini.cfg to match the actual name.

    nano /etc/network/interfaces.d/50-cloud-ini.cfg

    perform the edits, save and exit


  • Install a mDNS server

    sudo apt-get install avahi-daemon

  • Log out from the console, turn off monitor and ssh in from Mac:

    ssh ubuntu@ubuntu.local

  • Install personal ssh public key (.ssh doesn't exist, ssh localhost to get it created with right permissions)

    $HOME/.ssh may not exist so use ssh to create it with correct permissions (don't actually need to complete connection)

    ssh localhost vi .ssh/authorized_keys

    Append your public key from your Mac

  • Install prerequisites:

    sudo apt-get install -y git cmake ninja-build clang uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config

  • Install htop for fun monitoring builds

    sudo apt-get install htop

  • Install screen to be able to disconnect from a running build:

    sudo apt-get install screen

Configure Swap Space

  • Configure the swap file:

    sudo -s cd ~root fallocate -l 1G 1G.swap chmod 0600 1G.swap mkswap 1G.swap swapon 1G.swap exit

Prevent multiple concurrent invocations of the linker

  • Install a helper script

    sudo -s
    nano /usr/local/bin/exec-once

    Paste in the following (w/o leading whitespace):


    There should be a link from a command to this script and the real command should have a ".real" suffix.

    REAL_CMD="$0.real" LOCK_DIR="$HOME/locks" LOCK_FILE="$LOCK_DIR/$(basename $0)"

    mkdir -p "$LOCK_DIR" echo "Using lock file $LOCK_FILE..."

    flock "$LOCK_FILE" "$REAL_CMD" "$@"

    ^O ^X

    chmod ugo+x /usr/local/bin/exec-once

  • Set up to use the helper script. This will break updating dev tools likely...

    mv /usr/bin/ /usr/bin/ ln -s /usr/local/bin/exec-once /usr/bin/ exit

Check out package-swift

Manually patch


  • Build with nohup or screen:

    nohup ./ > swiftbuild.log&


    screen ./ |& tee swiftbuild.log

SPI support

  • SPI is enabled by default in Ubuntu


  • But, you need to run as root to access it.


  • Use external swap on USB stick again? which is faster, microSD swap or USB?

    • Probably not an issue; with exec-once wrapper Swap is barely used
  • Get wireless working

    sudo apt-get install wireless-tools ... configure interface ... sudo reboot

  • change host name

  • enable SPI?

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