Skip to content

Commit 0e8c2f3

Browse files
committed
Incremental WIP for testing, cleanup, VSCode move
1 parent 2e28ca9 commit 0e8c2f3

File tree

15 files changed

+588
-187
lines changed

15 files changed

+588
-187
lines changed

.editorconfig

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/test-build-cmake-dot-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ jobs:
9999
fi
100100
101101
# Sample build
102-
cmake --build build-stm32h7 -j
102+
cmake --build build-stm32h7 --parallel 8

.github/workflows/test-library.yml

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
steps:
4242
- uses: actions/checkout@v4
4343
with:
44+
clean: true
4445
submodules: true
4546

4647
- name: make clean
@@ -54,28 +55,89 @@ jobs:
5455
HASH: ${{ matrix.hash }}
5556
MATH: ${{ matrix.math }}
5657
run: |
58+
# Test various library parameters
59+
60+
export MAKE_SIGN="${ASYM^^}"
61+
export MAKE_HASH="${HASH^^}"
62+
export MAKE_MATH='${{ matrix.math }}' # e.g., "SPMATH=1 WOLFBOOT_SMALL_STACK=1"
63+
export PRIVATE_KEY="wolfboot_signing_private_key.der"
64+
65+
echo "This MAKE_SIGN=$MAKE_SIGN"
66+
echo "This MAKE_HASH=$MAKE_HASH"
67+
echo "This MAKE_MATH=$MAKE_MATH"
68+
5769
# Sample build
5870
build_once() {
5971
# Convert asym and hash to upper case, optionally add additional param
60-
make -j test-lib SIGN=${ASYM^^} HASH=${HASH^^} ${MATH} "$@"
72+
echo "Build test-lib..."
73+
echo "make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} \"$@\""
74+
make -j1 test-lib SIGN=${MAKE_SIGN} HASH=${MAKE_HASH} ${MATH} "$@"
6175
}
6276
6377
set -euo pipefail
6478
6579
# Get the reference config
6680
cp config/examples/library.config .config
6781
82+
# peek
83+
echo "Existing files?"
84+
if [ -f "src/keystore.c" ]; then
85+
echo "WARNING: Found unexpected src/keystore.c"
86+
fi
87+
if [ -f "include/target.h" ]; then
88+
echo "WARNING: Found unexpected include/target.h"
89+
fi
90+
if [ -f "keystore.der" ]; then
91+
echo "WARNING: Found unexpected keystore.der"
92+
fi
93+
if [ -f "wolfboot_signing_private_key.der" ]; then
94+
echo "WARNING: Found unexpected wolfboot_signing_private_key.der"
95+
fi
96+
if [ -f "./tools/keytools/keystore.der" ]; then
97+
echo "WARNING: Found unexpected ./tools/keytools/keystore.der"
98+
fi
99+
if [ -f "./tools/keytools/wolfboot_signing_private_key.der" ]; then
100+
echo "WARNING: Found unexpected ./tools/keytools/wolfboot_signing_private_key.der"
101+
fi
102+
68103
# Keytools
69-
make keytools
70-
./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
104+
echo ""
105+
echo "make -j1 keytools SIGN=\"${MAKE_SIGN}\" HASH=\"${MAKE_HASH}\" $MATH"
106+
make -j1 keytools SIGN="${MAKE_SIGN}" HASH="${MAKE_HASH}" $MATH
107+
108+
# Generate keys
109+
echo ""
110+
echo "./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der"
111+
./tools/keytools/keygen --${ASYM} -g wolfboot_signing_private_key.der
112+
113+
# Force fresh files
114+
# peek
115+
echo "Existing files?"
116+
if [ -f "src/keystore.c" ]; then
117+
echo "Found unexpected src/keystore.c"
118+
fi
119+
if [ -f "include/target.h" ]; then
120+
echo "Found unexpected include/target.h"
121+
fi
122+
if [ -f "keystore.der" ]; then
123+
echo "Found unexpected keystore.der"
124+
fi
125+
if [ -f "wolfboot_signing_private_key.der" ]; then
126+
echo "Found unexpected wolfboot_signing_private_key.der"
127+
fi
71128
72129
# Sign
130+
echo ""
73131
echo "Test" > test.bin
74-
./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
132+
echo "Sign test.bin"
133+
echo "./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1"
134+
./tools/keytools/sign --${ASYM} --${HASH} test.bin wolfboot_signing_private_key.der 1
75135
76136
# First attempt
77137
if build_once >build.out 2>build.err; then
78138
echo "Success on first attempt, WOLFBOOT_HUGE_STACK not applied."
139+
cat build.out
140+
cat build.err
79141
exit 0
80142
fi
81143
@@ -90,12 +152,16 @@ jobs:
90152
build_once WOLFBOOT_HUGE_STACK=1
91153
else
92154
echo "Build failed for another reason:"
155+
cat build.out
93156
cat build.err
94157
exit 1
95158
fi
96159
97160
- name: Run test-lib
98161
run: |
162+
# Check test_v1_signed.bin
163+
164+
echo "./test-lib test_v1_signed.bin"
99165
./test-lib test_v1_signed.bin
100166
./test-lib test_v1_signed.bin 2>&1 | grep "Firmware Valid"
101167
@@ -104,5 +170,25 @@ jobs:
104170
# Corrupt signed binary
105171
truncate -s -1 test_v1_signed.bin
106172
echo "A" >> test_v1_signed.bin
107-
./test-lib test_v1_signed.bin
108-
./test-lib test_v1_signed.bin 2>&1 | grep "Failure"
173+
174+
# Run once, capture output and status
175+
set +e
176+
output=$(./test-lib test_v1_signed.bin 2>&1)
177+
status=$?
178+
set -e
179+
180+
echo "$output"
181+
182+
# Must have failed (non-zero exit)
183+
if [ $status -eq 0 ]; then
184+
echo "Expected failure, but exit code was 0"
185+
exit 1
186+
fi
187+
188+
# Must include the expected Failure message
189+
echo "$output" | grep -F "Failure" >/dev/null || {
190+
echo "Expected 'Failure' not found in output"
191+
exit 1
192+
}
193+
194+
echo "Got expected non-zero exit and 'Failure' message."

.github/workflows/test-vscode.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: wolfBoot VSCode
2+
3+
on:
4+
push:
5+
# TODO: branches: [ 'master', 'main', 'release/**' ]
6+
branches: [ '*' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
workflow_dispatch:
10+
inputs:
11+
workspace_path:
12+
description: "Path to the .code-workspace file"
13+
required: true
14+
default: "IDE/VSCode/wolfBoot.code-workspace"
15+
cmake_list_presets:
16+
description: "Also run 'cmake --list-presets'"
17+
required: true
18+
default: "true"
19+
20+
jobs:
21+
check:
22+
runs-on: ubuntu-latest
23+
# Provide fallbacks when not workflow_dispatch
24+
env:
25+
WORKSPACE_PATH: ${{ github.event_name == 'workflow_dispatch' && inputs.workspace_path || 'IDE/VSCode/wolfBoot.code-workspace' }}
26+
CMAKE_LIST: ${{ github.event_name == 'workflow_dispatch' && inputs.cmake_list_presets || 'true' }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Install Python and CMake deps
32+
run: |
33+
sudo apt-get update
34+
sudo apt-get install -y python3 python3-pip ninja-build
35+
cmake --version
36+
ninja --version
37+
38+
- name: Validate workspace JSONC and folder paths
39+
shell: python3 {0}
40+
env:
41+
WORKSPACE_PATH: ${{ env.WORKSPACE_PATH }}
42+
run: |
43+
import os, sys, re, json, pathlib
44+
print("pwd:", pathlib.Path(".").resolve())
45+
ws_rel = os.environ.get("WORKSPACE_PATH", "").strip()
46+
print("WORKSPACE_PATH:", ws_rel or "<EMPTY>")
47+
48+
if not ws_rel:
49+
print("WORKSPACE_PATH input is required", file=sys.stderr)
50+
sys.exit(2)
51+
52+
ws = pathlib.Path(ws_rel)
53+
if not ws.exists():
54+
print(f"Workspace file not found: {ws}", file=sys.stderr)
55+
sys.exit(3)
56+
57+
txt = ws.read_text(encoding="utf-8", errors="replace")
58+
# strip /* */ and // comments (JSONC -> JSON)
59+
txt = re.sub(r"/\*.*?\*/", "", txt, flags=re.S)
60+
txt = re.sub(r"//.*", "", txt)
61+
try:
62+
data = json.loads(txt)
63+
except Exception:
64+
print("Failed to parse workspace as JSON after removing comments.", file=sys.stderr)
65+
raise
66+
67+
folders = data.get("folders", [])
68+
if not isinstance(folders, list) or not folders:
69+
print("No 'folders' defined in workspace.", file=sys.stderr)
70+
sys.exit(4)
71+
72+
ws_dir = ws.parent.resolve()
73+
errors = 0
74+
for idx, item in enumerate(folders):
75+
if not isinstance(item, dict):
76+
print(f"folders[{idx}] is not an object", file=sys.stderr)
77+
errors += 1
78+
continue
79+
path = item.get("path"); uri = item.get("uri")
80+
if path is None and uri is None:
81+
print(f"folders[{idx}] missing 'path' or 'uri'", file=sys.stderr)
82+
errors += 1
83+
continue
84+
if path is not None:
85+
if not isinstance(path, str):
86+
print(f"folders[{idx}].path is not a string", file=sys.stderr)
87+
errors += 1
88+
else:
89+
resolved = (ws_dir / path).resolve()
90+
print(f"[ok] folders[{idx}] path='{path}' -> '{resolved}'")
91+
if not resolved.exists():
92+
print(f"[warn] resolved path does not exist on runner: {resolved}", file=sys.stderr)
93+
if uri is not None:
94+
print(f"[info] folders[{idx}] uses 'uri': {uri}")
95+
96+
if errors:
97+
sys.exit(5)
98+
99+
settings = data.get("settings", {})
100+
if settings and not isinstance(settings, dict):
101+
print("settings is not an object", file=sys.stderr)
102+
sys.exit(6)
103+
104+
print("Workspace JSONC and folder paths look sane.")
105+
106+
- name: List CMake presets (optional)
107+
if: ${{ env.CMAKE_LIST == 'true' }}
108+
run: |
109+
cmake --list-presets || true

.vscode/launch.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 0 additions & 35 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ if(NOT SIGN STREQUAL "NONE")
14131413
add_custom_command(
14141414
OUTPUT ${KEYSTORE} ${WOLFBOOT_SIGNING_PRIVATE_KEY}
14151415
COMMAND "${KEYGEN_TOOL}" ${KEYTOOL_OPTIONS}
1416-
# --no-overwrite # not yet, see https://github.com/wolfSSL/wolfBoot/pull/636
1416+
--no-overwrite
14171417
-g ${WOLFBOOT_SIGNING_PRIVATE_KEY}
14181418
-keystoreDir ${CMAKE_CURRENT_BINARY_DIR}
14191419
DEPENDS ${KEYGEN_TOOL}

IDE/VSCode/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ set(USE_DOT_CONFIG false)
3333

3434
### VS Code extensions
3535

36-
- CMake Tools (ms-vscode.cmake-tools)
36+
- [CMake Tools (ms-vscode.cmake-tools)](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools)
3737
- C/C++ (ms-vscode.cpptools)
3838
- Cortex-Debug (marus25.cortex-debug)
3939

@@ -45,7 +45,7 @@ cmake, ninja-build, gcc-arm-none-eabi, openocd
4545

4646
#### Windows path:
4747

48-
Windows path: CMake, Ninja, Arm GNU Toolchain, OpenOCD (or ST's OpenOCD)
48+
Windows path: CMake, Ninja, Arm GNU Toolchain, OpenOCD (or ST’s OpenOCD)
4949

5050
Install via PowerShell (will need to restart VSCode):
5151

0 commit comments

Comments
 (0)