JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

New wiki page on C#

Sun Mar 10, 2013 6:45 pm

Hi all,

I've started a page on the elinux wiki about using C# on the Raspberry Pi:

http://elinux.org/CSharp_on_RPi

I know there are others here who know more about it than I do — please contribute what you can!

Thanks,
- Joe

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Sun Mar 10, 2013 8:01 pm

I think you should put in big bold letters that mono does not currently function on Raspbian (hard-float). As it stands, it will lead to lots of confusion.

PiPaul
Posts: 4
Joined: Sat Mar 09, 2013 5:53 pm

Re: New wiki page on C#

Sun Mar 10, 2013 8:16 pm

Great initiative to start a page on this topic!

On the hard / soft float issue: there is a bug report for this issue, see [url] https://bugzilla.xamarin.com/show_bug.cgi?id=7938 [url]. There seem to be some patches which are mentioned in the last comment. But as a Linux noob these are over my head. Maybe someone else can use this to fix mono. That would be a great improvement for us.

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Sun Mar 10, 2013 8:27 pm

i comment in another thread here: http://www.raspberrypi.org/phpBB3/viewt ... 34&t=36252
To shed a little light on things: There is a hard-float patch to mono that was done by Sony for armv7. This patch requires a patch to work on armv6 on Raspberry Pi. Since Xamarin is not the author of the patch, they do not include it in mono because, although mono is GPL/LGPL, they require copywrite assignment so they can re-license mono commercially. To further complicate things, the hard-float patch is against mono 2.10 while mono 3.x is now current

JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

Re: New wiki page on C#

Sun Mar 10, 2013 8:58 pm

I didn't include anything about the hard/soft float issue because, frankly, I don't understand it yet.

I hope to invest some time in the next few days coming to grips with it, but if you already know what it's all about, a wiki page on it would be extremely helpful.

I don't think this is just a Mono issue, though... Java seems to have the same problem (see here). Is it a bug in the kernel, or a bug in both Mono and Java?

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Sun Mar 10, 2013 9:12 pm

http://infocenter.arm.com/help/topic/co ... _aapcs.pdf
"The AAPCS defines how separately compiled and separately assembled routines can work together."

Its not a kernel bug or distro bug. Its a choice of standard implemented.

Oracle has chosen to support hard-float ABI in the recent Java 8 preview. To be clear: Mono not supporting hard-float is *NOT* a technical issue; its a political one. The ARM platforms that mono makes money on (Android / iOS) are soft-float.

JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

Re: New wiki page on C#

Sun Mar 10, 2013 10:28 pm

OK, I've added a section to the C# page about the float issue. Please have a look and let me know if I've misrepresented anything.

One thing we could really use is a list of which distros are safe to use; the official distro list is not entirely clear on that.

Also, it seems that our current choices are either a distro that uses the floating-point hardware and hardfloat ABI, so gets great performance but doesn't work with Mono (or the current version of Java?); or a distro that doesn't use the FP hardware at all, so it works, but gets poor performance.

How hard would it be to build a distro that used the floating-point hardware, but the softfloat ABI? Wouldn't that be the best of both worlds?

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Sun Mar 10, 2013 11:07 pm

The wiki page states
A patch to Mono is available to make it work on hardfloat ARM is available here
This implies that patch will make Mono work on Raspberry Pi which is not the case. As i stated before, additional changes are required to support armv6.

I have no idea if soft-float Debian is compiled to use floating point hardware (VFP) or not. But it seems rather counter intuitive for the world to revolve around Mono's deficiencies. Hard-float on ARM seems to be the trend everyone is taking. Armv6 was like the Intel 486 where floating point processors were optional. Armv7 is more like the Intel Penitum where its assumed to always be present.

The road forward with Mono probably lies in using its LLVM support for JIT. Support for both hard and soft float are understood by LLVM. However, Mono only works with its own specific branch of LLVM which also seems to be unusable on Raspberry PI (I tried compiling a 3.0 branch for PI recently and had no luck with it. Maybe someone else might fare better). I should note that Mono 3.0 still requires patching for armv6 functionality.

JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

Re: New wiki page on C#

Mon Mar 11, 2013 1:24 am

Ah, sorry, I didn't understand that.

So, nuts — we currently don't have any way to make Mono work properly on a hardfloat RPi? Or is there some other patch known to make it work on armv6?

JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

Re: New wiki page on C#

Mon Mar 11, 2013 12:30 pm

OtherCrashOverride wrote:But it seems rather counter intuitive for the world to revolve around Mono's deficiencies. Hard-float on ARM seems to be the trend everyone is taking.
I agree with this sentiment, in principle. On the other hand, Android and iPhone are by far the 900-pound gorillas in the ARM Linux space. If they're both softfloat, an argument could be made that RPi should be the same, in the interest of having lots more stuff (including Mono and Java, but quite likely including other things we're not thinking of) Just Work.

My fear is that the Mono developers are going to say, "Raspberry Pi? Meh — most of our users are on iPhone or Android." And the RPi folks are going to say, "C#? Meh — most of our users use Python." Of course C# will never have a big user base on RPi when it doesn't work well there. My belief is that C# on RPi could really catch on (it has a huge userbase on other platforms), if it would work properly — but that will never happen if both parties involved pass the buck. :cry:

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Mon Mar 11, 2013 2:26 pm

On the other hand, Android and iPhone are by far the 900-pound gorillas in the ARM Linux space
The actual software that is directly affected by the ABI choice is really not that substantial. Its only an issue that compilers (which a JIT is) must deal with. The larger issue with software compatibility is the choice of processor in Raspberry Pi (armv6 vs armv7) and has nothing to do with Android or iOS.
My fear is that the Mono developers are going to say, "Raspberry Pi? Meh — most of our users are on iPhone or Android."
In the Arm world, the life of a SoC is relatively short. So its a very tough argument to make that anyone should expend money and resources supporting an already legacy cpu (armv6). Supporting Raspberry PI is a 'labor of love' and I cant fault Xamarin (mono), Canonical (ubuntu) or anyone else for making good *business* decisions.

I stated elsewhere that C# is my language of choice on the Raspberry Pi and I would love to see first class support. Unfortunately this is not easy to achieve given all the contributing factors. Mono is not going to accept a patch (hard-float) that breaks their Tier 1 (money making) platforms nor will they accept a patch that is not copywrite assigned to them. This means at the least someone would have to maintain a 2.10 branch specifically for Pi and backport fixes from the 3.x branch. Porting the hard-float patch to 3.x branch would also require someone to maintain it as Mono progresses.

At this point I would say the best that could be hoped for realistically is a 'one-off' patch against Mono 2.10 that is frozen in time (including all its bugs) for the duration of the Pi's lifespan.

JoeStrout
Posts: 43
Joined: Sun Oct 09, 2011 12:11 pm
Contact: Website

Re: New wiki page on C#

Mon Mar 11, 2013 5:30 pm

OtherCrashOverride wrote:The actual software that is directly affected by the ABI choice is really not that substantial. Its only an issue that compilers (which a JIT is) must deal with. The larger issue with software compatibility is the choice of processor in Raspberry Pi (armv6 vs armv7) and has nothing to do with Android or iOS.
Except that this affects not just those coding in Mono or Java, but any software written in them as well. I expect to see more and more of that — the ability to make a binary (.exe file) that runs on multiple platforms — provided they have a working Mono runtime — is really attractive.

Of course it's true that of the software available for RPi, almost none of it relies on Mono. But I'd argue that's a chicken-and-egg problem. We don't have much Mono software, because Mono doesn't work. We don't care that Mono doesn't work, because we don't have much Mono software.
In the Arm world, the life of a SoC is relatively short. So its a very tough argument to make that anyone should expend money and resources supporting an already legacy cpu (armv6). Supporting Raspberry PI is a 'labor of love' and I cant fault Xamarin (mono), Canonical (ubuntu) or anyone else for making good *business* decisions.
I agree. I've contacted Xamarin to see if I can throw some money at the problem (which I would be willing to do). But I think it unlikely.
At this point I would say the best that could be hoped for realistically is a 'one-off' patch against Mono 2.10 that is frozen in time (including all its bugs) for the duration of the Pi's lifespan.
You're probably quite right. I would certainly be OK with such a patch.

However, barring that, I still think it's a mistake to adopt the hardfloat ABI on armv6, because of the compatibility problems it triggers. As you say, armv6 will be short-lived in the end, and on armv7, perhaps it's a different story.

So I've posted in the Raspbian forum asking whether they will reconsider the hardfloat decision, but I don't anticipate a positive response. My next step is to see whether I can find a distro already built with fp instructions and softfloat ABI — see here for that discussion.

OtherCrashOverride
Posts: 582
Joined: Sat Feb 02, 2013 3:25 am

Re: New wiki page on C#

Mon Mar 11, 2013 7:01 pm

I've contacted Xamarin to see if I can throw some money at the problem (which I would be willing to do).
If you want to throw money at it, throw it at me and I will get you the Raspberry Pi patch for the hard-float patch. ;)

Return to “Other programming languages”