[TIL] How to generate custom footprints in KiCad

Cover Image for [TIL] How to generate custom footprints in KiCad
Max Scheffler
Max Scheffler

I was debugging a new PCB that I developed a couple weeks back. The LiPo charger IC would just not charge the battery. I was probing the board with an oscilloscope, trying to debug with a thermal camera and looking at the data sheet over and over again. And then it hit me, did I perhaps select the wrong footprint? I did and I needed to update the board. That should be an easy fix except that KiCat didn't have the footprint I needed.

It's clear the IC would not make good contact with the pads as there are only about 100 micron or so overlap between inner edge of the pad and outer edge of the IC's contacts. The thermal pad is also way to big and close to the IC's contacts.
Footprint is just too large for this tiny IC.

I needed a TDFN-6-1EP_2x2mm_P0.5mm_EP0.6x1.6mm and all I got was a TDFN-6-1EP_2.5x2.5mm_P0.65mm_EP1.3x2mm. And that's the one I was using initially. I didn't think hard enough at the time and clearly missed that the IC would not fit at all. Now I had to go and copy the existing one and go through the hassle of making the necessary adjustments. But while doing so I noticed this line in the footprint’s description:

TDFN, 6 Pin (, generated with kicad-footprint-generator

Generated. To my surprise, there is a repository of scripts that generates all kinds of footprints and it should be very possible to generate the one I needed too. What follows are the steps I took to get my footprint.

  1. Check out KiCad Footprint Generator.
  2. Navigate to the script for the footprint category you're after. For me that was scripts/Packages/Package_NoLead__DFN_QFN_LGA_SON/size_definitions/dfn.yaml.
  3. Add the footprint of your choice to the YAML file copying from a similar footprint.
  4. Run the script responsible for the footprint category you're using. For me that was python size_definitions/dfn.yaml.
  5. Import the footprint in question into KiCad.
  6. Success ✨