|
|
This guide shows how to configure Visual Studio Code to easily develop embedded software with the Skyward Build System. The extensions suggested in this page are used by most of the team and are suggested to new members.
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
Visual Studio Code is available on all major platforms. Just download the installer from [code.visualstudio.com](http://code.visualstudio.com) and run it!
|
|
|
|
|
|
## Installing required extensions
|
|
|
|
|
|
Suggested extensions are:
|
|
|
|
|
|
- **C/C++**: language support for C/C++, including features such as IntelliSense;
|
|
|
- **CMake**: language support for CMake;
|
|
|
- **GitLens**: Enhanced git annotations;
|
|
|
- **Git Graph**: Visualize a Git graph of your repository, useful to quickly view the commit histrory;
|
|
|
- **Cortex-Debug**: ARM Cortex-M GDB debugger support;
|
|
|
- **Code Spell Checker**: Spelling checker for source code.
|
|
|
|
|
|
## Skyward configuration
|
|
|
|
|
|
When cloning on of our repository, you can find IDE configuration files already in the `.vscode` direcotory.
|
|
|
|
|
|
The configurations include different board setups for the C/C++ extension, this will allow intellisense to find the correct source files. Depending on your target board you need to select the proper option in the menu on the bottom right.
|
|
|
|
|
|
The other files in the `.vscode` direcotry contains other information for the debugger and the tasks explained below.
|
|
|
|
|
|
## Building with SBS
|
|
|
|
|
|
The easyest way to build and flash the code is to open the terminal with `ctrl + J` and use the build system directly, for example `./sbs -f test-serial` will build the `test-serial` entrypoint and flash it on to the board.
|
|
|
|
|
|
Another way to do this is thanks to the configuration files mentioned above. VSCode tasks have been prepared to build and flash a project to your board.
|
|
|
|
|
|
### Dependencies
|
|
|
|
|
|
The available commands for VSCode use the [SBS](Skyward-Build-System-(SBS)) script in order to build the project.\
|
|
|
Also the `st-flash` command is used to flash the executable to the board. You should install the [stlink-tools](https://github.com/stlink-org/stlink) package.
|
|
|
|
|
|
### Commands
|
|
|
|
|
|
By using the VSCode shortcut `Ctrl+P` a top bar opens. If you write `task` and hit space, the list of all possible commands will show up.\
|
|
|
These commands include:
|
|
|
|
|
|
- **BUILD current-entrypoint**: build the entrypoint that has the focus in the VSCode editor, according to the entrypoint configuration specified in `CMakeLists.txt`.
|
|
|
- **BUILD all entrypoints**: build all the entrypoints that are specified in `CMakeLists.txt`.
|
|
|
- **BUILD tests-catch**: build the _catch-tests-entry_ entrypoint, according to the entrypoint configuration specified in `CMakeLists.txt`.
|
|
|
- **BUILD+RUN current-entrypoint**: build the entrypoint that has the focus in the VSCode editor and automatically flash the resulting executable to the target board specified in `CMakeLists.txt`.
|
|
|
- **CLEAN**: clean binaries and build files.
|
|
|
- **RUN current-entrypoint**: flash to the target board the executable related to the entrypoint opened in VSCode.
|
|
|
- **RUN tests-catch**: flash to the target board the _catch-tests-entry_ entrypoint, it will automatically run all the catch tests specified in `CMakeLists.txt`.
|
|
|
|
|
|
### Shortcuts
|
|
|
|
|
|
It can be very useful to know that the keyboard shortcut `Ctrl+Shift+B` triggers the `BUILD+RUN current-entrypoint` command.
|
|
|
|
|
|
For what concerns `clang-format` you can use the shortcut `Ctrl+Shift+I` (or `Ctrl+Shift+F` on Windows). It should automatically format your code according to Skyward's `.clang-format` style. If it doesn't, configure the command to use it.\
|
|
|
You can also set it to be executed every time you save a file which is very comfortable.
|
|
|
|
|
|
# In circuit debugging
|
|
|
|
|
|
## Install required software & extensions
|
|
|
|
|
|
- Openocd: `sudo apt install openocd`
|
|
|
- Cortex-debug extension:<https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug>
|
|
|
|
|
|
## Configure your VSCode project
|
|
|
|
|
|
1. Copy the file `launch.json` into the `.vscode` folder in the root of your project.
|
|
|
2. Finally, run `./sbs -c` to make sure everything is clean.
|
|
|
|
|
|
## Debug your code
|
|
|
|
|
|
1. Build & flash your entrypoint on your board
|
|
|
2. In the "debug" menu in vscode, run "ST-LINK V2 (current entrypoint)" if you are using a st-link v2 device (recent discovery boards are all stlink v2) or "ST-LINK V1 (current entrypoint)" (run this if you are running on our custom boards). In the case of ST-LINK V1 devices, you may need to change the configuration file in `launch.json` with the one of your board (`configFiles` property)
|
|
|
3. Happy debugging!!
|
|
|
|
|
|
 |
|
|
\ No newline at end of file |