This repository is aimed to be used into an STM32Cube project in order to use GIT properly with different STM32 models.
In fact, the use of git with STM32Cube is not straightforward as the latter generates lots of different files depending on your STM32 model. This repo addresses the problem by decoupling STM32 specific files (that will be ignored by git), and your code files.
- Create your project on STM32CubeIDE with the right configuration according to your STM32 model
- Open a GIT bash into the root of your project
- Clone the stm32-base project:
git clone --depth=1 https://github.com/Nanssss/STM32Cube-git-base.git - Run the command
stm32-base/setup.sh - In STM32Cube, right click on your project -> Refresh
- In STM32Cube, go to Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> MCU GCC Compiler -> Include paths and add the path ${ProjDirPath}/Common
- Add
#include "real_main.h"in the /Core/Inc/main.h - In the while loop of the main function of the /Core/Src/main.c file, add
real_main();to call your real main - Now you can developp your own code and functions in the real_main.c file and Common directory
- Open a GIT bash in the root of your project
- Run the command
git init - Link your project with its GitLab repository:
git remote add origin <REPO_URL> - Pull the content:
git pull origin main - Add the files you want with
git add . - Create your first commit
git commit -m "Your commit message" - Push your commit:
git push origin main
Now that it's done, you can use your project repository with different STM32 as long as your configuration is OK. (Note you might have to adapt certain parts of the code if the configuration changes between 2 STM32)