init
This commit is contained in:
404
cmake/FindBSP.cmake
Normal file
404
cmake/FindBSP.cmake
Normal file
@@ -0,0 +1,404 @@
|
||||
# For information about why and how of this file: https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
|
||||
### F0 ###
|
||||
set(BSP_F0_BOARDS
|
||||
STM32F0xx_Nucleo_32 STM32F0xx-Nucleo STM32F072B-Discovery
|
||||
STM32F0308-Discovery STM32072B_EVAL STM32091C_EVAL
|
||||
)
|
||||
set(BSP_F0_COMPONENTS
|
||||
hx8347d l3gd20 spfd5408 st7735 stlm75
|
||||
)
|
||||
set(BSP_F0_SOURCES_STM32F072B_Discovery eeprom gyroscope)
|
||||
set(BSP_F0_SOURCES_STM32072B_EVAL eeprom lcd sd tsensor)
|
||||
set(BSP_F0_SOURCES_STM32091C_EVAL eeprom lcd sd tsensor)
|
||||
set(BSP_F0_DEVICE_STM32F072B_Discovery F072RB)
|
||||
set(BSP_F0_DEVICE_STM32F0308_Discovery F030R8)
|
||||
set(BSP_F0_DEVICE_STM32072B_EVAL F072VB)
|
||||
set(BSP_F0_DEVICE_STM32091C_EVAL F091VC)
|
||||
|
||||
### F1 ###
|
||||
set(BSP_F1_BOARDS
|
||||
STM32F1xx_Nucleo STM32VL-Discovery STM3210C_EVAL STM3210E_EVAL
|
||||
)
|
||||
set(BSP_F1_COMPONENTS
|
||||
ak4343 cs43l22 hx8347d ili9320 ili9325 lis302dl spfd5408 st7735 stlm75
|
||||
stmpe811
|
||||
)
|
||||
set(BSP_F1_SOURCES_STM3210C_EVAL accelerometer audio eeprom io lcd sd ts)
|
||||
set(BSP_F1_SOURCES_STM3210E_EVAL audio lcd nand nor sd serialflash sram tsensor)
|
||||
set(BSP_F1_DEVICE_STM32VL_Discovery F100RB)
|
||||
set(BSP_F1_DEVICE_STM3210C_EVAL F107VC)
|
||||
set(BSP_F1_DEVICE_STM3210E_EVAL F103ZE)
|
||||
|
||||
### F2 ###
|
||||
set(BSP_F2_BOARDS
|
||||
STM32F2xx_Nucleo_144 STM322xG_EVAL
|
||||
)
|
||||
set(BSP_F2_COMPONENTS
|
||||
cs43l22 ili9320 ili9325 ili9341 ov2640 st7735 stmpe811
|
||||
)
|
||||
set(BSP_F2_SOURCES_STM322xG_EVAL audio camera eeprom io lcd sd sram ts)
|
||||
set(BSP_F2_DEVICE_STM322xG_EVAL F207IG)
|
||||
|
||||
### F3 ###
|
||||
set(BSP_F3_BOARDS
|
||||
STM32F3-Discovery STM32F3xx_Nucleo_32 STM32F3xx_Nucleo_144 STM32F3xx-Nucleo
|
||||
STM32F3348-Discovery STM32303C_EVAL STM32303E_EVAL STM32373C_EVAL
|
||||
)
|
||||
set(BSP_F3_COMPONENTS
|
||||
cs42l52 cs43l22 hx8347d hx8347g hx8347i ili9320 ili9325 ili9328 l3gd20
|
||||
lsm303dlhc spfd5408 st7735 stts751
|
||||
)
|
||||
set(BSP_F3_SOURCES_STM32F3_Discovery accelerometer gyroscope)
|
||||
set(BSP_F3_SOURCES_STM32303C_EVAL audio eeprom lcd sd tsensor)
|
||||
set(BSP_F3_SOURCES_STM32303E_EVAL audio eeprom lcd sd tsensor)
|
||||
set(BSP_F3_SOURCES_STM32373C_EVAL audio eeprom lcd sd tsensor)
|
||||
set(BSP_F3_DEVICE_STM32F3_Discovery F303VC)
|
||||
set(BSP_F3_DEVICE_STM32F3348_Discovery F334C8)
|
||||
set(BSP_F3_DEVICE_STM32303C_EVAL F303VC)
|
||||
set(BSP_F3_DEVICE_STM32303E_EVAL F303VE)
|
||||
set(BSP_F3_DEVICE_STM32373C_EVAL F373VC)
|
||||
|
||||
### F4 ###
|
||||
set(BSP_F4_BOARDS
|
||||
STM32F4-Discovery STM32F4xx_Nucleo_144 STM32F4xx-Nucleo STM32F401-Discovery
|
||||
STM32F411E-Discovery STM32F413H-Discovery STM32F429I-Discovery
|
||||
STM324x9I_EVAL STM324xG_EVAL STM32412G-Discovery STM32446E_EVAL
|
||||
STM32469I_EVAL STM32469I-Discovery
|
||||
)
|
||||
set(BSP_F4_COMPONENTS
|
||||
ampire480272 ampire640480 cs43l22 exc7200 ft6x06 ili9325 ili9341 l3gd20
|
||||
lis3dsh lis302dl ls016b8uy lsm303dlhc mfxstm32l152 n25q128a n25q256a
|
||||
n25q512a otm8009a ov2640 s5k5cag s25fl512s st7735 st7789h2 stmpe811
|
||||
stmpe1600 ts3510 wm8994
|
||||
)
|
||||
set(BSP_F4_SOURCES_STM32F4_Discovery accelerometer audio)
|
||||
set(BSP_F4_SOURCES_STM32F401_Discovery accelerometer audio gyroscope)
|
||||
set(BSP_F4_SOURCES_STM32F411E_Discovery accelerometer audio gyroscope)
|
||||
set(BSP_F4_SOURCES_STM32F413H_Discovery audio lcd psram qspi sd ts)
|
||||
set(BSP_F4_SOURCES_STM32F429I_Discovery eeprom gyroscope io lcd sdram ts)
|
||||
set(BSP_F4_SOURCES_STM324x9I_EVAL audio camera eeprom io lcd nor sd sdram sram ts)
|
||||
set(BSP_F4_SOURCES_STM324xG_EVAL audio camera eeprom io lcd sd sram ts)
|
||||
set(BSP_F4_SOURCES_STM32412G_Discovery audio eeprom lcd qspi sd ts)
|
||||
set(BSP_F4_SOURCES_STM3232446E_EVAL audio camera eeprom io lcd qspi sd sdram ts)
|
||||
set(BSP_F4_SOURCES_STM32469I_EVAL audio camera eeprom io lcd nor qspi sd sdram sram ts)
|
||||
set(BSP_F4_SOURCES_STM32469I_Discovery audio eeprom lcd qspi sd sdram ts)
|
||||
set(BSP_F4_DEVICE_STM32F4_Discovery F407VG)
|
||||
set(BSP_F4_DEVICE_STM32F401_Discovery F401VC)
|
||||
set(BSP_F4_DEVICE_STM32F411E_Discovery F411VE)
|
||||
set(BSP_F4_DEVICE_STM32F413H_Discovery F413ZH)
|
||||
set(BSP_F4_DEVICE_STM32F429I_Discovery F429ZI)
|
||||
set(BSP_F4_DEVICE_STM324x9I_EVAL F429NI)
|
||||
set(BSP_F4_DEVICE_STM324xG_EVAL F407IG)
|
||||
set(BSP_F4_DEVICE_STM32412G_Discovery F412ZG)
|
||||
set(BSP_F4_DEVICE_STM32446E_EVAL F446ZE)
|
||||
set(BSP_F4_DEVICE_STM32469I_EVAL F469NI)
|
||||
set(BSP_F4_DEVICE_STM32469I_Discovery F469NI)
|
||||
|
||||
### F7 ###
|
||||
set(BSP_F7_BOARDS
|
||||
STM32F7xx_Nucleo_144 STM32F723E-Discovery STM32F769I_EVAL
|
||||
STM32F769I-Discovery STM32F7308-Discovery STM32F7508-Discovery
|
||||
STM32746G-Discovery STM32756G_EVAL
|
||||
)
|
||||
set(BSP_F7_COMPONENTS
|
||||
adv7533 ampire480272 ampire640480 exc7200 ft6x06 ft5336 mfxstm32l152
|
||||
mx25l512 n25q128a n25q512a otm8009a ov5640 ov9655 rk043fn48h s5k5cag st7735
|
||||
st7789h2 stmpe811 ts3510 wm8994
|
||||
)
|
||||
set(BSP_F7_SOURCES_STM32F723E_Discovery audio lcd psram qspi ts)
|
||||
set(BSP_F7_SOURCES_STM32F769I_EVAL audio camera eeprom io lcd nor qspi sd sdram sram ts)
|
||||
set(BSP_F7_SOURCES_STM32F769I_Discovery audio eeprom lcd qspi sd sdram ts)
|
||||
set(BSP_F7_SOURCES_STM32F7308_Discovery audio lcd psram qspi ts)
|
||||
set(BSP_F7_SOURCES_STM32F7508_Discovery audio camera eeprom lcd qspi sd sdram ts)
|
||||
set(BSP_F7_SOURCES_STM32746G_Discovery audio camera eeprom lcd qspi sd sdram ts)
|
||||
set(BSP_F7_SOURCES_STM32756G_EVAL audio camera eeprom io lcd nor qspi sd sdram sram ts)
|
||||
set(BSP_F7_DEVICE_STM32F723E_Discovery F723IE)
|
||||
set(BSP_F7_DEVICE_STM32F769I_EVAL F769NI)
|
||||
set(BSP_F7_DEVICE_STM32F769I_Discovery F769NI)
|
||||
set(BSP_F7_DEVICE_STM32F7308_Discovery F730I8)
|
||||
set(BSP_F7_DEVICE_STM32F7508_Discovery F750N8)
|
||||
set(BSP_F7_DEVICE_STM32746G_Discovery F746NG)
|
||||
set(BSP_F7_DEVICE_STM32756G_EVAL F756NG)
|
||||
|
||||
### G0 ###
|
||||
set(BSP_G0_BOARDS
|
||||
STM32G0xx_Nucleo STM32G0xx_Nucleo_32 STM32G071B-Discovery STM32G081B_EVAL
|
||||
STM32G0316-Discovery
|
||||
)
|
||||
set(BSP_G0_COMPONENTS
|
||||
hx8347d ina230 sn65dp141 ssd1315 st7735 stlm75 tusb546
|
||||
)
|
||||
set(BSP_G0_DIR_STM32G0316_Discovery STM32G0316-DISCO)
|
||||
set(BSP_G0_SOURCES_STM32G071B_Discovery lcd pwr pwrmon)
|
||||
set(BSP_G0_SOURCES_STM32G081B_EVAL lcd mux pwr sd tsensor)
|
||||
set(BSP_G0_DEVICE_STM32G071B_Discovery G071RB)
|
||||
set(BSP_G0_DEVICE_STM32G081B_EVAL G081RB)
|
||||
set(BSP_G0_DEVICE_STM32G0316_Discovery G031J6)
|
||||
|
||||
### G4 ###
|
||||
set(BSP_G4_BOARDS
|
||||
B-G474E-DPOW1 STM32G4xx_Nucleo STM32G474E-EVAL
|
||||
)
|
||||
set(BSP_G4_COMPONENTS
|
||||
hx8347d mfxstm32l152 mt25ql512abb st7735 stts751 wm8994
|
||||
)
|
||||
set(BSP_G4_SOURCES_B-G474E-DPOW1 usbpd_pwr)
|
||||
set(BSP_G4_SOURCES_STM32G481B_EVAL audio bus env_sensor idd io lcd qspi sd smartcard sram usbpd_pwr)
|
||||
set(BSP_G4_DEVICE_B_G474E_DPOW1 G474RE)
|
||||
set(BSP_G4_DEVICE_STM32G474E_EVAL G474QE)
|
||||
|
||||
### H7 ###
|
||||
set(BSP_H7_BOARDS
|
||||
STM32H7B3I-Discovery STM32H7B3I-EVAL STM32H7xx_Nucleo STM32H743I-EVAL
|
||||
STM32H745I-Discovery STM32H747I-Discovery STM32H747I-EVAL
|
||||
STM32H750B-Discovery
|
||||
)
|
||||
set(BSP_H7_COMPONENTS
|
||||
adv7533 ampire480272 ampire640480 cs42l51 es_wifi exc7200 ft6x06 ft5336
|
||||
is42s16800j is42s32800g is42s32800j lan8742 m24lr64 mfxstm32l152
|
||||
mt25tl01g mt48lc4m32b2 mx25lm51245g otm8009a ov5640 ov9655 rk043fn48h
|
||||
rk070er9427 s5k5cag st7735 stmpe811 ts3510 wm8994
|
||||
)
|
||||
set(BSP_H7_DIR_STM32H7B3I_Discovery STM32H7B3I-DK)
|
||||
set(BSP_H7_DIR_STM32H745I_Discovery STM32H745I-DISCO)
|
||||
set(BSP_H7_DIR_STM32H747I_Discovery STM32H747I-DISCO)
|
||||
set(BSP_H7_DIR_STM32H750B_Discovery STM32H750B-DK)
|
||||
set(BSP_H7_SOURCES_STM32H7B3I_Discovery audio bus camera eeprom lcd ospi sd sdram ts)
|
||||
set(BSP_H7_SOURCES_STM32H7B3I_EVAL audio bus camera eeprom io lcd nor ospi sd sdram sram ts)
|
||||
set(BSP_H7_SOURCES_STM32H743I_EVAL audio bus eeprom io lcd nor qspi sd sdram sram ts)
|
||||
set(BSP_H7_SOURCES_STM32H745I_Discovery audio bus lcd mmc qspi sdram ts)
|
||||
set(BSP_H7_SOURCES_STM32H747I_Discovery audio bus camera lcd qspi sd sdram ts)
|
||||
set(BSP_H7_SOURCES_STM32H747I_EVAL audio bus eeprom io lcd nor qspi sd sdram sram ts)
|
||||
set(BSP_H7_SOURCES_STM32H750B_Discovery audio bus lcd mmc qspi sdram ts)
|
||||
set(BSP_H7_DEVICE_STM32H7B3I_Discovery H7B3LI)
|
||||
set(BSP_H7_DEVICE_STM32H7B3I_EVAL H7B3LI)
|
||||
set(BSP_H7_DEVICE_STM32H743I_EVAL H743XI)
|
||||
set(BSP_H7_DEVICE_STM32H745I_Discovery H745XI)
|
||||
set(BSP_H7_DEVICE_STM32H747I_Discovery H747XI)
|
||||
set(BSP_H7_DEVICE_STM32H747I_EVAL H743XI)
|
||||
set(BSP_H7_DEVICE_STM32H750B_Discovery H750XB)
|
||||
|
||||
### L0 ###
|
||||
set(BSP_L0_BOARDS
|
||||
STM32L0xx_Nucleo STM32L0xx_Nucleo_32 STM32L073Z_EVAL STM32L0538-Discovery
|
||||
)
|
||||
set(BSP_L0_COMPONENTS
|
||||
gde021a1 hx8347d mfxstm32l152 st7735 stlm75
|
||||
)
|
||||
set(BSP_L0_SOURCES_STM32L073Z_EVAL eeprom glass_lcd idd io lcd sd tsensor)
|
||||
set(BSP_L0_SOURCES_STM32L0538_Discovery epd)
|
||||
set(BSP_L0_DEVICE_STM32L073Z_EVAL L073VZ)
|
||||
set(BSP_L0_DEVICE_STM32L0538_Discovery L053C8)
|
||||
|
||||
### L1 ###
|
||||
set(BSP_L1_BOARDS
|
||||
STM32L1xx_Nucleo STM32L100C-Discovery STM32L152C-Discovery STM32L152D_EVAL
|
||||
)
|
||||
set(BSP_L1_COMPONENTS
|
||||
cs43l22 hx8347d ili9320 ili9325 spfd5408 st7735 stlm75
|
||||
)
|
||||
set(BSP_L1_SOURCES_STM32L152C_Discovery glass_lcd)
|
||||
set(BSP_L1_SOURCES_STM32L152D_EVAL audio eeprom audio glass_lcd lcd nor sd sram tsensor)
|
||||
set(BSP_L1_DEVICE_STM32L100C_Discovery L100RC)
|
||||
set(BSP_L1_DEVICE_STM32L152C_Discovery L152RC)
|
||||
set(BSP_L1_DEVICE_STM32L152D_EVAL L152ZD)
|
||||
|
||||
### L4 ###
|
||||
set(BSP_L4_BOARDS
|
||||
STM32L475E-IOT01 STM32L4P5G-Discovery STM32L4R9I_EVAL STM32L4R9I-Discovery
|
||||
STM32L4xx_Nucleo STM32L4xx_Nucleo_32 STM32L4xx_Nucleo_144 STM32L476G_EVAL
|
||||
STM32L476G-Discovery STM32L496G-Discovery
|
||||
)
|
||||
set(BSP_L4_COMPONENTS
|
||||
cs42l51 cs43l22 cy8c4014lqi ft3x67 ft6x06 ft5336 hts221 hx8347g hx8347i
|
||||
iss66wvh8m8 l3gd20 lis3mdl lps22hb ls016b8uy lsm6dsl lsm303c lsm303dlhc
|
||||
m24sr mfxstm32l152 mx25lm51245g mx25r6435f n25q128a n25q256a ov9655
|
||||
rk043fn48h st7735 st7789h2 stmpe811 stmpe1600 wm8994
|
||||
)
|
||||
set(BSP_L4_SOURCES_B_L475E_IOT01 accelerometer gyro hsensor magneto psensor qspi tsensor iot01)
|
||||
set(BSP_L4_SOURCES_STM32L4P5G_Discovery idd io lcd mmc ospi_nor psram ts)
|
||||
set(BSP_L4_SOURCES_STM32L4R9I_EVAL audio dsi_lcd dsi_ts eeprom idd io nor ospi_nor ospi_ram rgb_ts sd sram)
|
||||
set(BSP_L4_SOURCES_STM32L4R9I_Discovery audio camera idd io lcd ospi_nor psram sd ts)
|
||||
set(BSP_L4_SOURCES_STM32L476G_EVAL audio eeprom glass_lcd idd io lcd nor qspi sd sram ts)
|
||||
set(BSP_L4_SOURCES_STM32L476G_Discovery audio compass glass_lcd gyroscope qspi)
|
||||
set(BSP_L4_SOURCES_STM32L496G_Discovery audio camera idd io lcd qspi sd sram ts)
|
||||
set(BSP_L4_DIR_STM32L475E_IOT01 B-L475E-IOT01)
|
||||
set(BSP_L4_DEVICE_STM32L475E_IOT01 L475VG)
|
||||
set(BSP_L4_DEVICE_STM32L4P5G_Discovery L4P5AG)
|
||||
set(BSP_L4_DEVICE_STM32L4R9I_EVAL L4R9AI)
|
||||
set(BSP_L4_DEVICE_STM32L4R9I_Discovery L4R9AI)
|
||||
set(BSP_L4_DEVICE_STM32L476G_EVAL L476ZG)
|
||||
set(BSP_L4_DEVICE_STM32L476G_Discovery L476VG)
|
||||
set(BSP_L4_DEVICE_STM32L496G_Discovery L496AG)
|
||||
|
||||
### L5 ###
|
||||
set(BSP_L5_BOARDS
|
||||
STM32L552E_EVAL STM32L562E-Discovery STM32L5xx_Nucleo_144
|
||||
)
|
||||
set(BSP_L5_COMPONENTS
|
||||
cs42l51 ft6x06 hx8347i iss66wvh8m8 lsm6dso mfxstm32l152 mx25lm51245g
|
||||
st7789h2 stmpe811
|
||||
)
|
||||
set(BSP_L5_SOURCES_STM32L562E_Discovery audio bus idd lcd motion_sensor ospi sd ts usbpd_pwr)
|
||||
set(BSP_L5_SOURCES_STM32L552E_EVAL audio bus idd io lcd ospi sd sram ts usbpd_pwr)
|
||||
set(BSP_L5_DEVICE_STM32L562E_Discovery L562QE)
|
||||
set(BSP_L5_DEVICE_STM32L552E_EVAL L552ZE)
|
||||
|
||||
### MP1 ###
|
||||
set(BSP_MP1_BOARDS
|
||||
STM32MP15xx_DISCO STM32MP15xx_EVAL)
|
||||
set(BSP_MP1_COMPONENTS )
|
||||
set(BSP_MP1_SOURCES_STM32MP15xx_DISCO bus stpmic1)
|
||||
set(BSP_MP1_SOURCES_STM32MP15xx_EVAL bus stpmic1)
|
||||
|
||||
### WB ###
|
||||
set(BSP_WB_BOARDS
|
||||
STM32WB15CC_Nucleo STM32WB55_Nucleo STM32WB55_USBDongle STM32WB5MM_Discovery
|
||||
)
|
||||
set(BSP_WB_COMPONENTS
|
||||
ism330dhcx s25fl128s ssd1315 stts22h
|
||||
)
|
||||
set(BSP_WB_DIR_STM32WB5MM_Discovery STM32WB5MM-DK)
|
||||
set(BSP_WB_SOURCES_STM32WB5MM_Discovery audio bus env_sensors env_sensors_ex lcd motion_sensors motion_sensors_ex qspi)
|
||||
set(BSP_WB_DEVICE_STM32WB5MM_Discovery WB5MMG)
|
||||
|
||||
### WL ###
|
||||
set(BSP_WL_BOARDS
|
||||
STM32WLxx_Nucleo
|
||||
)
|
||||
|
||||
|
||||
|
||||
if(NOT BSP_FIND_COMPONENTS)
|
||||
set(BSP_FIND_COMPONENTS ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
|
||||
endif()
|
||||
|
||||
if(STM32H7 IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM BSP_FIND_COMPONENTS STM32H7)
|
||||
list(APPEND BSP_FIND_COMPONENTS STM32H7_M7 STM32H7_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WB IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM BSP_FIND_COMPONENTS STM32WB)
|
||||
list(APPEND BSP_FIND_COMPONENTS STM32WB_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WL IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM BSP_FIND_COMPONENTS STM32WL)
|
||||
list(APPEND BSP_FIND_COMPONENTS STM32WL_M4 STM32WL_M0PLUS)
|
||||
endif()
|
||||
|
||||
if(STM32MP1 IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM BSP_FIND_COMPONENTS STM32MP1)
|
||||
list(APPEND BSP_FIND_COMPONENTS STM32MP1_M4)
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES BSP_FIND_COMPONENTS)
|
||||
|
||||
foreach(COMP ${BSP_FIND_COMPONENTS})
|
||||
string(TOLOWER ${COMP} COMP_L)
|
||||
string(TOUPPER ${COMP} COMP_U)
|
||||
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
|
||||
if(NOT CMAKE_MATCH_1)
|
||||
message(FATAL_ERROR "Unknown BSP component: ${COMP}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_3)
|
||||
set(CORE ${CMAKE_MATCH_3})
|
||||
set(CORE_C "::${CORE}")
|
||||
set(CORE_U "_${CORE}")
|
||||
else()
|
||||
unset(CORE)
|
||||
unset(CORE_C)
|
||||
unset(CORE_U)
|
||||
endif()
|
||||
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
|
||||
if((NOT STM32_CUBE_${FAMILY}_PATH) AND (DEFINED ENV{STM32_CUBE_${FAMILY}_PATH))
|
||||
set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "ENV STM32_CUBE_${FAMILY}_PATH specified, using STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT STM32_CUBE_${FAMILY}_PATH)
|
||||
set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "No STM32_CUBE_${FAMILY}_PATH specified using default: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
set(BSP_${FAMILY}_PATH "${STM32_CUBE_${FAMILY}_PATH}/Drivers/BSP")
|
||||
if(NOT EXISTS ${BSP_${FAMILY}_PATH})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set(BSP_${FAMILY}_INCLUDE "${BSP_${FAMILY}_PATH}/Components/Common")
|
||||
|
||||
add_library(BSP::STM32::${FAMILY}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(BSP::STM32::${FAMILY}${CORE_C} INTERFACE STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(BSP::STM32::${FAMILY}${CORE_C} INTERFACE "${BSP_${FAMILY}_PATH}/Components/Common")
|
||||
|
||||
foreach(BOARD ${BSP_${FAMILY}_BOARDS})
|
||||
string(REPLACE "-" "_" BOARD_CANONICAL ${BOARD})
|
||||
string(TOLOWER ${BOARD_CANONICAL} BOARD_CANONICAL_L)
|
||||
set(BOARD_DEVICE ${BSP_${FAMILY}_DEVICE_${BOARD_CANONICAL}})
|
||||
|
||||
stm32_get_cores(DEV_CORES FAMILY ${FAMILY} DEVICE ${BOARD_DEVICE})
|
||||
if(CORE AND (NOT ${CORE} IN_LIST DEV_CORES))
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_path(BSP_${BOARD_CANONICAL}_PATH
|
||||
NAMES ${BOARD_CANONICAL_L}.h
|
||||
PATHS "${BSP_${FAMILY}_PATH}/${BOARD}" "${BSP_${FAMILY}_PATH}/${BSP_${FAMILY}_DIR_${BOARD_CANONICAL}}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT EXISTS ${BSP_${BOARD_CANONICAL}_PATH})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
add_library(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE BSP::STM32::${FAMILY}${CORE_C} CMSIS::STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE "${BSP_${BOARD_CANONICAL}_PATH}")
|
||||
target_sources(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE "${BSP_${BOARD_CANONICAL}_PATH}/${BOARD_CANONICAL_L}.c")
|
||||
|
||||
foreach(SRC ${BSP_${FAMILY}_SOURCES_${BOARD_CANONICAL}})
|
||||
target_sources(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE "${BSP_${BOARD_CANONICAL}_PATH}/${BOARD_CANONICAL_L}_${SRC}.c")
|
||||
endforeach()
|
||||
if(BSP_${FAMILY}_DEVICE_${BOARD_CANONICAL})
|
||||
target_link_libraries(BSP::STM32::${BOARD_CANONICAL}${CORE_C} INTERFACE CMSIS::STM32::${BSP_${FAMILY}_DEVICE_${BOARD_CANONICAL}}${CORE_C})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(BCOMP ${BSP_${FAMILY}_COMPONENTS})
|
||||
string(TOLOWER ${BCOMP} BCOMP_L)
|
||||
string(TOUPPER ${BCOMP} BCOMP_U)
|
||||
|
||||
add_library(BSP::STM32::${FAMILY}${CORE_C}::${BCOMP_U} INTERFACE IMPORTED)
|
||||
target_link_libraries(BSP::STM32::${FAMILY}${CORE_C}::${BCOMP_U} INTERFACE BSP::STM32::${FAMILY}${CORE_C} CMSIS::STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(BSP::STM32::${FAMILY}${CORE_C}::${BCOMP_U} INTERFACE "${BSP_${FAMILY}_PATH}/Components/${BCOMP}")
|
||||
|
||||
find_file(BSP_${BOARD_CANONICAL}_${BCOMP}_SOURCE
|
||||
NAMES ${BCOMP}.c
|
||||
PATHS "${BSP_${FAMILY}_PATH}/Components/${BCOMP}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (BSP_${BOARD_CANONICAL}_${BCOMP}_SOURCE)
|
||||
target_sources(BSP::STM32::${FAMILY}${CORE_C}::${BCOMP_U} INTERFACE "${BSP_${BOARD_CANONICAL}_${BCOMP}_SOURCE}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(BSP_${COMP}_FOUND TRUE)
|
||||
|
||||
if(BSP_${COMP}_FOUND)
|
||||
list(APPEND BSP_INCLUDE_DIRS "${BSP_${FAMILY}_INCLUDE}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(BSP
|
||||
REQUIRED_VARS BSP_INCLUDE_DIRS
|
||||
FOUND_VAR BSP_FOUND
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
326
cmake/FindCMSIS.cmake
Normal file
326
cmake/FindCMSIS.cmake
Normal file
@@ -0,0 +1,326 @@
|
||||
# For information about why and how of this file: https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMSIS_RTOS RTOS RTOS_V2)
|
||||
|
||||
if(NOT CMSIS_FIND_COMPONENTS)
|
||||
set(CMSIS_FIND_COMPONENTS ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
|
||||
endif()
|
||||
|
||||
if(STM32H7 IN_LIST CMSIS_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32H7)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS STM32H7_M7 STM32H7_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WB IN_LIST CMSIS_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32WB)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS STM32WB_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WL IN_LIST CMSIS_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32WL)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS STM32WL_M4 STM32WL_M0PLUS)
|
||||
endif()
|
||||
|
||||
if(STM32MP1 IN_LIST CMSIS_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32MP1)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS STM32MP1_M4)
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES CMSIS_FIND_COMPONENTS)
|
||||
|
||||
# This section fills the RTOS or family components list
|
||||
foreach(COMP ${CMSIS_FIND_COMPONENTS})
|
||||
string(TOLOWER ${COMP} COMP_L)
|
||||
string(TOUPPER ${COMP} COMP)
|
||||
|
||||
# Component is RTOS component
|
||||
if(${COMP} IN_LIST CMSIS_RTOS)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS_RTOS ${COMP})
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# Component is not RTOS component, so check whether it is a family component
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP ${COMP})
|
||||
if(CMAKE_MATCH_1)
|
||||
list(APPEND CMSIS_FIND_COMPONENTS_FAMILIES ${COMP})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT CMSIS_FIND_COMPONENTS_FAMILIES)
|
||||
set(CMSIS_FIND_COMPONENTS_FAMILIES ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
|
||||
endif()
|
||||
|
||||
if(NOT CMSIS_FIND_COMPONENTS_RTOS)
|
||||
set(CMSIS_FIND_COMPONENTS_RTOS ${CMSIS_RTOS})
|
||||
endif()
|
||||
|
||||
message(STATUS "Search for CMSIS families: ${CMSIS_FIND_COMPONENTS_FAMILIES}")
|
||||
message(STATUS "Search for CMSIS RTOS: ${CMSIS_FIND_COMPONENTS_RTOS}")
|
||||
|
||||
include(stm32/devices)
|
||||
|
||||
function(cmsis_generate_default_linker_script FAMILY DEVICE CORE)
|
||||
if(CORE)
|
||||
set(CORE_C "::${CORE}")
|
||||
set(CORE_U "_${CORE}")
|
||||
endif()
|
||||
|
||||
set(OUTPUT_LD_FILE "${CMAKE_CURRENT_BINARY_DIR}/${DEVICE}${CORE_U}.ld")
|
||||
|
||||
if(${FAMILY} STREQUAL MP1)
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
find_file(CMSIS_${FAMILY}${CORE_U}_LD_SCRIPT
|
||||
NAMES stm32mp15xx_m4.ld
|
||||
PATHS "${CMSIS_${FAMILY}${CORE_U}_PATH}/Source/Templates/gcc/linker"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
add_custom_command(OUTPUT "${OUTPUT_LD_FILE}"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E copy ${CMSIS_${FAMILY}${CORE_U}_LD_SCRIPT} ${OUTPUT_LD_FILE})
|
||||
else()
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} FLASH SIZE FLASH_SIZE ORIGIN FLASH_ORIGIN)
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} RAM SIZE RAM_SIZE ORIGIN RAM_ORIGIN)
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} CCRAM SIZE CCRAM_SIZE ORIGIN CCRAM_ORIGIN)
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} RAM_SHARE SIZE RAM_SHARE_SIZE ORIGIN RAM_SHARE_ORIGIN)
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} HEAP SIZE HEAP_SIZE)
|
||||
stm32_get_memory_info(FAMILY ${FAMILY} DEVICE ${DEVICE} CORE ${CORE} STACK SIZE STACK_SIZE)
|
||||
|
||||
add_custom_command(OUTPUT "${OUTPUT_LD_FILE}"
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DFLASH_ORIGIN="${FLASH_ORIGIN}"
|
||||
-DRAM_ORIGIN="${RAM_ORIGIN}"
|
||||
-DCCRAM_ORIGIN="${CCRAM_ORIGIN}"
|
||||
-DRAM_SHARE_ORIGIN="${RAM_SHARE_ORIGIN}"
|
||||
-DFLASH_SIZE="${FLASH_SIZE}"
|
||||
-DRAM_SIZE="${RAM_SIZE}"
|
||||
-DCCRAM_SIZE="${CCRAM_SIZE}"
|
||||
-DRAM_SHARE_SIZE="${RAM_SHARE_SIZE}"
|
||||
-DSTACK_SIZE="${STACK_SIZE}"
|
||||
-DHEAP_SIZE="${HEAP_SIZE}"
|
||||
-DLINKER_SCRIPT="${OUTPUT_LD_FILE}"
|
||||
-P "${STM32_CMAKE_DIR}/stm32/linker_ld.cmake"
|
||||
)
|
||||
endif()
|
||||
add_custom_target(CMSIS_LD_${DEVICE}${CORE_U} DEPENDS "${OUTPUT_LD_FILE}")
|
||||
add_dependencies(CMSIS::STM32::${DEVICE}${CORE_C} CMSIS_LD_${DEVICE}${CORE_U})
|
||||
stm32_add_linker_script(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE "${OUTPUT_LD_FILE}")
|
||||
endfunction()
|
||||
|
||||
foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES})
|
||||
string(TOLOWER ${COMP} COMP_L)
|
||||
string(TOUPPER ${COMP} COMP)
|
||||
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP ${COMP})
|
||||
# CMAKE_MATCH_<n> contains n'th subexpression
|
||||
# CMAKE_MATCH_0 contains full match
|
||||
|
||||
if((NOT CMAKE_MATCH_1) AND (NOT CMAKE_MATCH_2))
|
||||
message(FATAL_ERROR "Unknown CMSIS component: ${COMP}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_2)
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
set(STM_DEVICES "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
|
||||
message(TRACE "FindCMSIS: full device name match for COMP ${COMP}, STM_DEVICES is ${STM_DEVICES}")
|
||||
else()
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
stm32_get_devices_by_family(STM_DEVICES FAMILY ${FAMILY})
|
||||
message(TRACE "FindCMSIS: family only match for COMP ${COMP}, STM_DEVICES is ${STM_DEVICES}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_3)
|
||||
set(CORE ${CMAKE_MATCH_3})
|
||||
set(CORE_C "::${CORE}")
|
||||
set(CORE_U "_${CORE}")
|
||||
set(CORE_Ucm "_c${CORE}")
|
||||
string(TOLOWER ${CORE_Ucm} CORE_Ucm)
|
||||
message(TRACE "FindCMSIS: core match in component name for COMP ${COMP}. CORE is ${CORE}")
|
||||
else()
|
||||
unset(CORE)
|
||||
unset(CORE_C)
|
||||
unset(CORE_U)
|
||||
unset(CORE_Ucm)
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
|
||||
if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH) AND (DEFINED ENV{STM32_CUBE_${FAMILY}_PATH}))
|
||||
# try to set path from environment variable. Note it could be ...-NOT-FOUND and it's fine
|
||||
set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "ENV STM32_CUBE_${FAMILY}_PATH specified, using STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
if((NOT STM32_CMSIS_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH))
|
||||
set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_CMSIS_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
# search for Include/cmsis_gcc.h
|
||||
find_path(CMSIS_${FAMILY}${CORE_U}_CORE_PATH
|
||||
NAMES Include/cmsis_gcc.h
|
||||
PATHS "${STM32_CMSIS_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT CMSIS_${FAMILY}${CORE_U}_CORE_PATH)
|
||||
message(VERBOSE "FindCMSIS: cmsis_gcc.h for ${FAMILY}${CORE_U} has not been found")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
# search for Include/stm32[XX]xx.h
|
||||
find_path(CMSIS_${FAMILY}${CORE_U}_PATH
|
||||
NAMES Include/stm32${FAMILY_L}xx.h
|
||||
PATHS "${STM32_CMSIS_${FAMILY}_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS/Device/ST/STM32${FAMILY}xx"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT CMSIS_${FAMILY}${CORE_U}_PATH)
|
||||
message(VERBOSE "FindCMSIS: stm32${FAMILY_L}xx.h for ${FAMILY}${CORE_U} has not been found")
|
||||
continue()
|
||||
endif()
|
||||
list(APPEND CMSIS_INCLUDE_DIRS "${CMSIS_${FAMILY}${CORE_U}_CORE_PATH}/Include" "${CMSIS_${FAMILY}${CORE_U}_PATH}/Include")
|
||||
|
||||
if(NOT CMSIS_${FAMILY}${CORE_U}_VERSION)
|
||||
find_file(CMSIS_${FAMILY}${CORE_U}_PDSC
|
||||
NAMES ARM.CMSIS.pdsc
|
||||
PATHS "${CMSIS_${FAMILY}${CORE_U}_CORE_PATH}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT CMSIS_${FAMILY}${CORE_U}_PDSC)
|
||||
set(CMSIS_${FAMILY}${CORE_U}_VERSION "0.0.0")
|
||||
else()
|
||||
file(STRINGS "${CMSIS_${FAMILY}${CORE_U}_PDSC}" VERSION_STRINGS REGEX "<release version=\"([0-9]*\\.[0-9]*\\.[0-9]*)\" date=\"[0-9]+\\-[0-9]+\\-[0-9]+\">")
|
||||
list(GET VERSION_STRINGS 0 STR)
|
||||
string(REGEX MATCH "<release version=\"([0-9]*)\\.([0-9]*)\\.([0-9]*)\" date=\"[0-9]+\\-[0-9]+\\-[0-9]+\">" MATCHED ${STR})
|
||||
set(CMSIS_${FAMILY}${CORE_U}_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}" CACHE INTERNAL "CMSIS STM32${FAMILY}${CORE_U} version")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMSIS_${COMP}_VERSION ${CMSIS_${FAMILY}${CORE_U}_VERSION})
|
||||
set(CMSIS_VERSION ${CMSIS_${COMP}_VERSION})
|
||||
|
||||
if(NOT (TARGET CMSIS::STM32::${FAMILY}${CORE_C}))
|
||||
message(TRACE "FindCMSIS: creating library CMSIS::STM32::${FAMILY}${CORE_C}")
|
||||
add_library(CMSIS::STM32::${FAMILY}${CORE_C} INTERFACE IMPORTED)
|
||||
#STM32::${FAMILY}${CORE_C} contains compile options and is define in <family>.cmake
|
||||
target_link_libraries(CMSIS::STM32::${FAMILY}${CORE_C} INTERFACE STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(CMSIS::STM32::${FAMILY}${CORE_C} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_CORE_PATH}/Include")
|
||||
target_include_directories(CMSIS::STM32::${FAMILY}${CORE_C} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_PATH}/Include")
|
||||
endif()
|
||||
|
||||
# search for system_stm32[XX]xx.c
|
||||
find_file(CMSIS_${FAMILY}${CORE_U}_SYSTEM
|
||||
NAMES system_stm32${FAMILY_L}xx.c
|
||||
PATHS "${CMSIS_${FAMILY}${CORE_U}_PATH}/Source/Templates"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list(APPEND CMSIS_SOURCES "${CMSIS_${FAMILY}${CORE_U}_SYSTEM}")
|
||||
|
||||
if(NOT CMSIS_${FAMILY}${CORE_U}_SYSTEM)
|
||||
message(VERBOSE "FindCMSIS: system_stm32${FAMILY_L}xx.c for ${FAMILY}${CORE_U} has not been found")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set(STM_DEVICES_FOUND TRUE)
|
||||
foreach(DEVICE ${STM_DEVICES})
|
||||
message(TRACE "FindCMSIS: Iterating DEVICE ${DEVICE}")
|
||||
|
||||
stm32_get_cores(DEV_CORES FAMILY ${FAMILY} DEVICE ${DEVICE})
|
||||
if(CORE AND (NOT ${CORE} IN_LIST DEV_CORES))
|
||||
message(TRACE "FindCMSIS: skip device because CORE ${CORE} provided doesn't correspond to FAMILY ${FAMILY} DEVICE ${DEVICE}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
stm32_get_chip_type(${FAMILY} ${DEVICE} TYPE)
|
||||
string(TOLOWER ${DEVICE} DEVICE_L)
|
||||
string(TOLOWER ${TYPE} TYPE_L)
|
||||
|
||||
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
if(NOT "ASM" IN_LIST languages)
|
||||
message(STATUS "FindCMSIS: Not generating target for startup file and linker script because ASM language is not enabled")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_file(CMSIS_${FAMILY}${CORE_U}_${TYPE}_STARTUP
|
||||
NAMES startup_stm32${TYPE_L}.s
|
||||
startup_stm32${TYPE_L}${CORE_Ucm}.s
|
||||
PATHS "${CMSIS_${FAMILY}${CORE_U}_PATH}/Source/Templates/gcc"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list(APPEND CMSIS_SOURCES "${CMSIS_${FAMILY}${CORE_U}_${TYPE}_STARTUP}")
|
||||
if(NOT CMSIS_${FAMILY}${CORE_U}_${TYPE}_STARTUP)
|
||||
set(STM_DEVICES_FOUND FALSE)
|
||||
message(VERBOSE "FindCMSIS: did not find file: startup_stm32${TYPE_L}.s or startup_stm32${TYPE_L}${CORE_Ucm}.s")
|
||||
break()
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET CMSIS::STM32::${TYPE}${CORE_C}))
|
||||
message(TRACE "FindCMSIS: creating library CMSIS::STM32::${TYPE}${CORE_C}")
|
||||
add_library(CMSIS::STM32::${TYPE}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(CMSIS::STM32::${TYPE}${CORE_C} INTERFACE CMSIS::STM32::${FAMILY}${CORE_C} STM32::${TYPE}${CORE_C})
|
||||
target_sources(CMSIS::STM32::${TYPE}${CORE_C} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_${TYPE}_STARTUP}")
|
||||
target_sources(CMSIS::STM32::${TYPE}${CORE_C} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_SYSTEM}")
|
||||
endif()
|
||||
|
||||
add_library(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE CMSIS::STM32::${TYPE}${CORE_C})
|
||||
cmsis_generate_default_linker_script(${FAMILY} ${DEVICE} "${CORE}")
|
||||
endforeach()
|
||||
|
||||
if(STM_DEVICES_FOUND)
|
||||
set(CMSIS_${COMP}_FOUND TRUE)
|
||||
message(DEBUG "CMSIS_${COMP}_FOUND TRUE")
|
||||
else()
|
||||
set(CMSIS_${COMP}_FOUND FALSE)
|
||||
message(DEBUG "CMSIS_${COMP}_FOUND FALSE")
|
||||
endif()
|
||||
|
||||
foreach(RTOS_COMP ${CMSIS_FIND_COMPONENTS_RTOS})
|
||||
if (${RTOS_COMP} STREQUAL "RTOS_V2")
|
||||
set(RTOS_COMP_VERSION "2")
|
||||
else()
|
||||
unset(RTOS_COMP_VERSION)
|
||||
endif()
|
||||
|
||||
find_path(CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH
|
||||
NAMES "cmsis_os${RTOS_COMP_VERSION}.h"
|
||||
PATHS "${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_file(CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_SOURCE
|
||||
NAMES "cmsis_os${RTOS_COMP_VERSION}.c"
|
||||
PATHS "${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_${RTOS_COMP}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_SOURCE)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET CMSIS::STM32::${FAMILY}${CORE_C}::${RTOS_COMP}))
|
||||
add_library(CMSIS::STM32::${FAMILY}${CORE_C}::${RTOS_COMP} INTERFACE IMPORTED)
|
||||
target_link_libraries(CMSIS::STM32::${FAMILY}${CORE_C}::${RTOS_COMP} INTERFACE CMSIS::STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(CMSIS::STM32::${FAMILY}${CORE_C}::${RTOS_COMP} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH}")
|
||||
target_sources(CMSIS::STM32::${FAMILY}${CORE_C}::${RTOS_COMP} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_SOURCE}")
|
||||
endif()
|
||||
|
||||
list(APPEND CMSIS_SOURCES "${CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_SOURCE}")
|
||||
list(APPEND CMSIS_INCLUDE_DIRS "${CMSIS_${FAMILY}${CORE_U}_${RTOS_COMP}_PATH}")
|
||||
set(CMSIS_${RTOS_COMP}_FOUND TRUE)
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES CMSIS_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES CMSIS_SOURCES)
|
||||
endforeach()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(CMSIS
|
||||
REQUIRED_VARS CMSIS_INCLUDE_DIRS CMSIS_SOURCES
|
||||
FOUND_VAR CMSIS_FOUND
|
||||
VERSION_VAR CMSIS_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
259
cmake/FindFreeRTOS.cmake
Normal file
259
cmake/FindFreeRTOS.cmake
Normal file
@@ -0,0 +1,259 @@
|
||||
# For information about why and how of this file: https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
set(FreeRTOS_PORTS ARM_CM0 ARM_CM3 ARM_CM3_MPU ARM_CM4_MPU ARM_CM4F ARM_CM7 ARM_CM7_MPU ARM_CM23 ARM_CM23_NTZ ARM_CM33 ARM_CM33_NTZ)
|
||||
set(FreeRTOS_armv8_PORTS ARM_CM23_NTZ ARM_CM33_NTZ ARM_CM23 ARM_CM33)
|
||||
set(FreeRTOS_armv8_trustZone_PORTS ARM_CM23 ARM_CM33)
|
||||
|
||||
if(NOT FreeRTOS_FIND_COMPONENTS)
|
||||
set(FreeRTOS_FIND_COMPONENTS ${FreeRTOS_PORTS})
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES FreeRTOS_FIND_COMPONENTS)
|
||||
|
||||
if((NOT FREERTOS_PATH) AND (DEFINED ENV{FREERTOS_PATH}))
|
||||
set(FREERTOS_PATH $ENV{FREERTOS_PATH} CACHE PATH "Path to FreeRTOS")
|
||||
message(STATUS "ENV FREERTOS_PATH specified, using FREERTOS_PATH: ${FREERTOS_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT FREERTOS_PATH)
|
||||
set(DEFAULT_FREERTOS_PATH "/opt/FreeRTOS")
|
||||
if(EXISTS ${DEFAULT_FREERTOS_PATH})
|
||||
set(FREERTOS_PATH ${DEFAULT_FREERTOS_PATH} CACHE PATH "Path to FreeRTOS")
|
||||
message(STATUS "No FREERTOS_PATH specified using default: ${DEFAULT_FREERTOS_PATH}")
|
||||
else()
|
||||
message(STATUS
|
||||
"No FreeRTOS folder found at default location ${DEFAULT_FREERTOS_PATH}. "
|
||||
"Leaving empty.."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(STM32H7 IN_LIST FreeRTOS_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM FreeRTOS_FIND_COMPONENTS STM32H7)
|
||||
list(APPEND FreeRTOS_FIND_COMPONENTS STM32H7_M7 STM32H7_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WB IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM FreeRTOS_FIND_COMPONENTS STM32WB)
|
||||
list(APPEND FreeRTOS_FIND_COMPONENTS STM32WB_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WL IN_LIST BSP_FIND_COMPONENTS)
|
||||
list(REMOVE_ITEM FreeRTOS_FIND_COMPONENTS STM32WL)
|
||||
list(APPEND FreeRTOS_FIND_COMPONENTS STM32WL_M4 STM32WL_M0PLUS)
|
||||
endif()
|
||||
|
||||
# This section fills the family and ports components list
|
||||
foreach(COMP ${FreeRTOS_FIND_COMPONENTS})
|
||||
string(TOUPPER ${COMP} COMP)
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" FAMILY_COMP ${COMP})
|
||||
# Valid family component, so add it (e.g. STM32H7)
|
||||
if(CMAKE_MATCH_1)
|
||||
list(APPEND FreeRTOS_FIND_COMPONENTS_FAMILIES ${FAMILY_COMP})
|
||||
continue()
|
||||
endif()
|
||||
# Was not a family component, so add it to the port list
|
||||
list(APPEND FreeRTOS_FIND_COMPONENTS_PORTS ${COMP})
|
||||
endforeach()
|
||||
|
||||
if(NOT FreeRTOS_FIND_COMPONENTS_PORTS)
|
||||
set(FreeRTOS_FIND_COMPONENTS_PORTS ${FreeRTOS_PORTS})
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES FreeRTOS_FIND_COMPONENTS)
|
||||
list(REMOVE_DUPLICATES FreeRTOS_FIND_COMPONENTS_PORTS)
|
||||
list(REMOVE_DUPLICATES FreeRTOS_FIND_COMPONENTS_FAMILIES)
|
||||
|
||||
set(FreeRTOS_HEAPS 1 2 3 4 5)
|
||||
|
||||
macro(stm32_find_freertos FreeRTOS_NAMESPACE FREERTOS_PATH)
|
||||
find_path(FreeRTOS_COMMON_INCLUDE
|
||||
NAMES FreeRTOS.h
|
||||
PATHS "${FREERTOS_PATH}" "${FREERTOS_PATH}/FreeRTOS"
|
||||
PATH_SUFFIXES "Source/include" "include"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(NOT FreeRTOS_COMMON_INCLUDE)
|
||||
message(WARNING "FreeRTOS common include path not found, build might fail")
|
||||
endif()
|
||||
|
||||
list(APPEND FreeRTOS_INCLUDE_DIRS "${FreeRTOS_COMMON_INCLUDE}")
|
||||
|
||||
find_path(FreeRTOS_SOURCE_DIR
|
||||
NAMES tasks.c
|
||||
PATHS "${FREERTOS_PATH}" "${FREERTOS_PATH}/FreeRTOS"
|
||||
PATH_SUFFIXES "Source"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT (TARGET FreeRTOS))
|
||||
add_library(FreeRTOS INTERFACE IMPORTED)
|
||||
target_sources(FreeRTOS INTERFACE
|
||||
"${FreeRTOS_SOURCE_DIR}/tasks.c"
|
||||
"${FreeRTOS_SOURCE_DIR}/list.c"
|
||||
"${FreeRTOS_SOURCE_DIR}/queue.c"
|
||||
)
|
||||
target_include_directories(FreeRTOS INTERFACE "${FreeRTOS_COMMON_INCLUDE}")
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::Coroutine))
|
||||
add_library(${FreeRTOS_NAMESPACE}::Coroutine INTERFACE IMPORTED)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::Coroutine INTERFACE "${FreeRTOS_SOURCE_DIR}/croutine.c")
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::Coroutine INTERFACE FreeRTOS)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::EventGroups))
|
||||
add_library(${FreeRTOS_NAMESPACE}::EventGroups INTERFACE IMPORTED)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::EventGroups INTERFACE "${FreeRTOS_SOURCE_DIR}/event_groups.c")
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::EventGroups INTERFACE FreeRTOS)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::StreamBuffer))
|
||||
add_library(${FreeRTOS_NAMESPACE}::StreamBuffer INTERFACE IMPORTED)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::StreamBuffer INTERFACE "${FreeRTOS_SOURCE_DIR}/stream_buffer.c")
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::StreamBuffer INTERFACE FreeRTOS)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::Timers))
|
||||
add_library(${FreeRTOS_NAMESPACE}::Timers INTERFACE IMPORTED)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::Timers INTERFACE "${FreeRTOS_SOURCE_DIR}/timers.c")
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::Timers INTERFACE FreeRTOS)
|
||||
endif()
|
||||
|
||||
foreach(HEAP ${FreeRTOS_HEAPS})
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::Heap::${HEAP}))
|
||||
add_library(${FreeRTOS_NAMESPACE}::Heap::${HEAP} INTERFACE IMPORTED)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::Heap::${HEAP} INTERFACE "${FreeRTOS_SOURCE_DIR}/portable/MemMang/heap_${HEAP}.c")
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::Heap::${HEAP} INTERFACE FreeRTOS)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(PORT ${FreeRTOS_FIND_COMPONENTS_PORTS})
|
||||
if(${PORT} IN_LIST FreeRTOS_armv8_trustZone_PORTS)
|
||||
set(ARMv8_NON_SECURE "::NON_SECURE")
|
||||
endif()
|
||||
|
||||
find_path(FreeRTOS_${PORT}_PATH
|
||||
NAMES portmacro.h
|
||||
PATHS "${FREERTOS_PATH}" "${FREERTOS_PATH}/FreeRTOS"
|
||||
PATH_SUFFIXES
|
||||
"portable/GCC/${PORT}"
|
||||
"portable/GCC/${PORT}/r0p1"
|
||||
"portable/GCC/${PORT}/non_secure"
|
||||
"Source/portable/GCC/${PORT}"
|
||||
"Source/portable/GCC/${PORT}/r0p1"
|
||||
"Source/portable/GCC/${PORT}/non_secure"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(NOT FreeRTOS_${PORT}_PATH)
|
||||
message(WARNING "FreeRTOS port path not found, build might fail")
|
||||
endif()
|
||||
|
||||
list(APPEND FreeRTOS_INCLUDE_DIRS "${FreeRTOS_${PORT}_PATH}")
|
||||
|
||||
find_file(FreeRTOS_${PORT}_SOURCE
|
||||
NAMES port.c
|
||||
PATHS "${FreeRTOS_${PORT}_PATH}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT (TARGET ${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE}))
|
||||
add_library(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE IMPORTED)
|
||||
target_link_libraries(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE FreeRTOS)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_SOURCE}")
|
||||
target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}")
|
||||
message(trace "FindFreeRTOS: creating target ${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE}")
|
||||
|
||||
# armv8-m needs additional file even if using "No Trust Zone" port
|
||||
if(${PORT} IN_LIST FreeRTOS_armv8_PORTS)
|
||||
target_sources(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}/portasm.c")
|
||||
endif()
|
||||
|
||||
if(${PORT} IN_LIST FreeRTOS_armv8_trustZone_PORTS)
|
||||
# create the secure target
|
||||
add_library(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE IMPORTED)
|
||||
# ::SECURE doesn't link FreeRTOS like ::NON_SECURE does
|
||||
target_sources(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE "${FreeRTOS_${PORT}_PATH}/../secure/secure_context.c"
|
||||
"${FreeRTOS_${PORT}_PATH}/../secure/secure_context_port.c"
|
||||
"${FreeRTOS_${PORT}_PATH}/../secure/secure_heap.c"
|
||||
"${FreeRTOS_${PORT}_PATH}/../secure/secure_init.c")
|
||||
message(trace "FindFreeRTOS: creating target ${FreeRTOS_NAMESPACE}::${PORT}::SECURE")
|
||||
|
||||
# non-secure part needs declaratation from secure includes
|
||||
target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}${ARMv8_NON_SECURE} INTERFACE "${FreeRTOS_${PORT}_PATH}/../secure")
|
||||
# secure part needs declaratation from non-secure includes and common freeRTOS includes
|
||||
target_include_directories(${FreeRTOS_NAMESPACE}::${PORT}::SECURE INTERFACE "${FreeRTOS_${PORT}_PATH}"
|
||||
"${FreeRTOS_COMMON_INCLUDE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FreeRTOS_${PORT}_PATH AND
|
||||
FreeRTOS_${PORT}_SOURCE AND
|
||||
FreeRTOS_COMMON_INCLUDE AND
|
||||
FreeRTOS_SOURCE_DIR)
|
||||
set(FreeRTOS_${PORT}_FOUND TRUE)
|
||||
else()
|
||||
set(FreeRTOS_${PORT}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
message(STATUS "Search for FreeRTOS ports: ${FreeRTOS_FIND_COMPONENTS_PORTS}")
|
||||
|
||||
if(NOT FreeRTOS_FIND_COMPONENTS_FAMILIES)
|
||||
stm32_find_freertos(FreeRTOS ${FREERTOS_PATH})
|
||||
else()
|
||||
message(STATUS "Search for FreeRTOS families: ${FreeRTOS_FIND_COMPONENTS_FAMILIES}")
|
||||
|
||||
foreach(COMP ${FreeRTOS_FIND_COMPONENTS_FAMILIES})
|
||||
string(TOLOWER ${COMP} COMP_L)
|
||||
string(TOUPPER ${COMP} COMP)
|
||||
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP ${COMP})
|
||||
|
||||
if((NOT CMAKE_MATCH_1) AND (NOT CMAKE_MATCH_2))
|
||||
message(FATAL_ERROR "Unknown FreeRTOS component: ${COMP}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_2)
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
set(STM_DEVICES "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
|
||||
else()
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
stm32_get_devices_by_family(STM_DEVICES FAMILY ${FAMILY})
|
||||
endif()
|
||||
|
||||
if(CMAKE_MATCH_3)
|
||||
set(CORE ${CMAKE_MATCH_3})
|
||||
set(CORE_C "::${CORE}")
|
||||
set(CORE_U "_${CORE}")
|
||||
else()
|
||||
unset(CORE)
|
||||
unset(CORE_C)
|
||||
unset(CORE_U)
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
if(NOT STM32_CUBE_${FAMILY}_PATH)
|
||||
set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "Did not specify STM32_CMSIS_${FAMILY}_PATH, using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
stm32_find_freertos(FreeRTOS::STM32::${FAMILY}${CORE_C} ${STM32_CUBE_${FAMILY}_PATH}/Middlewares/Third_Party/FreeRTOS)
|
||||
foreach(PORT_COMP ${FreeRTOS_FIND_COMPONENTS_PORTS})
|
||||
if(FreeRTOS_${PORT_COMP}_PATH AND
|
||||
FreeRTOS_${PORT_COMP}_SOURCE AND
|
||||
FreeRTOS_COMMON_INCLUDE AND
|
||||
FreeRTOS_SOURCE_DIR)
|
||||
set(FreeRTOS_${COMP}_FOUND TRUE)
|
||||
else()
|
||||
set(FreeRTOS_${COMP}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FreeRTOS
|
||||
REQUIRED_VARS FreeRTOS_INCLUDE_DIRS
|
||||
FOUND_VAR FreeRTOS_FOUND
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
315
cmake/FindHAL.cmake
Normal file
315
cmake/FindHAL.cmake
Normal file
@@ -0,0 +1,315 @@
|
||||
# For information about why and how of this file: https://cmake.org/cmake/help/latest/command/find_package.html
|
||||
|
||||
# This function gets a list of hal_driver using a given prefix and suffix
|
||||
#
|
||||
# out_list_hal_drivers list of hal_drivers found
|
||||
# hal_drivers_path path to the hal's drivers
|
||||
# hal_driver_type hal_driver type to find (hal/ll/ex)
|
||||
function(get_list_hal_drivers out_list_hal_drivers hal_drivers_path hal_driver_type)
|
||||
#The pattern to retrieve a driver from a file name depends on the hal_driver_type field
|
||||
if(${hal_driver_type} STREQUAL "hal" OR ${hal_driver_type} STREQUAL "ll")
|
||||
#This regex match and capture a driver type (stm32xx_hal_(rcc).c or stm32xx_ll_(rcc).c => catches rcc)
|
||||
set(file_pattern ".+_${hal_driver_type}_([a-z0-9]+)\\.c$")
|
||||
elseif(${hal_driver_type} STREQUAL "ex")
|
||||
#This regex match and capture a driver type (stm32xx_hal_(rcc)_ex.c => catches rcc)
|
||||
set(file_pattern ".+_hal_([a-z0-9]+)_ex\\.c$")
|
||||
else()
|
||||
message(FATAL_ERROR "the inputed hal_driver_type(${hal_driver_type}) is not valid.")
|
||||
endif()
|
||||
|
||||
#Retrieving all the .c files from hal_drivers_path
|
||||
file(GLOB filtered_files
|
||||
RELATIVE "${hal_drivers_path}/Src"
|
||||
"${hal_drivers_path}/Src/*.c")
|
||||
# For all matched .c files keep only those with a driver name pattern (e.g. stm32xx_hal_rcc.c)
|
||||
list(FILTER filtered_files INCLUDE REGEX ${file_pattern})
|
||||
# From the files names keep only the driver type part using the regex (stm32xx_hal_(rcc).c or stm32xx_ll_(rcc).c => catches rcc)
|
||||
list(TRANSFORM filtered_files REPLACE ${file_pattern} "\\1")
|
||||
#Making a return by reference by seting the output variable to PARENT_SCOPE
|
||||
set(${out_list_hal_drivers} ${filtered_files} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
# Checking the parameters provided to the find_package(HAL ...) call
|
||||
# The expected parameters are families and or drivers in *any orders*
|
||||
# Families are valid if on the list of known families.
|
||||
# Drivers are valid if on the list of valid driver of any family. For this
|
||||
# reason the requested families must be processed in two steps
|
||||
# - Step 1 : Checking all the requested families
|
||||
# - Step 2 : Generating all the valid drivers from requested families
|
||||
# - Step 3 : Checking the other requested components (Expected to be drivers)
|
||||
################################################################################
|
||||
# Step 1 : Checking all the requested families
|
||||
foreach(COMP ${HAL_FIND_COMPONENTS})
|
||||
string(TOUPPER ${COMP} COMP_U)
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
|
||||
if(CMAKE_MATCH_1) #Matches the family part of the provided STM32<FAMILY>[..] component
|
||||
list(APPEND HAL_FIND_COMPONENTS_FAMILIES ${COMP})
|
||||
message(TRACE "FindHAL: append COMP ${COMP} to HAL_FIND_COMPONENTS_FAMILIES")
|
||||
else()
|
||||
list(APPEND HAL_FIND_COMPONENTS_UNHANDLED ${COMP})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# If no family requested look for all families
|
||||
if(NOT HAL_FIND_COMPONENTS_FAMILIES)
|
||||
set(HAL_FIND_COMPONENTS_FAMILIES ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
|
||||
endif()
|
||||
|
||||
# Step 2 : Generating all the valid drivers from requested families
|
||||
foreach(family_comp ${HAL_FIND_COMPONENTS_FAMILIES})
|
||||
string(TOUPPER ${family_comp} family_comp)
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" family_comp ${family_comp})
|
||||
if(CMAKE_MATCH_1) #Matches the family part of the provided STM32<FAMILY>[..] component
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
find_path(HAL_${FAMILY}_PATH
|
||||
NAMES Inc/stm32${FAMILY_L}xx_hal.h
|
||||
PATHS "${STM32_HAL_${FAMILY}_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/STM32${FAMILY}xx_HAL_Driver"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT HAL_${FAMILY}_PATH)
|
||||
message(FATAL_ERROR "could not find HAL for family ${FAMILY}")
|
||||
else()
|
||||
set(HAL_${family_comp}_FOUND TRUE)
|
||||
endif()
|
||||
if(CMAKE_MATCH_1) #Matches the family part of the provided STM32<FAMILY>[..] component
|
||||
get_list_hal_drivers(HAL_DRIVERS_${FAMILY} ${HAL_${FAMILY}_PATH} "hal")
|
||||
get_list_hal_drivers(HAL_EX_DRIVERS_${FAMILY} ${HAL_${FAMILY}_PATH} "ex")
|
||||
get_list_hal_drivers(HAL_LL_DRIVERS_${FAMILY} ${HAL_${FAMILY}_PATH} "ll")
|
||||
list(APPEND HAL_DRIVERS ${HAL_DRIVERS_${FAMILY}})
|
||||
list(APPEND HAL_LL_DRIVERS ${HAL_LL_DRIVERS_${FAMILY}})
|
||||
else()
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES HAL_DRIVERS)
|
||||
list(REMOVE_DUPLICATES HAL_LL_DRIVERS)
|
||||
|
||||
# Step 3 : Checking the other requested components (Expected to be drivers)
|
||||
foreach(COMP ${HAL_FIND_COMPONENTS_UNHANDLED})
|
||||
string(TOLOWER ${COMP} COMP_L)
|
||||
|
||||
if(${COMP_L} IN_LIST HAL_DRIVERS)
|
||||
list(APPEND HAL_FIND_COMPONENTS_DRIVERS ${COMP})
|
||||
message(TRACE "FindHAL: append COMP ${COMP} to HAL_FIND_COMPONENTS_DRIVERS")
|
||||
continue()
|
||||
endif()
|
||||
string(REGEX REPLACE "^ll_" "" COMP_L ${COMP_L})
|
||||
if(${COMP_L} IN_LIST HAL_LL_DRIVERS)
|
||||
list(APPEND HAL_FIND_COMPONENTS_DRIVERS_LL ${COMP})
|
||||
message(TRACE "FindHAL: append COMP ${COMP} to HAL_FIND_COMPONENTS_DRIVERS_LL")
|
||||
continue()
|
||||
endif()
|
||||
message(FATAL_ERROR "FindHAL: unknown HAL component: ${COMP}")
|
||||
endforeach()
|
||||
|
||||
|
||||
if(STM32H7 IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
|
||||
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32H7)
|
||||
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32H7_M7 STM32H7_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WB IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
|
||||
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32WB)
|
||||
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32WB_M4)
|
||||
endif()
|
||||
|
||||
if(STM32WL IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
|
||||
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32WL)
|
||||
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32WL_M4 STM32WL_M0PLUS)
|
||||
endif()
|
||||
|
||||
if(STM32MP1 IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
|
||||
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32MP1)
|
||||
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32MP1_M4)
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES HAL_FIND_COMPONENTS_FAMILIES)
|
||||
|
||||
# when no explicit driver and driver_ll is given to find_component(HAL )
|
||||
# then search for all supported driver and driver_ll
|
||||
if((NOT HAL_FIND_COMPONENTS_DRIVERS) AND (NOT HAL_FIND_COMPONENTS_DRIVERS_LL))
|
||||
set(HAL_FIND_COMPONENTS_DRIVERS ${HAL_DRIVERS})
|
||||
set(HAL_FIND_COMPONENTS_DRIVERS_LL ${HAL_LL_DRIVERS})
|
||||
endif()
|
||||
list(REMOVE_DUPLICATES HAL_FIND_COMPONENTS_DRIVERS)
|
||||
list(REMOVE_DUPLICATES HAL_FIND_COMPONENTS_DRIVERS_LL)
|
||||
|
||||
message(STATUS "Search for HAL families: ${HAL_FIND_COMPONENTS_FAMILIES}")
|
||||
message(STATUS "Search for HAL drivers: ${HAL_FIND_COMPONENTS_DRIVERS}")
|
||||
message(STATUS "Search for HAL LL drivers: ${HAL_FIND_COMPONENTS_DRIVERS_LL}")
|
||||
|
||||
foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES})
|
||||
string(TOUPPER ${COMP} COMP_U)
|
||||
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
|
||||
if(CMAKE_MATCH_3)
|
||||
set(CORE ${CMAKE_MATCH_3})
|
||||
set(CORE_C "::${CORE}")
|
||||
set(CORE_U "_${CORE}")
|
||||
else()
|
||||
unset(CORE)
|
||||
unset(CORE_C)
|
||||
unset(CORE_U)
|
||||
endif()
|
||||
|
||||
set(FAMILY ${CMAKE_MATCH_1})
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
|
||||
if((NOT STM32_HAL_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH) AND (DEFINED ENV{STM32_CUBE_${FAMILY}_PATH}))
|
||||
set(STM32_CUBE_${FAMILY}_PATH $ENV{STM32_CUBE_${FAMILY}_PATH} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "ENV STM32_CUBE_${FAMILY}_PATH specified, using STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
if((NOT STM32_HAL_${FAMILY}_PATH) AND (NOT STM32_CUBE_${FAMILY}_PATH))
|
||||
set(STM32_CUBE_${FAMILY}_PATH /opt/STM32Cube${FAMILY} CACHE PATH "Path to STM32Cube${FAMILY}")
|
||||
message(STATUS "Neither STM32_CUBE_${FAMILY}_PATH nor STM32_HAL_${FAMILY}_PATH specified using default STM32_CUBE_${FAMILY}_PATH: ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
endif()
|
||||
|
||||
#Checking HAL patch or release version
|
||||
unset(VERSION_INFO)
|
||||
find_file(PACKAGE_FILE NAMES package.xml PATHS ${STM32_CUBE_${FAMILY}_PATH})
|
||||
if(PACKAGE_FILE)
|
||||
file(READ ${PACKAGE_FILE} PACKAGE_FILE_CONTENT)
|
||||
string(REGEX MATCH "PackDescription Release=\"FW.${FAMILY}.([0-9.]+)\"( Patch=\"FW.${FAMILY}.([0-9.]+)\")?" VERSION_INFO ${PACKAGE_FILE_CONTENT})
|
||||
if(CMAKE_MATCH_3) # This is the "Patch" revision
|
||||
set(HAL_${COMP}_VERSION ${CMAKE_MATCH_3})
|
||||
set(HAL_VERSION ${CMAKE_MATCH_3})
|
||||
else(CMAKE_MATCH_1) #This is the "Release" version
|
||||
set(HAL_${COMP}_VERSION ${CMAKE_MATCH_1})
|
||||
set(HAL_VERSION ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT VERSION_INFO)
|
||||
message(STATUS "Could not read the HAL version from package.xml for ${COMP}")
|
||||
endif()
|
||||
|
||||
find_path(HAL_${FAMILY}_PATH
|
||||
NAMES Inc/stm32${FAMILY_L}xx_hal.h
|
||||
PATHS "${STM32_HAL_${FAMILY}_PATH}" "${STM32_CUBE_${FAMILY}_PATH}/Drivers/STM32${FAMILY}xx_HAL_Driver"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if (NOT HAL_${FAMILY}_PATH)
|
||||
message(DEBUG "Missing HAL_${FAMILY}_PATH path")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_path(HAL_${FAMILY}${CORE_U}_INCLUDE
|
||||
NAMES stm32${FAMILY_L}xx_hal.h
|
||||
PATHS "${HAL_${FAMILY}_PATH}/Inc"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
find_file(HAL_${FAMILY}${CORE_U}_SOURCE
|
||||
NAMES stm32${FAMILY_L}xx_hal.c
|
||||
PATHS "${HAL_${FAMILY}_PATH}/Src"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if ((NOT HAL_${FAMILY}${CORE_U}_INCLUDE) OR (NOT HAL_${FAMILY}${CORE_U}_SOURCE))
|
||||
set(HAL_${COMP}_FOUND FALSE)
|
||||
message(DEBUG "FindHAL: did not find path to HAL /src or /inc dir")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET HAL::STM32::${FAMILY}${CORE_C}))
|
||||
message(TRACE "FindHAL: creating library HAL::STM32::${FAMILY}${CORE_C}")
|
||||
add_library(HAL::STM32::${FAMILY}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(HAL::STM32::${FAMILY}${CORE_C} INTERFACE
|
||||
STM32::${FAMILY}${CORE_C}
|
||||
CMSIS::STM32::${FAMILY}${CORE_C})
|
||||
target_include_directories(HAL::STM32::${FAMILY}${CORE_C} INTERFACE "${HAL_${FAMILY}${CORE_U}_INCLUDE}")
|
||||
target_sources(HAL::STM32::${FAMILY}${CORE_C} INTERFACE "${HAL_${FAMILY}${CORE_U}_SOURCE}")
|
||||
endif()
|
||||
|
||||
foreach(DRV_COMP ${HAL_FIND_COMPONENTS_DRIVERS})
|
||||
string(TOLOWER ${DRV_COMP} DRV_L)
|
||||
string(TOUPPER ${DRV_COMP} DRV)
|
||||
|
||||
if(NOT (DRV_L IN_LIST HAL_DRIVERS_${FAMILY}))
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_file(HAL_${FAMILY}${CORE_U}_${DRV}_SOURCE
|
||||
NAMES stm32${FAMILY_L}xx_hal_${DRV_L}.c
|
||||
PATHS "${HAL_${FAMILY}_PATH}/Src"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list(APPEND HAL_${FAMILY}${CORE_U}_SOURCES "${HAL_${FAMILY}_${DRV}_SOURCE}")
|
||||
if(NOT HAL_${FAMILY}${CORE_U}_${DRV}_SOURCE)
|
||||
message(WARNING "Cannot find ${DRV} driver for ${FAMILY}${CORE_U}")
|
||||
set(HAL_${DRV_COMP}_FOUND FALSE)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set(HAL_${DRV_COMP}_FOUND TRUE)
|
||||
if(HAL_${FAMILY}${CORE_U}_${DRV}_SOURCE AND (NOT (TARGET HAL::STM32::${FAMILY}::${DRV})))
|
||||
message(TRACE "FindHAL: creating library HAL::STM32::${FAMILY}${CORE_C}::${DRV}")
|
||||
add_library(HAL::STM32::${FAMILY}${CORE_C}::${DRV} INTERFACE IMPORTED)
|
||||
target_link_libraries(HAL::STM32::${FAMILY}${CORE_C}::${DRV} INTERFACE HAL::STM32::${FAMILY}${CORE_C})
|
||||
target_sources(HAL::STM32::${FAMILY}${CORE_C}::${DRV} INTERFACE "${HAL_${FAMILY}${CORE_U}_${DRV}_SOURCE}")
|
||||
endif()
|
||||
|
||||
if(HAL_${FAMILY}${CORE_U}_${DRV}_SOURCE AND (${DRV_L} IN_LIST HAL_EX_DRIVERS_${FAMILY}))
|
||||
find_file(HAL_${FAMILY}${CORE_U}_${DRV}_EX_SOURCE
|
||||
NAMES stm32${FAMILY_L}xx_hal_${DRV_L}_ex.c
|
||||
PATHS "${HAL_${FAMILY}_PATH}/Src"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list(APPEND HAL_${FAMILY}${CORE_U}_SOURCES "${HAL_${FAMILY}${CORE_U}_${DRV}_EX_SOURCE}")
|
||||
if(NOT HAL_${FAMILY}${CORE_U}_${DRV}_EX_SOURCE)
|
||||
message(WARNING "Cannot find ${DRV}Ex driver for ${FAMILY}${CORE_U}")
|
||||
endif()
|
||||
|
||||
if((TARGET HAL::STM32::${FAMILY}${CORE_C}::${DRV}) AND (NOT (TARGET HAL::STM32::${FAMILY}${CORE_C}::${DRV}Ex)))
|
||||
message(TRACE "FindHAL: creating library HAL::STM32::${FAMILY}${CORE_C}::${DRV}Ex")
|
||||
add_library(HAL::STM32::${FAMILY}${CORE_C}::${DRV}Ex INTERFACE IMPORTED)
|
||||
target_link_libraries(HAL::STM32::${FAMILY}${CORE_C}::${DRV}Ex INTERFACE HAL::STM32::${FAMILY}${CORE_C}::${DRV})
|
||||
target_sources(HAL::STM32::${FAMILY}${CORE_C}::${DRV}Ex INTERFACE "${HAL_${FAMILY}${CORE_U}_${DRV}_EX_SOURCE}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(DRV_COMP ${HAL_FIND_COMPONENTS_DRIVERS_LL})
|
||||
string(TOLOWER ${DRV_COMP} DRV_L)
|
||||
string(REGEX REPLACE "^ll_" "" DRV_L ${DRV_L})
|
||||
string(TOUPPER ${DRV_L} DRV)
|
||||
|
||||
if(NOT (DRV_L IN_LIST HAL_LL_DRIVERS_${FAMILY}))
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_file(HAL_${FAMILY}${CORE_U}_${DRV}_LL_SOURCE
|
||||
NAMES stm32${FAMILY_L}xx_ll_${DRV_L}.c
|
||||
PATHS "${HAL_${FAMILY}_PATH}/Src"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list(APPEND HAL_${FAMILY}${CORE_U}_SOURCES "${HAL_${FAMILY}_${DRV}_LL_SOURCE}")
|
||||
if(NOT HAL_${FAMILY}${CORE_U}_${DRV}_LL_SOURCE)
|
||||
message(WARNING "Cannot find LL_${DRV} driver for ${FAMILY}${CORE_U}")
|
||||
set(HAL_${DRV_COMP}_FOUND FALSE)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
set(HAL_${DRV_COMP}_FOUND TRUE)
|
||||
if(HAL_${FAMILY}${CORE_U}_${DRV}_LL_SOURCE AND (NOT (TARGET HAL::STM32::${FAMILY}${CORE_C}::LL_${DRV})))
|
||||
message(TRACE "FindHAL: creating library HAL::STM32::${FAMILY}${CORE_C}::LL_${DRV}")
|
||||
add_library(HAL::STM32::${FAMILY}${CORE_C}::LL_${DRV} INTERFACE IMPORTED)
|
||||
target_include_directories(HAL::STM32::${FAMILY}${CORE_C}::LL_${DRV} INTERFACE "${HAL_${FAMILY}${CORE_U}_INCLUDE}")
|
||||
target_sources(HAL::STM32::${FAMILY}${CORE_C}::LL_${DRV} INTERFACE "${HAL_${FAMILY}${CORE_U}_${DRV}_LL_SOURCE}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(HAL_${COMP}_FOUND TRUE)
|
||||
list(APPEND HAL_INCLUDE_DIRS "${HAL_${FAMILY}${CORE_U}_INCLUDE}")
|
||||
list(APPEND HAL_SOURCES "${HAL_${FAMILY}${CORE_U}_SOURCES}")
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES HAL_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES HAL_SOURCES)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(HAL
|
||||
REQUIRED_VARS HAL_INCLUDE_DIRS HAL_SOURCES
|
||||
FOUND_VAR HAL_FOUND
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
372
cmake/stm32/common.cmake
Normal file
372
cmake/stm32/common.cmake
Normal file
@@ -0,0 +1,372 @@
|
||||
set(STM32_SUPPORTED_FAMILIES_LONG_NAME
|
||||
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
|
||||
STM32G0 STM32G4
|
||||
STM32H7_M4 STM32H7_M7
|
||||
STM32L0 STM32L1 STM32L4 STM32L5
|
||||
STM32U5
|
||||
STM32WB_M4 STM32WL_M4 STM32WL_M0PLUS
|
||||
STM32MP1_M4 )
|
||||
|
||||
foreach(FAMILY ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
|
||||
# append short names (F0, F1, H7_M4, ...) to STM32_SUPPORTED_FAMILIES_SHORT_NAME
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])_?(M0PLUS|M4|M7)?" FAMILY ${FAMILY})
|
||||
list(APPEND STM32_SUPPORTED_FAMILIES_SHORT_NAME ${CMAKE_MATCH_1})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES STM32_SUPPORTED_FAMILIES_SHORT_NAME)
|
||||
|
||||
if(NOT STM32_TOOLCHAIN_PATH)
|
||||
if(DEFINED ENV{STM32_TOOLCHAIN_PATH})
|
||||
message(STATUS "Detected toolchain path STM32_TOOLCHAIN_PATH in environmental variables: ")
|
||||
message(STATUS "$ENV{STM32_TOOLCHAIN_PATH}")
|
||||
set(STM32_TOOLCHAIN_PATH $ENV{STM32_TOOLCHAIN_PATH})
|
||||
else()
|
||||
if(NOT CMAKE_C_COMPILER)
|
||||
set(STM32_TOOLCHAIN_PATH "/usr")
|
||||
message(STATUS "No STM32_TOOLCHAIN_PATH specified, using default: " ${STM32_TOOLCHAIN_PATH})
|
||||
else()
|
||||
# keep only directory of compiler
|
||||
get_filename_component(STM32_TOOLCHAIN_PATH ${CMAKE_C_COMPILER} DIRECTORY)
|
||||
# remove the last /bin directory
|
||||
get_filename_component(STM32_TOOLCHAIN_PATH ${STM32_TOOLCHAIN_PATH} DIRECTORY)
|
||||
endif()
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "${STM32_TOOLCHAIN_PATH}" STM32_TOOLCHAIN_PATH)
|
||||
endif()
|
||||
|
||||
if(NOT STM32_TARGET_TRIPLET)
|
||||
set(STM32_TARGET_TRIPLET "arm-none-eabi")
|
||||
message(STATUS "No STM32_TARGET_TRIPLET specified, using default: " ${STM32_TARGET_TRIPLET})
|
||||
endif()
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
set(TOOLCHAIN_SYSROOT "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}")
|
||||
set(TOOLCHAIN_BIN_PATH "${STM32_TOOLCHAIN_PATH}/bin")
|
||||
set(TOOLCHAIN_INC_PATH "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}/include")
|
||||
set(TOOLCHAIN_LIB_PATH "${STM32_TOOLCHAIN_PATH}/${STM32_TARGET_TRIPLET}/lib")
|
||||
|
||||
find_program(CMAKE_OBJCOPY NAMES ${STM32_TARGET_TRIPLET}-objcopy HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_OBJDUMP NAMES ${STM32_TARGET_TRIPLET}-objdump HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_SIZE NAMES ${STM32_TARGET_TRIPLET}-size HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_DEBUGGER NAMES ${STM32_TARGET_TRIPLET}-gdb HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_CPPFILT NAMES ${STM32_TARGET_TRIPLET}-c++filt HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
|
||||
function(stm32_print_size_of_target TARGET)
|
||||
add_custom_target(${TARGET}_always_display_size
|
||||
ALL COMMAND ${CMAKE_SIZE} ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C}
|
||||
COMMENT "Target Sizes: "
|
||||
DEPENDS ${TARGET}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(stm32_generate_binary_file TARGET)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C} ${TARGET}.bin
|
||||
BYPRODUCTS ${TARGET}.bin
|
||||
COMMENT "Generating binary file ${CMAKE_PROJECT_NAME}.bin"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(stm32_generate_srec_file TARGET)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -O srec ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C} ${TARGET}.srec
|
||||
BYPRODUCTS ${TARGET}.srec
|
||||
|
||||
COMMENT "Generating srec file ${CMAKE_PROJECT_NAME}.srec"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(stm32_generate_hex_file TARGET)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_OBJCOPY} -O ihex ${TARGET}${CMAKE_EXECUTABLE_SUFFIX_C} ${TARGET}.hex
|
||||
BYPRODUCTS ${TARGET}.hex
|
||||
COMMENT "Generating hex file ${CMAKE_PROJECT_NAME}.hex"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# This function takes FAMILY (e.g. L4) and DEVICE (e.g. L496VG) to output TYPE (e.g. L496xx)
|
||||
function(stm32_get_chip_type FAMILY DEVICE TYPE)
|
||||
set(INDEX 0)
|
||||
foreach(C_TYPE ${STM32_${FAMILY}_TYPES})
|
||||
list(GET STM32_${FAMILY}_TYPE_MATCH ${INDEX} REGEXP)
|
||||
if(${DEVICE} MATCHES ${REGEXP})
|
||||
set(RESULT_TYPE ${C_TYPE})
|
||||
endif()
|
||||
math(EXPR INDEX "${INDEX}+1")
|
||||
endforeach()
|
||||
if(NOT RESULT_TYPE)
|
||||
message(FATAL_ERROR "Invalid/unsupported device: ${DEVICE}")
|
||||
endif()
|
||||
set(${TYPE} ${RESULT_TYPE} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(stm32_get_chip_info CHIP)
|
||||
set(ARG_OPTIONS "")
|
||||
set(ARG_SINGLE FAMILY DEVICE TYPE)
|
||||
set(ARG_MULTIPLE "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARG "${ARG_OPTIONS}" "${ARG_SINGLE}" "${ARG_MULTIPLE}")
|
||||
|
||||
string(TOUPPER ${CHIP} CHIP)
|
||||
|
||||
string(REGEX MATCH "^STM32([FGHLMUW]P?[0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z]).*$" CHIP ${CHIP})
|
||||
|
||||
if((NOT CMAKE_MATCH_1) OR (NOT CMAKE_MATCH_2))
|
||||
message(FATAL_ERROR "Unknown chip ${CHIP}")
|
||||
endif()
|
||||
|
||||
set(STM32_FAMILY ${CMAKE_MATCH_1})
|
||||
set(STM32_DEVICE "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
|
||||
|
||||
|
||||
if(NOT (${STM32_FAMILY} IN_LIST STM32_SUPPORTED_FAMILIES_SHORT_NAME))
|
||||
message(FATAL_ERROR "Unsupported family ${STM32_FAMILY} for device ${CHIP}")
|
||||
endif()
|
||||
|
||||
stm32_get_chip_type(${STM32_FAMILY} ${STM32_DEVICE} STM32_TYPE)
|
||||
|
||||
if(ARG_FAMILY)
|
||||
set(${ARG_FAMILY} ${STM32_FAMILY} PARENT_SCOPE)
|
||||
endif()
|
||||
if(ARG_DEVICE)
|
||||
set(${ARG_DEVICE} ${STM32_DEVICE} PARENT_SCOPE)
|
||||
endif()
|
||||
if(ARG_TYPE)
|
||||
set(${ARG_TYPE} ${STM32_TYPE} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(stm32_get_cores CORES)
|
||||
set(ARG_OPTIONS "")
|
||||
set(ARG_SINGLE CHIP FAMILY DEVICE)
|
||||
set(ARG_MULTIPLE "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 ARG "${ARG_OPTIONS}" "${ARG_SINGLE}" "${ARG_MULTIPLE}")
|
||||
|
||||
if(ARG_CHIP)
|
||||
# TODO: I don't get why stm32_get_chip_info is called in stm32_get_cores
|
||||
stm32_get_chip_info(${ARG_CHIP} FAMILY ARG_FAMILY TYPE ARG_TYPE DEVICE ARG_DEVICE)
|
||||
elseif(ARG_FAMILY AND ARG_DEVICE)
|
||||
# TODO: I don't get why stm32_get_chip_type is called in stm32_get_cores
|
||||
stm32_get_chip_type(${ARG_FAMILY} ${ARG_DEVICE} ARG_TYPE)
|
||||
elseif(ARG_FAMILY)
|
||||
if(${ARG_FAMILY} STREQUAL "H7")
|
||||
set(${CORES} M7 M4 PARENT_SCOPE)
|
||||
elseif(${ARG_FAMILY} STREQUAL "WB")
|
||||
set(${CORES} M4 PARENT_SCOPE)
|
||||
elseif(${ARG_FAMILY} STREQUAL "WL")
|
||||
set(${CORES} M4 M0PLUS PARENT_SCOPE)
|
||||
elseif(${ARG_FAMILY} STREQUAL "MP1")
|
||||
set(${CORES} M4 PARENT_SCOPE)
|
||||
else()
|
||||
set(${CORES} "" PARENT_SCOPE)
|
||||
endif()
|
||||
return()
|
||||
else()
|
||||
message(FATAL_ERROR "Either CHIP or FAMILY or FAMILY/DEVICE should be specified for stm32_get_cores()")
|
||||
endif()
|
||||
|
||||
# TODO following is the only part really used by FindCMSIS. Maybe a cleanup is needed
|
||||
if(${ARG_FAMILY} STREQUAL "H7")
|
||||
stm32h7_get_device_cores(${ARG_DEVICE} ${ARG_TYPE} CORE_LIST)
|
||||
elseif(${ARG_FAMILY} STREQUAL "WB")
|
||||
# note STM32WB have an M0 core but in current state of the art it runs ST stacks and is not needed/allowed to build for customer
|
||||
set(CORE_LIST M4)
|
||||
elseif(${ARG_FAMILY} STREQUAL "MP1")
|
||||
set(CORE_LIST M4)
|
||||
elseif(${ARG_FAMILY} STREQUAL "WL")
|
||||
stm32wl_get_device_cores(${ARG_DEVICE} ${ARG_TYPE} CORE_LIST)
|
||||
endif()
|
||||
set(${CORES} "${CORE_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(stm32_get_memory_info)
|
||||
set(ARG_OPTIONS FLASH RAM CCRAM STACK HEAP RAM_SHARE)
|
||||
set(ARG_SINGLE CHIP FAMILY DEVICE CORE SIZE ORIGIN)
|
||||
set(ARG_MULTIPLE "")
|
||||
cmake_parse_arguments(INFO "${ARG_OPTIONS}" "${ARG_SINGLE}" "${ARG_MULTIPLE}" ${ARGN})
|
||||
|
||||
if((NOT INFO_CHIP) AND ((NOT INFO_FAMILY) OR (NOT INFO_DEVICE)))
|
||||
message(FATAL_ERROR "Either CHIP or FAMILY/DEVICE is required for stm32_get_memory_info()")
|
||||
endif()
|
||||
|
||||
if(INFO_CHIP)
|
||||
stm32_get_chip_info(${INFO_CHIP} FAMILY INFO_FAMILY TYPE INFO_TYPE DEVICE INFO_DEVICE)
|
||||
else()
|
||||
stm32_get_chip_type(${INFO_FAMILY} ${INFO_DEVICE} INFO_TYPE)
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "^[FGHLMUW]P?[0-9BL][0-9A-Z][0-9M].([3468ABCDEFGHIYZ])$" "\\1" SIZE_CODE ${INFO_DEVICE})
|
||||
|
||||
if(SIZE_CODE STREQUAL "3")
|
||||
set(FLASH "8K")
|
||||
elseif(SIZE_CODE STREQUAL "4")
|
||||
set(FLASH "16K")
|
||||
elseif(SIZE_CODE STREQUAL "6")
|
||||
set(FLASH "32K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(FLASH "64K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(FLASH "128K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(FLASH "256K")
|
||||
elseif(SIZE_CODE STREQUAL "D")
|
||||
set(FLASH "384K")
|
||||
elseif(SIZE_CODE STREQUAL "E")
|
||||
set(FLASH "512K")
|
||||
elseif(SIZE_CODE STREQUAL "F")
|
||||
set(FLASH "768K")
|
||||
elseif(SIZE_CODE STREQUAL "G")
|
||||
set(FLASH "1024K")
|
||||
elseif(SIZE_CODE STREQUAL "H")
|
||||
set(FLASH "1536K")
|
||||
elseif(SIZE_CODE STREQUAL "I")
|
||||
set(FLASH "2048K")
|
||||
elseif(SIZE_CODE STREQUAL "Y")
|
||||
set(FLASH "640K")
|
||||
elseif(SIZE_CODE STREQUAL "Z")
|
||||
set(FLASH "192K")
|
||||
else()
|
||||
set(FLASH "16K")
|
||||
message(WARNING "Unknow flash size for device ${DEVICE}. Set to ${FLASH}")
|
||||
endif()
|
||||
|
||||
list(FIND STM32_${INFO_FAMILY}_TYPES ${INFO_TYPE} TYPE_INDEX)
|
||||
list(GET STM32_${INFO_FAMILY}_RAM_SIZES ${TYPE_INDEX} RAM)
|
||||
list(GET STM32_${INFO_FAMILY}_CCRAM_SIZES ${TYPE_INDEX} CCRAM)
|
||||
list(GET STM32_${INFO_FAMILY}_RAM_SHARE_SIZES ${TYPE_INDEX} RAM_SHARE)
|
||||
set(FLASH_ORIGIN 0x8000000)
|
||||
set(RAM_ORIGIN 0x20000000)
|
||||
set(CCRAM_ORIGIN 0x10000000)
|
||||
set(RAM_SHARE_ORIGIN 0x20030000)
|
||||
|
||||
unset(TWO_FLASH_BANKS)
|
||||
if(FAMILY STREQUAL "F1")
|
||||
stm32f1_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH RAM)
|
||||
elseif(FAMILY STREQUAL "L1")
|
||||
stm32l1_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH RAM)
|
||||
elseif(FAMILY STREQUAL "F2")
|
||||
stm32f2_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH RAM)
|
||||
elseif(FAMILY STREQUAL "F3")
|
||||
stm32f3_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH RAM)
|
||||
elseif(FAMILY STREQUAL "H7")
|
||||
stm32h7_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} "${INFO_CORE}" RAM FLASH_ORIGIN RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
elseif(FAMILY STREQUAL "WL")
|
||||
stm32wl_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} "${INFO_CORE}" RAM FLASH_ORIGIN RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
elseif(FAMILY STREQUAL "WB")
|
||||
stm32wb_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} "${INFO_CORE}" RAM RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
elseif(FAMILY STREQUAL "MP1")
|
||||
stm32mp1_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH)
|
||||
endif()
|
||||
# when a device is dual core, each core uses half of total flash
|
||||
if(TWO_FLASH_BANKS)
|
||||
string(REGEX MATCH "([0-9]+)K" FLASH_KB ${FLASH})
|
||||
math(EXPR FLASH_KB "${CMAKE_MATCH_1} / 2")
|
||||
set(FLASH "${FLASH_KB}K")
|
||||
endif()
|
||||
|
||||
if(INFO_FLASH)
|
||||
set(SIZE ${FLASH})
|
||||
set(ORIGIN ${FLASH_ORIGIN})
|
||||
elseif(INFO_RAM)
|
||||
set(SIZE ${RAM})
|
||||
set(ORIGIN ${RAM_ORIGIN})
|
||||
elseif(INFO_CCRAM)
|
||||
set(SIZE ${CCRAM})
|
||||
set(ORIGIN ${CCRAM_ORIGIN})
|
||||
elseif(INFO_RAM_SHARE)
|
||||
set(SIZE ${RAM_SHARE})
|
||||
set(ORIGIN ${RAM_SHARE_ORIGIN})
|
||||
elseif(INFO_STACK)
|
||||
if (RAM STREQUAL "2K")
|
||||
set(SIZE 0x200)
|
||||
else()
|
||||
set(SIZE 0x400)
|
||||
endif()
|
||||
set(ORIGIN ${RAM_ORIGIN}) #TODO: Real stack pointer?
|
||||
elseif(INFO_HEAP)
|
||||
if (RAM STREQUAL "2K")
|
||||
set(SIZE 0x100)
|
||||
else()
|
||||
set(SIZE 0x200)
|
||||
endif()
|
||||
set(ORIGIN ${RAM_ORIGIN}) #TODO: Real heap pointer?
|
||||
endif()
|
||||
|
||||
if(INFO_SIZE)
|
||||
set(${INFO_SIZE} ${SIZE} PARENT_SCOPE)
|
||||
endif()
|
||||
if(INFO_ORIGIN)
|
||||
set(${INFO_ORIGIN} ${ORIGIN} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(stm32_add_linker_script TARGET VISIBILITY SCRIPT)
|
||||
get_filename_component(SCRIPT "${SCRIPT}" ABSOLUTE)
|
||||
target_link_options(${TARGET} ${VISIBILITY} -T "${SCRIPT}")
|
||||
|
||||
get_target_property(TARGET_TYPE ${TARGET} TYPE)
|
||||
if(TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
|
||||
set(INTERFACE_PREFIX "INTERFACE_")
|
||||
endif()
|
||||
|
||||
get_target_property(LINK_DEPENDS ${TARGET} ${INTERFACE_PREFIX}LINK_DEPENDS)
|
||||
if(LINK_DEPENDS)
|
||||
list(APPEND LINK_DEPENDS "${SCRIPT}")
|
||||
else()
|
||||
set(LINK_DEPENDS "${SCRIPT}")
|
||||
endif()
|
||||
|
||||
|
||||
set_target_properties(${TARGET} PROPERTIES ${INTERFACE_PREFIX}LINK_DEPENDS "${LINK_DEPENDS}")
|
||||
endfunction()
|
||||
|
||||
if(NOT (TARGET STM32::NoSys))
|
||||
add_library(STM32::NoSys INTERFACE IMPORTED)
|
||||
target_compile_options(STM32::NoSys INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nosys.specs>)
|
||||
target_link_options(STM32::NoSys INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nosys.specs>)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET STM32::Nano))
|
||||
add_library(STM32::Nano INTERFACE IMPORTED)
|
||||
target_compile_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
|
||||
target_link_options(STM32::Nano INTERFACE $<$<C_COMPILER_ID:GNU>:--specs=nano.specs>)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET STM32::Nano::FloatPrint))
|
||||
add_library(STM32::Nano::FloatPrint INTERFACE IMPORTED)
|
||||
target_link_options(STM32::Nano::FloatPrint INTERFACE
|
||||
$<$<C_COMPILER_ID:GNU>:-Wl,--undefined,_printf_float>
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET STM32::Nano::FloatScan))
|
||||
add_library(STM32::Nano::FloatScan INTERFACE IMPORTED)
|
||||
target_link_options(STM32::Nano::FloatScan INTERFACE
|
||||
$<$<C_COMPILER_ID:GNU>:-Wl,--undefined,_scanf_float>
|
||||
)
|
||||
endif()
|
||||
|
||||
include(stm32/utilities)
|
||||
include(stm32/f0)
|
||||
include(stm32/f1)
|
||||
include(stm32/f2)
|
||||
include(stm32/f3)
|
||||
include(stm32/f4)
|
||||
include(stm32/f7)
|
||||
include(stm32/g0)
|
||||
include(stm32/g4)
|
||||
include(stm32/h7)
|
||||
include(stm32/l0)
|
||||
include(stm32/l1)
|
||||
include(stm32/l4)
|
||||
include(stm32/l5)
|
||||
include(stm32/u5)
|
||||
include(stm32/wb)
|
||||
include(stm32/wl)
|
||||
include(stm32/mp1)
|
||||
1258
cmake/stm32/devices.cmake
Normal file
1258
cmake/stm32/devices.cmake
Normal file
File diff suppressed because it is too large
Load Diff
25
cmake/stm32/f0.cmake
Normal file
25
cmake/stm32/f0.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
set(STM32_F0_TYPES
|
||||
F030x6 F030x8 F031x6 F038xx F042x6 F048xx F051x8 F058xx
|
||||
F070x6 F070xB F071xB F072xB F078xx F091xC F098xx F030xC
|
||||
)
|
||||
set(STM32_F0_TYPE_MATCH
|
||||
"F030.[46]" "F030.8" "F031.[46]" "F038.." "F042.[46]" "F048.." "F051.[468]" "F058.."
|
||||
"F070.6" "F070.B" "F071.[8B]" "F072.[8B]" "F078.." "F091.[BC]" "F098.." "F030.C"
|
||||
)
|
||||
set(STM32_F0_RAM_SIZES
|
||||
4K 8K 4K 4K 6K 6K 8K 8K
|
||||
6K 16K 16K 16K 16K 32K 32K 32K
|
||||
)
|
||||
set(STM32_F0_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F0)
|
||||
|
||||
target_compile_options(STM32::F0 INTERFACE
|
||||
-mcpu=cortex-m0
|
||||
)
|
||||
target_link_options(STM32::F0 INTERFACE
|
||||
-mcpu=cortex-m0
|
||||
)
|
||||
78
cmake/stm32/f1.cmake
Normal file
78
cmake/stm32/f1.cmake
Normal file
@@ -0,0 +1,78 @@
|
||||
set(STM32_F1_TYPES
|
||||
F100xB F100xE F101x6 F101xB F101xE F101xG F102x6 F102xB
|
||||
F103x6 F103xB F103xE F103xG F105xC F107xC
|
||||
)
|
||||
set(STM32_F1_TYPE_MATCH
|
||||
"F100.[468B]" "F100.[CDE]" "F101.[46]" "F101.[8B]" "F101.[CDE]" "F101.[FG]" "F102.[46]" "F102.[8B]"
|
||||
"F103.[46]" "F103.[8B]" "F103.[CDE]" "F103.[FG]" "F105.[8BC]" "F107.[BC]"
|
||||
)
|
||||
set(STM32_F1_RAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
set(STM32_F1_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F1)
|
||||
|
||||
target_compile_options(STM32::F1 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
target_link_options(STM32::F1 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
|
||||
function(stm32f1_get_memory_info DEVICE TYPE FLASH_SIZE RAM_SIZE)
|
||||
string(REGEX REPLACE "F1[0-9][0-9].([468BCDEFGHI])" "\\1" SIZE_CODE ${DEVICE})
|
||||
|
||||
if((TYPE STREQUAL "F100xB") OR (TYPE STREQUAL "F100xE"))
|
||||
if((SIZE_CODE STREQUAL "4") OR (SIZE_CODE STREQUAL "6"))
|
||||
set(RAM "4K")
|
||||
elseif((SIZE_CODE STREQUAL "8") OR (SIZE_CODE STREQUAL "B"))
|
||||
set(RAM "8K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "24K")
|
||||
elseif((SIZE_CODE STREQUAL "D") OR (SIZE_CODE STREQUAL "E"))
|
||||
set(RAM "32K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "F101x6") OR (TYPE STREQUAL "F101xB") OR
|
||||
(TYPE STREQUAL "F101xE") OR (TYPE STREQUAL "F101xG") OR
|
||||
(TYPE STREQUAL "F102x6") OR (TYPE STREQUAL "F102xB"))
|
||||
if(SIZE_CODE STREQUAL "4")
|
||||
set(RAM "4K")
|
||||
elseif(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "6K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(RAM "10K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "16K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "32K")
|
||||
elseif((SIZE_CODE STREQUAL "D") OR (SIZE_CODE STREQUAL "E"))
|
||||
set(RAM "48K")
|
||||
elseif((SIZE_CODE STREQUAL "F") OR (SIZE_CODE STREQUAL "G"))
|
||||
set(RAM "80K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "F103x6") OR (TYPE STREQUAL "F103xB") OR
|
||||
(TYPE STREQUAL "F103xE") OR (TYPE STREQUAL "F103xG"))
|
||||
if(SIZE_CODE STREQUAL "4")
|
||||
set(RAM "6K")
|
||||
elseif(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "10K")
|
||||
elseif((SIZE_CODE STREQUAL "8") OR (SIZE_CODE STREQUAL "B"))
|
||||
set(RAM "20K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "48K")
|
||||
elseif((SIZE_CODE STREQUAL "D") OR (SIZE_CODE STREQUAL "E"))
|
||||
set(RAM "64K")
|
||||
elseif((SIZE_CODE STREQUAL "F") OR (SIZE_CODE STREQUAL "G"))
|
||||
set(RAM "96K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "F105xC") OR (TYPE STREQUAL "F107xC"))
|
||||
set(RAM "64K")
|
||||
endif()
|
||||
|
||||
set(${RAM_SIZE} ${RAM} PARENT_SCOPE)
|
||||
endfunction()
|
||||
39
cmake/stm32/f2.cmake
Normal file
39
cmake/stm32/f2.cmake
Normal file
@@ -0,0 +1,39 @@
|
||||
set(STM32_F2_TYPES
|
||||
F205xx F215xx F207xx F217xx
|
||||
)
|
||||
set(STM32_F2_TYPE_MATCH
|
||||
"F205.." "F215.." "F207.." "F217.."
|
||||
)
|
||||
set(STM32_F2_RAM_SIZES
|
||||
0K 128K 128K 128K
|
||||
)
|
||||
set(STM32_F2_CCRAM_SIZES
|
||||
0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F2)
|
||||
|
||||
target_compile_options(STM32::F2 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
target_link_options(STM32::F2 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
|
||||
function(stm32f2_get_memory_info DEVICE TYPE FLASH_SIZE RAM_SIZE)
|
||||
string(REGEX REPLACE "F2[0-9][0-9].([468BCDEFGHI])" "\\1" SIZE_CODE ${DEVICE})
|
||||
|
||||
if(TYPE STREQUAL "F205xx")
|
||||
if(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "64K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "96K")
|
||||
else()
|
||||
set(RAM "128K")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(RAM)
|
||||
set(${RAM_SIZE} ${RAM} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
59
cmake/stm32/f3.cmake
Normal file
59
cmake/stm32/f3.cmake
Normal file
@@ -0,0 +1,59 @@
|
||||
set(STM32_F3_TYPES
|
||||
F301x8 F302x8 F302xC F302xE F303x8 F303xC
|
||||
F303xE F318xx F328xx F334x8 F358xx F373xC
|
||||
F378xx F398xx
|
||||
)
|
||||
set(STM32_F3_TYPE_MATCH
|
||||
"301.[68]" "302.[68]" "302.[BC]" "302.[DE]" "303.[68]" "303.[BC]"
|
||||
"303.[DE]" "318.." "328.." "334.[468]" "358.." "373.[8BC]"
|
||||
"378.." "398.."
|
||||
)
|
||||
set(STM32_F3_RAM_SIZES
|
||||
16K 16K 0K 64K 12K 0K
|
||||
64K 16K 12K 12K 40K 0K
|
||||
32K 64K
|
||||
)
|
||||
set(STM32_F3_CCRAM_SIZES
|
||||
0K 0K 0K 0K 4K 8K
|
||||
16K 0K 4K 4K 8K 0K
|
||||
0K 16K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F3)
|
||||
|
||||
target_compile_options(STM32::F3 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::F3 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
|
||||
function(stm32f3_get_memory_info DEVICE TYPE FLASH_SIZE RAM_SIZE)
|
||||
string(REGEX REPLACE "F3[0-9][0-9].([468BCDEFGHI])" "\\1" SIZE_CODE ${DEVICE})
|
||||
|
||||
if(TYPE STREQUAL "F302xC")
|
||||
if(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "40K")
|
||||
else()
|
||||
set(RAM "32K")
|
||||
endif()
|
||||
elseif(TYPE STREQUAL "F303xC")
|
||||
if(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "40K")
|
||||
else()
|
||||
set(RAM "32K")
|
||||
endif()
|
||||
elseif(TYPE STREQUAL "F373xC")
|
||||
if(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "24K")
|
||||
elseif(SIZE_CODE STREQUAL "C")
|
||||
set(RAM "32K")
|
||||
else()
|
||||
set(RAM "16K")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(RAM)
|
||||
set(${RAM_SIZE} ${RAM} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
29
cmake/stm32/f4.cmake
Normal file
29
cmake/stm32/f4.cmake
Normal file
@@ -0,0 +1,29 @@
|
||||
set(STM32_F4_TYPES
|
||||
F401xC F401xE F405xx F407xx F410Cx F410Rx F410Tx F411xE
|
||||
F412Cx F412Rx F412Vx F412Zx F413xx F415xx F417xx F423xx
|
||||
F427xx F429xx F437xx F439xx F446xx F469xx F479xx
|
||||
)
|
||||
set(STM32_F4_TYPE_MATCH
|
||||
"F401.[CB]" "F401.[ED]" "F405.." "F407.." "F410C." "F410R." "F410T." "F411.[CE]"
|
||||
"F412C." "F412R." "F412V." "F412Z." "F413.." "F415.." "F417.." "F423.."
|
||||
"F427.." "F429.." "F437.." "F439.." "F446.." "F469.." "F479.."
|
||||
)
|
||||
set(STM32_F4_RAM_SIZES
|
||||
64K 96K 128K 128K 32K 32K 32K 128K
|
||||
256K 256K 256K 256K 320K 128K 128K 320K
|
||||
192K 192K 192K 192K 128K 320K 320K
|
||||
)
|
||||
set(STM32_F4_CCRAM_SIZES
|
||||
0K 0K 64K 64K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 64K 64K 0K
|
||||
64K 64K 64K 64K 0K 64K 64K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F4)
|
||||
|
||||
target_compile_options(STM32::F4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::F4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
25
cmake/stm32/f7.cmake
Normal file
25
cmake/stm32/f7.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
set(STM32_F7_TYPES
|
||||
F756xx F746xx F745xx F765xx F767xx F769xx F777xx F779xx
|
||||
F722xx F723xx F732xx F733xx F730xx F750xx
|
||||
)
|
||||
set(STM32_F7_TYPE_MATCH
|
||||
"F756.." "F746.." "F745.." "F765.." "F767.." "F769.." "F777.." "F77[89].."
|
||||
"F722.." "F723.." "F732.." "F733.." "F730.." "F750.."
|
||||
)
|
||||
set(STM32_F7_RAM_SIZES
|
||||
320K 320K 320K 512K 512K 512K 512K 512K
|
||||
256K 256K 256K 256K 256K 320K
|
||||
)
|
||||
set(STM32_F7_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(F7)
|
||||
|
||||
target_compile_options(STM32::F7 INTERFACE
|
||||
-mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::F7 INTERFACE
|
||||
-mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
25
cmake/stm32/g0.cmake
Normal file
25
cmake/stm32/g0.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
set(STM32_G0_TYPES
|
||||
G030xx G031xx G041xx G070xx G071xx G081xx
|
||||
G0B1xx G0C1xx
|
||||
)
|
||||
set(STM32_G0_TYPE_MATCH
|
||||
"G030.." "G031.." "G041.." "G070.." "G071.." "G081.."
|
||||
"G0B1.." "G0C1.."
|
||||
)
|
||||
set(STM32_G0_RAM_SIZES
|
||||
8K 8K 8K 36K 36K 36K
|
||||
144k 144K
|
||||
)
|
||||
set(STM32_G0_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K
|
||||
0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(G0)
|
||||
|
||||
target_compile_options(STM32::G0 INTERFACE
|
||||
-mcpu=cortex-m0plus
|
||||
)
|
||||
target_link_options(STM32::G0 INTERFACE
|
||||
-mcpu=cortex-m0plus
|
||||
)
|
||||
25
cmake/stm32/g4.cmake
Normal file
25
cmake/stm32/g4.cmake
Normal file
@@ -0,0 +1,25 @@
|
||||
set(STM32_G4_TYPES
|
||||
G431xx G441xx G471xx G473xx G483xx G474xx G484xx
|
||||
G491xx G4A1xx
|
||||
)
|
||||
set(STM32_G4_TYPE_MATCH
|
||||
"G431.." "G441.." "G471.." "G473.." "G483.." "G474.." "G484.."
|
||||
"G491.." "G4A1.."
|
||||
)
|
||||
set(STM32_G4_RAM_SIZES
|
||||
32K 32K 128K 128K 128K 128K 128K
|
||||
112K 112K
|
||||
)
|
||||
set(STM32_G4_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(G4)
|
||||
|
||||
target_compile_options(STM32::G4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::G4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
87
cmake/stm32/h7.cmake
Normal file
87
cmake/stm32/h7.cmake
Normal file
@@ -0,0 +1,87 @@
|
||||
set(STM32_H7_TYPES
|
||||
H723xx H725xx H730xx H730xxQ H733xx H735xx
|
||||
H743xx H753xx H750xx H742xx H745xx H755xx H747xx H757xx
|
||||
H7A3xx H7A3xxQ H7B3xx H7B3xxQ H7B0xx H7B0xxQ
|
||||
)
|
||||
set(STM32_H7_TYPE_MATCH
|
||||
"H723.." "H725.." "H730.." "H730..Q" "H733.." "H735.."
|
||||
"H743.." "H753.." "H750.." "H742.." "H745.." "H755.." "H747.." "H757.."
|
||||
"H7A3.." "H7A3..Q" "H7B3.." "H7B3..Q" "H7B0.." "H7B0..Q"
|
||||
)
|
||||
set(STM32_H7_RAM_SIZES
|
||||
128K 128K 128K 128K 128K 128K
|
||||
128K 128K 128K 128K 128K 128K 128K 128K
|
||||
128K 128K 128K 128K 128K 128K
|
||||
)
|
||||
set(STM32_H7_M4_RAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 288K 288K 288K 288K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
set(STM32_H7_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
set(STM32_H7_DUAL_CORE
|
||||
H745xx H755xx H747xx H757xx
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(H7 M7)
|
||||
|
||||
target_compile_options(STM32::H7::M7 INTERFACE
|
||||
-mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::H7::M7 INTERFACE
|
||||
-mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_compile_definitions(STM32::H7::M7 INTERFACE
|
||||
-DCORE_CM7
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(H7 M4)
|
||||
|
||||
target_compile_options(STM32::H7::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::H7::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_compile_definitions(STM32::H7::M4 INTERFACE
|
||||
-DCORE_CM4
|
||||
)
|
||||
|
||||
function(stm32h7_get_memory_info DEVICE TYPE CORE RAM FLASH_ORIGIN RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
if(${TYPE} IN_LIST STM32_H7_DUAL_CORE)
|
||||
set(${TWO_FLASH_BANKS} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${TWO_FLASH_BANKS} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
if(NOT CORE)
|
||||
set(CORE "M7")
|
||||
endif()
|
||||
list(FIND STM32_H7_TYPES ${TYPE} TYPE_INDEX)
|
||||
if(CORE STREQUAL "M7")
|
||||
list(GET STM32_H7_RAM_SIZES ${TYPE_INDEX} RAM_VALUE)
|
||||
set(${RAM} ${RAM_VALUE} PARENT_SCOPE)
|
||||
set(${FLASH_ORIGIN} 0x8000000 PARENT_SCOPE)
|
||||
set(${RAM_ORIGIN} 0x20000000 PARENT_SCOPE)
|
||||
elseif((${TYPE} IN_LIST STM32_H7_DUAL_CORE) AND (CORE STREQUAL "M4"))
|
||||
list(GET STM32_H7_M4_RAM_SIZES ${TYPE_INDEX} RAM_VALUE)
|
||||
set(${RAM} ${RAM_VALUE} PARENT_SCOPE)
|
||||
set(${FLASH_ORIGIN} 0x8100000 PARENT_SCOPE)
|
||||
set(${RAM_ORIGIN} 0x10000000 PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown core ${CORE}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(stm32h7_get_device_cores DEVICE TYPE CORES)
|
||||
if(${TYPE} IN_LIST STM32_H7_DUAL_CORE)
|
||||
set(${CORES} M7 M4 PARENT_SCOPE)
|
||||
else()
|
||||
set(${CORES} M7 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
29
cmake/stm32/l0.cmake
Normal file
29
cmake/stm32/l0.cmake
Normal file
@@ -0,0 +1,29 @@
|
||||
set(STM32_L0_TYPES
|
||||
L010x4 L010x6 L010x8 L010xB L011xx L021xx L031xx L041xx
|
||||
L051xx L052xx L053xx L061xx L062xx L063xx L071xx L072xx
|
||||
L073xx L081xx L082xx L083xx
|
||||
)
|
||||
set(STM32_L0_TYPE_MATCH
|
||||
"L010.4" "L010.6" "L010.8" "L010.B" "L011.." "L021.." "L031.." "L041.."
|
||||
"L051.." "L052.." "L053.." "L061.." "L062.." "L063.." "L071.." "L072.."
|
||||
"L073.." "L081.." "L082.." "L083.."
|
||||
)
|
||||
set(STM32_L0_RAM_SIZES
|
||||
2K 8K 8K 20K 2K 2K 8K 8K
|
||||
8K 8K 8K 8K 8K 8K 20K 20K
|
||||
20K 20K 20K 20K
|
||||
)
|
||||
set(STM32_L0_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(L0)
|
||||
|
||||
target_compile_options(STM32::L0 INTERFACE
|
||||
-mcpu=cortex-m0plus
|
||||
)
|
||||
target_link_options(STM32::L0 INTERFACE
|
||||
-mcpu=cortex-m0plus
|
||||
)
|
||||
73
cmake/stm32/l1.cmake
Normal file
73
cmake/stm32/l1.cmake
Normal file
@@ -0,0 +1,73 @@
|
||||
set(STM32_L1_TYPES
|
||||
L100xB L100xBA L100xC L151xB L151xBA L151xC L151xCA L151xD
|
||||
L151xDX L151xE L152xB L152xBA L152xC L152xCA L152xD L152xDX
|
||||
L152xE L162xC L162xCA L162xD L162xDX L162xE
|
||||
)
|
||||
set(STM32_L1_TYPE_MATCH
|
||||
"L100.[68B]" "L100.[68B]A" "L100.C" "L151.[68B]" "L151.[68B]A" "L151.C" "L151.CA" "L151.D"
|
||||
"L151.DX" "L151.E" "L152.[68B]" "L152.[68B]A" "L152.C" "L152.CA" "L152.D" "L152.DX"
|
||||
"L152.E" "L162.C" "L162.CA" "L162.D" "L162.DX" "L162.E"
|
||||
)
|
||||
set(STM32_L1_RAM_SIZES
|
||||
0K 0K 16K 0K 0K 32K 32K 48K
|
||||
80K 80K 0K 0K 32K 32K 48K 80K
|
||||
80K 32K 32K 48K 80K 80K
|
||||
)
|
||||
set(STM32_L1_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(L1)
|
||||
|
||||
target_compile_options(STM32::L1 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
target_link_options(STM32::L1 INTERFACE
|
||||
-mcpu=cortex-m3
|
||||
)
|
||||
|
||||
function(stm32l1_get_memory_info DEVICE TYPE FLASH_SIZE RAM_SIZE)
|
||||
string(REGEX REPLACE "L1[0-9][0-9].([68BCDE])" "\\1" SIZE_CODE ${DEVICE})
|
||||
|
||||
unset(RAM)
|
||||
|
||||
if((TYPE STREQUAL "L100xB"))
|
||||
if(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "4K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(RAM "8K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "10K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "L100xBA"))
|
||||
if(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "4K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(RAM "8K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "16K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "L151xB") OR (TYPE STREQUAL "L152xB"))
|
||||
if(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "10K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(RAM "10K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "16K")
|
||||
endif()
|
||||
elseif((TYPE STREQUAL "L151xBA") OR (TYPE STREQUAL "L152xBA"))
|
||||
if(SIZE_CODE STREQUAL "6")
|
||||
set(RAM "16K")
|
||||
elseif(SIZE_CODE STREQUAL "8")
|
||||
set(RAM "32K")
|
||||
elseif(SIZE_CODE STREQUAL "B")
|
||||
set(RAM "32K")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(RAM)
|
||||
set(${RAM_SIZE} ${RAM} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
40
cmake/stm32/l4.cmake
Normal file
40
cmake/stm32/l4.cmake
Normal file
@@ -0,0 +1,40 @@
|
||||
set(STM32_L4_TYPES
|
||||
L412xx L422xx L431xx L432xx L433xx L442xx
|
||||
L443xx L451xx L452xx L462xx L471xx L475xx
|
||||
L476xx L485xx L486xx L496xx L4A6xx L4P5xx
|
||||
L4Q5xx L4R5xx L4R7xx L4R9xx L4S5xx L4S7xx
|
||||
L4S9xx
|
||||
)
|
||||
set(STM32_L4_TYPE_MATCH
|
||||
"L412.." "L422.." "L431.." "L432.." "L433.." "L442.."
|
||||
"L443.." "L451.." "L452.." "L462.." "L471.." "L475.."
|
||||
"L476.." "L485.." "L486.." "L496.." "L4A6.." "L4P5.."
|
||||
"L4Q5.." "L4R5.." "L4R7.." "L4R9.." "L4S5.." "L4S7.."
|
||||
"L4S9.."
|
||||
)
|
||||
|
||||
set(STM32_L4_RAM_SIZES
|
||||
40K 40K 64K 64K 64K 64K
|
||||
64K 160K 160K 160K 96K 96K
|
||||
96K 96K 96K 320K 320K 320K
|
||||
320K 640K 640K 640K 640K 640K
|
||||
640K
|
||||
)
|
||||
# on devices where CCRAM is remapped to be contiguous with RAM it is included into RAM section
|
||||
# If you want to have dedicated section then you will need to use custom linker script
|
||||
set(STM32_L4_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K
|
||||
0K 0K 0K 0K 32K 32K
|
||||
32K 32K 32K 0K 0K 0K
|
||||
0K 0K 0K 0K 0K 0K
|
||||
0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(L4)
|
||||
|
||||
target_compile_options(STM32::L4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::L4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
22
cmake/stm32/l5.cmake
Normal file
22
cmake/stm32/l5.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
set(STM32_L5_TYPES
|
||||
L552xx L562xx
|
||||
)
|
||||
set(STM32_L5_TYPE_MATCH
|
||||
"L552.." "L562.."
|
||||
)
|
||||
|
||||
set(STM32_L5_RAM_SIZES
|
||||
256K 256K
|
||||
)
|
||||
set(STM32_L5_CCRAM_SIZES
|
||||
0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(L5)
|
||||
|
||||
target_compile_options(STM32::L5 INTERFACE
|
||||
-mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::L5 INTERFACE
|
||||
-mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
158
cmake/stm32/linker_ld.cmake
Normal file
158
cmake/stm32/linker_ld.cmake
Normal file
@@ -0,0 +1,158 @@
|
||||
if((NOT CCRAM_SIZE) OR (CCRAM_SIZE STREQUAL "0K"))
|
||||
set(CCRAM_DEFINITION "")
|
||||
set(CCRAM_SECTION "")
|
||||
else()
|
||||
set(CCRAM_DEFINITION " CCMRAM (rw) : ORIGIN = ${CCRAM_ORIGIN}, LENGTH = ${CCRAM_SIZE}\n")
|
||||
set(CCRAM_SECTION "
|
||||
_siccmram = LOADADDR(.ccmram);\n\
|
||||
.ccmram :\n\
|
||||
{\n\
|
||||
. = ALIGN(4);\n\
|
||||
_sccmram = .;\n\
|
||||
*(.ccmram)\n\
|
||||
*(.ccmram*)\n\
|
||||
. = ALIGN(4);\n\
|
||||
_eccmram = .;\n\
|
||||
} >CCMRAM AT> FLASH\n\
|
||||
")
|
||||
endif()
|
||||
|
||||
if((NOT RAM_SHARE_SIZE) OR (RAM_SHARE_SIZE STREQUAL "0K"))
|
||||
set(RAM_SHARE_DEFINITION "")
|
||||
set(RAM_SHARE_SECTION "")
|
||||
else()
|
||||
set(RAM_SHARE_DEFINITION " RAM_SHARED (rw) : ORIGIN = ${RAM_SHARE_ORIGIN}, LENGTH = ${RAM_SHARE_SIZE}\n")
|
||||
set(RAM_SHARE_SECTION "
|
||||
MAPPING_TABLE (NOLOAD) : { *(MAPPING_TABLE) } >RAM_SHARED\n\
|
||||
MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED\n\
|
||||
MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED\n\
|
||||
")
|
||||
endif()
|
||||
|
||||
set(SCRIPT_TEXT
|
||||
"ENTRY(Reset_Handler)\n\
|
||||
\n\
|
||||
_estack = ${RAM_ORIGIN} + ${RAM_SIZE};\n\
|
||||
_Min_Heap_Size = ${HEAP_SIZE};\n\
|
||||
_Min_Stack_Size = ${STACK_SIZE};\n\
|
||||
\n\
|
||||
MEMORY\n\
|
||||
{\n\
|
||||
FLASH (rx) : ORIGIN = ${FLASH_ORIGIN}, LENGTH = ${FLASH_SIZE}\n\
|
||||
RAM (xrw) : ORIGIN = ${RAM_ORIGIN}, LENGTH = ${RAM_SIZE}\n\
|
||||
${CCRAM_DEFINITION}\n\
|
||||
${RAM_SHARE_DEFINITION}\n\
|
||||
}\n\
|
||||
\n\
|
||||
SECTIONS\n\
|
||||
{\n\
|
||||
.isr_vector :\n\
|
||||
{\n\
|
||||
. = ALIGN(4);\n\
|
||||
KEEP(*(.isr_vector))\n\
|
||||
. = ALIGN(4);\n\
|
||||
} >FLASH\n\
|
||||
\n\
|
||||
.text :\n\
|
||||
{\n\
|
||||
. = ALIGN(4);\n\
|
||||
*(.text)\n\
|
||||
*(.text*)\n\
|
||||
*(.glue_7)\n\
|
||||
*(.glue_7t)\n\
|
||||
*(.eh_frame)\n\
|
||||
\n\
|
||||
KEEP (*(.init))\n\
|
||||
KEEP (*(.fini))\n\
|
||||
\n\
|
||||
. = ALIGN(4);\n\
|
||||
_etext = .;\n\
|
||||
} >FLASH\n\
|
||||
\n\
|
||||
.rodata :\n\
|
||||
{\n\
|
||||
. = ALIGN(4);\n\
|
||||
*(.rodata)\n\
|
||||
*(.rodata*)\n\
|
||||
. = ALIGN(4);\n\
|
||||
} >FLASH\n\
|
||||
\n\
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH\n\
|
||||
.ARM : {\n\
|
||||
__exidx_start = .;\n\
|
||||
*(.ARM.exidx*)\n\
|
||||
__exidx_end = .;\n\
|
||||
} >FLASH\n\
|
||||
\n\
|
||||
.preinit_array :\n\
|
||||
{\n\
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);\n\
|
||||
KEEP (*(.preinit_array*))\n\
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);\n\
|
||||
} >FLASH\n\
|
||||
.init_array :\n\
|
||||
{\n\
|
||||
PROVIDE_HIDDEN (__init_array_start = .);\n\
|
||||
KEEP (*(SORT(.init_array.*)))\n\
|
||||
KEEP (*(.init_array*))\n\
|
||||
PROVIDE_HIDDEN (__init_array_end = .);\n\
|
||||
} >FLASH\n\
|
||||
.fini_array :\n\
|
||||
{\n\
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);\n\
|
||||
KEEP (*(SORT(.fini_array.*)))\n\
|
||||
KEEP (*(.fini_array*))\n\
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);\n\
|
||||
} >FLASH\n\
|
||||
\n\
|
||||
_sidata = LOADADDR(.data);\n\
|
||||
\n\
|
||||
.data : \n\
|
||||
{\n\
|
||||
. = ALIGN(4);\n\
|
||||
_sdata = .; \n\
|
||||
*(.data)\n\
|
||||
*(.data*)\n\
|
||||
\n\
|
||||
. = ALIGN(4);\n\
|
||||
_edata = .;\n\
|
||||
} >RAM AT> FLASH\n\
|
||||
${CCRAM_SECTION}\n\
|
||||
. = ALIGN(4);\n\
|
||||
.bss :\n\
|
||||
{\n\
|
||||
_sbss = .;\n\
|
||||
__bss_start__ = _sbss;\n\
|
||||
*(.bss)\n\
|
||||
*(.bss*)\n\
|
||||
*(COMMON)\n\
|
||||
\n\
|
||||
. = ALIGN(4);\n\
|
||||
_ebss = .;\n\
|
||||
__bss_end__ = _ebss;\n\
|
||||
} >RAM\n\
|
||||
\n\
|
||||
._user_heap_stack :\n\
|
||||
{\n\
|
||||
. = ALIGN(8);\n\
|
||||
PROVIDE ( end = . );\n\
|
||||
PROVIDE ( _end = . );\n\
|
||||
. = . + _Min_Heap_Size;\n\
|
||||
. = . + _Min_Stack_Size;\n\
|
||||
. = ALIGN(8);\n\
|
||||
} >RAM\n\
|
||||
\n\
|
||||
/DISCARD/ :\n\
|
||||
{\n\
|
||||
libc.a ( * )\n\
|
||||
libm.a ( * )\n\
|
||||
libgcc.a ( * )\n\
|
||||
}\n\
|
||||
\n\
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }\n\
|
||||
${RAM_SHARE_SECTION}\n\
|
||||
}"
|
||||
)
|
||||
file(WRITE "${LINKER_SCRIPT}" "${SCRIPT_TEXT}")
|
||||
|
||||
|
||||
31
cmake/stm32/mp1.cmake
Normal file
31
cmake/stm32/mp1.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
set(STM32_MP1_TYPES
|
||||
MP151Axx MP151Cxx
|
||||
MP153Axx MP153Cxx
|
||||
MP157Axx MP157Cxx)
|
||||
|
||||
set(STM32_MP1_TYPE_MATCH
|
||||
"MP151[AD](A.?)?" "MP151[CF](A.?)?"
|
||||
"MP153[AD](A.?)?" "MP153[CF](A.?)?"
|
||||
"MP157[AD](A.?)?" "MP157[CF](A.?)?")
|
||||
|
||||
set(STM32_MP1_RAM_SIZES
|
||||
384K 384K
|
||||
384K 384K
|
||||
384K 384K)
|
||||
|
||||
set(STM32_MP1_CCRAM_SIZES
|
||||
0K 0K
|
||||
0K 0K
|
||||
0K 0K)
|
||||
|
||||
stm32_util_create_family_targets(MP1 M4)
|
||||
|
||||
target_compile_options(STM32::MP1::M4 INTERFACE -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
target_link_options(STM32::MP1::M4 INTERFACE -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard)
|
||||
target_compile_definitions(STM32::MP1::M4 INTERFACE CORE_CM4)
|
||||
|
||||
function(stm32mp1_get_memory_info DEVICE TYPE FLASH_SIZE)
|
||||
if(FLASH_SIZE)
|
||||
set(${FLASH_SIZE} "0KB" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
19
cmake/stm32/u5.cmake
Normal file
19
cmake/stm32/u5.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
set(STM32_U5_TYPES
|
||||
U575xx U585xx
|
||||
)
|
||||
set(STM32_U5_TYPE_MATCH
|
||||
"U575.." "U585.."
|
||||
)
|
||||
|
||||
set(STM32_U5_RAM_SIZES
|
||||
768K 768K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(U5)
|
||||
|
||||
target_compile_options(STM32::U5 INTERFACE
|
||||
-mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::U5 INTERFACE
|
||||
-mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
161
cmake/stm32/utilities.cmake
Normal file
161
cmake/stm32/utilities.cmake
Normal file
@@ -0,0 +1,161 @@
|
||||
function(stm32_util_create_family_targets FAMILY)
|
||||
set(CORES ${ARGN})
|
||||
list(LENGTH CORES NUM_CORES)
|
||||
if(${NUM_CORES} EQUAL 0)
|
||||
set(CORE "")
|
||||
set(CORE_C "")
|
||||
elseif(${NUM_CORES} EQUAL 1)
|
||||
set(CORE "_${CORES}")
|
||||
set(CORE_C "::${CORES}")
|
||||
else()
|
||||
message(FATAL_ERROR "Expected at most one core for family ${FAMILY}: ${CORES}")
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET STM32::${FAMILY}${CORE_C}))
|
||||
add_library(STM32::${FAMILY}${CORE_C} INTERFACE IMPORTED)
|
||||
# Set compiler flags for target
|
||||
# -Wall: all warnings activated
|
||||
# -ffunction-sections -fdata-sections: remove unused code
|
||||
target_compile_options(STM32::${FAMILY}${CORE_C} INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
-mthumb -Wall -ffunction-sections -fdata-sections
|
||||
)
|
||||
# Set linker flags
|
||||
# -mthumb: Generate thumb code
|
||||
# -Wl,--gc-sections: Remove unused code
|
||||
target_link_options(STM32::${FAMILY}${CORE_C} INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
-mthumb -Wl,--gc-sections
|
||||
)
|
||||
target_compile_definitions(STM32::${FAMILY}${CORE_C} INTERFACE
|
||||
STM32${FAMILY}
|
||||
)
|
||||
endif()
|
||||
foreach(TYPE ${STM32_${FAMILY}_TYPES})
|
||||
if(NOT (TARGET STM32::${TYPE}${CORE_C}))
|
||||
add_library(STM32::${TYPE}${CORE_C} INTERFACE IMPORTED)
|
||||
target_link_libraries(STM32::${TYPE}${CORE_C} INTERFACE STM32::${FAMILY}${CORE_C})
|
||||
target_compile_definitions(STM32::${TYPE}${CORE_C} INTERFACE
|
||||
STM32${TYPE}
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# A CMSIS or HAL driver can specify 'cube' as version number to indicate that the driver is taken from the Cube repository
|
||||
set(STM32_FETCH_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5 MP1 U5 WB WL )
|
||||
set(STM32_FETCH_CUBE_VERSIONS v1.11.2 v1.8.4 v1.9.3 v1.11.2 v1.26.1 v1.16.1 v1.4.1 v1.4.0 v1.9.0 v1.12.0 v1.10.3 v1.17.0 v1.4.0 1.5.0 v1.0.0 v1.12.0 v1.1.0)
|
||||
set(STM32_FETCH_CMSIS_VERSIONS v2.3.5 v4.3.3 v2.2.5 v2.3.5 v2.6.6 v1.2.6 v1.4.0 v1.2.1 v1.10.0 v1.9.1 v2.3.2 v1.7.1 v1.0.4 cube v1.0.0 v1.9.0 v1.1.0)
|
||||
set(STM32_FETCH_HAL_VERSIONS v1.7.5 v1.1.8 v1.2.7 v1.5.5 v1.7.12 v1.2.9 v1.4.1 v1.2.1 v1.10.0 v1.10.4 v1.4.4 v1.13.0 v1.0.4 cube v1.0.0 v1.9.0 v1.1.0)
|
||||
|
||||
FetchContent_Declare(
|
||||
STM32-CMSIS
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_core/
|
||||
GIT_TAG v5.6.0
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
set(IDX 0)
|
||||
foreach(FAMILY ${STM32_FETCH_FAMILIES})
|
||||
string(TOLOWER ${FAMILY} FAMILY_L)
|
||||
list(GET STM32_FETCH_CUBE_VERSIONS ${IDX} CUBE_VERSION)
|
||||
list(GET STM32_FETCH_CMSIS_VERSIONS ${IDX} CMSIS_VERSION)
|
||||
list(GET STM32_FETCH_HAL_VERSIONS ${IDX} HAL_VERSION)
|
||||
|
||||
FetchContent_Declare(
|
||||
STM32Cube${FAMILY}
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/STM32Cube${FAMILY}/
|
||||
GIT_TAG ${CUBE_VERSION}
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
if(CMSIS_VERSION STREQUAL cube)
|
||||
set(STM32_USE_CMSIS_FROM_CUBE_${FAMILY} ON)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
STM32-CMSIS-${FAMILY}
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_device_${FAMILY_L}/
|
||||
GIT_TAG ${CMSIS_VERSION}
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(HAL_VERSION STREQUAL cube)
|
||||
set(STM32_USE_HAL_FROM_CUBE_${FAMILY} ON)
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
STM32-HAL-${FAMILY}
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32${FAMILY_L}xx_hal_driver/
|
||||
GIT_TAG ${HAL_VERSION}
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
endif()
|
||||
|
||||
math(EXPR IDX "${IDX} + 1")
|
||||
endforeach()
|
||||
|
||||
function(stm32_fetch_cube)
|
||||
foreach(FAMILY ${ARGV})
|
||||
set(CUBE_NAME STM32Cube${FAMILY})
|
||||
string(TOLOWER ${CUBE_NAME} CUBE_NAME_L)
|
||||
|
||||
if(STM32_CUBE_${FAMILY}_PATH)
|
||||
message(VERBOSE "STM32_CUBE_${FAMILY}_PATH specified, skipping fetch for ${CUBE_NAME}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
FetchContent_MakeAvailable(${CUBE_NAME})
|
||||
set(STM32_CUBE_${FAMILY}_PATH ${${CUBE_NAME_L}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(stm32_fetch_cmsis)
|
||||
if(NOT STM32_CMSIS_PATH)
|
||||
FetchContent_MakeAvailable(STM32-CMSIS)
|
||||
set(STM32_CMSIS_PATH ${stm32-cmsis_SOURCE_DIR} PARENT_SCOPE)
|
||||
else()
|
||||
message(INFO "STM32_CMSIS_PATH specified, skipping fetch for STM32-CMSIS")
|
||||
endif()
|
||||
|
||||
foreach(FAMILY ${ARGV})
|
||||
if(STM32_USE_CMSIS_FROM_CUBE_${FAMILY})
|
||||
stm32_fetch_cube(${FAMILY})
|
||||
message(STATUS "Cube fetched for ${FAMILY} at ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
set(STM32_CMSIS_${FAMILY}_PATH ${STM32_CUBE_${FAMILY}_PATH}/Drivers/CMSIS/Device/ST/STM32${FAMILY}xx PARENT_SCOPE)
|
||||
else()
|
||||
set(CMSIS_NAME STM32-CMSIS-${FAMILY})
|
||||
string(TOLOWER ${CMSIS_NAME} CMSIS_NAME_L)
|
||||
|
||||
if(STM32_CMSIS_${FAMILY}_PATH)
|
||||
message(INFO "STM32_CMSIS_${FAMILY}_PATH specified, skipping fetch for ${CMSIS_NAME}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
FetchContent_MakeAvailable(${CMSIS_NAME})
|
||||
set(STM32_CMSIS_${FAMILY}_PATH ${${CMSIS_NAME_L}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(stm32_fetch_hal)
|
||||
foreach(FAMILY ${ARGV})
|
||||
if(STM32_USE_HAL_FROM_CUBE_${FAMILY})
|
||||
stm32_fetch_cube(${FAMILY})
|
||||
message(STATUS "Cube fetched for ${FAMILY} at ${STM32_CUBE_${FAMILY}_PATH}")
|
||||
set(STM32_HAL_${FAMILY}_PATH ${STM32_CUBE_${FAMILY}_PATH}/Drivers/STM32${FAMILY}xx_HAL_Driver PARENT_SCOPE)
|
||||
else()
|
||||
set(HAL_NAME STM32-HAL-${FAMILY})
|
||||
string(TOLOWER ${HAL_NAME} HAL_NAME_L)
|
||||
|
||||
if(STM32_HAL_${FAMILY}_PATH)
|
||||
message(INFO "STM32_HAL_${FAMILY}_PATH specified, skipping fetch for ${HAL_NAME}")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
FetchContent_MakeAvailable(${HAL_NAME})
|
||||
set(STM32_HAL_${FAMILY}_PATH ${${HAL_NAME_L}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
38
cmake/stm32/wb.cmake
Normal file
38
cmake/stm32/wb.cmake
Normal file
@@ -0,0 +1,38 @@
|
||||
set(STM32_WB_TYPES
|
||||
WB55xx WB55xx WB35xx WB15xx WB50xx WB30xx WB10xx WB5Mxx
|
||||
)
|
||||
set(STM32_WB_TYPE_MATCH
|
||||
"WB55.C" "WB55.[EGY]" "WB35.." "WB15.." "WB50.." "WB30.." "WB10.." "WB5M.."
|
||||
)
|
||||
|
||||
# this is not full RAM of the chip but only the part allocated to M4 core (SRAM1 in datasheet)
|
||||
set(STM32_WB_RAM_SIZES
|
||||
64K 192K 32K 12K 64K 32K 12K 192K
|
||||
)
|
||||
|
||||
# WB series need special area for SRAM2 shared with core M0PLUS
|
||||
set(STM32_WB_RAM_SHARE_SIZES
|
||||
10K 10K 10K 10K 10K 10K 10K 10K
|
||||
)
|
||||
|
||||
set(STM32_WB_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(WB M4)
|
||||
|
||||
target_compile_options(STM32::WB::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
target_link_options(STM32::WB::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfpu=fpv5-sp-d16 -mfloat-abi=hard
|
||||
)
|
||||
|
||||
function(stm32wb_get_memory_info DEVICE TYPE CORE RAM RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
set(${TWO_FLASH_BANKS} TRUE PARENT_SCOPE)
|
||||
list(FIND STM32_WB_TYPES ${TYPE} TYPE_INDEX)
|
||||
list(GET STM32_WB_RAM_SIZES ${TYPE_INDEX} RAM_VALUE)
|
||||
set(${RAM} "${RAM_VALUE}-4" PARENT_SCOPE)
|
||||
set(${RAM_ORIGIN} 0x20000004 PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
77
cmake/stm32/wl.cmake
Normal file
77
cmake/stm32/wl.cmake
Normal file
@@ -0,0 +1,77 @@
|
||||
set(STM32_WL_TYPES
|
||||
WL54xx WL55xx WLE4xx WLE5xx WLE4xx WLE5xx WLE4xx WLE5xx
|
||||
)
|
||||
set(STM32_WL_TYPE_MATCH
|
||||
"WL54.." "WL55.." "WLE4.8" "WLE5.8" "WLE4.B" "WLE5.B" "WLE4.C" "WLE5.C"
|
||||
)
|
||||
|
||||
# this is RAM size allocated to M4 core
|
||||
# Note devices with 20 and 48K RAM can use only half of available RAM because
|
||||
# there are 2 split sections of RAM and our default linker script only manages
|
||||
# one section.
|
||||
set(STM32_WL_RAM_SIZES
|
||||
32K 32K 10K 10K 24K 24K 64K 64K
|
||||
)
|
||||
|
||||
# this is RAM size allocated to M0PLUS core
|
||||
set(STM32_WL_M0PLUS_RAM_SIZES
|
||||
32K 32K 0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
set(STM32_WL_CCRAM_SIZES
|
||||
0K 0K 0K 0K 0K 0K 0K 0K
|
||||
)
|
||||
|
||||
set(STM32_WL_DUAL_CORE
|
||||
WL54xx WL55xx
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(WL M4)
|
||||
|
||||
target_compile_options(STM32::WL::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfloat-abi=soft
|
||||
)
|
||||
target_link_options(STM32::WL::M4 INTERFACE
|
||||
-mcpu=cortex-m4 -mfloat-abi=soft
|
||||
)
|
||||
|
||||
stm32_util_create_family_targets(WL M0PLUS)
|
||||
|
||||
target_compile_options(STM32::WL::M0PLUS INTERFACE
|
||||
-mcpu=cortex-m0plus -mfloat-abi=soft
|
||||
)
|
||||
target_link_options(STM32::WL::M0PLUS INTERFACE
|
||||
-mcpu=cortex-m0plus -mfloat-abi=soft
|
||||
)
|
||||
|
||||
function(stm32wl_get_memory_info DEVICE TYPE CORE RAM FLASH_ORIGIN RAM_ORIGIN TWO_FLASH_BANKS)
|
||||
if(${TYPE} IN_LIST STM32_WL_DUAL_CORE)
|
||||
set(${TWO_FLASH_BANKS} TRUE PARENT_SCOPE)
|
||||
else()
|
||||
set(${TWO_FLASH_BANKS} FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
list(FIND STM32_WL_TYPES ${TYPE} TYPE_INDEX)
|
||||
if(CORE STREQUAL "M4")
|
||||
list(GET STM32_WL_RAM_SIZES ${TYPE_INDEX} RAM_VALUE)
|
||||
set(${RAM} ${RAM_VALUE} PARENT_SCOPE)
|
||||
set(${FLASH_ORIGIN} 0x8000000 PARENT_SCOPE)
|
||||
set(${RAM_ORIGIN} 0x20000000 PARENT_SCOPE)
|
||||
elseif((${TYPE} IN_LIST STM32_WL_DUAL_CORE) AND (CORE STREQUAL "M0PLUS"))
|
||||
list(GET STM32_WL_M0PLUS_RAM_SIZES ${TYPE_INDEX} RAM_VALUE)
|
||||
set(${RAM} ${RAM_VALUE} PARENT_SCOPE)
|
||||
set(${FLASH_ORIGIN} 0x8020000 PARENT_SCOPE)
|
||||
set(${RAM_ORIGIN} 0x20008000 PARENT_SCOPE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown core ${CORE}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
function(stm32wl_get_device_cores DEVICE TYPE CORES)
|
||||
if(${TYPE} IN_LIST STM32_WL_DUAL_CORE)
|
||||
set(${CORES} M4 M0PLUS PARENT_SCOPE)
|
||||
else()
|
||||
set(${CORES} M4 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
23
cmake/stm32_gcc.cmake
Normal file
23
cmake/stm32_gcc.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
|
||||
message(WARNING "Current CMake version is ${CMAKE_VERSION}. stm32-cmake requires CMake 3.16 or greater")
|
||||
|
||||
endif()
|
||||
|
||||
get_filename_component(STM32_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} DIRECTORY)
|
||||
list(APPEND CMAKE_MODULE_PATH ${STM32_CMAKE_DIR})
|
||||
|
||||
include(stm32/common)
|
||||
include(stm32/devices)
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES ${STM32_TARGET_TRIPLET}-gcc HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_CXX_COMPILER NAMES ${STM32_TARGET_TRIPLET}-g++ HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_ASM_COMPILER NAMES ${STM32_TARGET_TRIPLET}-gcc HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_C .elf)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_CXX .elf)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_ASM .elf)
|
||||
|
||||
# This should be safe to set for a bare-metal cross-compiler
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
Reference in New Issue
Block a user