From 80d779bd442b3e2d2f364c091b580ea2c0fd5c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20S=C3=A1ez?= Date: Sat, 14 Feb 2026 12:11:49 +0100 Subject: [PATCH 1/5] chore: improve DX docs and tooling for simulator workflow --- .devcontainer/Dockerfile | 12 --- .devcontainer/devcontainer.json | 18 ---- .github/workflows/tests.yml | 8 +- .pre-commit-config.yaml | 6 ++ .vscode/settings.json | 123 ++++++---------------- CMakeLists.txt | 27 ++++- CMakePresets.json | 46 +++++++++ Inc/HALAL/Models/DMA/DMA2.hpp | 1 + README.md | 52 +++++----- Tests/CMakeLists.txt | 15 +-- docs/build-and-presets.md | 51 ++++++++++ docs/setup.md | 41 ++++++++ docs/testing.md | 39 +++++++ tools/build.py | 175 ++++++++++++++------------------ tools/build.sh | 47 +++++---- tools/run_sim_tests.sh | 8 +- tools/tar_tests.sh | 21 ++-- 17 files changed, 396 insertions(+), 294 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json create mode 100644 docs/build-and-presets.md create mode 100644 docs/setup.md create mode 100644 docs/testing.md mode change 100755 => 100644 tools/build.py diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 45a393abc..000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM ubuntu:24.04 - -ENV PATH="$PATH:/opt/st/stm32cubeclt_1.16.0/GNU-tools-for-STM32/bin:/opt/st/stm32cubeclt_1.16.0/CMake/bin:/opt/st/stm32cubeclt_1.16.0/Ninja/bin" - -# Install git, git-lfs, pip and colorama, and create workspace directory -RUN apt-get update && apt-get -y install git git-lfs python3-colorama cmake g++ build-essential && \ - git lfs install - -# Install cubeclt -RUN mkdir /temp && cd /temp && git clone https://github.com/Hyperloop-UPV/cubeclt.git && \ - cd cubeclt && git lfs pull && chmod +x cubeclt_1.16.0_installer.sh && \ - echo | LICENSE_ALREADY_ACCEPTED=1 ./cubeclt_1.16.0_installer.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index b6146a0fd..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name" : "Dev Container for ST-LIB", - "build" : { - "dockerfile" : "Dockerfile", - "options": [ "--platform=linux/amd64" ] - }, - "remoteUser": "root", - "customizations" : { - "vscode" : { - "extensions" : [ - "ms-vscode.cpptools-extension-pack", - "ms-python.python", - "mcu-debug.debug-tracker-vscode", - "marus25.cortex-debug" - ] - } - } -} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2a97e0146..80a1095e6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,7 +22,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y cmake ninja-build build-essential - + - name: Cache simulator deps uses: actions/cache@v4 with: @@ -33,15 +33,15 @@ jobs: - name: Configure (CMake) run: | - cmake -S . -B out/build/simulator -G Ninja -DCMAKE_BUILD_TYPE=Debug + cmake --preset simulator - name: Build run: | - cmake --build out/build/simulator + cmake --build --preset simulator - name: Run tests (ctest) run: | - ctest --test-dir out/build/simulator --no-tests=error --output-on-failure + ctest --preset simulator-all - name: Upload test reports if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d1201404c..33c6f87da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,12 @@ default_install_hook_types: - pre-commit - pre-push repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-merge-conflict + - id: end-of-file-fixer + - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-clang-format rev: v17.0.6 hooks: diff --git a/.vscode/settings.json b/.vscode/settings.json index 81ab120a1..106384d02 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,107 +1,42 @@ { "C_Cpp.default.cppStandard": "c++23", "C_Cpp.default.cStandard": "c17", - "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 80}", + "C_Cpp.clang_format_fallbackStyle": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100}", "C_Cpp.formatting": "clangFormat", - "C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 80}", + "C_Cpp.clang_format_style": "{BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 100}", "C_Cpp.clang_format_sortIncludes": true, "C_Cpp.intelliSenseCacheSize": 0, + "cmake.testExplorerIntegrationEnabled": true, + "cmake.defaultConfigurePreset": "simulator", + "cmake.defaultBuildPreset": "simulator", "files.associations": { -<<<<<<< HEAD - "any": "cpp", - "array": "cpp", - "atomic": "cpp", - "barrier": "cpp", - "bit": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "cfenv": "cpp", - "charconv": "cpp", - "chrono": "cpp", - "cinttypes": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "codecvt": "cpp", - "compare": "cpp", - "complex": "cpp", - "concepts": "cpp", - "condition_variable": "cpp", - "coroutine": "cpp", - "csetjmp": "cpp", - "csignal": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cuchar": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "forward_list": "cpp", - "list": "cpp", - "map": "cpp", - "set": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "exception": "cpp", - "expected": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "regex": "cpp", - "source_location": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "future": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "latch": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "numbers": "cpp", - "ostream": "cpp", - "ranges": "cpp", - "scoped_allocator": "cpp", - "semaphore": "cpp", - "shared_mutex": "cpp", - "span": "cpp", - "spanstream": "cpp", - "sstream": "cpp", - "stacktrace": "cpp", - "stdexcept": "cpp", - "stop_token": "cpp", - "streambuf": "cpp", - "syncstream": "cpp", - "thread": "cpp", - "typeindex": "cpp", - "typeinfo": "cpp", - "valarray": "cpp", - "variant": "cpp" -======= "*.embeddedhtml": "html", "mem.h": "c", "tinydir.h": "c", "dirent.h": "c", - "initializer_list": "cpp" ->>>>>>> origin/development + "initializer_list": "cpp", + "condition_variable": "cpp", + "chrono": "cpp", + "array": "cpp", + "*.tcc": "cpp", + "memory": "cpp", + "format": "cpp", + "istream": "cpp", + "functional": "cpp", + "tuple": "cpp", + "utility": "cpp", + "variant": "cpp", + "atomic": "cpp", + "string": "cpp", + "string_view": "cpp", + "ranges": "cpp", + "span": "cpp", + "bitset": "cpp", + "stacktrace": "cpp", + "regex": "cpp", + "valarray": "cpp", + "cstdlib": "cpp", + "mutex": "cpp", + "shared_mutex": "cpp" } } diff --git a/CMakeLists.txt b/CMakeLists.txt index 1da03a077..361946448 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ option(USE_ETHERNET "Enable ethernet peripheral" OFF) option(TARGET_NUCLEO "Targets the STM32H723 Nucleo development board" OFF) option(USE_CCACHE "Use ccache if available" ON) option(STLIB_USE_PCH "Enable precompiled headers for ST-LIB" ON) +option(STLIB_ENABLE_SANITIZERS "Enable AddressSanitizer + UBSan for simulator builds" OFF) if(NOT DEFINED ENABLE_LTO) if(CMAKE_CROSSCOMPILING) set(ENABLE_LTO OFF) @@ -79,6 +80,26 @@ endif() message(STATUS "${PROJECT_NAME} Ethernet: ${USE_ETHERNET}") message(STATUS "${PROJECT_NAME} Nucleo: ${TARGET_NUCLEO}") message(STATUS "${PROJECT_NAME} Crosscompiling: ${CMAKE_CROSSCOMPILING}") +message(STATUS "${PROJECT_NAME} Sanitizers: ${STLIB_ENABLE_SANITIZERS}") + +if(NOT CMAKE_CROSSCOMPILING) + add_library(stlib_sim_dev_flags INTERFACE) + + if(STLIB_ENABLE_SANITIZERS) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + target_compile_options(stlib_sim_dev_flags INTERFACE + -fsanitize=address,undefined + -fno-omit-frame-pointer + ) + target_link_options(stlib_sim_dev_flags INTERFACE + -fsanitize=address,undefined + ) + else() + message(WARNING "STLIB_ENABLE_SANITIZERS is ON but compiler does not support configured sanitizers") + endif() + endif() + +endif() if(CMAKE_CROSSCOMPILING) if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/STM32CubeH7/Drivers) @@ -430,6 +451,10 @@ set_target_properties(${STLIB_LIBRARY} PROPERTIES C_STANDARD_REQUIRED YES ) +if(NOT CMAKE_CROSSCOMPILING) + target_link_libraries(${STLIB_LIBRARY} PUBLIC stlib_sim_dev_flags) +endif() + target_compile_definitions(${STLIB_LIBRARY} PUBLIC $<$:USE_HAL_DRIVER> $<$:STM32H723xx> @@ -484,7 +509,7 @@ target_include_directories(${STLIB_LIBRARY} PUBLIC $<$>:${CMAKE_CURRENT_LIST_DIR}/Inc/MockedDrivers> ${CMAKE_CURRENT_LIST_DIR}/Inc/STM32CubeH7Wrapper - # LWIP includes + # LWIP includes $<$,$>:${LWIP_DIR}/src/include> $<$,$>:${LWIP_DIR}/system> $<$,$>:${LWIP_DIR}/src/netif/ppp> diff --git a/CMakePresets.json b/CMakePresets.json index f59704a49..4e4411486 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -203,6 +203,17 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } + }, + { + "name": "simulator-asan", + "displayName": "Simulator [ASAN+UBSAN]", + "inherits": [ + "sim" + ], + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "STLIB_ENABLE_SANITIZERS": "ON" + } } ], "buildPresets": [ @@ -269,6 +280,41 @@ { "name": "simulator", "configurePreset": "simulator" + }, + { + "name": "simulator-asan", + "configurePreset": "simulator-asan" + } + ], + "testPresets": [ + { + "name": "simulator-all", + "configurePreset": "simulator", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error" + } + }, + { + "name": "simulator-adc", + "inherits": "simulator-all", + "filter": { + "include": { + "name": "ADCTest" + } + } + }, + { + "name": "simulator-all-asan", + "configurePreset": "simulator-asan", + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error" + } } ] } diff --git a/Inc/HALAL/Models/DMA/DMA2.hpp b/Inc/HALAL/Models/DMA/DMA2.hpp index c09990432..ec153e9ea 100644 --- a/Inc/HALAL/Models/DMA/DMA2.hpp +++ b/Inc/HALAL/Models/DMA/DMA2.hpp @@ -183,6 +183,7 @@ struct DMA_Domain { return (IRQn_Type)0; else compile_error("No tiene que llegar aqui nunca, creo"); + return (IRQn_Type)0; } static constexpr inline bool is_one_of(Peripheral instance, auto... bases) { diff --git a/README.md b/README.md index 284143617..028e091e5 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,45 @@ # ST-LIB -Library to simplify programming an STM32 H7 MCU taking advantage of C++ objects. +Library to simplify STM32 H7 firmware development using C++. -The library is divided into three levels: +Main layers: -* HALAL (HAL Abstraction Layer): takes the STM32 HAL functions and exposes an object oriented interface -* STLIB-LOW: provides low level utilities on top of the HALAL and a couple of fundamental abstractions. -* STLIB-HIGH: provides high level programming utilities to validate sensor values and implement control loops. +- HALAL +- ST-LIB_LOW +- ST-LIB_HIGH -## Container Setup -To use it you must install [Dev Containers extension on VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) and [Docker](https://www.docker.com). Be careful,use the instructions related to your OS, as docker doesn't work the same way in all OS's. -Then, when you open this folder in VSCode, you will have the ability to reopen it inside the container. Don't worry, the first time you do it will take some time. - -## Submodules setup -The only needed submodules are: -- STM32CubeH7/Drivers/STM32H7xx_HAL_Driver -- STM32CubeH7/Drivers/CMSIS/Device/ST/STM32H7xx -- STM32CubeH7/Drivers/BSP/Components/lan8742 +## Quickstart ```sh -git submodule update --init -cd STM32CubeH7 -git submodule update --init Drivers/STM32H7xx_HAL_Driver Drivers/CMSIS/Device/ST/STM32H7xx Drivers/BSP/Components/lan8742 +./tools/init-submodules.sh +cmake --preset simulator +cmake --build --preset simulator +ctest --preset simulator-all ``` -The submodules initialization is also available by executing [this script](tools/init-submodules.sh) +## Documentation + +- Setup: [`docs/setup.md`](docs/setup.md) +- Build and presets: [`docs/build-and-presets.md`](docs/build-and-presets.md) +- Testing: [`docs/testing.md`](docs/testing.md) + +## Recommended Presets -## Automatic formatting (commit/push) -This repository uses `pre-commit` + `clang-format` to format C/C++ files automatically on `git commit` and `git push`. +- `simulator` +- `simulator-asan` +- `nucleo-*` +- `board-*` + +List all presets: -Install hooks once: ```sh -pip install pre-commit -./tools/install-git-hooks.sh +cmake --list-presets ``` -Run manually on all files: +## Formatting and Hooks + ```sh +pip install pre-commit +./tools/install-git-hooks.sh pre-commit run --all-files ``` diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ea120da06..f120d053d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -8,7 +8,9 @@ project( ${STLIB_TEST_EXECUTABLE}) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG v1.15.2 + DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) FetchContent_MakeAvailable(googletest) @@ -28,12 +30,13 @@ add_executable(${STLIB_TEST_EXECUTABLE} set_target_properties(${STLIB_TEST_EXECUTABLE} PROPERTIES CXX_STANDARD 23 CXX_STANDARD_REQUIRED YES - C_STANDARD 11 + C_STANDARD 17 C_STANDARD_REQUIRED YES ) target_link_libraries( ${STLIB_TEST_EXECUTABLE} + PRIVATE GTest::gtest_main ${STLIB_LIBRARY} ) @@ -42,10 +45,6 @@ if(MINGW OR CYGWIN) target_link_options(${STLIB_TEST_EXECUTABLE} PRIVATE -static) endif() -if(MINGW OR CYGWIN) - target_link_options(${STLIB_TEST_EXECUTABLE} PRIVATE -static) -endif() - target_compile_definitions(${STLIB_TEST_EXECUTABLE} PRIVATE SIM_ON ) @@ -56,6 +55,10 @@ target_include_directories(${STLIB_TEST_EXECUTABLE} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../Inc/ST-LIB_HIGH ) +if(TARGET stlib_sim_dev_flags) + target_link_libraries(${STLIB_TEST_EXECUTABLE} PRIVATE stlib_sim_dev_flags) +endif() + include(GoogleTest) gtest_discover_tests( ${STLIB_TEST_EXECUTABLE} diff --git a/docs/build-and-presets.md b/docs/build-and-presets.md new file mode 100644 index 000000000..c45923b6d --- /dev/null +++ b/docs/build-and-presets.md @@ -0,0 +1,51 @@ +# ST-LIB Build and Presets + +## 1. Available Presets + +```sh +cmake --list-presets +``` + +Main presets: + +- `simulator` +- `simulator-asan` +- `nucleo-*` +- `board-*` + +## 2. Simulator Build + +```sh +cmake --preset simulator +cmake --build --preset simulator +``` + +With sanitizers: + +```sh +cmake --preset simulator-asan +cmake --build --preset simulator-asan +``` + +## 3. MCU Build + +Example: + +```sh +cmake --preset board-debug-eth-ksz8041 +cmake --build --preset board-debug-eth-ksz8041 +``` + +## 4. Helper Scripts + +Python wrapper: + +```sh +python3 tools/build.py --preset simulator --run-tests +``` + +Shell wrapper: + +```sh +./tools/build.sh simulator --run-tests +``` diff --git a/docs/setup.md b/docs/setup.md new file mode 100644 index 000000000..232a6a7d3 --- /dev/null +++ b/docs/setup.md @@ -0,0 +1,41 @@ +# ST-LIB Setup + +## 1. Prerequisites + +- CMake + Ninja +- Python 3 +- C/C++ compiler toolchain + +For MCU builds: + +- `arm-none-eabi-*` toolchain + +## 2. Initialize Submodules + +```sh +./tools/init-submodules.sh +``` + +Manual equivalent: + +```sh +git submodule update --init +cd STM32CubeH7 +git submodule update --init \ + Drivers/STM32H7xx_HAL_Driver \ + Drivers/CMSIS/Device/ST/STM32H7xx \ + Drivers/BSP/Components/lan8742 +``` + +## 3. Automatic Formatting + +```sh +pip install pre-commit +./tools/install-git-hooks.sh +``` + +Manual validation: + +```sh +pre-commit run --all-files +``` diff --git a/docs/testing.md b/docs/testing.md new file mode 100644 index 000000000..a2c580b27 --- /dev/null +++ b/docs/testing.md @@ -0,0 +1,39 @@ +# ST-LIB Testing + +## 1. Run All Tests (simulator) + +```sh +cmake --preset simulator +cmake --build --preset simulator +ctest --preset simulator-all +``` + +## 2. Run a Test Subset + +ADC only: + +```sh +ctest --preset simulator-adc +``` + +## 3. Run Tests with Sanitizers + +```sh +cmake --preset simulator-asan +cmake --build --preset simulator-asan +ctest --preset simulator-all-asan +``` + +## 4. Quick Script + +```sh +./tools/run_sim_tests.sh +``` + +## 5. CI + +Main workflows: + +- `Compile Checks` +- `Run tests` +- `Format Checks` diff --git a/tools/build.py b/tools/build.py old mode 100755 new mode 100644 index cc699623f..c5c9d9f11 --- a/tools/build.py +++ b/tools/build.py @@ -1,109 +1,84 @@ -#!/usr/bin/python3 -import os +#!/usr/bin/env python3 import argparse -import shutil import subprocess +import sys +from pathlib import Path + + +VALID_PRESETS = [ + "nucleo-debug", + "nucleo-release", + "nucleo-relwithdebinfo", + "nucleo-debug-eth", + "nucleo-release-eth", + "nucleo-relwithdebinfo-eth", + "board-debug", + "board-release", + "board-relwithdebinfo", + "board-debug-eth-ksz8041", + "board-debug-eth-lan8700", + "board-release-eth-ksz8041", + "board-release-eth-lan8700", + "board-relwithdebinfo-eth-ksz8041", + "board-relwithdebinfo-eth-lan8700", + "simulator", + "simulator-asan", +] + +TEST_PRESET_BY_CONFIGURE = { + "simulator": "simulator-all", + "simulator-asan": "simulator-all-asan", +} + + +REPO_ROOT = Path(__file__).resolve().parent.parent + + +def run_cmd(cmd: list[str]) -> int: + return subprocess.call(cmd, cwd=REPO_ROOT) + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser( + prog="build.py", + description="Configure/build ST-LIB using CMake presets", + ) + parser.add_argument( + "-p", + "--preset", + choices=VALID_PRESETS, + default="simulator", + help="CMake configure/build preset to use", + ) + parser.add_argument( + "--run-tests", + action="store_true", + help="Run tests after build when preset supports simulator tests", + ) + return parser.parse_args() + + +def main() -> int: + args = parse_args() + print(f"[build.py] Repository: {REPO_ROOT}") + print(f"[build.py] Configure preset: {args.preset}") -# Requirements: -# colorama==0.4.6 -from colorama import Fore - - -parser = argparse.ArgumentParser( - prog="Build ST-LIB", - description="Build using CMake the ST-LIB" -) - -parser.add_argument( - '-bb', - '--build_behaviour', - choices=['Release', 'ReleaseDebug', 'Debug'], - required=True -) -parser.add_argument( - '-target', - '--target', - choices=['NUCLEO','BOARD'], - required=True -) -parser.add_argument( - '-eth', - '--ethernet_config', - choices=['ON','OFF'], - required=True -) - -parser.add_argument( - '-sim', - '--simulator', - choices=['ON','OFF'], - required=True -) - -stlib_path = os.environ.get('STLIB_PATH') - - -def main(args: argparse.Namespace): - if not stlib_path: - print(Fore.RED + "STLIB_PATH env variable is missing") - print(Fore.RESET, end="") + if run_cmd(["cmake", "--preset", args.preset]) != 0: return 1 - print(Fore.BLUE + "Building ST-LIB:") - print(Fore.BLUE + f"\tST-LIB path: {stlib_path}") - print(Fore.BLUE + f"\tTarget: {args.target}") - print(Fore.BLUE + f"\tBuild Behaviour: {args.build_behaviour}") - print(Fore.BLUE + f"\tEthernet: {args.ethernet_config}") - print(Fore.BLUE + f"\tSimulator: {args.simulator}") - print(Fore.RESET) - - output_dir = os.path.join( - stlib_path, - "build", - "Simulator" if args.simulator == "ON" else "MCU", - args.build_behaviour, - args.target, - "Ethernet" if args.ethernet_config == "ON" else "NoEthernet" - ) - os.makedirs(output_dir, exist_ok=True) - - cmake_exit_code = subprocess.call([ - "cmake", - stlib_path, - "-B", output_dir, - f"-DRELEASE={args.build_behaviour}", - f"-DNUCLEO={'TRUE' if args.target == 'NUCLEO' else 'FALSE'}", - f"-DETHERNET={'TRUE' if args.ethernet_config == 'ON' else 'FALSE'}", - f"-DSIMULATE={'TRUE' if args.simulator == 'ON' else 'FALSE'}", - "-G", "Unix Makefiles" - ]) - - if cmake_exit_code != 0: - print(Fore.RED, "\nCMake failed, aborted") - print(Fore.RESET, end="") - return cmake_exit_code - - make_exit_code = subprocess.call([ - "make", - "-j", str(os.cpu_count()), - "-C", output_dir - ]) - - if make_exit_code != 0: - print(Fore.RED + "\nMake failed, aborted") - print(Fore.RESET, end="") - return make_exit_code - - print() - print(Fore.GREEN + "ST-LIB built successfuly!") - print(Fore.GREEN + f"\tOutput path: {output_dir}") - print(Fore.GREEN + f"\tTarget: {args.target}") - print(Fore.GREEN + f"\tBuild Behaviour: {args.build_behaviour}") - print(Fore.GREEN + f"\tEthernet: {args.ethernet_config}") - print(Fore.GREEN + f"\tSimulator: {args.simulator}") - print(Fore.RESET, end="") + if run_cmd(["cmake", "--build", "--preset", args.preset]) != 0: + return 1 + + if args.run_tests: + test_preset = TEST_PRESET_BY_CONFIGURE.get(args.preset) + if not test_preset: + print(f"[build.py] Preset '{args.preset}' does not have an associated test preset.") + return 1 + if run_cmd(["ctest", "--preset", test_preset]) != 0: + return 1 return 0 + if __name__ == "__main__": - exit(main(parser.parse_args())) \ No newline at end of file + sys.exit(main()) diff --git a/tools/build.sh b/tools/build.sh index 5c4e1c610..020a1eeda 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,21 +1,32 @@ -## shell script for CI automation -#!/bin/sh -if [[ $# -eq 0 ]] ; then - echo "ERROR, provide a build configuration" +#!/usr/bin/env bash +set -euo pipefail + +if [[ $# -lt 1 ]]; then + echo "Usage: $0 [--run-tests]" exit 1 fi -mode=$1 -echo $mode -out_dir="out/build/$mode" -if [[ "$mode" == "simulator" ]]; then - echo "Simulator build" - cmake -DCMAKE_BUILD_TYPE=Debug -S . -B $out_dir -G "Unix Makefiles" - cd $out_dir - make -j 8 -else - echo "hardware build" - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=toolchains/stm32.cmake -DTARGET_NUCLEO=ON -DUSE_ETHERNET=ON -S . -B $out_dir -G "Unix Makefiles" - cd $out_dir - make -j 8 -fi # mode=simulator \ No newline at end of file +preset="$1" +run_tests="${2:-}" + +script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" +repo_root="$(CDPATH= cd -- "${script_dir}/.." && pwd)" +cd "${repo_root}" + +cmake --preset "${preset}" +cmake --build --preset "${preset}" + +if [[ "${run_tests}" == "--run-tests" ]]; then + case "${preset}" in + simulator) + ctest --preset simulator-all + ;; + simulator-asan) + ctest --preset simulator-all-asan + ;; + *) + echo "Preset '${preset}' does not support simulator tests" + exit 1 + ;; + esac +fi diff --git a/tools/run_sim_tests.sh b/tools/run_sim_tests.sh index 3335702bd..027743b9c 100755 --- a/tools/run_sim_tests.sh +++ b/tools/run_sim_tests.sh @@ -3,8 +3,8 @@ set -eu script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" repo_root="$(CDPATH= cd -- "${script_dir}/.." && pwd)" -build_dir="${repo_root}/out/build/simulator" -cmake -S "${repo_root}" -B "${build_dir}" -G Ninja -DCMAKE_BUILD_TYPE=Debug -cmake --build "${build_dir}" -ctest --test-dir "${build_dir}" --output-on-failure +cd "${repo_root}" +cmake --preset simulator +cmake --build --preset simulator +ctest --preset simulator-all diff --git a/tools/tar_tests.sh b/tools/tar_tests.sh index fc98bdc95..94a872e3a 100755 --- a/tools/tar_tests.sh +++ b/tools/tar_tests.sh @@ -1,18 +1,13 @@ -## shell script for CI automation and tests compressing +#!/usr/bin/env bash +set -euo pipefail -#only compress if using simulator -# otherwise it would create empty folder +archive_name="${1:-test_files.tar}" +test_binary="out/build/simulator/Tests/st-lib-test" -#!/bin/sh -if [[ $# -eq 0 ]] ; then - echo "ERROR, provide a build configuration" +if [[ ! -f "${test_binary}" ]]; then + echo "Test binary not found at '${test_binary}'. Build simulator tests first." exit 1 fi -mode=$1 - -if [[ "$mode" == "simulator" ]]; then - tar -cvf test_files.tar out/build/simulator/Tests/st-lib-test -else - exit 1 -fi # mode=simulator +tar -cvf "${archive_name}" "${test_binary}" +echo "Archive created: ${archive_name}" From 65d36f43533e461defac8e84f3e4f7a8ae62a304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20S=C3=A1ez?= Date: Sat, 14 Feb 2026 12:18:58 +0100 Subject: [PATCH 2/5] formatted files --- .github/workflows/build.yml | 2 +- .vscode/c_cpp_properties.json | 2 +- Inc/C++Utilities/Stack.hpp | 2 +- .../DataWatchpointTrace.hpp | 2 +- Inc/HALAL/Models/DMA/DMA.hpp | 2 +- Inc/HALAL/Models/Packets/MdmaPacket.hpp | 2 +- Inc/HALAL/Models/SPI/SPI2.hpp | 2 +- Inc/HALAL/Models/TimerDomain/TimerDomain.hpp | 2 +- Inc/HALAL/Services/ADC/ADC.hpp | 2 +- .../Communication/Ethernet/PHY/phy_driver.h | 2 +- Inc/HALAL/Services/Communication/I2C/I2C.hpp | 2 +- Inc/HALAL/Services/Communication/SPI/SPI.hpp | 2 +- Inc/HALAL/Services/Encoder/NewEncoder.hpp | 2 +- Inc/HALAL/Services/FMAC/FMAC.hpp | 2 +- .../PWM/DualCenterPWM/DualCenterPWM.hpp | 2 +- Inc/HALAL/Services/Time/RTC.hpp | 2 +- Inc/MockedDrivers/NVIC.hpp | 2 +- Inc/MockedDrivers/Register.hpp | 2 +- Inc/MockedDrivers/compiler_specific.hpp | 2 +- .../EncoderSensor/NewEncoderSensor.hpp | 2 +- .../stm32h7xx_ll_tim_wrapper.h | 2 +- STM32H723ZGTX_FLASH.ld | 34 +++++++++---------- STM32H723ZGTX_RAM.ld | 32 ++++++++--------- Src/HALAL/Models/DMA/DMA.cpp | 2 +- Src/HALAL/Models/SPI/SPI2.cpp | 2 +- Src/HALAL/Services/ADC/ADC.cpp | 2 +- Src/HALAL/Services/Communication/I2C/I2C.cpp | 2 +- Src/HALAL/Services/Communication/SPI/SPI.cpp | 2 +- .../DigitalOutputService.cpp | 2 +- .../PWM/DualCenterPWM/DualCenterPWM.cpp | 2 +- Src/HALAL/Services/Time/RTC.cpp | 2 +- Src/HALAL/Services/Watchdog/Watchdog.cpp | 2 +- Src/MockedDrivers/NVIC.cpp | 2 +- Src/MockedDrivers/mocked_ll_tim.cpp | 2 +- Src/ST-LIB_HIGH/Protections/Boundary.cpp | 2 +- Src/ST-LIB_LOW/Sd/Sd.cpp | 2 +- ci/Dockerfile | 2 +- startup_stm32h723zgtx.s | 2 -- toolchains/stm32.cmake | 1 - tools/init-submodules.sh | 1 - 40 files changed, 68 insertions(+), 72 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9988a9d13..5855ebf57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,7 +46,7 @@ jobs: - name: Init submodules run: | git config --global --add safe.directory '*' - ./tools/init-submodules.sh + ./tools/init-submodules.sh shell: bash - name: Build diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index df777ac28..1d6f1d63c 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -9,4 +9,4 @@ } ], "version": 4 -} \ No newline at end of file +} diff --git a/Inc/C++Utilities/Stack.hpp b/Inc/C++Utilities/Stack.hpp index 90b167d8e..ebc79f3b4 100644 --- a/Inc/C++Utilities/Stack.hpp +++ b/Inc/C++Utilities/Stack.hpp @@ -52,4 +52,4 @@ template class Stack { size_t top_idx; }; -#endif // STACK_HPP \ No newline at end of file +#endif // STACK_HPP diff --git a/Inc/HALAL/Benchmarking_toolkit/DataWatchpointTrace/DataWatchpointTrace.hpp b/Inc/HALAL/Benchmarking_toolkit/DataWatchpointTrace/DataWatchpointTrace.hpp index e1d5a0707..e483bef60 100644 --- a/Inc/HALAL/Benchmarking_toolkit/DataWatchpointTrace/DataWatchpointTrace.hpp +++ b/Inc/HALAL/Benchmarking_toolkit/DataWatchpointTrace/DataWatchpointTrace.hpp @@ -60,4 +60,4 @@ class DataWatchpointTrace { } } } -}; \ No newline at end of file +}; diff --git a/Inc/HALAL/Models/DMA/DMA.hpp b/Inc/HALAL/Models/DMA/DMA.hpp index b2bb1a020..76b384bb0 100644 --- a/Inc/HALAL/Models/DMA/DMA.hpp +++ b/Inc/HALAL/Models/DMA/DMA.hpp @@ -38,4 +38,4 @@ class DMA { private: static vector available_streams; static vector inscribed_streams; -}; \ No newline at end of file +}; diff --git a/Inc/HALAL/Models/Packets/MdmaPacket.hpp b/Inc/HALAL/Models/Packets/MdmaPacket.hpp index 44fbd8907..d60e4fd68 100644 --- a/Inc/HALAL/Models/Packets/MdmaPacket.hpp +++ b/Inc/HALAL/Models/Packets/MdmaPacket.hpp @@ -288,4 +288,4 @@ struct MdmaPacketDomain { }; }; -#endif // MDMA_PACKET_HPP \ No newline at end of file +#endif // MDMA_PACKET_HPP diff --git a/Inc/HALAL/Models/SPI/SPI2.hpp b/Inc/HALAL/Models/SPI/SPI2.hpp index 18ab84c96..5d94626d8 100644 --- a/Inc/HALAL/Models/SPI/SPI2.hpp +++ b/Inc/HALAL/Models/SPI/SPI2.hpp @@ -1458,4 +1458,4 @@ struct SPIDomain { } // namespace ST_LIB -#endif // SPI2_HPP \ No newline at end of file +#endif // SPI2_HPP diff --git a/Inc/HALAL/Models/TimerDomain/TimerDomain.hpp b/Inc/HALAL/Models/TimerDomain/TimerDomain.hpp index bd28923d4..98af03b94 100644 --- a/Inc/HALAL/Models/TimerDomain/TimerDomain.hpp +++ b/Inc/HALAL/Models/TimerDomain/TimerDomain.hpp @@ -1011,7 +1011,7 @@ TimerXList ST_LIB::compile_error( "Error: Timers with pins must have associated TimerAF (alternate functions)" ); - } else if(((pin.af == ST_LIB::TimerAF::InputCapture || pin.af == ST_LIB::TimerAF::PWM || pin.af == ST_LIB::TimerAF::Encoder) && + } else if(((pin.af == ST_LIB::TimerAF::InputCapture || pin.af == ST_LIB::TimerAF::PWM || pin.af == ST_LIB::TimerAF::Encoder) && (static_cast(pin.channel) == static_cast(tim_pins[(int)req].pins[j].use))) || ((pin.af == ST_LIB::TimerAF::BreakInput) && diff --git a/Inc/HALAL/Services/ADC/ADC.hpp b/Inc/HALAL/Services/ADC/ADC.hpp index c0c5f9766..9ee5a07a5 100644 --- a/Inc/HALAL/Services/ADC/ADC.hpp +++ b/Inc/HALAL/Services/ADC/ADC.hpp @@ -176,4 +176,4 @@ class ADC { static void init(Peripheral& peripheral); }; -#endif \ No newline at end of file +#endif diff --git a/Inc/HALAL/Services/Communication/Ethernet/PHY/phy_driver.h b/Inc/HALAL/Services/Communication/Ethernet/PHY/phy_driver.h index c2056b119..553cc76d4 100644 --- a/Inc/HALAL/Services/Communication/Ethernet/PHY/phy_driver.h +++ b/Inc/HALAL/Services/Communication/Ethernet/PHY/phy_driver.h @@ -14,4 +14,4 @@ typedef struct { phy_link_state_t (*get_link_state)(void); } phy_driver_t; -extern const phy_driver_t* phy_driver; \ No newline at end of file +extern const phy_driver_t* phy_driver; diff --git a/Inc/HALAL/Services/Communication/I2C/I2C.hpp b/Inc/HALAL/Services/Communication/I2C/I2C.hpp index 4817d98d4..ab21fa683 100644 --- a/Inc/HALAL/Services/Communication/I2C/I2C.hpp +++ b/Inc/HALAL/Services/Communication/I2C/I2C.hpp @@ -151,4 +151,4 @@ class I2C { static void init(I2C::Instance* i2c); }; -#endif \ No newline at end of file +#endif diff --git a/Inc/HALAL/Services/Communication/SPI/SPI.hpp b/Inc/HALAL/Services/Communication/SPI/SPI.hpp index e0c26f0be..e3d107887 100644 --- a/Inc/HALAL/Services/Communication/SPI/SPI.hpp +++ b/Inc/HALAL/Services/Communication/SPI/SPI.hpp @@ -363,4 +363,4 @@ class SPI { static void init(SPI::Instance* spi); }; -#endif \ No newline at end of file +#endif diff --git a/Inc/HALAL/Services/Encoder/NewEncoder.hpp b/Inc/HALAL/Services/Encoder/NewEncoder.hpp index db37126ce..b41370031 100644 --- a/Inc/HALAL/Services/Encoder/NewEncoder.hpp +++ b/Inc/HALAL/Services/Encoder/NewEncoder.hpp @@ -111,4 +111,4 @@ template class Encoder { }; } // namespace ST_LIB -#endif \ No newline at end of file +#endif diff --git a/Inc/HALAL/Services/FMAC/FMAC.hpp b/Inc/HALAL/Services/FMAC/FMAC.hpp index e2c7cea0b..403fe8371 100644 --- a/Inc/HALAL/Services/FMAC/FMAC.hpp +++ b/Inc/HALAL/Services/FMAC/FMAC.hpp @@ -162,4 +162,4 @@ class MultiplierAccelerator { ); }; -#endif \ No newline at end of file +#endif diff --git a/Inc/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.hpp b/Inc/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.hpp index 9967af046..3e7bebc60 100644 --- a/Inc/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.hpp +++ b/Inc/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.hpp @@ -7,4 +7,4 @@ class DualCenterPWM : public DualPWM { DualCenterPWM(Pin& pin, Pin& pin_negated); void set_frequency(uint32_t freq_in_hz); -}; \ No newline at end of file +}; diff --git a/Inc/HALAL/Services/Time/RTC.hpp b/Inc/HALAL/Services/Time/RTC.hpp index 8ed994061..f912fc096 100644 --- a/Inc/HALAL/Services/Time/RTC.hpp +++ b/Inc/HALAL/Services/Time/RTC.hpp @@ -34,4 +34,4 @@ class Global_RTC { ); }; -#endif \ No newline at end of file +#endif diff --git a/Inc/MockedDrivers/NVIC.hpp b/Inc/MockedDrivers/NVIC.hpp index e48a44d3e..1816e1ec7 100644 --- a/Inc/MockedDrivers/NVIC.hpp +++ b/Inc/MockedDrivers/NVIC.hpp @@ -55,4 +55,4 @@ void NVIC_EnableIRQ(IRQn_Type IRQn); uint32_t NVIC_GetEnableIRQ(IRQn_Type IRQn); void NVIC_DisableIRQ(IRQn_Type IRQn); -} \ No newline at end of file +} diff --git a/Inc/MockedDrivers/Register.hpp b/Inc/MockedDrivers/Register.hpp index b38d5c56d..0ae22b3ba 100644 --- a/Inc/MockedDrivers/Register.hpp +++ b/Inc/MockedDrivers/Register.hpp @@ -92,4 +92,4 @@ template class RegisterBase { protected: void set(uint32_t val) { RegisterTraits::write(this->reg, val); } -}; \ No newline at end of file +}; diff --git a/Inc/MockedDrivers/compiler_specific.hpp b/Inc/MockedDrivers/compiler_specific.hpp index 6901ec853..1524c886a 100644 --- a/Inc/MockedDrivers/compiler_specific.hpp +++ b/Inc/MockedDrivers/compiler_specific.hpp @@ -70,4 +70,4 @@ void _ReadWriteBarrier(void); #define __ISB() __COMPILER_BARRIER() #endif -#endif \ No newline at end of file +#endif diff --git a/Inc/ST-LIB_LOW/Sensors/EncoderSensor/NewEncoderSensor.hpp b/Inc/ST-LIB_LOW/Sensors/EncoderSensor/NewEncoderSensor.hpp index 9c72527f4..f8d52c1bf 100644 --- a/Inc/ST-LIB_LOW/Sensors/EncoderSensor/NewEncoderSensor.hpp +++ b/Inc/ST-LIB_LOW/Sensors/EncoderSensor/NewEncoderSensor.hpp @@ -85,4 +85,4 @@ template struct EncoderSensor { } }; -} // namespace ST_LIB \ No newline at end of file +} // namespace ST_LIB diff --git a/Inc/STM32CubeH7Wrapper/stm32h7xx_ll_tim_wrapper.h b/Inc/STM32CubeH7Wrapper/stm32h7xx_ll_tim_wrapper.h index 8dfa292ae..9374a653d 100644 --- a/Inc/STM32CubeH7Wrapper/stm32h7xx_ll_tim_wrapper.h +++ b/Inc/STM32CubeH7Wrapper/stm32h7xx_ll_tim_wrapper.h @@ -7,4 +7,4 @@ #include "MockedDrivers/mocked_ll_tim.hpp" #endif -#endif // STM32H7xx_LL_TIM_WRAPPER_H \ No newline at end of file +#endif // STM32H7xx_LL_TIM_WRAPPER_H diff --git a/STM32H723ZGTX_FLASH.ld b/STM32H723ZGTX_FLASH.ld index 16f605035..591a9946f 100644 --- a/STM32H723ZGTX_FLASH.ld +++ b/STM32H723ZGTX_FLASH.ld @@ -150,13 +150,13 @@ SECTIONS { . = ALIGN(32); __mpu_d1_nc_start = ABSOLUTE(.); - + /* New MPU system buffers */ *(.mpu_ram_d1_nc.buffer) - + /* User manual allocations via D1_NC macro */ *(.mpu_ram_d1_nc.user) - + /* Ethernet Rx Pool */ . = ALIGN(32); *(.Rx_PoolSection) @@ -243,17 +243,17 @@ SECTIONS { . = ALIGN(32); __mpu_d2_nc_start = ABSOLUTE(.); - + /* ETH Descriptors - Must be aligned */ - *(.RxDecripSection) + *(.RxDecripSection) *(.TxDecripSection) - + /* New MPU system buffers */ *(.mpu_ram_d2_nc.buffer) /* User manual allocations via D2_NC macro */ *(.mpu_ram_d2_nc.user) - + } >RAM_D2 /* CALCULATE PADDING FOR MPU SUBREGIONS (D2) */ @@ -270,16 +270,16 @@ SECTIONS { . = ALIGN(32); __mpu_d3_nc_start = ABSOLUTE(.); - + /* New MPU system buffers */ *(.mpu_ram_d3_nc.buffer) /* Legacy MPUManager allocations */ *(.mpu_ram_d3_nc.legacy) - + /* User manual allocations via D3_NC macro */ *(.mpu_ram_d3_nc.user) - + } >RAM_D3 @@ -296,7 +296,7 @@ SECTIONS .ram_code : { . = ALIGN(4); - _sram_code = .; + _sram_code = .; *(.ram_code) *(.ram_code*) . = ALIGN(4); @@ -318,10 +318,10 @@ SECTIONS .ram_d1 : { . = ALIGN(32); - + /* User manual allocations via D1_C macro */ *(.ram_d1.user) - + /* New MPU system buffers */ *(.ram_d1.buffer) } >RAM_D1 @@ -330,10 +330,10 @@ SECTIONS .ram_d2 : { . = ALIGN(32); - + /* User manual allocations via D2_C macro */ *(.ram_d2.user) - + /* New MPU system buffers */ *(.ram_d2.buffer) } >RAM_D2 @@ -342,10 +342,10 @@ SECTIONS .ram_d3 : { . = ALIGN(32); - + /* User manual allocations via D3_C macro */ *(.ram_d3.user) - + /* New MPU system buffers */ *(.ram_d3.buffer) } >RAM_D3 diff --git a/STM32H723ZGTX_RAM.ld b/STM32H723ZGTX_RAM.ld index ec59ab347..4b6dccc97 100644 --- a/STM32H723ZGTX_RAM.ld +++ b/STM32H723ZGTX_RAM.ld @@ -34,7 +34,7 @@ /* This linker script places code and read-only data in ITCM RAM for execution and places initialized data in DTCM RAM. This only leaves 64kB for code, so it could potentially overflow, if you want to host a big application, maybe - should use RAM_D1 for code as well (and either adjust MPU settings or mess + should use RAM_D1 for code as well (and either adjust MPU settings or mess arround with the memory areas specifications, so that the code thinks RAM_D1 is actually FLASH). */ @@ -149,10 +149,10 @@ SECTIONS /* New MPU system buffers */ *(.mpu_ram_d1_nc.buffer) - + /* User manual allocations via D1_NC macro */ *(.mpu_ram_d1_nc.user) - + /* Ethernet Rx Pool */ . = ALIGN(32); *(.Rx_PoolSection) @@ -215,14 +215,14 @@ SECTIONS { . = ALIGN(32); __mpu_d2_nc_start = ABSOLUTE(.); - + /* Ethernet descriptors */ - *(.RxDecripSection) + *(.RxDecripSection) *(.TxDecripSection) - + /* New MPU system buffers */ *(.mpu_ram_d2_nc.buffer) - + /* User manual allocations via D2_NC macro */ *(.mpu_ram_d2_nc.user) } >RAM_D2 @@ -241,13 +241,13 @@ SECTIONS { . = ALIGN(32); __mpu_d3_nc_start = ABSOLUTE(.); - + /* New MPU system buffers */ *(.mpu_ram_d3_nc.buffer) - + /* Legacy MPUManager allocations */ *(.mpu_ram_d3_nc.legacy) - + /* User manual allocations via D3_NC macro */ *(.mpu_ram_d3_nc.user) } >RAM_D3 @@ -265,7 +265,7 @@ SECTIONS .ram_code : { . = ALIGN(4); - _sram_code = .; + _sram_code = .; *(.ram_code) *(.ram_code*) . = ALIGN(4); @@ -276,10 +276,10 @@ SECTIONS .ram_d1 : { . = ALIGN(32); - + /* New MPU system buffers */ *(.ram_d1.buffer) - + /* User manual allocations via D1_C macro */ *(.ram_d1.user) } >RAM_D1 @@ -288,10 +288,10 @@ SECTIONS .ram_d2 : { . = ALIGN(32); - + /* New MPU system buffers */ *(.ram_d2.buffer) - + /* User manual allocations via D2_C macro */ *(.ram_d2.user) } >RAM_D2 @@ -303,7 +303,7 @@ SECTIONS /* New MPU system buffers */ *(.ram_d3.buffer) - + /* User manual allocations via D3_C macro */ *(.ram_d3.user) } >RAM_D3 diff --git a/Src/HALAL/Models/DMA/DMA.cpp b/Src/HALAL/Models/DMA/DMA.cpp index 32974dfad..21b6e911d 100644 --- a/Src/HALAL/Models/DMA/DMA.cpp +++ b/Src/HALAL/Models/DMA/DMA.cpp @@ -52,4 +52,4 @@ void DMA::start() { HAL_NVIC_SetPriority((IRQn_Type)dma_stream, 0, 0); HAL_NVIC_EnableIRQ((IRQn_Type)dma_stream); } -} \ No newline at end of file +} diff --git a/Src/HALAL/Models/SPI/SPI2.cpp b/Src/HALAL/Models/SPI/SPI2.cpp index f860af798..aff69a3a0 100644 --- a/Src/HALAL/Models/SPI/SPI2.cpp +++ b/Src/HALAL/Models/SPI/SPI2.cpp @@ -134,4 +134,4 @@ void HAL_SPI_ErrorCallback(SPI_HandleTypeDef* hspi) { ErrorHandler("SPI%i failed with error number %u", inst_idx + 1, error_code); } -} \ No newline at end of file +} diff --git a/Src/HALAL/Services/ADC/ADC.cpp b/Src/HALAL/Services/ADC/ADC.cpp index 8d2596ede..6d18a688f 100644 --- a/Src/HALAL/Services/ADC/ADC.cpp +++ b/Src/HALAL/Services/ADC/ADC.cpp @@ -187,4 +187,4 @@ void ADC::init(Peripheral& peripheral) { } void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {} -#endif \ No newline at end of file +#endif diff --git a/Src/HALAL/Services/Communication/I2C/I2C.cpp b/Src/HALAL/Services/Communication/I2C/I2C.cpp index 6b52a919a..90d3987d1 100644 --- a/Src/HALAL/Services/Communication/I2C/I2C.cpp +++ b/Src/HALAL/Services/Communication/I2C/I2C.cpp @@ -293,4 +293,4 @@ void I2C::init(I2C::Instance* i2c) { } i2c->is_initialized = true; } -#endif \ No newline at end of file +#endif diff --git a/Src/HALAL/Services/Communication/SPI/SPI.cpp b/Src/HALAL/Services/Communication/SPI/SPI.cpp index 7ac5c2865..439b7dc45 100644 --- a/Src/HALAL/Services/Communication/SPI/SPI.cpp +++ b/Src/HALAL/Services/Communication/SPI/SPI.cpp @@ -610,4 +610,4 @@ void SPI::spi_check_bus_collision(SPI::Instance* spi) { } } -#endif \ No newline at end of file +#endif diff --git a/Src/HALAL/Services/DigitalOutputService/DigitalOutputService.cpp b/Src/HALAL/Services/DigitalOutputService/DigitalOutputService.cpp index 4057eedec..889ecf865 100644 --- a/Src/HALAL/Services/DigitalOutputService/DigitalOutputService.cpp +++ b/Src/HALAL/Services/DigitalOutputService/DigitalOutputService.cpp @@ -68,4 +68,4 @@ bool DigitalOutputService::lock_pin_state(uint8_t id, PinState state) { HAL_GPIO_WritePin(pin.port, pin.gpio_pin, (GPIO_PinState)state); HAL_StatusTypeDef locked = HAL_GPIO_LockPin(pin.port, pin.gpio_pin); return locked == HAL_OK; -} \ No newline at end of file +} diff --git a/Src/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.cpp b/Src/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.cpp index aa6310b81..74a489339 100644 --- a/Src/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.cpp +++ b/Src/HALAL/Services/PWM/DualCenterPWM/DualCenterPWM.cpp @@ -36,4 +36,4 @@ void DualCenterPWM::set_frequency(uint32_t freq_in_hz) { TIM_TypeDef& timer = *peripheral->handle->Instance; timer.ARR = (HAL_RCC_GetPCLK1Freq() * 2 / (timer.PSC + 1)) / (frequency * 2); set_duty_cycle(duty_cycle); -} \ No newline at end of file +} diff --git a/Src/HALAL/Services/Time/RTC.cpp b/Src/HALAL/Services/Time/RTC.cpp index e4d82ff75..a5700a978 100644 --- a/Src/HALAL/Services/Time/RTC.cpp +++ b/Src/HALAL/Services/Time/RTC.cpp @@ -83,4 +83,4 @@ void Global_RTC::set_rtc_data( ErrorHandler("Error on writing Date on the RTC"); } } -void Global_RTC::update_rtc_data() { global_RTC = get_rtc_timestamp(); } \ No newline at end of file +void Global_RTC::update_rtc_data() { global_RTC = get_rtc_timestamp(); } diff --git a/Src/HALAL/Services/Watchdog/Watchdog.cpp b/Src/HALAL/Services/Watchdog/Watchdog.cpp index 2fcf78090..588c69c20 100644 --- a/Src/HALAL/Services/Watchdog/Watchdog.cpp +++ b/Src/HALAL/Services/Watchdog/Watchdog.cpp @@ -3,4 +3,4 @@ IWDG_HandleTypeDef watchdog_handle; std::chrono::microseconds Watchdog::watchdog_time = std::chrono::microseconds(1000000); // 1 second by default -bool reset_by_iwdg{}; \ No newline at end of file +bool reset_by_iwdg{}; diff --git a/Src/MockedDrivers/NVIC.cpp b/Src/MockedDrivers/NVIC.cpp index 6bd90f2e1..43acf210a 100644 --- a/Src/MockedDrivers/NVIC.cpp +++ b/Src/MockedDrivers/NVIC.cpp @@ -28,4 +28,4 @@ void NVIC_DisableIRQ(IRQn_Type IRQn) { __DSB(); __ISB(); } -} \ No newline at end of file +} diff --git a/Src/MockedDrivers/mocked_ll_tim.cpp b/Src/MockedDrivers/mocked_ll_tim.cpp index e73d3401b..bfaba1b73 100644 --- a/Src/MockedDrivers/mocked_ll_tim.cpp +++ b/Src/MockedDrivers/mocked_ll_tim.cpp @@ -96,4 +96,4 @@ void TIM_TypeDef::inc_cnt_and_check(uint32_t val) { this->CNT += val; simulate_ticks(this); } -} \ No newline at end of file +} diff --git a/Src/ST-LIB_HIGH/Protections/Boundary.cpp b/Src/ST-LIB_HIGH/Protections/Boundary.cpp index 8dd8d39e5..3c9f6847c 100644 --- a/Src/ST-LIB_HIGH/Protections/Boundary.cpp +++ b/Src/ST-LIB_HIGH/Protections/Boundary.cpp @@ -13,4 +13,4 @@ const map BoundaryInterface::format_look_up{ {type_id, 9}, {type_id, 10}, {type_id, 11}, -}; \ No newline at end of file +}; diff --git a/Src/ST-LIB_LOW/Sd/Sd.cpp b/Src/ST-LIB_LOW/Sd/Sd.cpp index 0eeacb54f..a3769d5d3 100644 --- a/Src/ST-LIB_LOW/Sd/Sd.cpp +++ b/Src/ST-LIB_LOW/Sd/Sd.cpp @@ -312,4 +312,4 @@ void HAL_SD_ErrorCallback(SD_HandleTypeDef* hsd) { } } -} // extern "C" \ No newline at end of file +} // extern "C" diff --git a/ci/Dockerfile b/ci/Dockerfile index 140064a34..a44409128 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -29,4 +29,4 @@ RUN git clone --depth 1 https://github.com/Hyperloop-UPV/cubeclt.git && \ ENV PATH="$PATH:/opt/st/stm32cubeclt_${CUBECLT_VERSION}/GNU-tools-for-STM32/bin:/opt/st/stm32cubeclt_${CUBECLT_VERSION}/CMake/bin:/opt/st/stm32cubeclt_${CUBECLT_VERSION}/Ninja/bin" -WORKDIR /workspace \ No newline at end of file +WORKDIR /workspace diff --git a/startup_stm32h723zgtx.s b/startup_stm32h723zgtx.s index 819741556..0679cb4bb 100644 --- a/startup_stm32h723zgtx.s +++ b/startup_stm32h723zgtx.s @@ -770,5 +770,3 @@ g_pfnVectors: .weak TIM24_IRQHandler .thumb_set TIM24_IRQHandler,Default_Handler - - diff --git a/toolchains/stm32.cmake b/toolchains/stm32.cmake index 9893d3253..0c1e00475 100644 --- a/toolchains/stm32.cmake +++ b/toolchains/stm32.cmake @@ -29,4 +29,3 @@ set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - diff --git a/tools/init-submodules.sh b/tools/init-submodules.sh index e917c7209..7d0c84152 100755 --- a/tools/init-submodules.sh +++ b/tools/init-submodules.sh @@ -13,4 +13,3 @@ git submodule update --init \ Drivers/STM32H7xx_HAL_Driver \ Drivers/CMSIS/Device/ST/STM32H7xx \ Drivers/BSP/Components/lan8742 - From 734f7b68cc5f01a9a19322a485ac55ced3b676f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20S=C3=A1ez?= Date: Sat, 14 Feb 2026 13:17:19 +0100 Subject: [PATCH 3/5] chore(dx): address Copilot review suggestions --- Tests/CMakeLists.txt | 2 +- docs/setup.md | 2 +- tools/build.py | 21 --------------------- tools/tar_tests.sh | 12 ++++++++++-- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f120d053d..0c882b8a7 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -10,7 +10,7 @@ FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git GIT_TAG v1.15.2 - DOWNLOAD_EXTRACT_TIMESTAMP TRUE + GIT_SHALLOW TRUE ) FetchContent_MakeAvailable(googletest) diff --git a/docs/setup.md b/docs/setup.md index 232a6a7d3..123b6f857 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -2,7 +2,7 @@ ## 1. Prerequisites -- CMake + Ninja +- CMake + Ninja (CMake >= 3.28 for `cmake --preset` / `ctest --preset` with this repo) - Python 3 - C/C++ compiler toolchain diff --git a/tools/build.py b/tools/build.py index c5c9d9f11..f783520eb 100644 --- a/tools/build.py +++ b/tools/build.py @@ -5,26 +5,6 @@ from pathlib import Path -VALID_PRESETS = [ - "nucleo-debug", - "nucleo-release", - "nucleo-relwithdebinfo", - "nucleo-debug-eth", - "nucleo-release-eth", - "nucleo-relwithdebinfo-eth", - "board-debug", - "board-release", - "board-relwithdebinfo", - "board-debug-eth-ksz8041", - "board-debug-eth-lan8700", - "board-release-eth-ksz8041", - "board-release-eth-lan8700", - "board-relwithdebinfo-eth-ksz8041", - "board-relwithdebinfo-eth-lan8700", - "simulator", - "simulator-asan", -] - TEST_PRESET_BY_CONFIGURE = { "simulator": "simulator-all", "simulator-asan": "simulator-all-asan", @@ -46,7 +26,6 @@ def parse_args() -> argparse.Namespace: parser.add_argument( "-p", "--preset", - choices=VALID_PRESETS, default="simulator", help="CMake configure/build preset to use", ) diff --git a/tools/tar_tests.sh b/tools/tar_tests.sh index 94a872e3a..d5b8ad4ab 100755 --- a/tools/tar_tests.sh +++ b/tools/tar_tests.sh @@ -2,7 +2,15 @@ set -euo pipefail archive_name="${1:-test_files.tar}" -test_binary="out/build/simulator/Tests/st-lib-test" +preset_or_build_dir="${2:-simulator}" + +if [[ "${preset_or_build_dir}" == */* ]]; then + build_dir="${preset_or_build_dir%/}" +else + build_dir="out/build/${preset_or_build_dir}" +fi + +test_binary="${build_dir}/Tests/st-lib-test" if [[ ! -f "${test_binary}" ]]; then echo "Test binary not found at '${test_binary}'. Build simulator tests first." @@ -10,4 +18,4 @@ if [[ ! -f "${test_binary}" ]]; then fi tar -cvf "${archive_name}" "${test_binary}" -echo "Archive created: ${archive_name}" +echo "Archive created: ${archive_name} (from ${test_binary})" From e8092b0651370bb32b725b7d927a2c8ec2c23823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20S=C3=A1ez?= Date: Sat, 14 Feb 2026 13:23:30 +0100 Subject: [PATCH 4/5] chore(ci): retrigger format checks From 33f6cf56a484c9cf9467a4803f9bf4b89b7f1837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20S=C3=A1ez?= Date: Sat, 14 Feb 2026 13:26:38 +0100 Subject: [PATCH 5/5] ci(format): run pre-commit on PR head ref --- .github/workflows/format-checks.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/format-checks.yml b/.github/workflows/format-checks.yml index a225afb4a..cbf2ce588 100644 --- a/.github/workflows/format-checks.yml +++ b/.github/workflows/format-checks.yml @@ -20,6 +20,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} - name: Setup Python uses: actions/setup-python@v5