Script for creating KiCad symbols for STM32 MCUs

ST has recently released a tool for creating projects for STM32 mcu’s called STM32CubeMX . This tool also allows you to plan your pin layout for a selected MCU part. Using the interface you see below, you can select pin features and configuration. You can also label the pins as you desire.

After you plan your pin layout, you can create a list of pins in the form of a CSV file. For this from menu select: “Pinout > Generate CSV pinout text file”. This should create a CSV file similar to this:

"Position","Name","Type","Signal","Label"
"1","VBAT","Power","",""
"2","PC13-ANTI_TAMP","I/O","",""
"3","PC14-OSC32_IN","I/O","RCC_OSC32_IN",""
"4","PC15-OSC32_OUT","I/O","RCC_OSC32_OUT",""
"5","PH0 - OSC_IN","I/O","RCC_OSC_IN",""
"6","PH1 - OSC_OUT","I/O","RCC_OSC_OUT",""
"7","NRST","Reset","",""
"8","VSSA/VREF-","Power","",""
...
...
...

Using this file and my script you can create a KiCad symbol that is specific to this pin layout in a whim. Get the script here.

When you run the script from the command line:

./makestmlib.py --name symbol_name input_file_name.csv output_file_name.lib

It should generate a KiCad symbol library which contains a symbol similar to what you see below.

As you can see output isn’t perfect. It certainly requires some edits. But it’s still very very useful.

Leave a Reply

Your email address will not be published. Required fields are marked *