Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions cmake/pico_pre_load_platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ if (DEFINED ENV{PICO_PLATFORM} AND NOT PICO_PLATFORM)
set(PICO_PLATFORM $ENV{PICO_PLATFORM})
message("Initializing PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
endif()

if (${PICO_PLATFORM} STREQUAL "host")
set(PICO_PLATFORM "host-rp2040")
endif()

set(PICO_SAVED_PLATFORM "${PICO_PLATFORM}")

# If PICO_PLATFORM is specified but not PICO_BOARD, we'll make a stab at defaulting
Expand Down Expand Up @@ -88,11 +93,12 @@ endif()

if (NOT COMMAND pico_expand_pico_platform)
function(pico_expand_pico_platform FUNC DO_MESSAGE)
if (${FUNC} STREQUAL "rp2350")
if (${FUNC} MATCHES "rp2350$")
string(REGEX REPLACE "rp2350$" "${PICO_DEFAULT_RP2350_PLATFORM}" NEW_PLATFORM ${${FUNC}})
if (DO_MESSAGE)
message("Auto-converting non-specific PICO_PLATFORM='rp2350' to '${PICO_DEFAULT_RP2350_PLATFORM}'")
message("Auto-converting non-specific PICO_PLATFORM='${${FUNC}}' to '${NEW_PLATFORM}'")
endif()
set(${FUNC} "${PICO_DEFAULT_RP2350_PLATFORM}" PARENT_SCOPE)
set(${FUNC} "${NEW_PLATFORM}" PARENT_SCOPE)
endif()
endfunction()
endif()
Expand All @@ -105,8 +111,9 @@ else()
pico_expand_pico_platform(PICO_PLATFORM 1)
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' based on PICO_BOARD setting.")
else()
string(REGEX REPLACE "-.*" "" PICO_PLATFORM_PREFIX ${PICO_PLATFORM})
string(REGEX REPLACE "-.*" "" PICO_SAVED_PLATFORM_PREFIX ${PICO_SAVED_PLATFORM})
string(REGEX REPLACE "((host-)?(rp[0-9]+))(-.*)?" "\\3" PICO_PLATFORM_PREFIX ${PICO_PLATFORM})
string(REGEX REPLACE "((host-)?(rp[0-9]+))(-.*)?" "\\3" PICO_SAVED_PLATFORM_PREFIX ${PICO_SAVED_PLATFORM})

if (PICO_PLATFORM_PREFIX STREQUAL PICO_SAVED_PLATFORM_PREFIX)
# the PICO_PLATFORM specified based on the board is compatible based on the one we were
# already using, so use that
Expand Down
Empty file.
Empty file.
8 changes: 2 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ macro(pico_simple_hardware_headers_target NAME)

target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs hardware_claim_headers)
endif()
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs hardware_claim_headers)
endif()
endmacro()

Expand All @@ -141,9 +139,7 @@ macro(pico_simple_hardware_headers_only_target NAME)
# a headers only target should still have an explicit _headers library for consistency
target_include_directories(hardware_${NAME}_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_link_libraries(hardware_${NAME}_headers INTERFACE pico_base_headers)
if (NOT PICO_NO_HARDWARE)
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs)
endif()
target_link_libraries(hardware_${NAME}_headers INTERFACE hardware_structs)

add_library(hardware_${NAME} INTERFACE)
target_link_libraries(hardware_${NAME} INTERFACE hardware_${NAME}_headers)
Expand Down
41 changes: 40 additions & 1 deletion src/cmake/no_hardware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,43 @@ function(pico_add_extra_outputs TARGET)
endfunction()

set(PICO_NO_HARDWARE "1" CACHE INTERNAL "")
set(PICO_ON_DEVICE "0" CACHE INTERNAL "")
set(PICO_ON_DEVICE "0" CACHE INTERNAL "")

# RP2040/RP2350 specific From standard build variants
pico_add_subdirectory(${RP2_VARIANT_DIR}/hardware_regs)
pico_add_subdirectory(${RP2_VARIANT_DIR}/hardware_structs)

# common
pico_add_subdirectory(${COMMON_DIR}/boot_picobin_headers)
pico_add_subdirectory(${COMMON_DIR}/boot_picoboot_headers)
pico_add_subdirectory(${COMMON_DIR}/boot_uf2_headers)
pico_add_subdirectory(${COMMON_DIR}/hardware_claim)
pico_add_subdirectory(${COMMON_DIR}/pico_base_headers)
pico_add_subdirectory(${COMMON_DIR}/pico_usb_reset_interface_headers)
pico_add_subdirectory(${COMMON_DIR}/pico_bit_ops_headers)
pico_add_subdirectory(${COMMON_DIR}/pico_binary_info)
pico_add_subdirectory(${COMMON_DIR}/pico_divider_headers)
pico_add_subdirectory(${COMMON_DIR}/pico_sync)
pico_add_subdirectory(${COMMON_DIR}/pico_time)
pico_add_subdirectory(${COMMON_DIR}/pico_util)
pico_add_subdirectory(${COMMON_DIR}/pico_stdlib_headers)

# host-specific
pico_add_subdirectory(${HOST_DIR}/hardware_divider)
pico_add_subdirectory(${HOST_DIR}/hardware_gpio)
pico_add_subdirectory(${HOST_DIR}/hardware_irq)
pico_add_subdirectory(${HOST_DIR}/hardware_sync)
pico_add_subdirectory(${HOST_DIR}/hardware_timer)
pico_add_subdirectory(${HOST_DIR}/hardware_uart)
pico_add_subdirectory(${HOST_DIR}/pico_bit_ops)
pico_add_subdirectory(${HOST_DIR}/pico_divider)
pico_add_subdirectory(${HOST_DIR}/pico_multicore)
pico_add_subdirectory(${HOST_DIR}/pico_platform)
pico_add_subdirectory(${HOST_DIR}/pico_rand)
pico_add_subdirectory(${HOST_DIR}/pico_runtime)
pico_add_subdirectory(${HOST_DIR}/pico_printf)
pico_add_subdirectory(${HOST_DIR}/pico_status_led)
pico_add_subdirectory(${HOST_DIR}/pico_stdio)
pico_add_subdirectory(${HOST_DIR}/pico_stdlib)
pico_add_subdirectory(${HOST_DIR}/pico_time_adapter)
pico_add_subdirectory(${HOST_DIR}/pico_unique_id)
19 changes: 19 additions & 0 deletions src/host-rp2040.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(CMAKE_DIR cmake)
set(COMMON_DIR common)
set(HOST_DIR host)

# include everything needed to build against rp2040

set(PICO_RP2040 "1" CACHE INTERNAL "")
set(PICO_RP2350 "0" CACHE INTERNAL "")
set(PICO_RISCV "0" CACHE INTERNAL "")
set(PICO_ARM "0" CACHE INTERNAL "")
set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2040)
set(PICO_CMSIS_DEVICE "RP2040" CACHE INTERNAL "")
set(PICO_DEFAULT_FLASH_SIZE_BYTES "2 * 1024 * 1024")

include (${CMAKE_DIR}/no_hardware.cmake)

unset(CMAKE_DIR)
unset(COMMON_DIR)
unset(HOST_DIR)
20 changes: 20 additions & 0 deletions src/host-rp2350-arm-s.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(CMAKE_DIR cmake)
set(COMMON_DIR common)
set(HOST_DIR host)

# include everything needed to build against rp2350

set(PICO_RP2040 "0" CACHE INTERNAL "")
set(PICO_RP2350 "1" CACHE INTERNAL "")
set(PICO_RISCV "0" CACHE INTERNAL "")
set(PICO_ARM "0" CACHE INTERNAL "")
set(RP2_VARIANT_DIR ${CMAKE_CURRENT_LIST_DIR}/rp2350)
set(PICO_PIO_VERSION "1" CACHE INTERNAL "")
set(PICO_CMSIS_DEVICE "RP2350" CACHE INTERNAL "")
set(PICO_DEFAULT_FLASH_SIZE_BYTES "4 * 1024 * 1024")

include (${CMAKE_DIR}/no_hardware.cmake)

unset(CMAKE_DIR)
unset(COMMON_DIR)
unset(HOST_DIR)
45 changes: 0 additions & 45 deletions src/host.cmake

This file was deleted.

9 changes: 8 additions & 1 deletion src/host/pico_platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

if (NOT TARGET pico_platform_headers)
add_library(pico_platform_headers INTERFACE)

target_compile_definitions(pico_platform_headers INTERFACE
PICO_NO_HARDWARE=1
PICO_ON_DEVICE=0
PICO_BUILD=1
)

if (DEFINED PICO_RP2040 AND ${PICO_RP2040})
target_compile_definitions(pico_platform_headers INTERFACE PICO_RP2040=1)
endif()

if (DEFINED PICO_RP2350 AND ${PICO_RP2350})
target_compile_definitions(pico_platform_headers INTERFACE PICO_RP2350=1)
endif()

target_include_directories(pico_platform_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
endif()

Expand Down
34 changes: 0 additions & 34 deletions src/host/pico_platform/include/hardware/platform_defs.h

This file was deleted.