Purpose
The purpose of this repo is for learning new (and old) tools used in embedded development. I am currently using the following tools:
- ARM GNU Toolchain
- Segger's Ozone Debugger
- CMake
- Ninja
- VS Code
- Advanced Software Framework v3.51.0 from Microchip (Atmel)
https://asf.microchip.com/docs/latest/index.html
The ASF download didn't include SVD files for peripheral register viewing in VS Code and Ozone. I found them here,
SVD Files
Repository Structure
- build (ignored)
- devices (future work for sensors, external memory, etc..)
- projects
- Submodules (External repos)
- scheduler (Simple CoOp scheduler I am playing with)
- tools (Cmake files/modules, svd files, SeggerRTT, etc.)
- xdk-asf-3.51.0 (need to trim files not needed)
Boards
I am currently using the following evaluation boards for developemnt.
- samd21_xplained_pro
a. CMake arg for target is SAMD21J18A
b. J-Link arg for target is ATSAMD21J18
c. SVD file is ATSAMD21J18A.svd - Adafruit Feather M0 Basic Proto
a. CMake arg for target is SAMD21G18A
b. J-Link arg for target is ATSAMD21G18
c. SVD file is ATSAMD21G18A.svd
I updated the EDBG firmware on the SAMD21_Xplained_pro evaluation board to Segger_OB firmware by following the instructions at this link, Firmware for Atmel EDBG on Xplained Platforms. This firmware makes the EDBG mcu J-Link compatiable with some limitations that are documented at the previous link.
VS Code & CMake Workspace/Project structure
I have structured my CMake and VS Code workspace files to support a workspace/project structure. The root CmakeLists.txt file adds a subdirectory 'projects'. The projects directory CmakeLists.txt file adds each project as a sub directory allowing for a workspace/project perspective from the root of the repo. All projects are buildable and debugable from the root VS Code workspace.
In addition, each project has its own VS Code workspace file allowing for working with that project stand alone if desired.
To add a new project, start at the project level.
- Add a new folder under projects with your project name.
- Add a CmakeLists.txt file to the root of your project using an existing project's CmakeLists.txt file as an example.
- Add .vscode folder and copy contents of existing projects .vscode folder to yours. Update appropriately.
- Add a jdebug project file for your project for Ozone
- In the 'projects' directories CmakeLists.txt file insert an add_subdirectory() command for your project.
- Update the top level launch.json and tasks.json files for your project.
If anyone has suggestions for improvements on this strategy with respect to my use of Cmake and VS Code workspaces, I would appreciate the feedback. Please be constructive.
Building Projects
The workspace uses Cmake with Cmake tools for VS code to configure the build for each project and Ninja as the build generator. To build the projects you will need to install the following tools:
- VS Code with the following extensions:
a. C/C++ Extension Pack
b. Cmake Tools
c. Cmake language support (optional)
d. Cortex-Debug - CMake build configuration tool
- Ninja build generator
- ARM GNU Toolchain
After installing the above tools, add the following environment variable:
ARM_GCC_INSTALL, which should point to something like C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2020-q4-major
With the above tools installed, you should be able to open the top level workspace file (or an indicidual project workspace file) with VS Code and select GNU ARM Embeeded Toolchain as the active kit. If the CMake extension hasn't already started configuring the build for the project(s), use ctrl+shift+p to bring up the command pallate, type CMake and select CMake: Configure.
Once the build configurations have completed successfully, click the build icon (with 'all' selected, or the individual project you want to build) in the bottom ribon of VS code.
Debugging Projects
Launch configurations have already been added for debugging existing projects with gdb and VS Code. There are plenty of tutorials out there for doing this.
I have also added tasks for debugging with Segger's Ozone. You will need to download and install Ozone, add it to your path, and add the environment variable OZONE for the tasks to work. Running the task should launch Ozone for the project named by the task.
Feedback welcome
For anyone stumbling across this repo and finds these notes to brief, constructive feedback is welcome