Code Monkey home page Code Monkey logo

embeddedsystemswithcmakeandvscode's Introduction

Purpose

The purpose of this repo is for learning new (and old) tools used in embedded development. I am currently using the following tools:

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.

  1. samd21_xplained_pro
    a. CMake arg for target is SAMD21J18A
    b. J-Link arg for target is ATSAMD21J18
    c. SVD file is ATSAMD21J18A.svd
  2. 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.

  1. Add a new folder under projects with your project name.
  2. Add a CmakeLists.txt file to the root of your project using an existing project's CmakeLists.txt file as an example.
  3. Add .vscode folder and copy contents of existing projects .vscode folder to yours. Update appropriately.
  4. Add a jdebug project file for your project for Ozone
  5. In the 'projects' directories CmakeLists.txt file insert an add_subdirectory() command for your project.
  6. 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:

  1. VS Code with the following extensions:
    a. C/C++ Extension Pack
    b. Cmake Tools
    c. Cmake language support (optional)
    d. Cortex-Debug
  2. CMake build configuration tool
  3. Ninja build generator
  4. 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

embeddedsystemswithcmakeandvscode's People

Contributors

j3270 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.