These instructions build the firmware and uses the .hex file to flash to the board using the ST-Link on the board and the ST-Link Utility, no hardware hacking required. These instructions may also work with the following Nucleo 64 boards (ST reference: MB1136):
This guide assumes a basic general knowledge of computers, programming, software issue handling, working with Electronics and microcontrollers. I will shorten microcontroller to MCU.
Software Requirements
Get the Board Ready
Build the Firmware
Donwload the Firmware
Test MicroPython
Upload Python Files
Useful Links
Pinouts
Contributing
Most of the other guides on the Internet explains how to program and flash the MicroPython on a Linux based development system. This made it difficult for me to get it working on a Windows based system, hence Why I made this guide to help other people who wants to get started on a Windows based environment.
The specific environment this was tested on was Windows 10 Enterprise 64 Bit.
Many of the other guides also shows how to upload by bypassing the ST-Link on the Nucleo board. This is because the ST-Link on the Nucleo board actually connects serially to the MCU and not using USB as in the boards like the Adafruit Feather etc. The Adafruit Feather and many other boards has a onboard USB port which when you connect via the micro USB connector to your PC, it will actually show a "drive" which is a portion of the flash memory of the MCU. This is why in these cases you can see the boot.py , main.py and other micropython files directly on the MCU in these cases versus NOT in the Nucleo-F411RE case.
The following software is required and needs to be downloaded and installed, if not already:
I really did not do any research on which versions to use with what versions. I just used the most recent versions I could find and install if it was not already installed on my computer.
I do however recommend to use stable release versions for obvious reasons.
python --version
or py --version
and it should return the Python version for you. When you type python
or py
and enter you will get the REPL Python Interpreter.Note that other versions of the Arm-none-eabi-gcc toolchain would also be acceptable to install if preferred.
You may need to install a unzip utility which can unpack 7Z compressed files, I use the 7-Zip utility which is small and free
How to add Environment Variable PATH entries
4. Open a new command prompt and test by typing arm-non-eabi-gcc --version
and you should see the version number, if not, your environment path variable did not take effect.
You can also install or use another type of build utility like Ninja Build
pip install adafruit-ampy
ampy --help
to test if the installation was successful.Obviously you would need Python to be installed first before doing these steps.
All the required software will now be installed.
It is also recommended that you get some sort of terminal program which will be used later on to access the REPL on the MCU, it is however not a prerequisite to be able to get your files onto the MCU, but nice to test. In the older days Wondws had the Hyper Terminal, but you can also use PuTTY or TeraTerm or any other terminal program that you know or prefer to use.
Environment Variables
on the windows menu the Environment variables links will appear like this:You will need:
c:\MinGW
on my computer. Then go to the msys\1.0
sub directory.cd e:/dev/micropython
Note that in Bash the directory seperator is different direction from the standard command prompt "/" instead of "".
Now type make -C mpy-cross
It will build some files and then it will finish with an error, My experience is to ignore this error, everything works with this error.
Change directory to the STM32 sub directory cd ports/STM32
Now type make submodules
Steps 4 and 6 only have to be performed once when you install micropython, thereafter only the required MCU board is build when needed.
make BOARD=NUCLEO_F411RE
e:\dev\micropython\ports\stm32\
directory. This will be named as build-NUCLEO_F411RE
Congratulations! MicroPython is now loaded onto the Nucleo-F411RE board.
Lets test it now.
Connect your board then open up your favorite Terminal Program and setup your serial connection as follow:
You will now be presented with the Python REPL interpreter.
If it does not show you the interpreter like above, then you will have to reset the device by following these steps:
We can now test if Python is working by trying out some common Python oneliners.
1 + 1
then Enter
should give the integer two in the next line.print('Hello')
then Enter
should give the string Hello in the next line.from pyb import LED
led = LED(1)
led.toggle()
led.off()
led.on()
If all that worked you should have seen the LED goes on and off as we do some of the commands. Congrats, this means Python is working on our MCU.
Create a project directory where you will add your main.py and boot.py files.
Create a file called main.py
and edit the file with the following code which will be our blink the user LED code:
from pyb import LED
import time
led = LED(1)
while True:
led.toggle()
time.sleep(1)
Open up command prompt and change dirtectory to this project directory. Your board should still be connected and powered on.
Remembering the previous COM port number, type the following ampy -p COM11 ls
(Just use the right com port number) This should return /flash
which means that the main.py and boot.py is under the /flash directory on the MCU "drive".
If you type ampy -p COM11 get main.py
it will print out the contents of the main.py file (the default one at this stage) on the MCU.
Now we upload our edited main.py by typing the following command ampy -p COM11 put main.py
The user LED will flash fast as the file is uploaded. You can now press the Reset button to restart the board and run the user code.
The green user LED will now flash at a rate of one second on and one second off.
Congratulations! We have written our first program which is now running.
The MicroPython documents is really helpful to get you started, be sure to check it out on the MicroPython website.
STM32 Nucleo Basic User Manual
MicroPython - Github Repository
MicroPython - Documents Online
Pre-Compiled DFU firmware Files
Bleeding Edge Arm Toolchain
Safe mode and factory reset
MicroPython Forums
Alternate way to load MicroPython
Library pyb, the class Pin
MicroPython vs CircuitPython plus Great links
Why do I not see the main.py, boot.py and other default MicroPython files in the drive when I connect the board?
A: The drive that you see with the files is the MBED storage on the ST-Link onboard programmer and NOT the MCU flash. Other development boards like the Arduino Feather exposes the USB from the MCU which maps the flash memory where you can see these files, but not on this Nucleo-F411RE board.
Cats or Dogs?
Dogs, always...
This guide was made available for free by me. You are welcome to get in contact with me to fix errors, update, add or change something to this guide.
roanfourie@gmail.com
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。