Skip to content

Conversation

gojimmypi
Copy link
Contributor

@gojimmypi gojimmypi commented Oct 6, 2025

This is a static, idea-sharing-only PR proposing improvements to wolfBoot Cmake. See also my active dev branch.


Test Drive

Work remains on CMake files, but the initial VS Code build should be working:

https://github.com/gojimmypi/wolfBoot.git
cd wolfboot
git checkout pr-cmake-improvements
git pull --recurse-submodules
git submodule update --init --recursive

#launch VS Code and open  wolfBoot.code-workspace  
code wolfBoot.code-workspace

# or your favorite cmake-aware editor such as Visual Studio 2022, etc.

Select STM32L4 wait for Cmake to finish, then click build. The output pane might be not visible. Grab frame to expand up:

image

I'm not sure yet which extensions are required, but at least the Microsoft ms-vscode.cmake-tools.

image

Here's a list of what I have installed:

code --list-extensions

davidanson.vscode-markdownlint
github.vscode-github-actions
marus25.cortex-debug
mcu-debug.debug-tracker-vscode
mcu-debug.memory-view
mcu-debug.peripheral-viewer
mcu-debug.rtos-views
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-wsl
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
ms-vscode.makefile-tools
nordic-semiconductor.nrf-kconfig
platformio.platformio-ide
trond-snekvik.gnu-mapfiles
twxs.cmake

Development

I use Visual Studio for CMake development but the objective is for an IDE-agnostic CMake build experience.

I use VisualGDB for embedded development; this will be a good exercise for flexible HAL file positioning and config.

I'm using an STM32L4, specifically the B-L475E-IOT01A Discovery kit IoT node that I happened to have on hand related to #585.

Some of the changes are specifically hard-code to the above. My objective is to make everything a configuration setting.

Included so far:

VS Code Presets

Was previously OS-specific, and needed to be launched from VS2022 command prompt. The stm32l4 tested (see above).

image

Visual Studio 2022

There's currently no VS2022 project file. Simply open the directory.

Select a device from the ribbon bar, shown here for the stm32l4

image

From Solution Explorer, right-click CmakeLists.txt and then select Configure wolfBoot.

image

To build, follow the same steps to right click, and select Build.

View the CMake and Build messages in the Output Window. Noter the dropdown to select view:

image


CMake Dev Status:

Status Environment Test With
VS 2022 Right-Click on CMakeLists.txt, Build
WSL ./my_test.sh
⚠️ Mac test-build-cmake-mac.yml
VS Code, Dev Prompt Click "build" on bottom toolbar ribbon
DOS Prompt, Dev Prompt my_test.bat
PowerShell, Dev Prompt .\my_test.bat
DOS Prompt, direct launch my_test.bat (cmake missing from path)
PowerShell, direct launch my_test.bat (cmake missing from path)
VS Code, direct launch Needs CMake Tools. Click "build" after launching:
code wolfBoot.code-workspace

Make Dev Status:

Status Environment Test With
? VS 2022 N/A (?)
WSL ./wolfbuild.sh --target stm32l4
⚠️ Mac test-build-cmake-mac.yml
? VS Code, Dev Prompt N/A (?)
DOS Prompt, Dev Prompt
PowerShell, Dev Prompt
DOS Prompt, direct launch
PowerShell, direct launch
? VS Code, direct launch N/A (?)

@gojimmypi gojimmypi self-assigned this Oct 6, 2025
@gojimmypi gojimmypi marked this pull request as draft October 6, 2025 17:17
Copy link
Member

@danielinux danielinux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR Jim.

I did not test but I've spotted a bit too much pollution of the / directory. Please move .sh and .bat files under tools/scripts/. There are also some cmake-specific json files that could go under cmake/

The documentation for cmake builds (including existing one) should probably be moved in a new file under docs/ and referred to from /README.md

Let's not put platform-specific (stm32?) information in the main README.md either. This will confuse users on all other targets. Anything target-specific should be in docs/Targets.md.

Some files have meaningless or confusing names (my_test, wolfbuild)

Some instructions point to your private repository

arm-none-eabi-gcc --version # should print the version
```

The device manufacturer toolchain _also_ needs to be installed. For example without the [STM32CubeIDE Software](https://www.st.com/en/development-tools/stm32cubeide.html),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation seems STM32 specific. Should it be in docs/Target.md or a separate docs/Cmake.md perhaps?

## Quick Start

```bash
git clone https://github.com/gojimmypi/wolfBoot.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your branch?

@@ -0,0 +1,63 @@
# wolfboot/cmake/config_defaults.cmake
#
# Copyright (C) 2022 wolfSSL Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix copyright year

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix those in my WIP / dev, also put up #609

@@ -0,0 +1,94 @@
# wolfboot/cmake/current_user.cmake
#
# Copyright (C) 2022 wolfSSL Inc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2025

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move ths to tools/scripts/ (create a new directory there if needed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move under tools/scripts/... and rename to something meaninful

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to tools/scripts and rename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps:
wolfboot_build.sh
wolfboot_cmake_build.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved under cmake/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it needs to be in the root with CMakeLists.txt. See docs. I'll add comments & README link.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved under cmake/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved under cmake/ ?

}
},
{
"name": "mac-stm32l4",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preset was very nice and worked... it built. But There will be 100's of targets, so idealy the pre-set for each OS and have way for someone to customize that for their board.

Also warnings:

[cmake] CMake Warning:
[cmake]   Manually-specified variables were not used by the project:
[cmake] 
[cmake]     BOARD
[cmake]     CORTEX_M0
[cmake]     DEBUG
[cmake]     DUALBANK_SWAP
[cmake]     STM32L4_PART
[cmake]     V
[cmake]     VTOR
[cmake]     WOLFTPM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dgarske - yay! That's just what I was looking for, as I don't have a Mac.

As you noted, there are hundreds of targets; I'm working on removing the OS target from the preselects.

For customizations, there are a variety of locations:

  • Primarily in CMakeSettings.json (and in there, common settings can be inherited from templates, for example:
    {
      "name": "stm32l4",
      "displayName": "STM32L4",
      "inherits": [
        "base",
        "stm32"
      ],

Much work remains, including cleanup... but the end product will be quite nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants