自从去年测评板卡结束,这块板子就闲置起来了。在浏览MicroPython官网的时候,发现官方已经适配好了固件。赶紧来烧录体验一下。
官网也介绍了几种不同的烧录方式:
Installation instructionsSTM32 via ST-Link
Nucleo and Discovery boards typically include a built-in ST-Link programmer.
A .bin or .hex file can be flashed using st-flash.
# Optional erase to clear existing filesystem. st-flash erase # Flash .bin st-flash write firmware.bin 0x08000000 # or, flash .hex st-flash --format ihex write firmware.hex
A .hex file can be flashed using STM32 Cube Programmer.
STM32_Programmer.sh -c port=SWD -d firmware.hex -hardRst
STM32 via DFU
Boards with USB support can also be programmed via the ST DFU bootloader, using e.g. dfu-util or pydfu.py.
To enter the bootloader the BOOT0 pin can be connected to VCC during reset, or you can use machine.bootloader() from the MicroPython REPL.
dfu-util --alt 0 -D firmware.dfu
这里选择的最新的HEX固件:
打开STM32 CubeProgrammer,右侧ST-LINK区域,点击Connect:
选择Micropython固件,点击Start Programming.等待烧录完成。
打开Thonny,右下角选择端口与板子:
在输出窗口可以看到已经显示出了F412ZG的固件信息。
编写简单的脚本测试一下:
import pyb import time led_g = pyb.LED(1) led_b = pyb.LED(2) led_r = pyb.LED(3) i = 0 while True: i = i + 1 led_g.toggle() led_b.toggle() led_r.toggle() time.sleep(1) print("Blinking Times: ", i)
板子三个LED闪烁:
感觉起来跟CubeIDE或者Keil开发体验差异很大,可能是刚接触micropython的原因。后续有时间继续熟悉、体验。