Skip to main content
Visitor II
February 22, 2024
Question

How to programming a STM32 microcontroller with C#

  • February 22, 2024
  • 2 replies
  • 5007 views

I want to make a GUI with C# that I could choose the STM32 microcontroller and the xxx.elf file and programming it without using STM32CubeProgrammer with USB .

With the STM32CubeProgrammer it is look like this:

talg1996_0-1708601253567.png

 

talg1996_0-1708601024348.png

What to look for? where should I begin?

I saw that there is an API for STM32CubeProgrammer on C++. is there an option to call C++ program to C#?

 

    This topic has been closed for replies.

    2 replies

    Super User
    February 22, 2024

    Not much out there on using C# on a microcontroller. It is not common. See here for the only promising thing I saw. No affiliation, seems fine.

    https://www.nanoframework.net/

    Fairly sure you can call C++ libraries from C#.

    > programming it without using STM32CubeProgrammer with USB

    Doesn't calling the STM32CubeProgrammer API come with the same drawbacks as using the tool itself?

    Super User
    February 23, 2024

    Yes you can use that API. But it is in C++ with dependency on Qt runtime libraries, and it hauls a lot of data files with it. If this is fine for you, make wrappers for native C++ code as usual in C# and basically that's all.

    If you need help in interfacing C# with C++, please visit the Microsoft forums or look here.

    Or, you can start "from scratch", write a C# program that works with WinUSB API (this is how USB DFU bootloader of STM32 looks to host), and convert .elf file to format that DFU understands. This is harder but doesn't haul dependencies.