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

Multiple definitions linking error #256

Closed
zisi opened this issue Aug 3, 2021 · 8 comments
Closed

Multiple definitions linking error #256

zisi opened this issue Aug 3, 2021 · 8 comments

Comments

@zisi
Copy link
Contributor

zisi commented Aug 3, 2021

Describe the bug
When the stm32_fetch_cube() is used it gets also templates like system_stm32h7xx.c.
In case that a modified system_stm32h7xx.c is used, an error in linking is appeared related
to multiple definition of functions inside the system_stm32h7xx.c.

Sources to reproduce
https://gitlab.com/librespacefoundation/satnogs-comms/libsatnogs-comms/-/merge_requests/1/diffs
The project it is under development.

Steps to reproduce

  1. Under test/CMakeLists.txt in add_executable(test ... add system_stm32h7xx.c
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make

Expected behavior

Screenshots

Environment (please complete the following information):

  • OS: kubuntu 20.04
  • Compiler: arm-none-eabi-gcc 9.3.1
  • stm32-cmake: 70a5a0a
  • cmake: 3.21.0
  • HAL/cube/CMSIS: stm32cubeH7 v1.9.0

Additional context
In order to fix the issue, the below code is used:

# Do not use HAL template
set(CMSIS_TEMPLATE "${PROJECT_SOURCE_DIR}/build/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c")
set(CMSIS_TEMPLATE_PATH "${PROJECT_SOURCE_DIR}/build/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates")
file(REMOVE ${CMSIS_TEMPLATE})
file(COPY "${PROJECT_SOURCE_DIR}/test/system_stm32h7xx.c"
    DESTINATION ${CMSIS_TEMPLATE_PATH}
)

Does it exists another way to not include templates?

@atsju
Copy link
Collaborator

atsju commented Aug 3, 2021

Thank you for reporting. I think you use wrong target.
When you wish to replace some template files you must update target.

From readme:

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::

But your code uses this:
image

Please have a look at #237 and #252 that have same issues with .ld files.

@atsju atsju closed this as completed Aug 3, 2021
@zisi
Copy link
Contributor Author

zisi commented Aug 17, 2021

Hey, i use the CMSIS::STM32::H7::M7 and this commit 1dd8b73. I add to the build system system_stm32h7xx.c and startup_stm32h743vitx.s and i got errors like error: 'GPIOD' undeclared (first use in this function). I can't understand how by using the CMSIS family the building system does not include the CMSIS template like system_stm32h7xx.c.

@atsju
Copy link
Collaborator

atsju commented Aug 18, 2021

Thank you for reporting.
I do not see the question ? Please clarify the question you have.

I have seen your history and you are not a noob. You can understand we maintain this repo in our free time (several hours a week). It would realy help if you could do a quality questions or clearly documented bugs. If needed please provide a code

  • Github hosted
  • minimalist (ideally it would be based on our examples)
  • reproducing the issue

This would really help us to help you. Personally I won't look any deeper for now.

@zisi
Copy link
Contributor Author

zisi commented Sep 8, 2021

Hey, sorry for the delay. I prepare an example to reproduce the error. This is the example, https://github.com/zisi/stm32-cmake/tree/linking-error/examples/link-error. To reproduce it, run:

  1. mkdir build
  2. cd build
  3. cmake ..
  4. make

The output:

[ 92%] Linking C executable stm32-linker-error.elf
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h743xx.s.obj:(.isr_vector+0x0): multiple definition of `g_pfnVectors'; CMakeFiles/stm32-linker-error.dir/startup_stm32h743vitx.s.obj:(.isr_vector+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h743xx.s.obj: in function `Default_Handler':
(.text.Default_Handler+0x0): multiple definition of `Default_Handler'; CMakeFiles/stm32-linker-error.dir/startup_stm32h743vitx.s.obj:(.text.Default_Handler+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c.obj:(.data.SystemCoreClock+0x0): multiple definition of `SystemCoreClock'; CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj:(.data.SystemCoreClock+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c.obj:(.data.SystemD2Clock+0x0): multiple definition of `SystemD2Clock'; CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj:(.data.SystemD2Clock+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c.obj:(.rodata.D1CorePrescTable+0x0): multiple definition of `D1CorePrescTable'; CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj:(.rodata.D1CorePrescTable+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c.obj: in function `SystemInit':
system_stm32h7xx.c:(.text.SystemInit+0x0): multiple definition of `SystemInit'; CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj:system_stm32h7xx.c:(.text.SystemInit+0x0): first defined here
/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: CMakeFiles/stm32-linker-error.dir/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c.obj: in function `SystemCoreClockUpdate':
system_stm32h7xx.c:(.text.SystemCoreClockUpdate+0x0): multiple definition of `SystemCoreClockUpdate'; CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj:system_stm32h7xx.c:(.text.SystemCoreClockUpdate+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/stm32-linker-error.dir/build.make:272: stm32-linker-error.elf] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/stm32-linker-error.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

System:

  • OS: kubuntu 20.04
  • Compiler: arm-none-eabi-gcc 9.2.1

Expected behavior
I expect to use the system_stm32h7xx.c and startup_stm32h743vitx.s that are placed inside the project and not the templates which is provided by the stm32_hal.

Thanks!!

@atsju
Copy link
Collaborator

atsju commented Sep 8, 2021

Hello,
as already stated

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::

So in your example it's normal that with CMSIS::STM32::H743xx::M7 you use template system and startup files.

Please add a commit to reproduce what you described here #256 (comment)

@zisi
Copy link
Contributor Author

zisi commented Sep 8, 2021

Hey, add this commit, https://github.com/zisi/stm32-cmake/tree/linking-error and got this:

[  8%] Building C object CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj
In file included from /home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:48:
/home/azisi/Documents/stm32-cmake/examples/link-error/build/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h:164:3: error: #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)"
  164 |  #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)"
      |   ^~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:113:3: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  113 |   uint32_t SystemCoreClock = 64000000;
      |   ^~~~~~~~
      |   wint_t
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:114:3: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  114 |   uint32_t SystemD2Clock = 64000000;
      |   ^~~~~~~~
      |   wint_t
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:115:10: error: unknown type name 'uint8_t'
  115 |   const  uint8_t D1CorePrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
      |          ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c: In function 'SystemInit':
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:153:6: error: 'FLASH_LATENCY_DEFAULT' undeclared (first use in this function)
  153 |   if(FLASH_LATENCY_DEFAULT  > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
      |      ^~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:153:6: note: each undeclared identifier is reported only once for each function it appears in
In file included from /home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:48:
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:153:42: error: 'FLASH' undeclared (first use in this function)
  153 |   if(FLASH_LATENCY_DEFAULT  > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
      |                                          ^~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:153:55: error: 'FLASH_ACR_LATENCY' undeclared (first use in this function)
  153 |   if(FLASH_LATENCY_DEFAULT  > (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)))
      |                                                       ^~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:156:45: error: 'uint32_t' undeclared (first use in this function); did you mean 'wint_t'?
  156 |  MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(FLASH_LATENCY_DEFAULT));
      |                                             ^~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:160:3: error: 'RCC' undeclared (first use in this function)
  160 |   RCC->CR |= RCC_CR_HSION;
      |   ^~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:160:14: error: 'RCC_CR_HSION' undeclared (first use in this function)
  160 |   RCC->CR |= RCC_CR_HSION;
      |              ^~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:261:3: error: 'FMC_Bank1_R' undeclared (first use in this function)
  261 |   FMC_Bank1_R->BTCR[0] = 0x000030D2;
      |   ^~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:267:3: error: 'SCB' undeclared (first use in this function)
  267 |   SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
      |   ^~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:267:15: error: 'FLASH_BANK1_BASE' undeclared (first use in this function)
  267 |   SCB->VTOR = FLASH_BANK1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
      |               ^~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c: In function 'SystemCoreClockUpdate':
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:313:3: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  313 |   uint32_t pllp, pllsource, pllm, pllfracen, hsivalue, tmp;
      |   ^~~~~~~~
      |   wint_t
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:314:3: error: unknown type name 'uint32_t'; did you mean 'wint_t'?
  314 |   uint32_t common_system_clock;
      |   ^~~~~~~~
      |   wint_t
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:320:11: error: 'RCC' undeclared (first use in this function)
  320 |   switch (RCC->CFGR & RCC_CFGR_SWS)
      |           ^~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:320:23: error: 'RCC_CFGR_SWS' undeclared (first use in this function)
  320 |   switch (RCC->CFGR & RCC_CFGR_SWS)
      |                       ^~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:322:8: error: 'RCC_CFGR_SWS_HSI' undeclared (first use in this function)
  322 |   case RCC_CFGR_SWS_HSI:  /* HSI used as system clock source */
      |        ^~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:323:28: error: 'uint32_t' undeclared (first use in this function); did you mean 'wint_t'?
  323 |     common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
      |                            ^~~~~~~~
      |                            wint_t
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:59:35: error: expected ')' before numeric constant
   59 |   #define HSI_VALUE    ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:323:39: note: in expansion of macro 'HSI_VALUE'
  323 |     common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
      |                                       ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:323:64: error: 'RCC_CR_HSIDIV' undeclared (first use in this function)
  323 |     common_system_clock = (uint32_t) (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3));
      |                                                                ^~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:326:8: error: 'RCC_CFGR_SWS_CSI' undeclared (first use in this function)
  326 |   case RCC_CFGR_SWS_CSI:  /* CSI used as system clock  source */
      |        ^~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:55:35: error: expected ')' before numeric constant
   55 |   #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:327:27: note: in expansion of macro 'CSI_VALUE'
  327 |     common_system_clock = CSI_VALUE;
      |                           ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:330:8: error: 'RCC_CFGR_SWS_HSE' undeclared (first use in this function)
  330 |   case RCC_CFGR_SWS_HSE:  /* HSE used as system clock  source */
      |        ^~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:51:33: error: expected ')' before numeric constant
   51 | #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
      |                      ~          ^~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:331:27: note: in expansion of macro 'HSE_VALUE'
  331 |     common_system_clock = HSE_VALUE;
      |                           ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:334:8: error: 'RCC_CFGR_SWS_PLL1' undeclared (first use in this function)
  334 |   case RCC_CFGR_SWS_PLL1:  /* PLL1 used as system clock  source */
      |        ^~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:339:35: error: 'RCC_PLLCKSELR_PLLSRC' undeclared (first use in this function)
  339 |     pllsource = (RCC->PLLCKSELR & RCC_PLLCKSELR_PLLSRC);
      |                                   ^~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:340:31: error: 'RCC_PLLCKSELR_DIVM1' undeclared (first use in this function)
  340 |     pllm = ((RCC->PLLCKSELR & RCC_PLLCKSELR_DIVM1)>> 4)  ;
      |                               ^~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:341:34: error: 'RCC_PLLCFGR_PLL1FRACEN' undeclared (first use in this function)
  341 |     pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:341:59: error: 'RCC_PLLCFGR_PLL1FRACEN_Pos' undeclared (first use in this function)
  341 |     pllfracen = ((RCC->PLLCFGR & RCC_PLLCFGR_PLL1FRACEN)>>RCC_PLLCFGR_PLL1FRACEN_Pos);
      |                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:342:64: error: 'RCC_PLL1FRACR_FRACN1' undeclared (first use in this function)
  342 |     fracn1 = (float_t)(uint32_t)(pllfracen* ((RCC->PLL1FRACR & RCC_PLL1FRACR_FRACN1)>> 3));
      |                                                                ^~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:348:14: error: 'RCC_PLLCKSELR_PLLSRC_HSI' undeclared (first use in this function)
  348 |         case RCC_PLLCKSELR_PLLSRC_HSI:  /* HSI used as PLL clock source */
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:59:35: error: expected ')' before numeric constant
   59 |   #define HSI_VALUE    ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:350:21: note: in expansion of macro 'HSI_VALUE'
  350 |         hsivalue = (HSI_VALUE >> ((RCC->CR & RCC_CR_HSIDIV)>> 3)) ;
      |                     ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:351:94: error: 'RCC_PLL1DIVR_N1' undeclared (first use in this function)
  351 |         pllvco = ( (float_t)hsivalue / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
      |                                                                                              ^~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:355:14: error: 'RCC_PLLCKSELR_PLLSRC_CSI' undeclared (first use in this function)
  355 |         case RCC_PLLCKSELR_PLLSRC_CSI:  /* CSI used as PLL clock source */
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:55:35: error: expected ')' before numeric constant
   55 |   #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:356:30: note: in expansion of macro 'CSI_VALUE'
  356 |           pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
      |                              ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:359:14: error: 'RCC_PLLCKSELR_PLLSRC_HSE' undeclared (first use in this function)
  359 |         case RCC_PLLCKSELR_PLLSRC_HSE:  /* HSE used as PLL clock source */
      |              ^~~~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:51:33: error: expected ')' before numeric constant
   51 | #define HSE_VALUE    ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
      |                      ~          ^~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:360:30: note: in expansion of macro 'HSE_VALUE'
  360 |           pllvco = ((float_t)HSE_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
      |                              ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:55:35: error: expected ')' before numeric constant
   55 |   #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:364:30: note: in expansion of macro 'CSI_VALUE'
  364 |           pllvco = ((float_t)CSI_VALUE / (float_t)pllm) * ((float_t)(uint32_t)(RCC->PLL1DIVR & RCC_PLL1DIVR_N1) + (fracn1/(float_t)0x2000) +(float_t)1 );
      |                              ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:367:33: error: 'RCC_PLL1DIVR_P1' undeclared (first use in this function)
  367 |       pllp = (((RCC->PLL1DIVR & RCC_PLL1DIVR_P1) >>9) + 1U ) ;
      |                                 ^~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:368:41: error: expected expression before 'float_t'
  368 |       common_system_clock =  (uint32_t)(float_t)(pllvco/(float_t)pllp);
      |                                         ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:55:35: error: expected ')' before numeric constant
   55 |   #define CSI_VALUE    ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/
      |                        ~          ^~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:377:27: note: in expansion of macro 'CSI_VALUE'
  377 |     common_system_clock = CSI_VALUE;
      |                           ^~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:392:42: error: 'RCC_CDCFGR1_CDCPRE' undeclared (first use in this function)
  392 |   tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos];
      |                                          ^~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:392:64: error: 'RCC_CDCFGR1_CDCPRE_Pos' undeclared (first use in this function)
  392 |   tmp = D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos];
      |                                                                ^~~~~~~~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:398:78: error: 'RCC_CDCFGR1_HPRE' undeclared (first use in this function)
  398 |   SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
      |                                                                              ^~~~~~~~~~~~~~~~
/home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:398:98: error: 'RCC_CDCFGR1_HPRE_Pos' undeclared (first use in this function)
  398 |   SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
      |                                                                                                  ^~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/stm32-linker-error.dir/build.make:90: CMakeFiles/stm32-linker-error.dir/system_stm32h7xx.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/stm32-linker-error.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Thanks!

@atsju
Copy link
Collaborator

atsju commented Sep 8, 2021

I have no time to look a this now but have you tried to understand the problem ?

In file included from /home/azisi/Documents/stm32-cmake/examples/link-error/system_stm32h7xx.c:48:
/home/azisi/Documents/stm32-cmake/examples/link-error/build/_deps/stm32cubeh7-src/Drivers/CMSIS/Device/ST/STM32H7xx/Include/stm32h7xx.h:164:3: error: #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)"
  164 |  #error "Please select first the target STM32H7xx device used in your application (in stm32h7xx.h file)"

first error seems to be pretty clear. You want to use your own files it's normal that you have more defines and other things to provide yourself. Please open the file and you will see that your are obviously missing a simple and mandatory define.

@zisi
Copy link
Contributor Author

zisi commented Sep 9, 2021

Thanks for the comment, i add this definition:

add_definitions(-DSTM32H743xx)

add it works.

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