# patch_temp **Repository Path**: arthurhi/patch_temp ## Basic Information - **Project Name**: patch_temp - **Description**: self use - **Primary Language**: Unknown - **License**: BSD-3-Clause - **Default Branch**: com_stack - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-10-19 - **Last Updated**: 2025-12-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README STM32CubeH7 - CMake build instructions ===================================== This repository contains the STM32CubeH7 firmware package. These instructions show how to configure and build the provided example (Projects/NUCLEO-H743ZI/Examples/GPIO/GPIO_EXTI) and the FreeRTOS kernel using a local GNU Arm Embedded toolchain via a CMake toolchain file. Prerequisites ------------- - GNU Arm Embedded toolchain (tested with arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi) - CMake >= 3.13 - Make (or other build driver supported by CMake) Recommended toolchain location ------------------------------- Put the toolchain in a stable path. Example used during testing: $HOME/Downloads/work_test/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi Important files --------------- - CMake toolchain file (used in examples): `cmake/toolchain-gcc-arm-none-eabi.cmake` - Example: `Projects/NUCLEO-H743ZI/Examples/GPIO/GPIO_EXTI` - FreeRTOS sources: `Middlewares/Third_Party/FreeRTOS/Source` Basic clean build (copy-and-paste) --------------------------------- Run these commands from the repository root. ```bash # adjust paths below if your toolchain or FreeRTOSConfig.h are in different locations TOOLCHAIN="$HOME/Downloads/work_test/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi" TOOLCHAIN_FILE="${PWD}/cmake/toolchain-gcc-arm-none-eabi.cmake" # optional: path to a application-provided FreeRTOSConfig.h FREERTOS_CONFIG_PATH="${PWD}/Projects/NUCLEO-H743ZI/Applications/FreeRTOS/FreeRTOS_ThreadCreation/Inc" # create a clean build dir rm -rf build mkdir build && cd build # Configure. This tells CMake where the toolchain lives and where to find FreeRTOSConfig.h cmake -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ -DARM_TOOLCHAIN_ROOT="${TOOLCHAIN}" \ -DFREERTOS_CONFIG_PATH="${FREERTOS_CONFIG_PATH}" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ .. # Build (parallel) cmake --build . -j$(nproc) # After a successful build you will find the example ELF/BIN/HEX under build/-build ``` Notes and common pitfalls ------------------------- - CMake try-compile/link checks: the toolchain file sets CMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY to avoid configure-time link errors when CMake runs test programs. - `-specs=nosys.specs` behavior: some GCC 11 toolchains rename or handle specs differently. The provided toolchain file conditionally injects `-specs=nosys.specs` only for older GCC versions; if you see a fatal "attempt to rename spec" error remove or adjust specs flags in the toolchain file. - FreeRTOS config: pass `-DFREERTOS_CONFIG_PATH` to point to the directory containing `FreeRTOSConfig.h` (this CMake option causes the file to be included BEFORE the kernel sources so the kernel compiles with your configuration). - Editor static analysis ("uint32_t undefined" etc.): enable `compile_commands.json` in your editor by keeping `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` during configure and pointing your editor to the generated `build/compile_commands.json`. What I verified ----------------- - I built the `GPIO_EXTI` example and the FreeRTOS kernel with arm-gnu-toolchain-11.3.rel1 successfully (ELF produced). The final `GPIO_EXTI.elf` from my run had text=8896 data=32 bss=1984 (total 10912 bytes). Next steps (optional) ---------------------- - Generate and point your editor to `build/compile_commands.json` to fix the editor parsing warnings. - Minimize the HAL sources compiled for the example (only include GPIO, RCC, EXTI, CORE) to speed up iteration — the example's `CMakeLists.txt` already includes logic to read `stm32h7xx_hal_conf.h` and select HAL module sources, and can be tightened further. If you want I can: - add this README.md to the repo (already done), - re-run a clean build and attach the full build log, - produce a smaller CMake configuration for faster iteration (fewer HAL source files). Building LwIP (lwipcore) ------------------------ The repo includes the lwIP middleware under `Middlewares/Third_Party/LwIP`. To build just the lwIP core (static library `liblwipcore.a`) from the top-level CMake using the same cross-toolchain, run the steps below. Notes before you start: - lwIP expects an application-provided `lwipopts.h` that configures features (NO_SYS, memory options, sockets, etc.). The CMake rules attempt to auto-discover example `lwipopts.h` locations (Projects/*) but you can override/include a specific directory by passing `-DLWIP_INCLUDE_DIRS`. - Some LwIP ports include `cmsis_os.h` (CMSIS-RTOS API). The LwIP CMake defaults add common CMSIS template/include directories so `cmsis_os.h` is usually found. If your build uses a different RTOS or a custom `cmsis_os.h`, pass its include dir via `-DLWIP_INCLUDE_DIRS`. Example: configure & build lwipcore only ```bash # variables (adjust to your paths) TOOLCHAIN="$HOME/Downloads/work_test/toolchain/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi" TOOLCHAIN_FILE="${PWD}/cmake/toolchain-gcc-arm-none-eabi.cmake" # optional: point to a directory containing your lwipopts.h # e.g. Projects/NUCLEO-H743ZI/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Inc LWIP_APP_INC="${PWD}/Projects/NUCLEO-H743ZI/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Inc" rm -rf build mkdir build && cd build cmake -DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \ -DARM_TOOLCHAIN_ROOT="${TOOLCHAIN}" \ -DLWIP_INCLUDE_DIRS="${LWIP_APP_INC}" \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ .. # Build only the lwIP core static library cmake --build . --target lwipcore -j$(nproc) ``` If you see missing header errors like `fatal error: cmsis_os.h: No such file or directory` then pass the directory that supplies `cmsis_os.h` (for example `Drivers/CMSIS/RTOS/Template` or your RTOS wrapper) in `-DLWIP_INCLUDE_DIRS`. If instead you want lwIP to compile without any RTOS integration (NO_SYS), provide an `lwipopts.h` that sets `NO_SYS=1` and point `-DLWIP_INCLUDE_DIRS` to the directory that contains it.