-
Couldn't load subscription status.
- Fork 131
WIP CMake Improvements #598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
README.md
Outdated
| 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), |
There was a problem hiding this comment.
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?
README.md
Outdated
| ## Quick Start | ||
|
|
||
| ```bash | ||
| git clone https://github.com/gojimmypi/wolfBoot.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
your branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, removed
cmake/config_defaults.cmake
Outdated
| @@ -0,0 +1,63 @@ | |||
| # wolfboot/cmake/config_defaults.cmake | |||
| # | |||
| # Copyright (C) 2022 wolfSSL Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix copyright year
There was a problem hiding this comment.
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
cmake/current_user.cmake
Outdated
| @@ -0,0 +1,94 @@ | |||
| # wolfboot/cmake/current_user.cmake | |||
| # | |||
| # Copyright (C) 2022 wolfSSL Inc. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fixed now
my_test.sh
Outdated
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. see cmake_test.sh
wolfbuild.sh
Outdated
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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/ ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
CMakePresets.json
Outdated
| } | ||
| }, | ||
| { | ||
| "name": "mac-stm32l4", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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"
],
- Optionally in
CMakeUserPresets.json(see CMakeUserPresets.json.sample)
Much work remains, including cleanup... but the end product will be quite nice.
|
Hi @danielinux Thanks for your feedback! I realize that I came in for a remodel and left a bunch of trash laying around. I've cleaned this up in my latest 32e46e6 commit. Thing are still WIP on my dev branch, but things here in this PR should be a bit cleaner now. @dgarske - I've not yet addressed the unused cmake vars. Changes of interest since my prior commit include non-os-specific presets. more testing, more docs (including cmake .config), script improvements, VS Code workspace moved to root directory, improved dynamic cmake downloads, main cmake functionality moved to include files in the There's more work to be done, particularly around supporting all of the targets. I'd like to get this initial update stable and merged before moving on to additional features and target devices. Suggestions welcome. EDIT: Launching VS Code from a non-VS2022 dev prompt (compiler NOT in the path by default) is not working, failing here: I'm revisiting compiler detection. I had this working, must have broke it. The features still work if everything is in the path (e.g. launch from Visual Studio command prompt), but it should support a fully specified toolchain & include path with no assumptions, nothing in path. |
| 3. Cannot open compiler generated file ... Permission denied | ||
|
|
||
| ```text | ||
| sp_c32.c : fatal error C1083: Cannot open compiler generated file: '... sp_c32.obj': Permission denied | ||
| ``` | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
| Some interim notes on progress in various environments: | ||
|
|
||
| ## CMake Dev Status: | ||
|
|
||
| |Status | Environment | Test With | ||
| |-------| ------------------------- | -------- | ||
| | ✅ | VS 2022 | Right-Click on [CMakeLists.txt](./CMakeLists.txt), Build | ||
| | ✅ | WSL | [./tools/scripts/cmake_test.sh](./tools/scripts/cmake_test.sh) | ||
| | ✅ | Mac | [test-build-cmake-mac.yml](./github/workflows/test-build-cmake-mac.yml) | ||
| | ✅ | VS Code, Dev Prompt | Click "build" on bottom toolbar ribbon | ||
| | ✅ | DOS Prompt, Dev Prompt | [.\tools\scripts\cmake_dev_prompt_test.bat](./tools/scripts/cmake_dev_prompt_test.bat) | ||
| | ✅ | PowerShell, Dev Prompt | [.\tools\scripts\cmake_dev_prompt_test.bat](./tools/scripts/cmake_dev_prompt_test.bat) | ||
| | ✅ | DOS Prompt, direct launch | [.\tools\scripts\cmake_test.bat](./tools/scripts/cmake_test.bat) (needs toolchain path) | ||
| | ✅ | PowerShell, direct launch | [.\tools\scripts\cmake_test.bat](./tools/scripts/cmake_test.bat) (needs toolchain path) | ||
| | ✅ | VS Code, direct launch | Click "build" | ||
|
|
||
| ## Make Dev Status: | ||
|
|
||
| |Status | Environment | Test With | ||
| |-------| ------------------------- | -------- | ||
| | ? | VS 2022 | N/A (?) | ||
| | ✅ | WSL | `./tools/scripts/wolfboot_build.sh --target stm32l4` | ||
| | ⚠️ | Mac | [test-build-cmake-mac.yml](./github/workflows/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 (?) | ||
|
|
||
| --- | ||
|
|
||
| wolfSSL Secure Bootloader ([Home page](https://www.wolfssl.com/products/wolfboot/), [Manual](https://www.wolfssl.com/documentation/manuals/wolfboot/), [wolfBoot-examples](https://github.com/wolfSSL/wolfBoot-examples)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this should not be here.
|
|
||
| OBJS+=$(WOLFCRYPT_OBJS) | ||
|
|
||
| # ==== VisualGDB remap (opt-in) ============================================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to a separate .mk file, then include it here.
| @@ -0,0 +1,11 @@ | |||
| root = true | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file supposed to be here? It seems like your editor configuration. Please remove (and add to .gitignore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more dotfiles from your editor. It looks like the .vscode directory should be in .gitiginore
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:
Select
STM32L4wait for Cmake to finish, then clickbuild. Theoutputpane might be not visible. Grab frame to expand up:I'm not sure yet which extensions are required, but at least the Microsoft
ms-vscode.cmake-tools.Here's a list of what I have installed:
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:
load_dot_config(path)VS Code Presets
Was previously OS-specific, and needed to be launched from VS2022 command prompt. The
stm32l4tested (see above).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
stm32l4From
Solution Explorer, right-clickCmakeLists.txtand then selectConfigure wolfBoot.To build, follow the same steps to right click, and select
Build.View the CMake and Build messages in the
OutputWindow. Noter the dropdown to select view:CMake Dev Status:
Make Dev Status:
./tools/scripts/wolfboot_build.sh --target stm32l4