This tutorial will explain step by step how to build and deploy MicroPython on STM32F407xx and STM32F411CEU boards, using both DFU mode over USB, as well as SWD with ST-Link and OpenOCD in case you can't get the board into DFU mode (happened to me with the "black pill").
It should be applicable to other boards, such as the other "black pill" STM32F401, Nucleo boards etc., provided you can find an appropriate board definition to build.
git clone https://github.com/micropython/micropython
in micropython/ports/stm32 folder:
make submodules
(this will take a while, as it will built the necessary STM32 pieces of code)
in micropython/ folder:
make -C mpy-cross
(this will take a while, as it will build the necessary cross compiler code)
in micropython/ports/stm32/boards folder:
git clone https://github.com/mcauser/BLACK_F407VE.git
git clone https://github.com/mcauser/WEACT_F411CEU6.git
in micropython/ports/stm32/ folder:
make BOARD=BLACK_F407VE
make BOARD=WEACT_F411CEU6
put the board into the DFU mode, connecting BT0 pin to 3V3 with a jumper as described, then connect the USB cable and do:
make BOARD=BLACK_F407VE deploy
after it's done, unplug the board, connect BT0 to GND with the jumper, and reconnect the board
cd micropython/ports/stm32/build-WEACT_F411CEU6
openocd -f interface/stlink-v2.cfg -f target/stm32f0x.cfg
in another terminal window:
telnet localhost 4444
> reset halt
> flash write_image erase build-STM32F4NUCLEO/firmware.elf
rshell -p /dev/ttyACM0 repl
Hi,
I tried to put micropython on my black pill following these instructions, but it failed at the deploy step.
I used the 'hold down the boot button while pressing and releasing the nrst button' to put it into dfu mode as documented in various places, rather than shorting bt0 to 3v3 as you recommend, but I'm not sure that would be an issue. It looks to me like something bad has happened during the build process and a library has been missed somehow. There were no error messages displayed in any of the steps before this one. How do I get around this problem?
Thanks, Ian