Flashing SeriouslyProF3 Cleanflight using ST-LINKV2

Introduction

If for some reason you cannot use the bootloader that reads from the USB port via the CP2102, you can resort to programming the MCU chip using the SWD port and a programmer that supports that protocol.

WARNING: there is potential for damage if you get this stuff wrong. No warranty is offered, if you break it, you get to keep both parts.

Example hardware configuration

FlashCleanflightWithStlink2

Above is the hardware configuration for programming. I have used a LiPo and BEC to supply 5V to the SPF3 board (the target), and a clone ST-LINKV2 (~$4 on eBay) is connected to the Serial Wire Debug (SWD) connector on the SPF3 with a custom cable. Note that you cannot use USART2 concurrently with SWD.

The custom SWD cable has a JST-SH 4 pin connector for the SPF3 end, and a FC-10P IDC header connector for the other. You should be able to buy a 4pin JST-SH cable and the FC-10P plug separately pretty easily on eBay for a few dollars.

Screenshot - 02_07_16 , 19_03_34

Above is the colour code and pinout from the SPF3 manual, beware your own cable colours may be different.

SWD pins 1-4 connect to the 10 pin header pins 5,1,4,2 (note that 3 and 6-10 are unused). Check and recheck before connecting.

Software

Download the Cleanflight hex file for your board.

Dowload a copy of ST’s STVP and install it.

Screenshot - 02_07_16 , 18_46_02Above is STVP opened, configured and the hex file loaded. Note that some of these settings might not be correct for your board, check the MCU type especially and make sure that the hex file suits your board.

Erase the chip, and if that works ok, program all active sectors (~20s).

If all that works, the red LED is probably flashing and you can power it down, disconnect and connect it to USB and try to connect with Cleanflight Configurator.

This technique is broadly applicable to the Cleanflight controllers using ST 32bit MCUs, but not all will have a convenient SWD connector installed… you may need to connect some wires to PCB pads.

Yes, I could have made a 20min video of this, but if you are literate, the above should be more concise and a better reference.