mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
RP2040: Allow FreeRTOS to be added to the parent CMake project post initialization of the Pico SDK (#497)
Co-authored-by: graham sanderson <graham.sanderson@raspeberryi.com>
This commit is contained in:
parent
7af41c29cb
commit
d2a81539e0
37
portable/ThirdParty/GCC/RP2040/CMakeLists.txt
vendored
37
portable/ThirdParty/GCC/RP2040/CMakeLists.txt
vendored
|
@ -21,20 +21,31 @@ if (NOT TARGET _FreeRTOS_kernel_inclusion_marker)
|
||||||
|
|
||||||
pico_is_top_level_project(FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
|
pico_is_top_level_project(FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
|
||||||
|
|
||||||
# The real work gets done in library.cmake which is called at the end of pico_sdk_init
|
# if the SDK has already been initialized, then just add our libraries now - this allows
|
||||||
list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/library.cmake)
|
# this FreeRTOS port to just be added as a sub-directory or include within another project, rather than
|
||||||
|
# having to include it at the top level before pico_sdk_init()
|
||||||
# We need to inject the following header file into ALL SDK files (which we do via the config header)
|
if (TARGET _pico_sdk_inclusion_marker)
|
||||||
list(APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/include/freertos_sdk_config.h)
|
if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.2")
|
||||||
|
message(FATAL_ERROR "Require at least Raspberry Pi Pico SDK version 1.3.2 to include FreeRTOS after pico_sdk_init()")
|
||||||
if (FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
|
endif()
|
||||||
message("FreeRTOS: initialize SDK since we're the top-level")
|
include(${CMAKE_CURRENT_LIST_DIR}/library.cmake)
|
||||||
# Initialize the SDK
|
|
||||||
pico_sdk_init()
|
|
||||||
else()
|
else()
|
||||||
set(PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
|
# The real work gets done in library.cmake which is called at the end of pico_sdk_init
|
||||||
set(PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
|
list(APPEND PICO_SDK_POST_LIST_FILES ${CMAKE_CURRENT_LIST_DIR}/library.cmake)
|
||||||
set(FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} PARENT_SCOPE)
|
if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.2")
|
||||||
|
# We need to inject the following header file into ALL SDK files (which we do via the config header)
|
||||||
|
list(APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/include/freertos_sdk_config.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (FREERTOS_KERNEL_TOP_LEVEL_PROJECT)
|
||||||
|
message("FreeRTOS: initialize SDK since we're the top-level")
|
||||||
|
# Initialize the SDK
|
||||||
|
pico_sdk_init()
|
||||||
|
else()
|
||||||
|
set(FREERTOS_KERNEL_PATH ${FREERTOS_KERNEL_PATH} PARENT_SCOPE)
|
||||||
|
set(PICO_CONFIG_HEADER_FILES ${PICO_CONFIG_HEADER_FILES} PARENT_SCOPE)
|
||||||
|
set(PICO_SDK_POST_LIST_FILES ${PICO_SDK_POST_LIST_FILES} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
20
portable/ThirdParty/GCC/RP2040/README.md
vendored
20
portable/ThirdParty/GCC/RP2040/README.md
vendored
|
@ -10,16 +10,28 @@ Note that a FreeRTOS SMP version of this port is also available in the FreeRTOS-
|
||||||
|
|
||||||
## Using this port
|
## Using this port
|
||||||
|
|
||||||
Copy [FreeRTOS-Kernel-import.cmake](FreeRTOS-Kernel-import.cmake) into your project, and
|
You can copy [FreeRTOS-Kernel-import.cmake](FreeRTOS-Kernel-import.cmake) into your project, and
|
||||||
add:
|
add the following in your `CMakeLists.txt`:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
import(FreeRTOS_Kernel_import.cmake)
|
import(FreeRTOS_Kernel_import.cmake)
|
||||||
```
|
```
|
||||||
|
|
||||||
below the usual import of `pico_sdk_import.cmake`
|
This will locate the FreeRTOS kernel if it is a direct sub-module of your project, or if you provide the
|
||||||
|
`FREERTOS_KERNEL_PATH` variable in your environment or via `-DFREERTOS_KERNEL_PATH=/path/to/FreeRTOS-Kernel` on the CMake command line.
|
||||||
|
|
||||||
|
**NOTE:** If you are using version 1.3.1 or older of the Raspberry Pi Pico SDK then this line must appear before the
|
||||||
|
`pico_sdk_init()` and will cause FreeRTOS to be included/required in all RP2040 targets in your project. After this SDK
|
||||||
|
version, you can include the FreeRTOS-Kernel support later in your CMake build (possibly in a subdirectory) and the
|
||||||
|
FreeRTOS-Kernel support will only apply to those targets which explicitly include FreeRTOS support.
|
||||||
|
|
||||||
|
As an alternative to the `import` statement above, you can just add this directory directly via thw following (with
|
||||||
|
the same placement restrictions related to the Raspberry Pi Pico SDK version above):
|
||||||
|
|
||||||
|
```cmake
|
||||||
|
add_subdirectory(path/to/this/directory FreeRTOS-Kernel)
|
||||||
|
```
|
||||||
|
|
||||||
This will find the FreeRTOS kernel if it is a direct sub-module of your project, or if you provide the `FREERTOS_KERNEL_PATH` variable in your environment or via `-DFREERTOS_KERNEL_PATH=/path/to/FreeRTOS-Kernel` on the CMake command line.
|
|
||||||
|
|
||||||
## Advanced Configuration
|
## Advanced Configuration
|
||||||
|
|
||||||
|
|
5
portable/ThirdParty/GCC/RP2040/library.cmake
vendored
5
portable/ThirdParty/GCC/RP2040/library.cmake
vendored
|
@ -16,6 +16,11 @@ target_sources(FreeRTOS-Kernel-Core INTERFACE
|
||||||
)
|
)
|
||||||
target_include_directories(FreeRTOS-Kernel-Core INTERFACE ${FREERTOS_KERNEL_PATH}/include)
|
target_include_directories(FreeRTOS-Kernel-Core INTERFACE ${FREERTOS_KERNEL_PATH}/include)
|
||||||
|
|
||||||
|
if (PICO_SDK_VERSION_STRING VERSION_GREATER_EQUAL "1.3.2")
|
||||||
|
target_compile_definitions(FreeRTOS-Kernel-Core INTERFACE
|
||||||
|
PICO_CONFIG_RTOS_ADAPTER_HEADER=${CMAKE_CURRENT_LIST_DIR}/include/freertos_sdk_config.h)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(FreeRTOS-Kernel INTERFACE)
|
add_library(FreeRTOS-Kernel INTERFACE)
|
||||||
target_sources(FreeRTOS-Kernel INTERFACE
|
target_sources(FreeRTOS-Kernel INTERFACE
|
||||||
${CMAKE_CURRENT_LIST_DIR}/port.c
|
${CMAKE_CURRENT_LIST_DIR}/port.c
|
||||||
|
|
Loading…
Reference in a new issue