目录

  • .net core 对龙芯的支持情况和对 .net core 开发嵌入式的思考
    • 二,.net core在嵌入式下的几点不足
    • 三,.net core 龙芯移植的进展和资料

.net core 对龙芯的支持情况和对 .net core 开发嵌入式的思考

一,遗憾的尝试

前些天看到了张队公众推送的《asp.net终于可以在龙芯服务器上运行啦:jexus成功完成对国产系列cpu的适配》,联想到上一周与朋友在龙芯捣鼓 .net core,就想写一下关于 .net core 在龙芯下的资料。

jexus web server 能够在龙芯服务器上跑,但是 asp.net 呢?.net core 呢?安装什么版本的 mono ?jexus 作者的文章表达有点模糊呀~

上一周与朋友在龙芯上面为了部署 .net 项目,颇费心机。朋友公司中标政府项目,开发好 .net core 做的项目后,才发现要部署的服务器是龙芯的,.net core 无法在上面运行。

服务器有什么有 mono 4.x,可以创建简单的 proparm.cs ,编译出程序,使用 mono xx.exe 运行,可是把项目放进去编译不出来~想编译安装 mono 6.x 也不行,中间有些过程报错。

.net core 自然不用想了,完全无法编译,通过 google 查询资料,要重写 c++ 部分(移植),才能在 龙芯 下编译出 coreclr。

官方 coreclr 源码库,可以看到一些脚本和编译工具链。

risv-c 是精简指令集,mips 是指 基于 risc-v 的 cpu 架构,龙芯服务器使用 mips 架构。

最终,无法部署 .net 软件,朋友公司改用 java 开发。。。

之前笔者为了在 armel 的 cpu 下运行 .net core ,花了很多时间手动编译 .net core,最终还是失败。我将编译过程详细写了一篇文章,地址《瞎折腾实录:构建 armel 版本的 .net core 教程和资料资源》。

二,.net core在嵌入式下的几点不足

18年7月张队来我校组织了大湾区 .net 交流会,从那时起开始学习 .net ,19 年三月月份进入敢为实习转正至此。

使用 .net core 开发半年的时间里,在嵌入式开发中,我个人总结当前 .net core 在嵌入式领域有几个问题/建议。

1,不支持前几年的cpu

.net core 无法在树莓派 zero上运行(arm v6);

无法在华为海思a9芯片上运行(armel armv7);

这两种芯片虽说是几年前出的芯片,但是 .net core 大张旗鼓的说要搞 iot,却不兼容旧一些的 cpu,目前很多旧式设备依然会在未来一段时间内是主流的存在 。

微软官方也说了:

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.

arm 方面的支持还是不够广。

2,测试的硬件设备较少

官方对嵌入式设备的测试,主要在 树莓派 2 / 3,还有很多开发板没有测试~

3,支持兼容的系统版本较少

.net core 支持很多 linux 系统,但是对应这些系统的支持,都是以最新版本的系统为主,例如 .net core 3.0 在ubuntu 上是支持 16.x、18.x,14.x 和 17.x 被无情的抛弃了。

.net core 3.0 支持的系统如下:

4,体积依然太大

对于嵌入式开发来说, .net core 的体积依然太大,.net core 3.0 也拯救不了。。。哪怕只有一行 hello world,也要 70mb+ 以上。

5,依赖库比较伤脑筋

经常会出现 icu、libssl、gcc 等依赖库版本不一致或没有安装这些库时的报错信息,石头哥曾经被这些问题搞得掉头发。

三,.net core 龙芯移植的进展和资料

根据大佬们的移植,在 11 月 9 号时,已经实现了 在龙芯上面运行 .net core 的 hello world 实例,

the code base was upgraded to 3.0. hello world and serveral tests in coreclr can run on mips64 now. 

这是对于 coreclr 的移植,还有很多问题等待大神解决。

对于 .net core 在 mips 上的移植讨论,可以到 issue 查看

不过,微软官方目前没有移植计划,只能靠社区去完成了。

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.

还有另一个大神的作品

https://github.com/reignstudios/il2x

this project will focus on translating .net il for non-supported .net targets. portibility 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