CMake Build Issue with STM32H563ZI
Hi ST team,
Been trying to build a bare bones MX generated project for the STM32H563ZI using CMake, for both TrustZone and non-TrustZone Projects. Had the same issue on both Ubuntu22.04 and Ubuntu24.04, and am unable to compile any of these projects.
When I have TrustZone enabled with both S and NSC projects enabled I get the following error messages:
```
lachjet@lachjet-Katana-GF76-12UD:~/tzt2/uild$ make
[ 6%] Creating directories for 'tzt2_S'
[ 12%] No download step for 'tzt2_S'
[ 18%] No update step for 'tzt2_S'
[ 25%] No patch step for 'tzt2_S'
[ 31%] Performing configure step for 'tzt2_S'
Build type: Debug
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lachjet/tzt2/Secure/build
[ 37%] Performing build step for 'tzt2_S'
[ 4%] Building C object CMakeFiles/STM32_Drivers.dir/Core/Src/system_stm32h5xx_s.c.o
In file included from /home/lachjet/tzt2/Secure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h563xx.h:242,
from /home/lachjet/tzt2/Secure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h5xx.h:113,
from /home/lachjet/tzt2/Secure/Core/Src/system_stm32h5xx_s.c:121:
/home/lachjet/tzt2/Secure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_SetVector’:
/home/lachjet/tzt2/Secure/../Drivers/CMSIS/Include/core_cm33.h:2686:23: warning: cast to pointer from integer of different s
ize [-Wint-to-pointer-cast]
2686 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
/home/lachjet/tzt2/Secure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_GetVector’:
/home/lachjet/tzt2/Secure/../Drivers/CMSIS/Include/core_cm33.h:2702:23: warning: cast to pointer from integer of different s
ize [-Wint-to-pointer-cast]
2702 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
In file included from /home/lachjet/tzt2/Secure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/partition_stm32h5xx.h:56,
from /home/lachjet/tzt2/Secure/Core/Src/system_stm32h5xx_s.c:122:
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h: In function ‘TZ_SAU_Setup’:
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:635:5: error: ‘SAU’ undeclared (first use in this function)
635 | SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) |
| ^~~
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:635:5: note: each undeclared identifier is reported only once for
each function it appears in
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:635:43: error: ‘SAU_CTRL_ENABLE_Pos’ undeclared (first use in thi
s function); did you mean ‘MPU_CTRL_ENABLE_Pos’?
635 | SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) |
| ^~~~~~~~~~~~~~~~~~~
| MPU_CTRL_ENABLE_Pos
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:635:66: error: ‘SAU_CTRL_ENABLE_Msk’ undeclared (first use in thi
s function); did you mean ‘MPU_CTRL_ENABLE_Msk’?
635 | SAU->CTRL = ((SAU_INIT_CTRL_ENABLE << SAU_CTRL_ENABLE_Pos) & SAU_CTRL_ENABLE_Msk) |
| ^~~~~~~~~~~~~~~~~~~
| MPU_CTRL_ENABLE_Msk
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:636:43: error: ‘SAU_CTRL_ALLNS_Pos’ undeclared (first use in this
function)
636 | ((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk) ;
| ^~~~~~~~~~~~~~~~~~
/home/lachjet/tzt2/Secure/Core/Inc/partition_stm32h563xx.h:636:66: error: ‘SAU_CTRL_ALLNS_Msk’ undeclared (first use in this
function)
636 | ((SAU_INIT_CTRL_ALLNS << SAU_CTRL_ALLNS_Pos) & SAU_CTRL_ALLNS_Msk) ;
| ^~~~~~~~~~~~~~~~~~
/home/lachjet/tzt2/Secure/Core/Src/system_stm32h5xx_s.c: At top level:
/home/lachjet/tzt2/Secure/Core/Src/system_stm32h5xx_s.c:413:1: warning: ‘cmse_nonsecure_entry’ attribute directive ignored
-Wattributes]
413 | {
| ^
make[5]: *** [CMakeFiles/STM32_Drivers.dir/build.make:76: CMakeFiles/STM32_Drivers.dir/Core/Src/system_stm32h5xx_s.c.o] Erro
r 1
make[4]: *** [CMakeFiles/Makefile2:111: CMakeFiles/STM32_Drivers.dir/all] Error 2
make[3]: *** [Makefile:91: all] Error 2
make[2]: *** [CMakeFiles/tzt2_S.dir/build.make:95: Secure/src/tzt2_S-stamp/tzt2_S-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/tzt2_S.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
```
Just a secure project I get the same issue.
Then for only a non-secure project I get the following issue:
```
lachjet@lachjet-Katana-GF76-12UD:~/tzt2/build$ make
Build context: NonSecure
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lachjet/tzt2/build
[ 12%] Creating directories for 'tzt2_NS'
[ 25%] No download step for 'tzt2_NS'
[ 37%] No update step for 'tzt2_NS'
[ 50%] No patch step for 'tzt2_NS'
[ 62%] Performing configure step for 'tzt2_NS'
Build type: Debug
-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lachjet/tzt2/NonSecure/build
[ 75%] Performing build step for 'tzt2_NS'
[ 5%] Building C object CMakeFiles/STM32_Drivers.dir/Core/Src/system_stm32h5xx_ns.c.o
In file included from /home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h563xx.h:242,
from /home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h5xx.h:113,
from /home/lachjet/tzt2/NonSecure/Core/Src/system_stm32h5xx_ns.c:55:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_SetVector’:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h:2686:23: warning: cast to pointer from integer of differen
t size [-Wint-to-pointer-cast]
2686 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_GetVector’:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h:2702:23: warning: cast to pointer from integer of differen
t size [-Wint-to-pointer-cast]
2702 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
[ 10%] Building C object CMakeFiles/STM32_Drivers.dir/home/lachjet/tzt2/Drivers/STM32H5xx_HAL_Driver/Src/stm32h5xx_hal_corte
x.c.o
In file included from /home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h563xx.h:242,
from /home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Device/ST/STM32H5xx/Include/stm32h5xx.h:113,
from /home/lachjet/tzt2/NonSecure/../Drivers/STM32H5xx_HAL_Driver/Inc/stm32h5xx_hal_def.h:33,
from /home/lachjet/tzt2/NonSecure/../Drivers/STM32H5xx_HAL_Driver/Inc/stm32h5xx_hal_rcc.h:28,
from /home/lachjet/tzt2/NonSecure/Core/Inc/stm32h5xx_hal_conf.h:277,
from /home/lachjet/tzt2/NonSecure/../Drivers/STM32H5xx_HAL_Driver/Inc/stm32h5xx_hal.h:29,
from /home/lachjet/tzt2/Drivers/STM32H5xx_HAL_Driver/Src/stm32h5xx_hal_cortex.c:121:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_SetVector’:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h:2686:23: warning: cast to pointer from integer of differen
t size [-Wint-to-pointer-cast]
2686 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h: In function ‘__NVIC_GetVector’:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/core_cm33.h:2702:23: warning: cast to pointer from integer of differen
t size [-Wint-to-pointer-cast]
2702 | uint32_t *vectors = (uint32_t *)SCB->VTOR;
| ^
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h: Assembler messages:
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:271: Error: number of operands mismatch for `ds'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:260: Error: no such instruction: `isb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:271: Error: number of operands mismatch for `ds'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:271: Error: number of operands mismatch for `ds'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:282: Error: no such instruction: `dmb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:271: Error: number of operands mismatch for `ds'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:260: Error: no such instruction: `isb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:282: Error: no such instruction: `dmb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:271: Error: number of operands mismatch for `ds'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:260: Error: no such instruction: `isb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:282: Error: no such instruction: `dmb 0xF'
/home/lachjet/tzt2/NonSecure/../Drivers/CMSIS/Include/cmsis_gcc.h:282: Error: no such instruction: `dmb 0xF'
make[5]: *** [CMakeFiles/STM32_Drivers.dir/build.make:90: CMakeFiles/STM32_Drivers.dir/home/lachjet/tzt2/Drivers/STM32H5xx_H
AL_Driver/Src/stm32h5xx_hal_cortex.c.o] Error 1
make[4]: *** [CMakeFiles/Makefile2:111: CMakeFiles/STM32_Drivers.dir/all] Error 2
make[3]: *** [Makefile:91: all] Error 2
make[2]: *** [CMakeFiles/tzt2_NS.dir/build.make:95: NonSecure/src/tzt2_NS-stamp/tzt2_NS-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/tzt2_NS.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
```
In which from a non-tz project I got a similar error message where it didn't understand instructions from the cmsis_gcc driver.
I did notice the following note in the 6.15 patch notes wrt using the H5 series.
- The makefile generation no longer works as soon as the project structure is changed from "Secure Project only" or "Non Secure Project only" to "Secure Project and Non Secure Project enabled (dual project)".
However for me using the H563zi, I an unable to get any successful builds due to these two issues.
