|
| 1 | +# Running PowerShell Core 6 on a Raspberry-Pi |
| 2 | + |
| 3 | +## Setup your Pi |
| 4 | + |
| 5 | +Note that CoreCLR (and thus PowerShell Core) will only work on Pi 2 and Pi 3 devices as other devices |
| 6 | +like [Pi Zero](https://github.com/dotnet/coreclr/issues/10605) have an unsupported processor. |
| 7 | + |
| 8 | +Download [Raspbian](https://www.raspberrypi.org/downloads/raspbian/) and follow the [installation instructions](https://www.raspberrypi.org/documentation/installation/installing-images/README.md) to get it onto your Pi. |
| 9 | + |
| 10 | +Once your Pi is up and running, [enable SSH remoting](https://www.raspberrypi.org/documentation/remote-access/ssh/). |
| 11 | + |
| 12 | +## Building PowerShell Core 6 for arm32 |
| 13 | + |
| 14 | +We'll need to cross-compile for the Linux arm32 architecture from Ubuntu. |
| 15 | + |
| 16 | +Follow the [Linux instructions to Build PowerShell](https://github.com/PowerShell/PowerShell/blob/master/docs/building/linux.md). |
| 17 | + |
| 18 | +Once your environment is working, you'll need to setup the toolchain for cross compilation: |
| 19 | + |
| 20 | +```powershell |
| 21 | +Start-PSBootstrap -BuildLinuxArm |
| 22 | +``` |
| 23 | + |
| 24 | +You can now build PowerShell Core: |
| 25 | + |
| 26 | +```powershell |
| 27 | +Start-PSBuild -Clean -Runtime linux-arm -PSModuleRestore |
| 28 | +``` |
| 29 | + |
| 30 | +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. |
| 31 | + |
| 32 | +## Copy the bits to your Pi |
| 33 | + |
| 34 | +Use SSH to copy the bits remotely, replace `yourPi` with the name or IP address of your Pi. |
| 35 | + |
| 36 | +```powershell |
| 37 | +scp -r "$(split-path (Get-PSOutput))/*" pi@yourPi:/home/pi/powershell |
| 38 | +``` |
| 39 | + |
| 40 | +## Get latest CoreCLR runtime |
| 41 | + |
| 42 | +We need to get a CoreCLR that fixes a [threading bug](https://github.com/dotnet/coreclr/pull/13922) which is in DotNetCore 2.0.0. |
| 43 | + |
| 44 | +You can do these steps locally on your Pi, but we're using SSH remoting here. |
| 45 | + |
| 46 | +We'll be using the latest [build](https://github.com/dotnet/core-setup#daily-builds) from master which has the fix. |
| 47 | +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. |
| 48 | + |
| 49 | +We'll use `curl` to get the latest DotNetCore runtime. |
| 50 | + |
| 51 | +```bash |
| 52 | +sudo apt install curl |
| 53 | +``` |
| 54 | + |
| 55 | +Now we'll download it and unpack it. |
| 56 | + |
| 57 | +```bash |
| 58 | +# Connect to your Pi. |
| 59 | +ssh pi@yourpi |
| 60 | +# We'll make a folder to put latest CoreCLR runtime. |
| 61 | +mkdir dotnet |
| 62 | +cd dotnet |
| 63 | +# Download the latest CoreCLR runtime. |
| 64 | +curl -O https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master/dotnet-runtime-latest-linux-arm.tar.gz |
| 65 | +# Unpack it. |
| 66 | +tar xvf ./dotnet-runtime-latest-linux-arm.tar.gz |
| 67 | +# We're going to overwrite the CoreCLR bits we built with newer ones, replace the version named folder below as appropriate. |
| 68 | +# 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. |
| 69 | +cp shared/Microsoft.NetCore.App/2.1.0-preview1-25719-04/* ~/powershell |
| 70 | +``` |
| 71 | + |
| 72 | +## Start PowerShell |
| 73 | + |
| 74 | +```bash |
| 75 | +~/powershell/powershell |
| 76 | +``` |
| 77 | + |
| 78 | +Note that until arm32 is [fully supported by CoreCLR](https://github.com/dotnet/coreclr/issues/3977), it's not supported by PowerShell Core. |
0 commit comments