I am having some trouble programming the STM32F411CE chip with the Arduino IDE. I loaded the official "Blink" code and added another line above:
#define LED_BUILTIN PC13
because apparently the LED_BUILTIN was not defined with the STM core.
I did a "Full chip erase" using the "automatic mode" in the STM Cube Programmer, disconnected the chip from the software and proceeded to upload the sketch.
Here is the output:
Sketch uses 23792 bytes (4%) of program storage space. Maximum is 524288 bytes.
Global variables use 4936 bytes (3%) of dynamic memory, leaving 126136 bytes for local variables. Maximum is 131072 bytes.
Selected interface: dfu
-------------------------------------------------------------------
STM32CubeProgrammer v2.22.0
-------------------------------------------------------------------
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : STM32 BOOTLOADER
SN : 319B35763435
DFU protocol: 1.1
Board : --
Device ID : 0x431
Device name : STM32F411xC/E
NVM size : 512 KBytes (default)
Device type : MCU
Revision ID : --
Device CPU : Cortex-M4
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
Download in Progress:
Error:
Write failed at address: 0x8000000
Error: failed to download Sector[0]
Error: failed to download the File
Failed uploading: uploading error: exit status 1
Hardware used:
STM32F411CE, WeAct v3.0 board
Macbook Air M2 (I tried it with my windows pc as well but the STM programmer returned "Error: Unknown or unsupported device (DevId 0x0000)", meaning it does not even connect with the stm programmer, and the arduino ide, configured in the same way, fails to connect to the board)
I have given up on using Windows for this board as all of my code is on my mac, but yes, the board is recognised by both PCs. When the device is plugged into my Windows PC and DFU is entered (i.e. by holding Boot0, pressing NRST and then releasing Boot0), my Windows PC plays the same sound as it would if my phone is plugged in. I do not have my Windows PC with me now but my guess is that the board is recognised by it. Here is a screenshot of the Mac equivalent of "device manager". On the Mac, the board does require a few tries (and I suspect it's just the Mac not updating the page as often, given it worked with Windows) to get it to be shown on the device manager but it still shows.
I suspect that the problem is with some software, given that most of the other forum posts did not have any issues when uploading the code, but I have no idea which part of the software leads to the problem.
Update:
Today when connecting the board to the computer the power LED light did not turn on and I suspect it is a short circuit, which, however, still does not explain the problem. I have ordered a new one and will keep the forum open just in case the new one has the same problem which means it is probably a software issue.
Hi @k_w
I don't know the solution to your problem, I just want to share my experience. I've been working with the STM32 in Arduino for 10 years, using two different packages: Roger Clark's and STM-micro.
For the STM32F4 boards, the easiest and most reliable flashing method turned out to be using ST-Link - the cheapest clones on AliExpress, costing less than $2.
I have acquired a new STM32 black pill board, and it is the WeAct studio v3.1 (I believe with 8MB of ram). It has run very well so I think my conclusion is that the previous board (v3.0) just had problems with its internal circuits. Before my testing finishes I will continue to leave this forum open but if I have no issues at all with my testing I will close this.
All I have to do now is to make sure the board is in DFU when I upload the code.