My first serious work with STM processors as powerful ARM-based Arduinos started with ST32L071 and is documented here. As part of that article, I found a way to integrate a custom board into the Arduino environment and how to use the ST-Link to upload a sketch from the Arduino IDE. Satisfied as I am with that work, I realize that no one is likely to build any of my L071 based Arduinos, even if they can be itsy-bitsy, low power, etc. However, my work may still be very useful!
Let's talk about the WeAct Duino. As discussed in the Description section above, the STM32G431 on the WeAct Mini Core Board offers a lot of power along with many peripherals. WeAct offers this unit at a very affordable price - less than three bucks! (Even in quantity, the G431 chip from Digikey costs more than the cost of the system from WeAct. How can they make it so cheap? Who knows! But we can all benefit!) While the G4xx draws more power than the L0xx, it is an M4 core with floating point hardware, runs over 4 times faster, and has additional resources. The version from WeAct is in a 48 pin package, so more of the resources are accessible. ST Nucleo versions of the G431 are available from Digikey (and others). The 32 pin version costs $12 and the 64 pin version is $16. Both are significantly larger than the WeAct board, but not any more powerful (same chip).
As a useful bonus, WeAct also offers a clone of the ST-LINK_2.1 programmer. Not only does it cost half what the cheapest ST version costs, it also provides a serial interface. The usual sort of Serial.print() debug can be easily used for program debug; for harder problems, gdb (g-debugger) can be invoked as described here (but it might be broken also - not sure)??
So lots of reasons to love the G431, but how do we use it as an Arduino?? That brings us back to my work on the L071! As mentioned above, that project is currently broken. It will be fixed soon and the documentation will be directly applicable to the G431. In the paragraphs to follow, I will explain how to make the G431 into an Arduino: WeAct Duino!
Let's have a look at the hardware side. WeAct supplies dual rows of square pins to be soldered into the holes in the board, but I wanted something that could plug into a breadboard. I used Arduino connectors on the inside rows and standard square pins on the outer rows as shown.
Now I can plug the WeAct Duino into a breadboard if I want and still have a row or two of connections available for each pin.
WeAct kindly provides pdf versions of the schematics and the board layout. These are very helpful in understanding the design and how to use it effectively. I've included these in the Files section.
The files that actually define a board to the Arduino IDE are those in the variant directories. This is all (or soon will be) explained in the revisions to the tDuino prject referenced above. For now, know that the necessary files (which you will put in place in a few paragraphs) have been suitably modified for the WeAct Duino. The external 8MHz clock crystal on the WeAct board is implemented as the system clock source. The WeAct Duino board runs at 170MHz.
To assist in understanding and using the resources of the WeAct Duino, I created a map of the pin functions. This is WeAct_Pin_Map.png in the Files section, and will be used as a guide to experiments in the Project Logs to follow.
Final hardware note: There are still a few details of the WeAct board that are not clear to me. I am still investigating and will report as I learn.
Hardware ready, let's look at software. Although I will explain all the steps I went through to add the WeAct Duino to the Arduino IDE (as part of the update to the tDuino project), I've provided the necessary files so you can just copy them and go. I'm now running Ubuntu 18.04, but this should work with other recent versions and operating systems. My Arduino version is 1.8.15, but more recent versions should work also. (However, I haven't tried Arduino 2.0...Read more »