PowerShell/demos/Raspberry-Pi
2017-09-23 16:38:27 -07:00
..
README.md instructions to demo PowerShell Core on Raspbian (#4882) 2017-09-23 16:38:27 -07:00

Running PowerShell Core 6 on a Raspberry-Pi

Setup your Pi

Note that CoreCLR (and thus PowerShell Core) will only work on Pi 2 and Pi 3 devices as other devices like Pi Zero have an unsupported processor.

Download Raspbian and follow the installation instructions to get it onto your Pi.

Once your Pi is up and running, enable SSH remoting.

Building PowerShell Core 6 for arm32

We'll need to cross-compile for the Linux arm32 architecture from Ubuntu.

Follow the Linux instructions to Build PowerShell.

Once your environment is working, you'll need to setup the toolchain for cross compilation:

Start-PSBootstrap -BuildLinuxArm

You can now build PowerShell Core:

Start-PSBuild -Clean -Runtime linux-arm -PSModuleRestore

Note that it's important to do a -Clean build because if you previously built for Ubuntu, it won't try to rebuild the native library pslnative for arm32.

Copy the bits to your Pi

Use SSH to copy the bits remotely, replace yourPi with the name or IP address of your Pi.

scp -r "$(split-path (Get-PSOutput))/*" pi@yourPi:/home/pi/powershell

Get latest CoreCLR runtime

We need to get a CoreCLR that fixes a threading bug which is in DotNetCore 2.0.0.

You can do these steps locally on your Pi, but we're using SSH remoting here.

We'll be using the latest build from master which has the fix. Note that at the time of authoring these instructions, the 2.0.x servicing build didn't have the necessary fix and the 2.1.x builds may be more unstable.

We'll use curl to get the latest DotNetCore runtime.

sudo apt install curl

Now we'll download it and unpack it.

# Connect to your Pi.
ssh pi@yourpi
# We'll make a folder to put latest CoreCLR runtime.
mkdir dotnet
cd dotnet
# Download the latest CoreCLR runtime.
curl -O https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master/dotnet-runtime-latest-linux-arm.tar.gz
# Unpack it.
tar xvf ./dotnet-runtime-latest-linux-arm.tar.gz
# We're going to overwrite the CoreCLR bits we built with newer ones, replace the version named folder below as appropriate.
# If you build a newer version of PowerShell Core, you'll need to make sure you get latest CoreCLR runtime otherwise you may hit a segmentation fault.
cp shared/Microsoft.NetCore.App/2.1.0-preview1-25719-04/* ~/powershell

Start PowerShell

~/powershell/powershell

Note that until arm32 is fully supported by CoreCLR, it's not supported by PowerShell Core.