Introduction: STM32F407VET6 Black Board and MicroPython


I've come across cheap STM32F407 board from AliExpress

I decided to give it a try with MicroPython.

STM32F407 pretty much the same controller as STM32F405 used in

original pyboard, but turned out on MicroPython download page there is DFU file for STM32F407 discovery board. That file I tried on the Black board and it worked pretty good except some functions prom 'pyb' library.

So it's better to use 'machine' library as much as it possible.

If you don't want to wait a few weeks before black board arrives, order original discovery board but it is twice more expensive.

There is as well a guide how to install MicroPython on STM32F4Discovery.



Download DFU file for STM32F4 Discovery board . Download DfuSe USB device firmware upgrade tool from STMicroelectronics website. In order to do that you have to register a free account. Install DfuSe tool on you computer.


There is two jumpers on the board connecting pins BT0 and BT1 to GND. Move BT0 to 3.3V (see the picture). Open“DfuSe Demonstration” tool, connect the board to USB. You should see in top left corner box ''STM device in USB mode'', than at bottom right click ''CHOOSE'' , select downloaded DFU file and click ''UPGRADE''. Move BT0 jumper back to GND and reconnect USB cable. PYBFLASH grive should appear on your file system. You can read original MicroPython PDF "The care and feeding of Pythons at the Redmond Zoo."


Now you can start to have fun with MicroPython. You can write your program in any text editor , even Windows Notepad. I prefer original Pyton 3 IDE. Open PYBFLASH drive and open from it in your text editor. Let's start with simple LED blink program. There are two LEDS on the board marked D2 and D3 connected to PA6 and PA7 pins of the controller. Write this simple program in your text editor:

        import machine, time #import micropython libraries
        led = machine.Pin( 'A6', machine.Pin.OUT) #assign pin PA6 as output 
        while True : #infinite loop
               led.low() #switch led on
               time.sleep(1) #let led be on for one second 
               led.high() #switch led off
               time.sleep(1) #let it be off for one second

Save file to your board, press reset button LED D2 should start flashing. The best way to reset the board is from command line in REPL . For that download and install Putty. In order to use Putty get COM port number for the board from Control panel>Device manager. When you get connected, use keyboard shortcut ' CTRL' + 'C' to stop running program before saving a new program and 'CTRL' + 'D' to restart the board after saving a program. I found out that is safest way to save and restart MicoPython programs instead of just disconnecting and reconnecting USB cable (during this process PYBFLASH drive can get corrupted) Now, at the end, let's make LEDS D2 and D3 blink alternatively and faster :

      import machine, time
      led = machine.Pin( 'A6', machine.Pin.OUT)
      led1 = machine.Pin( 'A7', machine.Pin.OUT) 
      while True :

P.S. You can get more information about the STM32F407 Black board on GitHub and if you are familiar with Linux you can compile DFU file for this particular board. I didn't try that. I don't have any Linux machine currently running.

Have fun with MicroPython !