From 5b36a6ddddf317d547d716928b4f626f2c425fbe Mon Sep 17 00:00:00 2001 From: Alex Lanzano Date: Sat, 21 Jun 2025 14:43:30 -0400 Subject: [PATCH] Fix build and test issues with stm32f4 targets - Add the new CLOCK_SPEED and STM32_PLLx variables to the CMakeLists file - Rename references of 'stm32f4.config' to 'stm32f407-discovery.config' documentation and github workflow files. --- .github/workflows/footprint.yml | 2 +- .github/workflows/test-build-cmake.yml | 11 +++++++-- .github/workflows/test-configs.yml | 10 ++++++-- CMakeLists.txt | 23 +++++++++++++++++++ IDE/IAR/README.md | 4 ++-- .../stm32f4-small-blocks-uart-update.config | 5 ++++ 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/.github/workflows/footprint.yml b/.github/workflows/footprint.yml index 24740365..9bd0dda6 100644 --- a/.github/workflows/footprint.yml +++ b/.github/workflows/footprint.yml @@ -30,7 +30,7 @@ jobs: - name: Select config run: | - cp config/examples/stm32f4.config .config && make include/target.h + cp config/examples/stm32f407-discovery.config .config && make include/target.h - name: Build key tools run: | diff --git a/.github/workflows/test-build-cmake.yml b/.github/workflows/test-build-cmake.yml index a322627b..67b7f23f 100644 --- a/.github/workflows/test-build-cmake.yml +++ b/.github/workflows/test-build-cmake.yml @@ -30,10 +30,17 @@ jobs: - name: Build wolfBoot run: make -C build - - name: Run CMake build for STM32F4 + - name: Run CMake build for STM32F407-DISCOVERY run: | rm -rf ./build - cmake -B build -DWOLFBOOT_TARGET=stm32f4 -DWOLFBOOT_PARTITION_SIZE=0x20000 -DWOLFBOOT_SECTOR_SIZE=0x20000 -DWOLFBOOT_PARTITION_BOOT_ADDRESS=0x08020000 -DWOLFBOOT_PARTITION_UPDATE_ADDRESS=0x08040000 -DWOLFBOOT_PARTITION_SWAP_ADDRESS=0x08060000 + cmake -B build -DWOLFBOOT_TARGET=stm32f4 -DWOLFBOOT_PARTITION_SIZE=0x20000 -DWOLFBOOT_SECTOR_SIZE=0x20000 -DWOLFBOOT_PARTITION_BOOT_ADDRESS=0x08020000 -DWOLFBOOT_PARTITION_UPDATE_ADDRESS=0x08040000 -DWOLFBOOT_PARTITION_SWAP_ADDRESS=0x08060000 -DCLOCK_SPEED=160000000 -DSTM32_PLLM=8 -DSTM32_PLLN=336 -DSTM32_PLLP=2 -DSTM32_PLLQ=7 + - name: Build wolfBoot + run: make -C build + + - name: Run CMake build for STM32F411-BLACKPILL + run: | + rm -rf ./build + cmake -B build -DWOLFBOOT_TARGET=stm32f4 -DWOLFBOOT_PARTITION_SIZE=0x20000 -DWOLFBOOT_SECTOR_SIZE=0x20000 -DWOLFBOOT_PARTITION_BOOT_ADDRESS=0x08020000 -DWOLFBOOT_PARTITION_UPDATE_ADDRESS=0x08040000 -DWOLFBOOT_PARTITION_SWAP_ADDRESS=0x08060000 -DCLOCK_SPEED=84000000 -DSTM32_PLLM=25 -DSTM32_PLLN=336 -DSTM32_PLLP=4 -DSTM32_PLLQ=7 - name: Build wolfBoot run: make -C build diff --git a/.github/workflows/test-configs.yml b/.github/workflows/test-configs.yml index 87fa2f71..a1167316 100644 --- a/.github/workflows/test-configs.yml +++ b/.github/workflows/test-configs.yml @@ -272,11 +272,17 @@ jobs: arch: arm config-file: ./config/examples/stm32f4-small-blocks-uart-update.config - stm32f4_test: + stm32f407_discovery_test: uses: ./.github/workflows/test-build.yml with: arch: arm - config-file: ./config/examples/stm32f4.config + config-file: ./config/examples/stm32f407-discovery.config + + stm32f411_blackpill_test: + uses: ./.github/workflows/test-build.yml + with: + arch: arm + config-file: ./config/examples/stm32f411-blackpill.config stm32f7_dualbank_test: uses: ./.github/workflows/test-build.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4190bb99..7708fba0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,29 @@ if(ARCH STREQUAL "ARM") if(${WOLFBOOT_TARGET} STREQUAL "stm32f4") set(ARCH_FLASH_OFFSET 0x08000000) set(WOLFBOOT_ORIGIN ${ARCH_FLASH_OFFSET}) + + if(NOT DEFINED CLOCK_SPEED) + message(FATAL_ERROR "CLOCK_SPEED must be defined") + endif() + if(NOT DEFINED STM32_PLLM) + message(FATAL_ERROR "STM32_PLLM must be defined") + endif() + if(NOT DEFINED STM32_PLLN) + message(FATAL_ERROR "STM32_PLLN must be defined") + endif() + if(NOT DEFINED STM32_PLLP) + message(FATAL_ERROR "STM32_PLLP must be defined") + endif() + if(NOT DEFINED STM32_PLLQ) + message(FATAL_ERROR "STM32_PLLQ must be defined") + endif() + add_compile_definitions( + CLOCK_SPEED=${CLOCK_SPEED} + STM32_PLLM=${STM32_PLLM} + STM32_PLLN=${STM32_PLLN} + STM32_PLLP=${STM32_PLLP} + STM32_PLLQ=${STM32_PLLQ} + ) endif() if(${WOLFBOOT_TARGET} STREQUAL "stm32u5") diff --git a/IDE/IAR/README.md b/IDE/IAR/README.md index 587fb28a..05fa7b1c 100644 --- a/IDE/IAR/README.md +++ b/IDE/IAR/README.md @@ -12,7 +12,7 @@ application image starts at address 0x08020000. ``` $template=Get-Content -path ..\..\include\target.h.in; -Get-Content -path ..\..\config\examples\stm32f4.config | ForEach-Object {$v=$_.Split('?='); $a=$v[0]; $b=$v[2]; $template=($template -replace "##$a##",$b) }; +Get-Content -path ..\..\config\examples\stm32f407-discovery.config | ForEach-Object {$v=$_.Split('?='); $a=$v[0]; $b=$v[2]; $template=($template -replace "##$a##",$b) }; $template=($template -replace "##.*##",""); Set-Content -path target.h $template ``` @@ -91,4 +91,4 @@ If you are using a STM32F407-discovery board, a red LED will turn on upon applic ## Armored Mode (Glitch Resistance) -If you would like to enable the "Armored" mode (glitch resistance) in IAR you can set the compiler pre-processor macro `WOLFBOOT_ARMORED`. Note: This has only been tested with ECDSA on Cortex-M. \ No newline at end of file +If you would like to enable the "Armored" mode (glitch resistance) in IAR you can set the compiler pre-processor macro `WOLFBOOT_ARMORED`. Note: This has only been tested with ECDSA on Cortex-M. diff --git a/config/examples/stm32f4-small-blocks-uart-update.config b/config/examples/stm32f4-small-blocks-uart-update.config index 8b321c7e..908bfc46 100644 --- a/config/examples/stm32f4-small-blocks-uart-update.config +++ b/config/examples/stm32f4-small-blocks-uart-update.config @@ -27,3 +27,8 @@ WOLFBOOT_PARTITION_UPDATE_ADDRESS?=0x00000 WOLFBOOT_PARTITION_SWAP_ADDRESS?=0x4000 WOLFBOOT_LOAD_ADDRESS?=0x200000 WOLFBOOT_LOAD_DTS_ADDRESS?=0x400000 +CLOCK_SPEED?=160000000 +STM32_PLLM?=8 +STM32_PLLN?=336 +STM32_PLLP?=2 +STM32_PLLQ?=7