Motor Board Bring Up

I've populated the critical parts of the motor driver board now. The connectors and pin headers can wait until I've verified the microcontroller is running.

Motor driver PCB with the main components populated.
Mostly just connectors to add, there are some missing ESD protection diodes which are on backorder

The STM32G0 series microcontroller on our motor board is pretty new. To get support in OpenOCD (the open-source programming/debugging tool I use) I had to build from source. The guide on this blog worked well for me on Ubuntu 20.04. I'm using my old Olimex ARM USB OCD JTAG adapter, but the STM32G0 series only do serial wire debug (SWD) so I need to add one of the JTAG to SWD adaptors. Getting that working on the command line means an extra config file but it's all been in OpenOCD for a while so:

openocd -f interface/ftdi/olimex-arm-usb-ocd.cfg -f interface/ftdi/olimex-arm-jtag-swd.cfg -f target/stm32g0x.cfg

is enough to get the OpenOCD server running and you can then telnet in and check the chip is talking. That's a good first step for board bring up as it doesn't rely on any code.

Next I need to get a skeleton project working. I've not used a new ST part for a few years and the old Standard Peripheral Library I'm familiar with is no longer supported on new parts. I really don't like the new HAL library, it's too high level for me. I'm going to use the LL API which comes bundled with the HAL in STM32Cube and looks a lot like the old library I'm used to but with "LL_" on the start of everything.

I've linked in the library as a submodule and copied one of the template projects. I'm not going to rely on the STM32Cube IDE, I don't like IDEs generally because they often hide details about compiler switches or defines in some weird project file that you can't reproduce on the CLI easily. Instead I'm creating a simple Makefile which will compile, link and flash my code and keeps all the options in a format I can just run on the command line.

With it all hooked up, the object files listed in the Makefile and a couple of lines added to the dummy project to make GPIOB pin 0 toggle I've got the red LED on the board blinking!

You can see the firmware in GitHub, the very first commit was the blinking light demo. If you're cloning, don't forget to do git submodule update --init to get the STM32Cube dependency.

Motor driver PCB with red LED illuminated.
The red LED is blinking about once a second now.