After multiple Windows crashes caused by ST’s “Flash Loader Demonstrator” v2.7.0 I decided to write my own library that will allow me to talk to STM32’s on-chip bootloaders via USART in C# .net. This is the initial yet fully functional version: https://github.com/MightyDevices/STBootLib (binaries: here). This implementation uses classic SerialPort class with no additional magic which allows for safe operation (no system hangs whatsoever, even with very cheap USB<->UART dongles). In addition I’ve written a simple firmware updater app that I use extensively without any problems.
Keep is simple, stupid. Simple, usable and operational.
As you can see I’ve kept the interface to a minimum, just to make the application less demanding in terms of occupied space. Here’s the list of functionalities for version 1.0:
- Initialization of communication – getting bootloader version, product ID, command list
- Writing to a memory area
- Reading from memory ares
- Erasing Flash pages (with Flash erase or Extended flash erase commands – both supported)
This small code snippet shows the basic usage of library functions:
/* bootloader class instance */ STBoot stb = new STBoot(); /* open the port */ stb.Open(portName, baudRate); /* initialize communication */ await stb.Initialize(); /* write memory @ address, bin = binary file in byte array */ await stb.WriteMemory(address, bin, 0, bin.Length, null, CancellationToken.None); /* jump to user application */ await stb.Jump(address); /* close port */ stb.Close();