Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full build can occur without linker script or multiple linker scripts #237

Open
atsju opened this issue Jul 22, 2021 · 1 comment
Open

Comments

@atsju
Copy link
Collaborator

atsju commented Jul 22, 2021

It is possible to build example that won't work because there is no linker script called.
Maybe there is a way to force user to either provide a linker script or information that will lead to automatic generation

Blinky example without linker script

if(BLINKY_F4_EXAMPLE)
    add_executable(stm32-blinky-f4 blinky.c stm32f4xx_hal_conf.h)
    target_link_libraries(stm32-blinky-f4
        HAL::STM32::F4::RCC
        HAL::STM32::F4::GPIO
        HAL::STM32::F4::CORTEX
        CMSIS::STM32::F407xx
        STM32::NoSys
    )
    stm32_print_size_of_target(stm32-blinky-f4)
    stm32_generate_hex_file(stm32-blinky-f4)
endif()

Notice the use ofCMSIS::STM32::F407xx instead of CMSIS::STM32::F407VG

Extract of documentation

CMSIS creates the following targets:

CMSIS::STM32:: (e.g. CMSIS::STM32::F4) - common includes, compiler flags and defines for family
CMSIS::STM32:: (e.g. CMSIS::STM32::F407xx) - common startup source for device type, depends on CMSIS::STM32::
CMSIS::STM32:: (e.g. CMSIS::STM32::F407VG) - linker script for device, depends on CMSIS::STM32::

This will provide 2 linker scripts

        CMSIS::STM32::WB55RG::M4
        STM32::NoSys
    )
    stm32_print_size_of_target(stm32-blinky-wb)
    stm32_add_linker_script(stm32-blinky-wb PRIVATE stm32wb55xx_flash_cm4.ld)

Should be avoided/warned by cmake

@atsju atsju changed the title Full build can occur without linker script Full build can occur without linker script or multiple linker scripts Jul 22, 2021
@TheSlowGrowth
Copy link

TheSlowGrowth commented Jan 2, 2024

It seems there is still an easy configuration error where no linker file is actually used.
Example:

target_link_libraries(targetName
    CMSIS::STM32::F103xB
)

Could a CMake warning be added for this case as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants