patrislav1 / cubemx.cmake

Script collection to build CubeMX projects with CMake and debug them with VSCode
The Unlicense
34 stars 10 forks source link

Fails to configure if RCC.HSI_VALUE missing #4

Closed BenBE closed 2 years ago

BenBE commented 2 years ago

When the RCC.HSI_VALUE is not set (e.g. with the NUCLEO-H723ZG) then configuring the project fails:

cmake_minimum_required(VERSION 3.16)

# Possible values: openocd, pyocd, stlink. stlink is default
# set(CMX_DEBUGGER "openocd")
# set(OPENOCD_CFG "${CMAKE_CURRENT_SOURCE_DIR}/openocd.cfg")

include(cubemx.cmake/cubemx.cmake)

project(evaltest)

file(
    GLOB_RECURSE APP_SRC_FILES "app/*.c"
)

add_executable(evaltest ${APP_SRC_FILES})
cubemx_target(
    TARGET evaltest
    IOC "${CMAKE_CURRENT_LIST_DIR}/evaltest.ioc"
#    STARTUP "custom_startup.s"    # optional custom startup
#    LDSCRIPT "custom_ldscript.ld" # optional custom ldscript
)
target_compile_options(evaltest PRIVATE -Og -Wall -g -gdwarf-2)

# Depending on the project setup, sometimes one of these symbols must be omitted. (Cannot be reliably derived from the .ioc file)
target_compile_definitions(evaltest PRIVATE USE_FULL_LL_DRIVER USE_HAL_DRIVER)
$ cmake ..
-- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter 
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Traceback (most recent call last):
  File "/home/user/work/evaltest/cubemx.cmake/cubemx-cmake.py", line 87, in <module>
    f"HSI_VALUE={iocConf['RCC.HSI_VALUE']}",
KeyError: 'RCC.HSI_VALUE'
CMake Error at cubemx.cmake/cubemx.cmake:28 (message):
  cubemx-cmake.py failed - aborting
Call Stack (most recent call first):
  cubemx.cmake/cubemx.cmake:98 (cmx_get)
  CMakeLists.txt:16 (cubemx_target)

-- Configuring incomplete, errors occurred!
See also "/home/user/work/evaltest/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/work/evaltest/build/CMakeFiles/CMakeError.log".
patrislav1 commented 2 years ago

Fixed in 9667f62c8ae904f0b2b9a36c5fb15ceff9c56307