This tutorial is intended to setup an inital Sailbot STM32 development environment along with git version control. We assume you are using a Windows operating system. Before we begin, make sure your system has the following prerequisite tools.
List of tools required to get started:
- STM32Cube IDE - Used to generate initial code and peripherial configurations using the in-built STM32CubeMX.
- Visual Studio Code - Alternative IDE for editting code option to Cube IDE. (optional)
- Putty - Used for serial communication between host and STM32U5 board.
- Git - Version control.
Once you have all the tools ready, we can begin initializing you coding environment.
- Open STM32CubeIDE
- You will be promted to select your workspace. A workspace is a directory that will contain your STM32 projects. If you have not created it before click 'launch' and it should automatically create a workspace in
C:\Users\Sailbot\STM32CubeIDE\workspace_1.14.1
- Open the directory of your workspace (default:
C:\Users\Sailbot\STM32CubeIDE\workspace_1.14.1
) on your file explorer - Right click then 'Git Bash Here' to open up your git bash terminal
- Clone this repo by typing in the command
git clone https://github.com/UBCSailbot/com-module-firmware.git
- You will be in the main branch (Optional you an switch branches using
git checkout branchName
) - Open up CubeIDE again and leave it open on the side
- Go to a project folder that you want to work on e.g project/base-library/project/
- Double click the
.project
file - The Cube IDE should prompt a success and the project should be added to your workspace (under the project explorer)
You have now learnt how to add a project to your workspace. You can create multiple workspaces in STM32 CubeIDE. A workplace can contain projects from any location on your local device and the mapping is stored inside the .metadata
directory. Usually I like to have a workspace that is dedicated to only contain test projects created under the 'tests' directory.
To create a new project under projects/
- Duplicate the preexisting project template directory
projects/template
and change the name to whatever your project is called - Template folder contains all the default configuration and generated files for the STM32U5
- Navigate to the
project/
directory under your newly created project - Open up your workspace in CubeIDE
- Click on
.project
file to add this project to your workspace - The name of the project as seen in the project explorer tab should be "template"
- Right click the project on the project explorer tab and click rename
- Set the name to whatever your project is called and ensure that "Update references" is checked
- Click "Ok"
- To verify that everything is good run a build. Right click the project and bulid (Or Ctr-B)
- You can then open up the ".ioc" file to modify your Pinout and configurations as per project requirements
Inside your projects tests directory, there should contain a test stm32 project template. Follow similar steps listed in the above section to create a new test project.
STM32CubeMX generated Core
directory is where user source code will be written for you applicaion. The Drivers
location contains all the STM32U5 Hardware Abstraction Layer (HAL) drivers, you most probably won't ever need to modify them.
TODO: Walk through the development process. Would be ideal to create seperate folder under src/
that contains all the user codebase instead of dumping them under src/
.
TODO: Possibily create another markdown file detailing the github workflow