Projects

Project Orientation

STM32CubeIDE for Visual Studio Code supports many different types of projects. Some examples of the supported project types are listed below.

  1. STM32CubeMX Generated Projects

    STM32CubeIDE for VS Code supports projects generated by STM32CubeMX, ST’s graphical configuration tool. These projects include hardware configuration, middleware, and peripheral initialization code tailored to the selected STM32 MCU.

    • Project Structure: Auto-generated HAL (Hardware Abstraction Layer) code, middleware stacks (USB, TCP/IP, FATFS, etc.), and user application code.

    • Use Case: Rapid prototyping and development with automatic initialization of peripherals and middleware.

    • Build System: Uses Makefiles or CMake depending on project setup.

  2. Bare-Metal STM32 Projects

    Users can create bare-metal projects from scratch or import existing ones. These projects directly control the STM32 hardware without relying on HAL or middleware.

    • Project Structure: Startup files, linker scripts, CMSIS core files, and user-written source code.

    • Use Case: Low-level programming, real-time applications, or when minimal overhead is required.

    • Build System: Typically Makefile or CMake based.

  3. FreeRTOS-Based Projects

    STM32CubeIDE for VS Code supports projects that integrate the FreeRTOS real-time operating system.

    • Project Structure: Includes FreeRTOS kernel source files, configuration headers, and user tasks.

    • Use Case: Applications requiring multitasking, real-time scheduling, and inter-task communication.

    • Build System: Compatible with Makefile or CMake workflows.

  4. STM32Cube Middleware Projects

    Projects that leverage STM32Cube middleware components such as USB Device/Host, TCP/IP stack (LwIP), File System (FATFS), Graphics (TouchGFX), and more.

    • Project Structure: Middleware libraries integrated with HAL and user application layers.

    • Use Case: Complex applications needing advanced connectivity, storage, or graphical interfaces.

    • Build System: Managed via Makefile or CMake.

  5. Example and Template Projects

    STM32CubeIDE for VS Code provides example projects and templates for various STM32 series and application domains.

    • Project Structure: Pre-configured projects demonstrating peripheral usage, communication protocols, or RTOS integration.

    • Use Case: Learning, prototyping, and reference for application development.

    • Build System: Predefined build configurations.

Creating a New Project

Convert and import an Eclipse STM32CubeIDE project

Note

This operation is also available through the CLI. For more information, use the command:

$ cube ide-project-convert --help

In order to convert an existing Eclipse-based STM32CubeIDE project to STM32CubeIDE for VS Code, navigate to the STM32Cube Key Actions section and select Convert Eclipse STM32CubeIDE project .

After selecting this option a drop-down menu where you need to select Project source and Project destination .

Project source: Navigate to and select the root folder of your current Eclipse-based STM32CubeIDE project.

Project destination: Either create a new folder or select a folder where you wish the converted project to be located.

When both of these fields have been filled in a third option will appear, Convert project .

Clicking the Convert project button will invoke the STM32CubeIDE Eclipse exporter.

Once the process is complete you can choose whether you want to open the converted project in the current VS Code window, open it in a new window or add it to your workspace.

Project Configuration

Key components of project configuration include:

  • Settings (`settings.json`) Customize editor behavior, formatting, linting, and other preferences specific to the project. These settings override user-level defaults when the workspace is opened.

  • Tasks (`tasks.json`) Define automated tasks such as building, testing, or deploying your project. Tasks can be executed directly from the VS Code interface or integrated into debugging workflows.

  • Launch Configurations (`launch.json`) Configure debugging options including environment variables, program arguments, and runtime settings for different languages and frameworks.

  • Extensions Recommendations (`extensions.json`) Suggest extensions that are useful for the project, helping team members maintain a consistent development setup.

  • Workspace Configuration (`*.code-workspace`) Optionally, you can use a workspace file to group multiple folders and their configurations into a single project workspace.

By leveraging these configuration files, VS Code provides a flexible and powerful way to tailor the development environment to the specific needs of your project, enhancing productivity and consistency across teams.

For more information, visit the Visual Studio Code Documentation .

Managing Project Properties

Key aspects of managing project properties in VS Code include:

  • Workspace Settings VS Code uses workspace settings stored in the .vscode/settings.json file to configure project-specific options such as formatting rules, linting, and editor preferences.

  • Tasks Configuration The .vscode/tasks.json file allows defining custom build, test, and deployment tasks that can be executed within the editor.

  • Launch Configurations Debugging settings are managed through .vscode/launch.json , where you specify how to run and debug your applications with different environments and parameters.

  • Extensions and Language Support Project-specific configurations often depend on extensions, which may add their own settings to the workspace configuration files to tailor the development experience.

  • Version Control Integration VS Code seamlessly integrates with Git and other version control systems, allowing project-level source control management.

Overall, managing project properties in VS Code revolves around editing JSON configuration files within the .vscode folder, offering flexibility and customization tailored to diverse development workflows.

For detailed customization, visit the Visual Studio Code Documentation .

Project Organization

Effective project organization in Visual Studio Code (VS Code) helps streamline development workflows and improve productivity. VS Code provides flexible tools and features to structure your projects efficiently.

Key aspects of project organization include:

  • Workspace and Folder Structure Organize your source code, assets, and configuration files into logical folders. VS Code supports single-folder workspaces as well as multi-root workspaces that allow managing multiple folders in one window.

  • .vscode Folder This hidden folder contains project-specific configuration files such as settings.json , tasks.json , and launch.json , which customize the editor behavior and tooling per project.

  • Source Control Integration VS Code integrates seamlessly with Git and other version control systems, enabling branch management, commits, and diffs directly within the editor.

  • File and Symbol Navigation Utilize features like the Explorer, Outline view, and Go to Definition to quickly navigate large codebases.

  • Extensions for Organization Leverage extensions such as project managers, file explorers, and code linters to enhance project structure and maintain code quality.

  • Workspace Settings Customize settings at the workspace level to tailor the development environment to the specific needs of each project.

By organizing your project thoughtfully within VS Code, you can maintain clarity, reduce complexity, and foster collaboration across your development team.

For more details, visit the Visual Studio Code Documentation .

Source Folder Structure Best Practices

Organizing the source folder structure effectively is crucial for maintainability, scalability, and collaboration in software projects. While Visual Studio Code (VS Code) is flexible and agnostic about folder layouts, following best practices helps streamline development and improve clarity.

Key best practices for source folder structure include:

  • Logical Separation of Concerns Group files by their roles or features, such as src/ for source code, tests/ for unit tests, docs/ for documentation, and assets/ for images or other resources.

  • Consistent Naming Conventions Use clear and consistent folder and file names to reflect their purpose, making navigation intuitive for all team members.

  • Feature-Based Organization For larger projects, consider organizing code by feature or module rather than by file type, which can improve modularity and ease of maintenance.

  • Configuration and Build Files Keep configuration files (e.g., .vscode/ , package.json , Makefile ) at the root or in dedicated folders to separate them from source code.

  • Avoid Deep Nesting Limit folder depth to reduce complexity and make files easier to locate.

  • Use `.vscode` Folder for Project Settings Store project-specific settings, tasks, and launch configurations in the .vscode folder to keep them organized and version-controlled.

  • Version Control Considerations Ensure that the folder structure aligns well with your version control system, including proper .gitignore files to exclude unnecessary files.

By adhering to these best practices, you can create a clean, maintainable, and scalable project structure that enhances productivity and collaboration within VS Code.

For further guidance, visit the Visual Studio Code Documentation .

Sharing projects

Sharing projects with colleagues in Visual Studio Code (VS Code) can streamline collaboration and ensure everyone is working with the same setup. This guide outlines the steps to share your projects effectively.

Using Version Control Systems (VCS)

Version control systems like Git are essential for sharing projects and collaborating with colleagues. Git allows you to track changes, manage versions, and collaborate on code seamlessly.

  1. Initialize a Git Repository :

    • Open your project in VS Code.

    • Open the terminal and run:

      git init

  2. Add and Commit Files :

    • Stage your files for commit:

      git add .

    • Commit your changes:

      git commit -m "Initial commit"

  3. Push to a Remote Repository :

    • Create a repository on a platform like GitHub, GitLab, or Bitbucket.

    • Add the remote repository to your local Git repository:

      git remote add origin <repository-url>

    • Push your changes:

      git push -u origin master

Sharing Configuration Files

To ensure that your colleagues have the same development environment, share relevant configuration files along with your project.

  1. Extensions : - List the extensions you use in your project and share the list with your colleagues. They can install the same extensions from the Extensions Marketplace.

  2. Settings : - Share your workspace settings by including the .vscode/settings.json file in your project. This file contains custom settings specific to your project.

  3. Tasks and Launch Configurations : - Include the .vscode/tasks.json and .vscode/launch.json files in your project to share build tasks and debugging configurations.

Using Live Share

VS Code’s Live Share extension allows you to collaborate in real-time with your colleagues. It enables you to share your project, terminal, and debugging sessions instantly.

  1. Install Live Share : - Install the Live Share extension from the Extensions Marketplace.

  2. Start a Live Share Session : - Click on the Live Share icon in the status bar. - Sign in with your Microsoft or GitHub account. - Click “Start Collaboration Session” to generate a shareable link.

  3. Join a Live Share Session : - Share the generated link with your colleagues. - They can join the session by clicking the link and opening it in VS Code.

Further Reading

Sharing projects in VS Code can enhance collaboration and ensure everyone is on the same page. By using version control systems, sharing configuration files, and leveraging Live Share, you can create a seamless collaborative environment.

For more detailed information, visit Visual Studio Code Documentation .

Code Freeze and Release Management

Managing code freeze and release processes effectively within Visual Studio Code (VS Code) ensures stability and quality in software development. This guide outlines the specific actions to take inside VS Code.

Code Freeze

  1. Create a Code Freeze Branch :

    • Open your project in VS Code.

    • Open the integrated terminal ( `` Ctrl+` `` ).

    • Create a new branch for code freeze: ` git checkout -b code-freeze `

  2. Commit and Push Changes :

    • Make sure all changes are committed. Use the Source Control view ( Ctrl+Shift+G) to stage, commit, and push changes:
      • Stage all changes: Click the “+” icon next to the changes.

      • Commit changes: Enter a commit message and click the checkmark icon.

      • Push changes: Click the “…” menu and select “Push”.

  3. Restrict Changes to Critical Bug Fixes :

    • Communicate with your team to ensure only critical bug fixes are made in the code-freeze branch. Use the Source Control view to manage commits related to critical bug fixes.

  4. Review and Merge Changes :

    • Use the GitLens extension or the built-in Git features to review and merge any necessary changes into the code-freeze branch: - Open the Command Palette ( Ctrl+Shift+P). - Type “Git: Merge Branch” and select the branch to merge.

Release Management

  1. Create a Release Branch :

    • Open the integrated terminal ( `` Ctrl+` `` ).

    • Create a new branch for the release: ` git checkout -b release-v1.0 `

  2. Tag the Release :

    • Tag the release to mark it in the repository: ` git tag -a v1.0 -m "Release version 1.0" git push origin v1.0 `

  3. Build and Test :

    • Use VS Code tasks to build and test the project: - Open the Command Palette ( Ctrl+Shift+P). - Type “Tasks: Run Task” and select the build or test task. - Monitor the terminal output for any build or test issues.

  4. Prepare Release Notes :

    • Use the Markdown editor in VS Code to prepare release notes: - Create a new file ( Ctrl+N) and save it as RELEASE_NOTES.md . - Document the changes, features, and bug fixes included in the release.

  5. Deploy to Production :

    • Use deployment extensions or integrated terminal commands to deploy the release: - For example, use the Azure App Service extension to deploy to Azure, or use terminal commands for other deployment platforms.

  6. Monitor and Support :

    • Use the integrated terminal and extensions to monitor the release: - Open the terminal ( `` Ctrl+` `` ) to run monitoring scripts. - Use extensions like Docker or Kubernetes to manage and monitor deployments.

Further Reading

Handling code freeze and release management effectively within VS Code ensures the stability and quality of software releases. By following these specific actions, you can manage the process efficiently and deliver reliable software to your users.

For more detailed information, visit the Visual Studio Code Documentation .

Updating Bundles and Components

Keeping your development environment up to date is crucial for maintaining productivity and taking advantage of the latest features and improvements. This guide outlines the steps to update bundles and components in Visual Studio Code (VS Code).

Updating Extensions

Extensions add functionality to VS Code and are a key component of bundles. Regularly updating extensions ensures you have the latest features, bug fixes, and security updates.

  1. Check for Extension Updates :

    • Open the Extensions view ( Ctrl+Shift+X).

    • Click on the “…” menu in the top right corner.

    • Select “Check for Updates”.

  2. Update Extensions :

    • If updates are available, you will see an “Update” button next to each extension.

    • Click the “Update” button to install the latest version of the extension.

  3. Automatic Updates :

    • VS Code can automatically update extensions. To enable this: - Open the Command Palette ( Ctrl+Shift+P). - Type “Preferences: Open Settings (UI)” and select it. - Search for “Extensions: Auto Update” and ensure it is enabled.