Showing results for 
Search instead for 
Did you mean: 

How to programming a STM32 microcontroller with C#


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:




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#?



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.

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?

If you feel a post has answered your question, please click "Accept as Solution".
Pavel A.
Evangelist III

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.