Like many of you, I bought a sample blackpill just for testing purposes with no special need to address. Later on, I learned that several flavors of Python were available for these boards and I gave them a try, both MicroPython and CircuitPython worked ok.
But I read on the comments on a Hackaday entry about the board that the 8-pin chip that was not soldered in the bottom was a provision for an SPI flash memory. Again, I had no particular need for more memory, as the current 32KB flash drive that MicroPython exposed was ok, but you never know when you might need more memory. And sooner than later you find that need for extra memory. So I ordered a W25Q128F chip for around $1 and I soldered it to the board when it arrived.
However, none of the Python binaries I had changed the size of the exposed flash drive when I connected the USB to my computer. So I went on a quest to learn how to make it work. I failed to find meaningful references online until I visited the WeAct github repo: https://github.com/WeActTC/WeAct_F411CE-MicroPython
There they had some instructions on how to compile your own binary of MicroPython and the required files for the board plus a comment about a value to change on mpconfigboard.h depending on the location of the flash memory you wanted the board to use. Default value uses the internal flash memory, but setting the define to 0 would make the firmware use the external memory.
Unfortunately, I was using a Windows 10 computer and all the instructions were to build the firmware on a Linux system. However, that problem represented an opportunity for me to try WSL (Windows Services for Linux), which in a nutshell is a way to run a Linux shell on top of Windows. It is not the same as VMware or VirtualBox, as there is not a hypervisor running Linux on a virtual environment but a much lighter solution, which only offers support for console applications that make not many assumptions over the underlying hardware (programs like nmap will just not work here, but ssh does).
Installing WSL
It was relatively quick and painless but it required one reboot (something I am not fond of). I went to the Windows Store and looked for "ubuntu" and I downloaded and installed it. Next, I opened a PowerShell window with administrative rights and typed some magic command: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
After a system reboot, I could run the "ubuntu" command and I was asked to provide a username and password (just for Linux, no need to match the ones in Windows). Some things were still being installed and briefly, I was offered the familiar shell of an ubuntu system. A quick check of the list of running processes was surprisingly short though.
Compiling the code
To be able to successfully compile the Micropython blackpill some additional packages will need to be installed into your "Linux" system: sudo apt install git make gcc gcc-arm-none-eabi libnewlib-arm-none-eabi
Next step is to follow the steps listed on github, but with one more to edit the flash memory to use:
git clone https://github.com/micropython/micropython.git
cd micropython
git submodule update --init
cd mpy-cross
make -j4
cd ../ports/stm32/boards
git clone https://github.com/WeActTC/WeAct_F411CE-MicroPython.git WeAct_F411CE
Now make sure the define above is changed to 0 in mpconfigboard.h on WeAct_F411CE folder. And finish the process by typing the following commands:
cd ..
make BOARD=WeAct_F411CE -j4
Uploading the firmware to the board
Now the firmware is in the folder build-WeAct_F411CE and I am going to use the file firmware.hex, though there are other formats with the firmware too. I am going to upload the code (though ST favors the word download for reasons I ignore) using the program
STM32CubeProgrammer (quite a mouthful of a name).
The program is offered free of charge but you just cannot download it, instead, you have to provide your email address so a link is sent to your inbox (not a fan of this approach). Luckily, it is available for several operating systems so they have you covered there.
The program gave me some trouble and it is my understanding it needs to be run with administrative rights (so it can gain access to the USB port). The blackpill can be programmed in a variety of ways: serial connection, USB connection, ST-Link. I use the simplest one which is USB connection. But I have used the others on different occasions with no trouble with this same program. Just open the file, to do the "download" :-)
Please remember that you need to place the board in loading mode so, press NRST and without releasing it, press BOOT0 button. Now release NRST and next release BOOT0. Now, if you press the update button with two arrows you should read USB1 instead of Not DFU detected.
Once the part has been detected on the USB, connected by pressing the green Connect button, and next you can press the blue Download button to upload the firmware.
After "downloading" the firmware the board needs to be reset. Windows will detect a new USB flash drive named "WEACTF411CE" with four files initially. This is where your Python code and libraries are going to be stored. If you go to the Device Manager you will find a new COM port where you can have access to the MicroPython REPL. You can use putty to access it.
Not sure why but my 128 Mbit SPI flash translates into an 8 MByte flash drive (I reckon it should be 16 MB though). That is a significant improvement over the 32 KB of the bare F411 board.
Update
I should be paying more attention to the source code, in particular to
this line. Where the size of the external flash is specified. I need to change the 64 by a 128 to match the 128 Mbits of the flash I have soldered to my board, this error on my side explains why I was seeing a smaller flash memory space than I should.
Binary released
If you have exactly the same hardware and want to go ahead and download the binary file you can do so from my
github.
Comments