Replies: 3 comments 1 reply
|
Nice! Besides C# APIs, can we use GPIO, SPI, network, etc? |
|
This looked interesting, so I downloaded and managed to build a test program. Seemed to take about 1.8MBytes of flash and 180Kb of RAM ( More research needed, just a preliminary finding) I then asked Microsoft Copilot to give me a summary of the code and what is happening. It uses Nuttx, and I see on the Nuttx site that they support the ESP32, so maybe it could cover these SOC's as well. Microsoft Copilot summary of the code ICS_CSHARP Summary: ICS C# SDK Architecture - C# to ARM Code CompilationThis is an ICS (Integrated Control System) C# embedded SDK that enables developers to write C# applications for embedded ARM boards running NuttX RTOS. It uses Microsoft NativeAOT to compile C# code directly to native ARM machine code (no runtime needed).BUILD PIPELINE: C# → IL → Native Code → LinkingPhase 1: C# to Intermediate Language (IL) Phase 2: IL to Native ARM Code ILC Compiler (IL to Code compiler) Phase 3: Object Linking and Compilation CMAKE AUTO-GENERATION & NATIVEAOT USER BUILDWorkflow: User C# Project
↓
MSBuild runs "IcsLinkWithSdkTemplate" target
↓
Copies SDK template → user project directory:
- CMakeLists.txt (from CMakeLists.txt.ics_nativeaot_user.cmake)
- IcsUserAotImageHeader.c (NativeAOT image header)
↓
Copies NativeObject (.o file) from ILC compilation
↓
Runs CMake configuration & build
↓
Links everything with arm-none-eabi-gcc
↓
Post-processing (CRC, binary conversion)Generated CMakeLists.txt Contents (CMakeLists.txt.ics_nativeaot_user.cmake): Toolchain Setup: Architecture Flags: -march=armv7e-m # ARM Cortex-M7 instruction set
-mfloat-abi=hard # Hardware floating point ABI
-mfpu=fpv5-d16 # FPU with 16 double registers
-mthumb # Thumb instruction setC Compiler Flags: -O1 # Optimization level 1
-ffunction-sections # Separate functions for GC
-fdata-sections # Separate data sections
-fvisibility=hidden # Hide symbols by default
-fno-asynchronous-unwind-tables # Custom unwind handlingPreprocessor Definitions: Include Directories: $(SDK)/libs/include/apps
$(SDK)/libs/include/nuttx
$(SDK)/libs/include/nuttx/cxx
$(SDK)/libs/include/nuttx_buildLinker Settings: Pre-linked Libraries: libics_nativeaot_user_export.a # NativeAOT runtime exports
libBrotli.a # Compression
libSystem_*.a # .NET runtime system libraries
libics_csharp_pinvoke.a # P/Invoke support
libopenssl.a # Crypto/TLSPost-Build Steps: arm-none-eabi-objcopy -O binary → .bin file
post_link_crc.py (Python script):
- Calculates CRC32 checksum
- Updates IcsUserAotImageHeader with CRC
- Patches binary with correct image signatureNUTTX INTEGRATIONHow NuttX is Used: Kernel Interface: User Application Model: Symbol Export: Startup: PUBLICATION & DISTRIBUTION SYSTEMpublish_ics_csharp_sdk.py - Prepares SDK for distribution: Finds Demo Project: Executes NativeAOT Build: Detects ILC Version: Patches Microsoft.NETCore.Native.targets: Installation: COMPILATION FLOW DIAGRAM┌─────────────────────────────────────────────────────────┐
│ User C# Project (.csproj) │
└────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────┐
│ dotnet publish │
│ --configuration=Release │
│ --runtime=linux-arm │
│ --self-contained │
└────────┬────────────────────┘
│
▼
┌─────────────────────────────┐
│ ILC.exe (IL Compiler) │
│ Compiles IL → native code │
│ Outputs: NativeObject (.o) │
└────────┬────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ MSBuild Target: IcsLinkWithSdkTemplate │
│ - Copies CMakeLists.txt template │
│ - Copies .o file to build dir │
│ - Runs cmake configure │
└────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ CMake Build (with ARM GCC) │
│ - Links .o files │
│ - Links pre-built libraries (.a) │
│ - Applies custom unwind wrapping │
│ - Uses linker scripts (.ld) │
│ Outputs: ics_nativeaot_user.elf │
└────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Post-Link Processing │
│ - objcopy: ELF → .bin │
│ - post_link_crc.py: Calculate CRC32 │
│ - Patch image header signature │
└────────┬────────────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Final Output: │
│ - ics_nativeaot_user.elf (ELF binary) │
│ - ics_nativeaot_user.bin (raw binary) │
│ - ics_nativeaot_user.map (memory map) │
└─────────────────────────────────────────┘KEY CONFIGURATION PROPERTIESUser configures in GpioForCSharpDriver.csproj: <IcsCSharpSdk>D:\path\to\sdk</IcsCSharpSdk>
<DisableUnsupportedError>true</DisableUnsupportedError>
<InvariantGlobalization>true</InvariantGlobalization>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<PublishAot>true</PublishAot>
<RuntimeIdentifier>linux-arm</RuntimeIdentifier>Optional overrides: <IcsNativeAotUserCmakeGenerator>Ninja</IcsNativeAotUserCmakeGenerator>
<IcsNativeAotUserCmakeArgs>-DCUSTOM=value</IcsNativeAotUserCmakeArgs>
<IcsNativeAotUserBuildArgs>--verbose</IcsNativeAotUserBuildArgs>
<IcsNativeAotUserForceConfigure>false</IcsNativeAotUserForceConfigure>SummaryThis system is a sophisticated end-to-end compiler toolchain that:
|
|
Looks like the ILC compiler only supports ARM based SOC's, so this is limited to ARM at the moment |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
For too long, the choice for high-performance embedded development has been limited to C and C++. While effective, these languages often come with memory safety pitfalls and slower development cycles. What if you could use modern C# on STM32H7 without the overhead of traditional interpreters?
The ICS-CSHARP-SDK makes this a reality. It leverages the raw power of .NET 10 technology to transform your C# code directly into optimized ARM machine code.
Beyond Traditional Frameworks
This is not nanoFramework.
https://github.com/snikeguo/ICS-CSHARP-SDK
All reactions