Skip to content

Commit c35f117

Browse files
author
gojimmypi
committed
update from dev
1 parent a1ca06c commit c35f117

11 files changed

Lines changed: 714 additions & 87 deletions

.github/workflows/test-build-cmake-mac.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
submodules: true
2525

26-
- name: Cache Homebrew bottles # downloads (so retries dont redownload)
26+
- name: Cache Homebrew bottles # downloads (so retries don't redownload)
2727
uses: actions/cache@v4
2828
with:
2929
path: |
@@ -48,16 +48,30 @@ jobs:
4848
sleep "$throttle_delay"
4949
brew install --force-bottle ninja
5050
51+
# Use cask to include headers such as <stdlib.h>
5152
sleep "$throttle_delay"
52-
brew install --force-bottle arm-none-eabi-gcc
53+
brew install --cask gcc-arm-embedded
5354
54-
- name: Probe GCC sysroot (headers check)
55+
- name: Probe ARM GCC (paths + smoke build)
5556
run: |
5657
set -euxo pipefail
57-
SYSROOT="$(arm-none-eabi-gcc -print-sysroot)"
58-
echo "GCC sysroot: $SYSROOT"
59-
test -f "$SYSROOT/include/stdlib.h" || { echo "Missing stdlib.h in $SYSROOT/include"; exit 1; }
60-
test -f "$SYSROOT/include/string.h" || { echo "Missing string.h in $SYSROOT/include"; exit 1; }
58+
59+
which arm-none-eabi-gcc
60+
arm-none-eabi-gcc --version
61+
62+
echo "=== GCC search dirs ==="
63+
arm-none-eabi-gcc -print-search-dirs
64+
65+
echo "=== GCC verbose include paths (preprocess only) ==="
66+
# This prints the built-in include search order; harmless with empty stdin.
67+
arm-none-eabi-gcc -x c -E -v - < /dev/null || true
68+
69+
echo "=== Compile a freestanding object (no stdlib headers needed) ==="
70+
cat > hello.c <<'EOF'
71+
int main(void) { return 0; }
72+
EOF
73+
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -ffreestanding -nostdlib -c hello.c -o hello.o
74+
ls -l hello.o
6175
6276
- name: Configure (STM32L4)
6377
run: |
@@ -71,7 +85,7 @@ jobs:
7185
7286
- name: Presets
7387
run: |
74-
rm -rf ./build-mac-stm32l4
88+
rm -rf ./build-stm32l4
7589
76-
cmake --preset mac-stm32l4
77-
cmake --build --preset mac-stm32l4
90+
cmake --preset stm32l4
91+
cmake --build --preset stm32l4

.github/workflows/test-build-cmake-windows.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,20 @@ jobs:
7373
shell: bash
7474
run: |
7575
# cmake runs in git bash
76-
echo "disabled"
7776
78-
#BUILD_DIR="build-${{ matrix.target }}"
79-
#cmake -S . -B "$BUILD_DIR" -G Ninja \
80-
# -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_arm-none-eabi.cmake \
81-
# -DWOLFBOOT_CONFIG_MODE=preset \
82-
# -DWOLFBOOT_TARGET=${{ matrix.target }} \
83-
# -DBUILD_TEST_APPS=ON \
84-
# ${{ matrix.extra_cache }}
85-
#echo "Configured: $BUILD_DIR"
77+
BUILD_DIR="build-${{ matrix.target }}"
78+
cmake -S . -B "$BUILD_DIR" -G Ninja \
79+
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain_arm-none-eabi.cmake \
80+
-DWOLFBOOT_CONFIG_MODE=preset \
81+
-DWOLFBOOT_TARGET=${{ matrix.target }} \
82+
-DBUILD_TEST_APPS=ON \
83+
-DWOLFBOOT_PARTITION_BOOT_ADDRESS=0x8020000 \
84+
-DWOLFBOOT_SECTOR_SIZE=0x20000 \
85+
-DWOLFBOOT_PARTITION_SIZE=0xD0000 \
86+
-DWOLFBOOT_PARTITION_UPDATE_ADDRESS=0x80F0000 \
87+
-DWOLFBOOT_PARTITION_SWAP_ADDRESS=0x81C0000 \
88+
${{ matrix.extra_cache }}
89+
echo "Configured: $BUILD_DIR"
8690
8791
- name: Build
8892
shell: bash

CMakeLists.txt

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
cmake_minimum_required(VERSION 3.16)
3333
include(cmake/config_defaults.cmake)
3434

35+
3536
# ------------------------------------------------------------------------------
3637
# Initial environment checks
3738
# ------------------------------------------------------------------------------
@@ -44,6 +45,7 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
4445
You must delete them, or cmake will refuse to work.")
4546
endif()
4647

48+
# This must appear before project(wolfBoot)
4749
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4850
if(DEFINED WOLFBOOT_TARGET AND
4951
NOT WOLFBOOT_TARGET STREQUAL "x86_64_efi" AND
@@ -54,13 +56,26 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
5456
endif()
5557
endif()
5658

59+
5760
# ------------------------------------------------------------------------------
5861
# ------------------------------------------------------------------------------
5962
project(wolfBoot)
6063
# ------------------------------------------------------------------------------
6164
# ------------------------------------------------------------------------------
6265
include(cmake/functions.cmake)
6366

67+
# include(cmake/cube_ide_config.cmake)
68+
69+
# Some OS-specific checks and configs
70+
if(CMAKE_HOST_WIN32)
71+
include(cmake/vs2022_config.cmake)
72+
endif()
73+
74+
if(WOLFBOOT_TARGET STREQUAL "stm32l4" AND NOT FOUND_STM32L4_LIB)
75+
include(cmake/stm32_hal_download.cmake)
76+
endif()
77+
78+
6479
# set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "" CACHE STRING "" FORCE)
6580

6681
# ---- Host compiler (for native tools only) -----------------------------------
@@ -900,24 +915,37 @@ target_sources(wolfboothal PRIVATE include/hal.h hal/${WOLFBOOT_TARGET}.c ${WOLF
900915

901916

902917
# --- HAL for STM32L4 (only the pieces we need) ---
918+
# TODO move this to preset and/or cmake dir
903919
if(WOLFBOOT_TARGET STREQUAL "stm32l4")
904920
if(CMAKE_HOST_WIN32 AND IS_DIRECTORY "${LIB_STM32L4_WINDOWS}" )
905921
message(STATUS "Win32 Path found: ${LIB_STM32L4_WINDOWS}")
906922
set(HAL_BASE "${LIB_STM32L4_WINDOWS}")
907923
elseif(IS_DIRECTORY "${LIB_STM32L4_WSL}")
908924
message(STATUS "WSL Path found: ${LIB_STM32L4_WSL}")
909925
set(HAL_BASE "${LIB_STM32L4_WSL}")
910-
else()
911-
message(STATUS "STM32L4 Path not found")
912-
set(HAL_BASE "")
913926
endif()
914927

915-
if(true)
916-
917-
set(HAL_DRV "${HAL_BASE}/STM32L4xx_HAL_Driver")
918-
set(HAL_CMSIS_DEV "${HAL_BASE}/CMSIS_HAL/Device/ST/STM32L4xx/Include")
919-
set(HAL_CMSIS_CORE "${HAL_BASE}/CMSIS_HAL/Include")
920-
set(HAL_TEMPLATE_INC "${HAL_BASE}/VendorSamples/L4/Projects/B-L475E-IOT01A/Templates/Inc")
928+
# HAL_BASE "C:/Users/${CURRENT_USER}/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32L4xxxx"
929+
#
930+
#1> [CMake] -- Found directory: C:/Users/gojimmypi/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.0/Drivers/STM32L4xx_HAL_Driver (set HAL_DRV)
931+
#1> [CMake] -- Directory not found: C:/Users/gojimmypi/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.0/CMSIS_HAL/Device/ST/STM32L4xx/Include (set HAL_CMSIS_DEV)
932+
#1> [CMake] -- Directory not found: C:/Users/gojimmypi/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.0/CMSIS_HAL/Include (set HAL_CMSIS_CORE)
933+
#1> [CMake] -- Found directory: C:/Users/gojimmypi/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.0/Projects/B-L475E-IOT01A/Templates/Inc (set HAL_TEMPLATE_INC)
934+
#1> [CMake] -- HAL_DRV=C:/Users/gojimmypi/STM32Cube/Repository/STM32Cube_FW_L4_V1.18.0/Drivers/STM32L4xx_HAL_Driver
935+
if(NOT HAL_BASE STREQUAL "")
936+
if(false)
937+
# VisualGDB
938+
set_and_echo_dir(HAL_DRV "${HAL_BASE}/Drivers/STM32L4xx_HAL_Driver")
939+
set_and_echo_dir(HAL_CMSIS_DEV "${HAL_BASE}/CMSIS_HAL/Device/ST/STM32L4xx/Include")
940+
set_and_echo_dir(HAL_CMSIS_CORE "${HAL_BASE}/CMSIS_HAL/Include")
941+
set_and_echo_dir(HAL_TEMPLATE_INC "${HAL_BASE}/VendorSamples/L4/Projects/B-L475E-IOT01A/Templates/Inc")
942+
else()
943+
# CubeIDE
944+
# set_and_echo_dir(HAL_DRV "${HAL_BASE}/Drivers/STM32L4xx_HAL_Driver")
945+
# set_and_echo_dir(HAL_CMSIS_DEV "${HAL_BASE}/Drivers/CMSIS/Device/ST/STM32L4xx/Include")
946+
# set_and_echo_dir(HAL_CMSIS_CORE "${HAL_BASE}/Drivers/CMSIS/Include")
947+
# set_and_echo_dir(HAL_TEMPLATE_INC "${HAL_BASE}/Projects/B-L475E-IOT01A/Templates/Inc")
948+
endif()
921949
endif()
922950

923951
message(STATUS "HAL_DRV=${HAL_DRV}")

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
},
196196
{
197197
"name": "stm32l4",
198-
"displayName": "macOS ARM (STM32L4)",
198+
"displayName": "STM32L4",
199199
"inherits": [ "base" ],
200200
"generator": "Ninja",
201201
"binaryDir": "${sourceDir}/build-stm32l4",

cmake/config_defaults.cmake

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,40 @@
2222
# This is NOT a place for device-specific project settings. For that, see CMakePresets.json
2323

2424
set(FOUND_STM32L4_LIB false)
25+
2526
include(cmake/current_user.cmake)
2627

2728
get_current_user(CURRENT_USER)
2829
message(STATUS "Current user detected: ${CURRENT_USER}")
2930

30-
set(LIB_STM32L4_WINDOWS "c:/Users/${CURRENT_USER}/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32L4xxxx")
31-
set(LIB_STM32L4_WSL "/mnt/c/Users/${CURRENT_USER}/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32L4xxxx")
32-
33-
if(IS_DIRECTORY "${LIB_STM32L4_WINDOWS}")
34-
set(FOUND_STM32L4_LIB true)
35-
message(STATUS "LIB_STM32L4_WINDOWS found: ${LIB_STM32L4_WINDOWS}")
36-
endif()
37-
38-
if(IS_DIRECTORY "${LIB_STM32L4_WSL}")
39-
set(FOUND_STM32L4_LIB true)
40-
message(STATUS "LIB_STM32L4_WSL found: ${LIB_STM32L4_WSL}")
41-
endif()
42-
43-
# set(ARM_GCC_BIN "")
4431

45-
if(NOT FOUND_STM32L4_LIB)
46-
include(FetchContent)
47-
# TIP: Always pin a real tag/commit; avoid main/master.
32+
# The ST CubeIDE location is searched in cmake/cube_ide_config.cmake
33+
# Want to specify your specific STCubeIDE? Uncomment and set it here:
34+
# set(STM32CUBEIDE_DIR "/your/path")
4835

49-
# Make behavior explicit & chatty while debugging
50-
set(FETCHCONTENT_QUIET OFF)
51-
set(FETCHCONTENT_BASE_DIR "${CMAKE_BINARY_DIR}/_deps")
36+
if(false)
37+
# TODO need to be more generic, in presets?
38+
if(IS_DIRECTORY "C:/Users/${CURRENT_USER}/AppData/Local/VisualGDB")
39+
set(LIB_STM32L4_WINDOWS "C:/Users/${CURRENT_USER}/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32L4xxxx")
40+
endif()
5241

53-
# HAL driver
54-
message(STATUS "Fetching https://github.com/STMicroelectronics/stm32l4xx_hal_driver.git")
55-
FetchContent_Declare(st_hal
56-
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32l4xx_hal_driver.git
57-
# Pick a tag you want to lock to:
58-
GIT_TAG v1.13.5
59-
GIT_SHALLOW TRUE
60-
GIT_PROGRESS FALSE
61-
)
42+
if(IS_DIRECTORY "/mnt/c/Users/${CURRENT_USER}/AppData/Local/VisualGDB")
43+
set(LIB_STM32L4_WSL "/mnt/c/Users/${CURRENT_USER}/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32/STM32L4xxxx")
44+
endif()
6245

63-
# CMSIS device headers for L4
64-
message(STATUS "Fetching https://github.com/STMicroelectronics/cmsis_device_l4.git")
65-
FetchContent_Declare(cmsis_dev
66-
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_device_l4.git
67-
GIT_TAG v1.7.4
68-
GIT_SHALLOW TRUE
69-
GIT_PROGRESS FALSE
70-
)
46+
if(IS_DIRECTORY "${LIB_STM32L4_WINDOWS}")
47+
set(FOUND_STM32L4_LIB true)
48+
message(STATUS "LIB_STM32L4_WINDOWS found: ${LIB_STM32L4_WINDOWS}")
49+
endif()
7150

72-
# CMSIS Core headers
73-
message(STATUS "Fetching https://github.com/ARM-software/CMSIS_5.git")
74-
FetchContent_Declare(cmsis_core
75-
GIT_REPOSITORY https://github.com/ARM-software/CMSIS_5.git
76-
GIT_TAG 5.9.0
77-
GIT_SHALLOW TRUE
78-
GIT_PROGRESS FALSE
79-
)
51+
if(IS_DIRECTORY "${LIB_STM32L4_WSL}")
52+
set(FOUND_STM32L4_LIB true)
53+
message(STATUS "LIB_STM32L4_WSL found: ${LIB_STM32L4_WSL}")
54+
endif()
55+
endif()
8056

81-
FetchContent_MakeAvailable(st_hal cmsis_dev cmsis_core)
57+
# set(ARM_GCC_BIN "")
8258

83-
# Map to the include structures of the fetched repos
84-
set(HAL_DRV "${st_hal_SOURCE_DIR}") # Inc/, Src/
85-
set(HAL_CMSIS_DEV "${cmsis_dev_SOURCE_DIR}/Include") # device
86-
set(HAL_CMSIS_CORE "${cmsis_core_SOURCE_DIR}/CMSIS/Core/Include") # core
87-
endif()
8859

8960
message(STATUS "config.defaults:")
9061
message(STATUS "-- HAL_DRV: ${HAL_DRV}")

0 commit comments

Comments
 (0)