CubeMX and Kicad - a helper tool

Hi everyone. I’ve been playing with ST Micro’s CubeMX tool recently, as part of a hobby project. I have no intention of making the PCB, I just find schematic capture and perusing datasheets quite theraputic :slight_smile:

My design uses an STM32F767 - a big 208 pin LQFP Cortex-M7, along with a VGA DAC, Ethernet, USB Hub, Audio Codec, etc. I have been configuring my STM32 pinout using ST’s CubeMX software. If you haven’t seen it, it lets you pick a CPU from the ST catalog, then enable various peripherals. ST’s chips have some flexibility in function routing, but they are not fully flexible like, say, Nordic chips are. By that I mean, if you want to turn on UART4, you might find there are three possible pins that can be U4TX and another three that can be U4RX. If you then enable SPI3, you might find that some of those options for the UART pins are no longer available. Even with a the big 208 pin devices, it can be quite a balancing act to enable all the types of peripherals you want without pin collisions, and CubeMX can help.

What I found tedious though, was copying the pin definitions from CubeMX (PA0 is UART4TX, PC15 is FMC_D3, etc) into Kicad. After I’d relaid out my chip twice and had to tear up a huge set of labels and re-do them, I figured there was an easier way.

Well, here’s a Python tool I wrote. It reads in a Symbol library, a CPU name, a Schematic and a CubeMX pin spreadsheet in CSV format. It then adds labels to the schematic according to the CubeMX configuration, lined up with the pins.

It won’t work for vertical pins, and currently it only appends to the schematic, so you have to manually move the final “$EndSCHEMATC” line otherwise Kicad won’t see all the labels you just added. And you have to delete any existing labels before you run the tool. But so far, it’s helped me out a bit.

Before I go too far down this road, does anyone know if there a plugin system for Kicad which would allow me to integrate this sort of thing? What does everyone else do to copy pin configuration into their schematic tool of choice? Does Altium have features which make this easier? What about for Atmel, or TI, or Silicon Labs parts with configurable pins?

2 Likes

I use ALTIUM and my first thought is always to write scripts for anything that takes me more than 3 repetitive steps stuff, but with every project being just slightly different #xkcd 1205 just did not work out.

The compromise between automation and manual labor I ended up with is it taking the datasheet and/or pin configuration tool, managing that data into an excel sheet and the using Altium’s list editor to paste the date into net labels or whatever makes the most sense. It really is a powerful tool that tends to be overlooked even by experienced users.

https://www.altium.com/documentation/altium-designer/sch-pnl-schlistsch-list-ad

Maybe there is something similar for Kicad.

1 Like