Support for Loongson in .NET Core and Thoughts on .NET Core for Embedded Development

2019年11月19日 68点热度 0人点赞 1条评论
内容目录

Support for .NET Core on Loongson and Thoughts on Embedded Development with .NET Core

[TOC]

1. Regrettable Attempts

A few days ago, I came across Zhang's public post titled 《Asp.Net Can Finally Run on Loongson Servers: Jexus Successfully Adapts to Domestic Series CPUs》. This reminded me of last week when my friends and I were tinkering with .NET Core on Loongson, and I wanted to write about the information regarding .NET Core running on Loongson.

The Jexus Web Server can run on Loongson servers, but what about ASP.NET? .NET Core? Which version of Mono should be installed? The author's article on Jexus is a bit ambiguous~

Last week, my friend and I put a lot of effort into deploying a .NET project on Loongson. After my friend's company won a government project and developed a project with .NET Core, they discovered that the server for deployment was a Loongson server, and .NET Core could not run on it.

The server had Mono 4.x, and we could create a simple Proparm.cs, compile it, and run it using mono xx.exe, but we couldn't compile our project~ We also tried to compile and install Mono 6.x, but there were errors during the process.

Needless to say, .NET Core was completely out of the question; it could not be compiled at all. Through Google searches, we found out that we would need to rewrite the C++ parts (porting) to compile CoreCLR on Loongson.

The official CoreCLR source repository has some scripts and a compilation toolchain available.

https://github.com/dotnet/coreclr/

RISC-V is a reduced instruction set, and MIPS refers to the RISC-V based CPU architecture, which is what Loongson servers use.

Ultimately, we were unable to deploy .NET software, and my friend's company switched to Java development...

Previously, I spent a lot of time manually compiling .NET Core to run on Armel CPU architectures, but I ultimately failed. I detailed the compilation process in an article titled 《A Record of My Troubles: Building the Armel Version of .NET Core Tutorial and Resource》.

2. Several Drawbacks of .NET Core in Embedded Development

In July 2018, Zhang organized a .NET exchange meeting at my school in the Greater Bay Area, and that's when I began learning .NET. In March 2019, I interned with a firm which later turned into a full-time position.

During my six months of developing with .NET Core, I have personally summarized several issues/suggestions concerning .NET Core in the embedded field.

1. Incompatibility with Older CPUs

.NET Core cannot run on Raspberry Pi Zero (Arm v6);

It also cannot run on Huawei's HiSilicon A9 chip (Armel Armv7);

Although these two chips are from a few years ago, .NET Core boasts about supporting IoT but does not support older CPUs. Many older devices are likely to remain mainstream for the foreseeable future.

Microsoft has also stated:

Note: .NET Core 2.1 is supported on Raspberry Pi 2+. It isn’t supported on the Pi Zero or other devices that use an ARMv6 chip. .NET Core requires ARMv7 or ARMv8 chips, like the ARM Cortex-A53.

Support for different Arm architectures is still insufficient.

2. Limited Testing on Hardware Devices

The official testing of embedded devices is primarily done on Raspberry Pi 2/3, and many development boards remain untested~

3. Limited Compatibility with System Versions

.NET Core supports many Linux systems, but the support primarily targets the latest versions. For instance, .NET Core 3.0 supports Ubuntu versions 16.x and 18.x, while 14.x and 17.x have been ruthlessly abandoned.

The supported systems for .NET Core 3.0 are as follows:

https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-supported-os.md

4. Size is Still Too Large

For embedded development, the size of .NET Core is still too large; even with just a single Hello World, it still exceeds 70MB.

5. Troublesome Dependency Libraries

Errors often arise due to version inconsistencies in or absence of dependent libraries such as ICU, libssl, gcc, etc., which once drove my friend Shitou to the brink.

3. Progress and Resources on .NET Core Porting to Loongson

According to contributions from experts, as of November 9, it has been achieved to run a Hello World example of .NET Core on Loongson.

The code base was upgraded to 3.0. Hello World and several tests in coreclr can run on MIPS64 now.

This is a port of CoreCLR, and there are still many issues waiting for resolution by the experts.

For discussions on porting .NET Core to MIPS, please check the Issue page.

https://github.com/dotnet/coreclr/issues/969#issuecomment-550129085

However, Microsoft currently has no plans for porting and relies on the community to accomplish this.

Microsoft currently has no plans or work in progress to support MIPS. Of course, we would be willing to accept external contributions towards that goal as appropriate. Note that it is, certainly, a significant amount of work to port .NET Core to a new platform.

There is also another notable project:

https://github.com/reignstudios/IL2X

This project will focus on translating .NET IL for non-supported .NET targets. Portability is a huge focus.

  • .NET Standard compatibility
  • Native C performance
  • C89: modern, legacy and embedded platforms (x86, MIPS, SPARK, RISC-V, PPC, AVR, etc)
  • CC65: 6502 platforms (Atari, C64, NES, Apple II, etc) [CS2X may be better suited]
  • SDCC: Many targets (ColecoVision, etc) [CS2X may be better suited]
  • Assembly: CP1610 (Intellivision) [CS2X may be better suited]
  • Retarget: Custom assembly targets via plugin system (FPGA CPU, 16bit bytes, etc)
  • Custom Standard lib(s) for various targets.
  • Documentation

痴者工良

高级程序员劝退师

文章评论