Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspbian support #447

Closed
TVoc opened this issue Jan 24, 2017 · 54 comments
Closed

Raspbian support #447

TVoc opened this issue Jan 24, 2017 · 54 comments

Comments

@TVoc
Copy link

TVoc commented Jan 24, 2017

I am waiting for a working build of dotnet for the Raspberry Pi. Currently, this page links to builds targeted to Ubuntu, but my Raspberry Pi is running Raspbian and installing Ubuntu specifically for this would be a major inconvenience. I would therefore like to know if there are plans to support Raspbian in the future.

@TVoc
Copy link
Author

TVoc commented Jan 27, 2017

As an addendum, when I run dotnet.bootstrap.py as outlined here, this is the result:

pi@raspberrypi:~/src/core/tools/dotnet-bootstrap $ ./dotnet.bootstrap.py
** ROVER Building: ['coreclr', 'corefx', 'core-setup', 'libuv']
** ROVER Patching? True
** ROVER Staging in raspbian.8-x64-dotnet
** ROVER RID: raspbian.8-x64
** ROVER is downloading latest .NET CLI for bootstrapping (dotnet.latest.tar.gz)
** ROVER CAUGHT AN UNEXPECTED EXCEPTION: "SemanticVersion instance has no attribute 'find'" of type: <type 'exceptions.AttributeError'>
  File "./dotnet.bootstrap.py", line 545, in <module>
    SpawnPatchTarget(RoverSettings._binDirectory, RoverSettings.PayloadPath)
  File "./dotnet.bootstrap.py", line 342, in SpawnPatchTarget
    RoverSettings.SetPatchTargetPath(path.join(RoverSettings._ScriptDirectory, destination_folder))
  File "./dotnet.bootstrap.py", line 261, in SetPatchTargetPath
    RoverSettings.PatchTarget_Shared   = path.join(shared_containerFolder, RoverSettings.SelectGreatestPrecendenceDirectory(shared_containerFolder))
  File "./dotnet.bootstrap.py", line 248, in SelectGreatestPrecendenceDirectory
    maxVersion = RoverSettings.MaxPrecedence(dirName, maxVersion)
  File "./dotnet.bootstrap.py", line 234, in MaxPrecedence
    versionB = SemanticVersion(versionStrB)
  File "./dotnet.bootstrap.py", line 156, in __init__
    self.VersionTuple = self.GetVersionTuple(versionStr)
  File "./dotnet.bootstrap.py", line 141, in GetVersionTuple
    middleIndex = versionStr.find('-')
** ROVER None

@perlun
Copy link
Contributor

perlun commented Jan 28, 2017

This would be very, very nice! .NET core is already a great piece of software, being able to use it on my Raspberry Pi(s) would be even greater. Raspbian is a much more natural and popular choice there, so adding support for it should be considered.

@Petermarcu
Copy link
Member

So far, we've only built in on Ubuntu and it worked great on a Raspberry Pi. I expect we will shortly be able to have something that will work on Raspian too.

@TVoc
Copy link
Author

TVoc commented Feb 27, 2017

I compiled it on my Raspberry Pi, but there were some things I did differently:

  • edited dotnet.bootstrap.py as follows:
diff --git a/tools/dotnet-bootstrap/dotnet.bootstrap.py b/tools/dotnet-bootstrap/dotnet.bootstrap.py
index 92749bc..1093c40 100755
--- a/tools/dotnet-bootstrap/dotnet.bootstrap.py
+++ b/tools/dotnet-bootstrap/dotnet.bootstrap.py
@@ -382,21 +382,22 @@ def BuildNativeComponents(  coreclr_git_directory,
         # Build CoreCLR
         # skipping non-essential for bootstrapping.
         if 'coreclr' in RoverSettings.BuildSet:
-            RoverShellCall('./build.sh x64 release skiptests skipnuget', cwd=coreclr_git_directory)
+            #RoverShellCall('./build.sh x64 release skiptests skipnuget', cwd=coreclr_git_directory)
+            RoverShellCall('./build.sh arm release skiptests skipnuget skipmscorlib clang3.7', cwd=coreclr_git_directory)
 
         # Build CoreFX Native Pieces
         if 'corefx' in RoverSettings.BuildSet:
             # at different points in the history of CoreFX there have been differing build behaviors, these conditionals
             # cover that. However, if we find these differences, we will need to adapt.s
             if path.exists(path.join(corefx_git_directory, 'src', 'Native', 'build-native.sh')):
-                RoverShellCall('./build-native.sh x64 release Linux --numProc 1', cwd="%s/src/Native"%(corefx_git_directory))
+                RoverShellCall('./build-native.sh arm release Linux --numProc 1', cwd="%s/src/Native"%(corefx_git_directory))
             else:
-                RoverShellCall('./build.sh native x64 release', cwd=corefx_git_directory) 
+                RoverShellCall('./build.sh native arm release', cwd=corefx_git_directory) 
 
         # Build corehost from core-setup
         # TODO: Pull versions from the runtimes.
         if 'core-setup' in RoverSettings.BuildSet:
-            RoverShellCall('./build.sh --arch x64 --rid %s --hostver 0.0.0 --fxrver 0.0.0 --policyver 0.0.0 --commithash %s'%(RoverSettings._Rid, RoverSettings.DotNetCommitHash), cwd="%s/src/corehost"%(core_setup_git_directory))
+            RoverShellCall('./build.sh --arch arm --rid %s --hostver 0.0.0 --fxrver 0.0.0 --policyver 0.0.0 --commithash %s'%(RoverSettings._Rid, RoverSettings.DotNetCommitHash), cwd="%s/src/corehost"%(core_setup_git_directory))
 
         # Build libUV
         if 'libuv' in RoverSettings.BuildSet:
@@ -502,8 +503,8 @@ if __name__ == "__main__":
     core_setup_working_git_directory    = path.join(RoverSettings._srcDirectory, 'core-setup')
     libuv_working_git_directory         = path.join(RoverSettings._srcDirectory, 'libuv')
 
-    default_coreclr_bin_directory       = '%s/bin/Product/Linux.x64.Release/'%(coreclr_working_git_directory)
-    default_corefx_native_bin_directory = '%s/bin/Linux.x64.Release/Native'%(corefx_working_git_directory)
+    default_coreclr_bin_directory       = '%s/bin/Product/Linux.arm.Release/'%(coreclr_working_git_directory)
+    default_corefx_native_bin_directory = '%s/bin/Linux.arm.Release/Native'%(corefx_working_git_directory)
     default_core_setup_cli_bin_directory= '%s/src/corehost/cli'%(core_setup_working_git_directory)
     default_libuv_bin_directory         = '%s/.libs'%(libuv_working_git_directory)
  • edited build files for CoreCLR to support clang 3.7/lldb 3.7, like here
  • downloaded latest release for Debian (from here) to use as payload
  • ran dotnet.bootstrap.py with ./dotnet.bootstrap.py -b coreclr corefx core-setup libuv -payload dotnet.tar.gz (with dotnet.tar.gz the archive I mentioned in the previous step)

When I run ./dotnet --version in /core/tools/dotnet-bootstrap/raspbian.8-x64-dotnet/bin, the result is Failed to initialize CoreCLR, HRESULT: 0x80004005

Does anyone have an idea of what I did wrong?

@Petermarcu
Copy link
Member

@janvorli @gkhanna79

@Petermarcu
Copy link
Member

We're going to be changing some things such that we build linux binaries for ARM that will work on many different distros. That will address this.

@Lewiscowles1986
Copy link

Does anyone know if this could work in a dockerised ubuntu on raspbian? Build the container, send to dockerhub, cuts down drastically on the commands needed to run.

@moozoo64
Copy link

I just wanted to add that there are 11+ million raspberry pi's sold. Most of which will be running Raspbian.
"The Raspberry Pi Foundation sells about 350,000 to 400,000 units a month"
From http://www.belfasttelegraph.co.uk/business/news/raspberry-pi-sales-hit-11-million-and-could-overtake-commodore-64-35245709.html

I'd also like to see dotnet core support aarch64 (suse, debian stretch) on the raspberry pi 3+

@kmleow
Copy link

kmleow commented Apr 1, 2017

@Petermarcu on documentation, it says Ubuntu 16.04 is supported. Is this the Ubuntu Core or Ubuntu MATE?

@Petermarcu
Copy link
Member

Petermarcu commented Apr 1, 2017

@kmleow it should work on either.

@valeriob
Copy link

valeriob commented Apr 3, 2017

I've been following the guide here https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md with .net core 2.0.0-beta-001834-00 i published the app, but it does not generate an executable with the name of the project, the folder contains instead an "apphost" elf. When i run it it says :
"root@ubuntu:/home/ubuntu/dev/publish# ./apphost
This executable is not bound to a managed DLL to execute. The binding value is: 'c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2'
A fatal error was encountered. This executable was not bound to load a managed DLL.
"

@Petermarcu
Copy link
Member

@valeriob - can you confirm what info you get on the development machine when you run dotnet --version?

Can you also share the contents of your project?

@valeriob
Copy link

valeriob commented Apr 5, 2017

Thanks @Petermarcu you nailed it !! 💃
I was confused by the version of the shared framework host !
I did the same thing with a AspNet Core app with the same procedure, but it did not produce an executable, however it works running "dotnet mywebapp.dll".

image

@Petermarcu
Copy link
Member

If you get the latest 2.0 sdk as a zip, extract it somewhere and call that version of dotnet for your commands, do you get a different result. That will make sure you are getting the 2.0 sdk.

@shripathi-kamath
Copy link

Any update on when .NET Core and ASP.NET Core will be available on Raspbian?

@Petermarcu
Copy link
Member

It should work. Go ahead and try the instructions at https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md and let us know if you hit any problems.

@shripathi-kamath
Copy link

Thank you, the instructions say Linux, and not Raspbian (specifically), which is why I wanted to make sure, given that the thread above hints that it may not run on Raspbian.

@TVoc
Copy link
Author

TVoc commented May 22, 2017

Where exactly do we need to go to get a working dotnet runtime binary? Or do we need to build it ourselves?

@perlun
Copy link
Contributor

perlun commented May 22, 2017

Or do we need to build it ourselves?

I think that's the current status. @Petermarcu, is there any chance Raspbian could get added eventually as an official target with prebuilt packages?

@Tealons
Copy link

Tealons commented May 25, 2017

I followed the instructions and got it working with Raspbian. I think Raspbian is preferred over Ubuntu, because Ubuntu has a major bug with respect to the Raspberry Pi 3:
https://stackoverflow.com/questions/41353092/ubuntu-freezes-after-boot-starting-kernel-raspberry-pi-3
https://bugs.launchpad.net/ubuntu/+source/linux-raspi2/+bug/1652270

@TVoc
Copy link
Author

TVoc commented May 25, 2017

@Tealons If I may ask, how did you accomplish this? Coreclr fails to build on my Raspberry Pi 3 when I try to build dotnet on it.

@Tealons
Copy link

Tealons commented May 25, 2017

Like mentioned in the instructions I'm publishing on a Windows machine with linux-arm as the target. The resulting files are copied to the Raspberry Pi: https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md

@TVoc
Copy link
Author

TVoc commented May 25, 2017

I see. The application that I want to run on my Pi requires the dotnet runtime, so unfortunately, that is not an option for me.

@Tealons
Copy link

Tealons commented May 25, 2017

From what I understand the runtime is included in the app when you publish it. Or do you need the cli available for your application?

@TVoc
Copy link
Author

TVoc commented May 25, 2017

It's not my application, and as far as I'm aware, there is no version that is built for the Pi, specifically.

@kinglionsoft
Copy link

@Tealons It works fine with a console application, but not mvc application as dotnet publish failed.
https://github.com/dotnet/cli/issues/6746

@pksorensen
Copy link

pksorensen commented Jun 9, 2017

It should work. Go ahead and try the instructions at https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md and let us know if you hit any problems.

I followed it, but getting a Segmentation fault when running it on raspberry pi zero w.

/cc @Petermarcu

@Petermarcu
Copy link
Member

Raspberry Pi Zero doesn't work because it doesn't support armv7 instructions that .net core depends on. It should work on a raspberry pi.

@pksorensen
Copy link

thanks @Petermarcu - is this a dependency that will alsways be there or would there be a solution/workaround that would allow us to run on pi zero?

@Petermarcu
Copy link
Member

We don't currently have plans to remove the armv7 dependency and it's not really something that can be worked around. At some point we may decide to do that and/or would welcome a community effort to make it work.

@shripathi-kamath
Copy link

shripathi-kamath commented Jun 9, 2017

I apologize for being a little bit dense about this, but is there currently a way to run .NET Core and ASP.NET Core apps on Raspbian. I see instructions and help about how to run apps for those platforms on the Raspberry Pi, but they all involve using non-Raspbian OSes.

@TVoc
Copy link
Author

TVoc commented Jun 9, 2017

As I understand it, you can build your app on a different machine such that it runs on Raspbian; it is self-contained. There is currently no SDK or runtime for Raspbian.

@Petermarcu
Copy link
Member

That is correct. You can use the .NET Core 2.0 SDK to build the app, copy it over to your Pi and run it.

@Petermarcu
Copy link
Member

Technically, you can probably copy the SDK over to the Pi and see if it works. There is a decent chance but its not tested there and its performance is not ideal for development on the Pi.

@shripathi-kamath
Copy link

Thanks @TVoc

@Petermarcu I am fine building the app elsewhere, and not interested in developing on the Pi. I guess I will wait until the Pi has runtime(s) for the Raspbian OS.

Thank you.

@Petermarcu
Copy link
Member

What do you mean wait until Pi has runtime(s) for the Raspbian OS? If you follow the instructions here: https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md the output should run on Raspbian.

@Tealons
Copy link

Tealons commented Jun 9, 2017

Manual for an MVC application:

  1. Create a new MVC app with the latest SDK and via the command line: dotnet new mvc on a windows laptop/pc
  2. Change the cproj file with the following:
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
  <RuntimeIdentifiers>win-arm;linux-arm</RuntimeIdentifiers>
    <UserSecretsId>aspnet-test6-1765DAD7-51F4-4572-8443-7F7BD9581173</UserSecretsId>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-25159" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0-preview2-25159" />
  </ItemGroup>

</Project>


  1. run dotnet restore
  2. run dotnet publish -r linux-arm
  3. copy the output in the pubished folder (bin\Debug\netcoreapp2.0\linux-arm\publish) to a folder on your raspberry pi (in my case raspbian)
  4. go to the folder by ssh and run: sudo ./yourprojectname

Tada! A working MVC application on your raspberry pi!

@shripathi-kamath
Copy link

Sigh!

Perhaps I am missing the trick.

I go over to the page you indicated. It tells me how I should build my app, how to change the .csproj, and publish my app to a folder.

Then there is a section on Getting the app to run on the Pi.

The first step is to install Linux. Let's say I do that as well and install Raspbian.

The next step says to install prereq packages. I click on that link, and there is no section for Raspbian. Which makes me wonder if the Linux I had to install in the first step was Ubuntu?

What am I missing?

@TVoc
Copy link
Author

TVoc commented Jun 9, 2017

I think I remember installing all of the packages listed under Ubuntu on Raspbian. I suspect it should work if you did that as well and tried to run your app.

@Petermarcu
Copy link
Member

@shripathi-kamath , you are right. That doc should be updated to be more clear. @TVoc is correct that the Ubuntu instructions should just work. That said, that list there is focused on what you need to do development. If you look here you will see the list of runtime dependencies we have for Debian Jessie which I assume will be much closer to Raspbian.

@Tealons
Copy link

Tealons commented Jun 9, 2017

@TVoc Yeah, forgot about that. I did that as the first step in trying to get it working on the raspberry pi. I used the following command:
sudo apt-get install libunwind8 libunwind8-dev gettext libicu-dev liblttng-ust-dev libcurl4-openssl-dev libssl-dev uuid-dev

@shripathi-kamath
Copy link

OK @Petermarcu, that clears it up. Thanks again to @TVoc.

@Petermarcu
Copy link
Member

For others, this would be the command for the runtime dependencies:

apt-get install libc6 libcurl3 libgcc1 libgssapi-krb5-2 libicu52 liblttng-ust0 libssl1.0.0 libstdc++6 libunwind8 libuuid1 zlib1g

@Tealons
Copy link

Tealons commented Jun 9, 2017

@Petermarcu Funny, seems like de dependencies changed over time?

@Petermarcu
Copy link
Member

@Tealons not really, I dont think we've done a good job documenting the runtime dependencies. This list is also very explicit and many of those things are pulled in transitively by others.

BTW, I missed your comment about making a PR to add ASP.NET scenarios to the how to doc. Go ahead. Just put it in a section at the end so the hello world example still flows and then people can add onto it with ASP.NET.

@shripathi-kamath
Copy link

shripathi-kamath commented Jun 10, 2017

Not that anyone asked, but after I added the above-mentioned prerequisites for Raspbian, I successfully built, deployed and executed a sample application on the Pi.

Thank you

@TFTomSun
Copy link

Are you planning to create docker images for Raspbian?

@Petermarcu
Copy link
Member

@TFTomSun, I believe it's being looked into.

/cc @richlander @MichaelSimons

@MichaelSimons
Copy link
Member

@TFTomSun, Yes, .NET Core Docker images that can be used on RaspberryPis are actively being worked on. This is the issue tracking the work.

@jeremylindsayni
Copy link

If anyone is still hitting problems getting a C# app deployed and working on Raspbian, I wrote a post about my experiences, and how I managed it - https://jeremylindsayni.wordpress.com/2017/07/23/running-a-net-core-2-app-on-raspbian-jessie-and-deploying-to-the-pi-with-cake/

Hopefully this'll help any folks still trying to get running on Raspbian.

@Petermarcu
Copy link
Member

I'm going to close this issue now because as far as I know, everything is working on Raspbian for .NET Core 2.0. If there are specific issues, we should open a new issue to track them. Thanks to all who contributed to this issue and helped get things moving!

@MartinTeichler
Copy link

Hi guys, would it be possible to run a dotnet core app inside a docker container on a Raspberry Pi Zero?

@wfurt
Copy link
Member

wfurt commented Feb 21, 2018

no, it won't @LeonidasFettikus . The CPU (ARMv6) does not have instructions .NET needs.
(https://github.com/dotnet/core/blob/master/samples/RaspberryPiInstructions.md)

@MartinTeichler
Copy link

I thought so. Just wanted a confirmation before I abandoned/committed to the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests