Skip to content

Commit

Permalink
Add support for MP2 family (#285)
Browse files Browse the repository at this point in the history
* MP2 Family support
  • Loading branch information
xanthio authored Aug 10, 2024
1 parent 7691eeb commit 19b546a
Show file tree
Hide file tree
Showing 9 changed files with 1,020 additions and 11 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ jobs:
TEMPLATES=($(find _deps -name "*_template.h"))
for template in ${TEMPLATES[@]}; do
#get rid off "_template" in file name
DEST=$(basename ${template}| sed -rn "s@([^/]*)(_template)(\.h)@\1\3@p")
DEST=$(basename ${template} | sed -rn "s@([^/]*)(_template)(\.h)@\1\3@p")
cp ${template} ${DEST}
done
if: ${{ matrix.family != 'MP2'}}

- name: Build tests/fetch
working-directory: ${{ runner.workspace }}/tests/fetch/build
Expand All @@ -60,19 +61,19 @@ jobs:

- name: Create build directory for tests/cmsis
run: cmake -E make_directory ${{ runner.workspace }}/tests/cmsis/build
if: ${{ matrix.family != 'MP1' }}
if: ${{ matrix.family != 'MP1' && matrix.family != 'MP2'}}

- name: Configure tests/cmsis
shell: bash
working-directory: ${{ runner.workspace }}/tests/cmsis/build
run: cmake -DTEST_FAMILIES=${{ matrix.family }} -DFETCH_ST_SOURCES=TRUE $GITHUB_WORKSPACE/tests/cmsis/
if: ${{ matrix.family != 'MP1' }}
if: ${{ matrix.family != 'MP1' && matrix.family != 'MP2'}}

- name: Build tests/cmsis
working-directory: ${{ runner.workspace }}/tests/cmsis/build
shell: bash
run: cmake --build . --config $BUILD_TYPE
if: ${{ matrix.family != 'MP1' }}
if: ${{ matrix.family != 'MP1' && matrix.family != 'MP2'}}

Test-HAL:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -101,9 +102,10 @@ jobs:
TEMPLATES=($(find _deps -name "*_template.h"))
for template in ${TEMPLATES[@]}; do
#get rid off "_template" in file name
DEST=$(basename ${template}| sed -rn "s@([^/]*)(_template)(\.h)@\1\3@p")
DEST=$(basename ${template} | sed -rn "s@([^/]*)(_template)(\.h)@\1\3@p")
cp ${template} ${DEST}
done
if: ${{ matrix.family != 'MP2'}}

- name: Build tests/hal
working-directory: ${{ runner.workspace }}/tests/hal/build
Expand Down
14 changes: 11 additions & 3 deletions cmake/FindCMSIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ if(STM32MP1 IN_LIST CMSIS_FIND_COMPONENTS)
list(APPEND CMSIS_FIND_COMPONENTS STM32MP1_M4)
endif()

if(STM32MP2 IN_LIST CMSIS_FIND_COMPONENTS)
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32MP2)
list(APPEND CMSIS_FIND_COMPONENTS STM32MP2_M33)
endif()

list(REMOVE_DUPLICATES CMSIS_FIND_COMPONENTS)

# This section fills the RTOS or family components list
Expand Down Expand Up @@ -134,13 +139,15 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES})
set(CORE ${C})
set(CORE_C "::${CORE}")
set(CORE_U "_${CORE}")
string(TOLOWER ${CORE_U} CORE_u)
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_u)
unset(CORE_Ucm)
endif()

Expand Down Expand Up @@ -208,9 +215,9 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES})
target_include_directories(CMSIS::STM32::${FAMILY}${CORE_C} INTERFACE "${CMSIS_${FAMILY}${CORE_U}_PATH}/Include")
endif()

# search for system_stm32[XX]xx.c
# search for system, can be named system_stm32[XX]xx.c / system_stm32[XX]x.c / system_stm32[XX]xx_mY.c
find_file(CMSIS_${FAMILY}${CORE_U}_SYSTEM
NAMES system_stm32${FAMILY_L}xx.c system_stm32${FAMILY_L}x.c
NAMES system_stm32${FAMILY_L}xx.c system_stm32${FAMILY_L}x.c system_stm32${FAMILY_L}xx${CORE_u}.c
PATHS "${CMSIS_${FAMILY}${CORE_U}_PATH}/Source/Templates"
NO_DEFAULT_PATH
)
Expand Down Expand Up @@ -244,13 +251,14 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES})
find_file(CMSIS_${FAMILY}${CORE_U}_${TYPE}_STARTUP
NAMES startup_stm32${TYPE_L}.s
startup_stm32${TYPE_L}${CORE_Ucm}.s
startup_stm32${TYPE_L}${CORE_u}.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")
message(VERBOSE "FindCMSIS: did not find startup file")
break()
endif()

Expand Down
5 changes: 5 additions & 0 deletions cmake/FindHAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ if(STM32MP1 IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32MP1_M4)
endif()

if(STM32MP2 IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32MP2)
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32MP2_M33)
endif()

list(REMOVE_DUPLICATES HAL_FIND_COMPONENTS_FAMILIES)

# when no explicit driver and driver_ll is given to find_component(HAL )
Expand Down
8 changes: 7 additions & 1 deletion cmake/stm32/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function(stm32_extract_info identifier)
set(ARG_MULTIPLE "")
cmake_parse_arguments(PARSE_ARGV 1 INFO "${ARG_OPTIONS}" "${ARG_SINGLE}" "${ARG_MULTIPLE}")

string(REGEX MATCH "^(STM32)?([CFGHLU][0123457]|MP[12]|WL|WB[0A]?)([0-9A-Z][0-9M]?)?([A-Z135])?([3468ABCDEFGHIJYZ])?_?(M0PLUS|M4|M7)?.*$" ID ${identifier})
string(REGEX MATCH "^(STM32)?([CFGHLU][0123457]|MP[12]|WL|WB[0A]?)([0-9A-Z][0-9M]?)?([A-Z135])?([3468ABCDEFGHIJYZ])?_?(M0PLUS|M33|M4|M7)?.*$" ID ${identifier})
set(FAMILY ${CMAKE_MATCH_2})
set(SUB_FAMILY ${CMAKE_MATCH_3})
set(PIN_COUNT ${CMAKE_MATCH_4})
Expand Down Expand Up @@ -203,6 +203,8 @@ function(stm32_get_cores CORES)
set(${CORES} M4 M0PLUS PARENT_SCOPE)
elseif(${ARG_FAMILY} STREQUAL "MP1")
set(${CORES} M4 PARENT_SCOPE)
elseif(${ARG_FAMILY} STREQUAL "MP2")
set(${CORES} M33 PARENT_SCOPE)
else()
set(${CORES} "" PARENT_SCOPE)
endif()
Expand All @@ -219,6 +221,8 @@ function(stm32_get_cores CORES)
set(CORE_LIST M4)
elseif(${ARG_FAMILY} STREQUAL "MP1")
set(CORE_LIST M4)
elseif(${ARG_FAMILY} STREQUAL "MP2")
set(CORE_LIST M33)
elseif(${ARG_FAMILY} STREQUAL "WL")
stm32wl_get_device_cores(${ARG_DEVICE} ${ARG_TYPE} CORE_LIST)
endif()
Expand Down Expand Up @@ -305,6 +309,8 @@ function(stm32_get_memory_info)
stm32wba_get_memory_info(${INFO_DEVICE} RAM)
elseif(FAMILY STREQUAL "MP1")
stm32mp1_get_memory_info(${INFO_DEVICE} ${INFO_TYPE} FLASH)
elseif(FAMILY STREQUAL "MP2")
stm32mp2_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)
Expand Down
1 change: 1 addition & 0 deletions cmake/stm32/devices.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ include(stm32/wb0)
include(stm32/wba)
include(stm32/wl)
include(stm32/mp1)
include(stm32/mp2)

# Store a list of devices into a given STM_DEVICES list.
# You can also specify multiple device families. Examples:
Expand Down
79 changes: 79 additions & 0 deletions cmake/stm32/mp2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
set(STM32_MP2_TYPES
MP251Axx MP251Cxx MP251Dxx MP251Fxx
MP253Axx MP253Cxx MP253Dxx MP253Fxx
MP255Axx MP255Cxx MP255Dxx MP255Fxx
MP257Axx MP257Cxx MP257Dxx MP257Fxx
)

set(STM32_MP2_TYPE_MATCH
"MP251A" "MP251C" "MP251D" "MP251F"
"MP253A" "MP253C" "MP253D" "MP253F"
"MP255A" "MP255C" "MP255D" "MP255F"
"MP257A" "MP257C" "MP257D" "MP257F"
)

set(STM32_MP2_RAM_SIZES
0K 0K 0K 0K
0K 0K 0K 0K
0K 0K 0K 0K
0K 0K 0K 0K
)

set(STM32_MP2_CCRAM_SIZES
0K 0K 0K 0K
0K 0K 0K 0K
0K 0K 0K 0K
0K 0K 0K 0K
)

stm32_util_create_family_targets(MP2 M33)

target_compile_options(STM32::MP2::M33 INTERFACE -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard)
target_link_options(STM32::MP2::M33 INTERFACE -mcpu=cortex-m33 -mfpu=fpv5-sp-d16 -mfloat-abi=hard)
target_compile_definitions(STM32::MP2::M33 INTERFACE CORE_CM33)

function(stm32mp2_get_memory_info DEVICE TYPE FLASH_SIZE)
if(FLASH_SIZE)
set(${FLASH_SIZE} "0KB" PARENT_SCOPE)
endif()
endfunction()

function(stm32mp2_get_ld_filename DEVICE FILENAME)
if(FILENAME)
set(${FILENAME} "stm32mp2xx_DDR_m33_ns.ld" PARENT_SCOPE)
endif()
endfunction()

set(STM32_MP2_DEVICES
MP251A
MP251C
MP251D
MP251F
MP253A
MP253C
MP253D
MP253F
MP255A
MP255C
MP255D
MP255F
MP257A
MP257C
MP257D
MP257F
)
list(APPEND STM32_ALL_DEVICES STM32MP2_DEVICES MP257C)

list(APPEND STM32_SUPPORTED_FAMILIES_LONG_NAME
STM32MP2_M33
)

list(APPEND STM32_FETCH_FAMILIES MP2)

set(STM32MP2_HAL_TEST_DEVICE MP257C)

# SERIE SS2315

set(CUBE_MP2_VERSION v1.0.0)
set(CMSIS_MP2_VERSION cube)
set(HAL_MP2_VERSION cube)
Loading

0 comments on commit 19b546a

Please sign in to comment.