Author(s): Peter Giannetos, Thomas McManamen
KiCad files are more difficult and delicate to merge than standard code. Working with multiple contributors requires a specialized workflow. Please use the following guide below as a reference.
How to quickly get started via terminal commands. Recommended Terminal: Git Bash
The Electronic Design Automation (EDA) software used to design our Printed Circuit Boards (PCBs). Install the latest stable release of KiCad v6 and up. This guide was originally written for KiCad v6 but applies to later versions as well.
- Download KiCad: kicad.org/download
The rest of this guide assumes you are somewhat familiar with Git and GitHub. Below is a link to our GitHub guide, but there are also many other online resources and tutorials if you search.
GitHub Guide
- Create a folder where you'd like to localy store the repository.
- Navigate to that folder.
cd /c/Users/Your_PC_Name/Desktop/ISS
- Clone the repository.
git clone https://github.com/ISSUIUC/ISS-PCB
- Check the status of the repository. (Optional)
git status
There are three commonly used branch types in this repository.
-
- The primary branch that only stores finished projects
- Do not directly push to this branch! (Pull requests only!)
- Example:
main
-
- Projects that are being actively developed
- Used to review work from Ticket Branches via pull requests
- Do not directly push to this branch! (Pull requests only!)
- Example:
TARS-MK4-dev
-
- Specific tasks for Project_Dev branches sourced from our Trello
- This is where the majority of the development happens
- Example:
AV-999/Route-FCB-Sensors
There are nine rules you must follow when working in ticket branches to avoid merge conflicts and loss of work.
-
git pull
before every time you begin working and before pushing. This ensures you have the most recent edits from other contributors on the same branch. As a general rule you can nevergit pull
too much.
-
- Merge your work into the Project_Dev branch with a pull request. This allows for new ticket branches to have your work and current ticket branches to rebase with your work. If your work is incomplete, create a draft pull request to still receive feedback.
-
- Rebase your ticket branch from the Project_Dev branch before every work session. This ensures you have the most up to date work from other ticket branches editing Project_Dev. You could alternatively merge your old work and then make a new branch.
-
- Only
git add
one file pergit commit
. However, you may have multiple commits pergit push
. KiCad will ghost edit files even if you don't open them. This will causegit status
to mark them as edited even though no actual changes were made. In short, never automatically add all the 'edited' files to a commit. You must delibratlygit add
the individual files you opened and edited. This also ensures you don't accidentally add any random files.
- Only
-
- There should only be one ticket branch editing a specific file. However a single ticket branch may edit multiple files. This ensures no parallel work is happening on a specific file between multiple branches. This would cause merge conflicts and some work is almost always lost.
-
- Only one person can edit a branch at a time. Co-contributors must coordinate with each other to ensure that only one person is activly editing.
-
- Do not edit files beyond the scope of your ticket for your project. This includes editing files in other project folders and other files in your project folder. This ensures you don't cause merge conflicts for someone else's work on another branch, and that the Project_Dev branch doesn't accidentally edit other projects in Main or other Project_Dev branches. Adding files to the KiCad Parts Library is allowed as long as the parts are related to your work. Rule #4 is the best way to ensure compliance.
-
- Ticket branches should be focused on completing a specific task. This allows you to finish the work faster, receive feedback faster, merge the branch into the Project_Dev branch faster, and start work on a newer up to date Ticket branch faster. For example
Route-FCB-Sensors
is relatively focused, butFinish-FCB
is not and can have a broad interpretation.
- Ticket branches should be focused on completing a specific task. This allows you to finish the work faster, receive feedback faster, merge the branch into the Project_Dev branch faster, and start work on a newer up to date Ticket branch faster. For example
-
- All Ticket branches should be created by branching off of the Project_Dev branch you are working within. Do not make any Ticket branches off of main.
The main
and Project_Dev
branches should be locked down and require pull requests and peer review to add new work. Even admins should have to abide by these restrictions.
Keep the naming of branches consistent between each other.
- Project_Dev:
PROJECT_NAME-dev
➡TARS-MK4-dev
- Ticket Branch:
TEAM-NUMBER/TITLE
➡AV-884/Route-FCB
- The team currently employs a ticketing system where members are assigned to a ticket with a serialized number to complete tasks. (Trello usually works well for this)
- Teams: AV (Avionics), PAY (Payload), REC (Recovery), STR (Structures)
- If you merge your ticket branch but are still working on the same ticket make a new branch with that number but a different
/TITLE
- Ticket #884 Make FCB ➡
AV-884/FCB-Schematic
➡AV-884/FCB-Routing
- Ticket #884 Make FCB ➡
- Other Branches: Name them according to their task/purpose
- The branch this contributing guide was made on was called
Contributing
- The branch this contributing guide was made on was called
Pull requests (PRs) are how to submit work for peer review and merge into Project_Dev branches or main. Submit pull requests as soon as possible in the development cycle to recieve feedback early. It is recomended that PRs and comments are made through github.com and not via the command line.
- Annotate schematics and PCBs before submitting PR's to allow for easier referencing
- Open "Draft" pull requests to review work that is not yet ready to merge.
- Two additional contributors not directly involved with the work should review every pull request before merging.
- Reviews requesting modifications should try to include the component reference number and a checkbox list.
- Critiques should be directed towards the work and not the individual. Be respectful, everyone at one point knew nothing about KiCad.
- If you have an open PR, check GitHub diligently for new comments. It should be an active discussion section for reviewing work. (You can configure notifications to your exact preferences.)
KiCad has a rich default library of parts but often we need to create custom part files for unique components. If the part files can not be found online then custom files can be made with the built-in symbol editor, footprint editor, and your choice of CAD software.
- SnapEDA: Download free symbols, footprints, & 3D models for millions of electronic components.
The KiCad Library Convention (KLC) is a set of guidelines for contributing to the official KiCad libraries. Read over these requirments beforehand and follow them when making custom libraries. Our libraries follow the same guidelines. All libraries should be created with the intent to upstream them to the offficial KiCad Libraries.
- KiCad Library Convention: Library maintainer rules & guidelines
There are three main categories of part files. When adding new components please ensure you source or create all three types.
-
- Used to create schematics and easily diagram electrical connections
.kicad_sym
: A library file containing multiple unique component symbols.
-
- Used to map and route the physical layout of the components
.pretty
: A library folder containing multiple.kicad_mod
files.kicad_mod
: An individual component footprint
-
- Used to render 3D images of the boards
.3dshapes
: A library folder contating multiple.step
and.wrl
files.step
: An individual component 3D model.wrl
: An individual component 3D model with texture data for advanced rendering (Optional)
The custom library used by all the projects in this repository is stored in the root of the repository under the /libs
folder. Any new parts should be added here.
When adding custom libraries to a project, you must point KiCad to the library file using a path linked to the repository and not your local computer, or else the library will not load correctly when the project is opened by other contributors.
-
- In KiCad, locate Preferences ➡ Configure Paths
- Create new variables:
ISS_SYMBOL_DIR
,ISS_FOOTPRINT_DIR
, andISS_3DMODEL_DIR
- Set the locations to those of the
symbols
,footprints
, and3d_models
folders within thelib
folder of your local repository.
-
- Schematics: Symbol Editor ➡ Preferences ➡ Manage Symbol Libraries ➡ Project Specific Libraries
- Footprints: Footprint Editor ➡ Preferences ➡ Manage Footprint Libraries ➡ Project Specific Libraries
- 3D Models: Footprint Editor ➡ Open Footprint ➡ File ➡ Footprint Properties ➡ 3D Models
-
(KiCad may autofill the path if you set it up correctly.)
- Symbols:
${ISS_SYMBOL_DIR}
copy this and replace everything before thefile.kicad_sym
file in the path for the library file - Footprints:
${ISS_FOOTPRINT_DIR}
copy this and replace everything before thefile.pretty
folder in the path for the library file - 3D Models:
${ISS_3DMODEL_DIR}
copy this and replace everything before thefile.3dshapes
folder in the path for the library file - ${ } tells KiCad to look in the folders specified by the path variable. KiCad then searches for the rest of the file path as normal.
- Replace all \ with / in file paths
- Symbols:
-
Every time you import a new custom library to a specific project you must save and push the following files or else your library and relative path won't be imported!
sym-lib-table
: Table of custom imported symbol librariesfp-lib-table
: Table of custom imported footprint librariesfp-info-cache
: GARBAGE! DO NOT PUSH THIS. It's a local cache of your libraries for faster loading on your PC. It's safe to delete but will be regenerated.
Below is a good example with a relative path and a bad example with a user specific path. The steps to import a library are also shown. Navigate to this window by following the "Accessing Settings" section.
If you ever run into merge conflicts, which are common with KiCad, there are a few methods you can take to resolve them. However, there is always a chance that some work may be lost, which is why following the proactive measures in the sections above is crucial.
-
- If you are unable to merge a branch, you can create a new branch and then copy over any work from the old branch to the new branch. This is often the best solution for Ticket branches.
-
-
If you are experienced with KiCad, merge conflict(s) can sometimes be solved by manually editing the files line by line. VSCode or any other text editor should be able to open the files. Be warned that this method is the most complex and likely to cause other issues if done incorrectly.
-
Fun Fact: You can automate KiCad tasks with Python by editing these text files directly or by using the KiCad Python API. However, there is very little documentation regarding this topic.
-
-
- If your entire local repository is acting strange and you can not solve it within 20 minutes, you can opt to reclone the repository in a new folder. You can delete your old local repository if you have no work that you want to save! It is recomended that you copy and paste any work you want to keep from the old repository to the new local repository, and then delete the old repository.
Here is a barebones demo of a typical workflow when working with Ticket branches.
- Run
git pull
to make sure you have the latest version - Make sure you are on the correct branch; If not run
git checkout BRANCH_NAME
- Do some work
- Run
git status
to see the files you've edited - Run
git add FILE_PATH/FILE_NAME
for every individual file you'd like to add - Run
git status
to make sure you added the correct files. - Run
git commit -m "Type Your Comment Here"
to make a commit with your changes - Run
git push
to upload your changes to GitHub
You can clean your repository by running the following commands. Just make sure you commit and push any unsaved work first! We suggest doing this after every time you push to ensure you don't build a heap of untracked and modified files that'll make it more confusing when running git add
.
git clean -d -n
a dry run of what untracked files your about to permantely deletegit clean -d -f
nukes every untracked directory
See a typo? Think we left some vital information out? Make a branch and edit this file!