-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMSIS RTOS Feature #227
CMSIS RTOS Feature #227
Changes from all commits
d74300a
28e4de0
a035f82
9089819
995eca8
664bd3f
1e6353e
f7f0df7
e16eab7
283261b
5b0bd76
7c47793
9cb4d5a
cbc35f5
e1ec091
3c5484e
07798ed
ac679f4
edf1234
e78f20e
9d76f52
c616752
90c73d7
69c26da
fcbdfc3
15ae0bf
aca3a3e
e8ae4e4
465bed9
faa4337
e61e358
ae4ba41
3f462ec
b3f97e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
set(CMSIS_RTOS RTOS RTOS_V2) | ||
|
||
if(NOT CMSIS_FIND_COMPONENTS) | ||
set(CMSIS_FIND_COMPONENTS ${STM32_SUPPORTED_FAMILIES_LONG_NAME}) | ||
endif() | ||
|
@@ -7,6 +9,35 @@ if(STM32H7 IN_LIST CMSIS_FIND_COMPONENTS) | |
endif() | ||
list(REMOVE_DUPLICATES CMSIS_FIND_COMPONENTS) | ||
|
||
# This section fills the RTOS or family components list | ||
foreach(COMP ${CMSIS_FIND_COMPONENTS}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not expert so I'm sorry if it's supposed to be trivial for me. But if you find it relevant to beginners and maintainers: please add (relevant) comments into the code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added more documentation for all component list filler loops |
||
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([A-Z][0-9])([0-9A-Z][0-9][A-Z][0-9A-Z])?_?(M[47])?.*$" 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) | ||
|
@@ -41,7 +72,7 @@ function(cmsis_generate_default_linker_script FAMILY DEVICE CORE) | |
stm32_add_linker_script(CMSIS::STM32::${DEVICE}${CORE_C} INTERFACE "${OUTPUT_LD_FILE}") | ||
endfunction() | ||
|
||
foreach(COMP ${CMSIS_FIND_COMPONENTS}) | ||
foreach(COMP ${CMSIS_FIND_COMPONENTS_FAMILIES}) | ||
string(TOLOWER ${COMP} COMP_L) | ||
string(TOUPPER ${COMP} COMP) | ||
|
||
|
@@ -176,6 +207,44 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS}) | |
else() | ||
set(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() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a cube path is provided this should be populated and usable but it is not the case from my tests.
Maybe
FREERTOS_PATH
should not be mandatory when aSTM32_CUBE_<FAMILY>_PATH
is provided?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you added the
STM32<Family>
to the FreeRTOS components? This is necessary to use the target inside the namespace I thinkThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No I have not. And it was not enough to solve the issue.
But this did:
You are more expert that I am. Does the example need update ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah was that the example? That is weird,
FREERTOS_PATH
should not be necessary.. What was the build generation command?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it. I loaded the STM32_CUBE_H7_PATH by setting it as an environment with
export STM32_CUBE_H7_PATH=<pathToCube>
and the toolchain withexport STM32_TOOLCHAIN_PATH=<pathToToolchain>
I the ran the following command inside
example/freertos/build
:For CMSIS V2 I ran
cmake -DUSE_CMSIS_RTOS_V2=ON -DFREERTOS_H743ZI_EXAMPLE=ON -DSTM32_TOOLCHAIN_PATH=$STM32_TOOLCHAIN_PATH ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, if neither
USE_CMSIS_RTOS
norUSE_CMSIS_RTOS_V2
is specified the example could theoretically use both external kernel or STM32H7 kernel. But then what is taken as the default choice? Maybe introduce another option for that? For CMSIS, it is recommended to take the Cube kernel, so I just hardcoded itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I updated it. It should work for your case now as well. There is an option to specify whether the Cube FreeRTOS or an external kernel is picked.