Getting started with the STM32G071

I bought a couple of STM32G071’s about a month ago but didn’t do much with them as openocd as supplied in Ubuntu didn’t support them. There is however a snapshot of openocd that does. It’s a little out of the way for now and no doubt will be included in the next release so check before trying any of this. So the steps I followed are:

Download and extract :;a=snapshot;h=dcec354bfc756c4a4e1034c9461b5d3f4e55a63e;sf=tgz
Go in to this directory and run the following
git clone
Now, I wasn’t expecting to have to do the next edit but I got compiler errors without it – I suspect my gcc version (8.3.0) is different from the original author’s.
Open file src/flash/nor/stm32g0x.c and starting at line 929 you will see the following code:
struct target *target = NULL;
//struct stm32g0x_flash_bank *stm32x_info = NULL; // <—— COMMENT OUT THIS LINE

if (CMD_ARGC < 1)

struct flash_bank *bank;
int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
if (ERROR_OK != retval)
return retval;

//stm32x_info = bank->driver_priv; // <—— COMMENT OUT THIS LINE

target = bank->target;

if (target->state != TARGET_HALTED) {
LOG_ERROR(“Target not halted”);


run ./bootstrap
run ./configure –enable-stlink –enable-maintainer-mode –disable-internal-libjaylink
sudo make install
This left me with an installation of openocd in /usr/local

Now that I had openocd I needed to get set up for blinky. The STM32G071 version I have is an LQFP32 so a breakout board is needed along with pin headers. Lots of flux and some solder wick was used to fix errors.

The picture below shows the finished circuit

Next step was to put together a simple blinky program. A little background work was needed first to get register definitions and so on. I dug around the web and found the appropriate SVD file for this chip and used svdconv to generate a header file. The final code and the openocd configuration script (stm32g0.cfg) can be found over on github. More examples will follow.

Dublin Maker and Apollo 11

As it happens, Dublin Maker 2019 will occur on the same day as the 50th anniversary of the Apollo 11 moon landing. Once I realized this I had to add a simple moon-lander style game to the Dublin Maker (unofficial) badge.
Flash memory usage is running at 99.98% so I suppose the software for the badge is now “done”
Final badge code is available over here on github.