mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2026-03-14 21:19:43 +01:00
Allow 'host' platform to simulate either RP2040 or RP2350
The 'host' platform only really partially simulates an RP2040 environment, with no way to specify a particular board either, so attempting to build a host version of a existing code that uses an RP2350 or relies on values defined in a board file is either difficult or impossible. Instead of setting PICO_PLATFORM to just 'host', it can now be set to 'host-rp2040' or 'host-rp2350' and PICO_BOARD can be set to any board configuration that is compatible with the given chip type. Platform definitions for the given chip will be fetched, meaning defines such as 'NUM_IRQS' will be set correctly. Fixes #2778
This commit is contained in:
parent
52d3592d41
commit
754bdf16bf
11 changed files with 101 additions and 92 deletions
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
|
@ -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
|
||||
|
|
|
|||
0
cmake/preload/platforms/host-rp2350-arm-s.cmake
Normal file
0
cmake/preload/platforms/host-rp2350-arm-s.cmake
Normal file
0
cmake/preload/platforms/host-rp2350-riscv.cmake
Normal file
0
cmake/preload/platforms/host-rp2350-riscv.cmake
Normal file
|
|
@ -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()
|
||||
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
src/host-rp2040.cmake
Normal file
19
src/host-rp2040.cmake
Normal file
|
|
@ -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
src/host-rp2350-arm-s.cmake
Normal file
20
src/host-rp2350-arm-s.cmake
Normal file
|
|
@ -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)
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
set(CMAKE_DIR cmake)
|
||||
set(COMMON_DIR common)
|
||||
set(HOST_DIR host)
|
||||
|
||||
include (${CMAKE_DIR}/no_hardware.cmake)
|
||||
|
||||
|
||||
# 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)
|
||||
|
||||
unset(CMAKE_DIR)
|
||||
unset(COMMON_DIR)
|
||||
unset(HOST_DIR)
|
||||
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _HARDWARE_PLATFORM_DEFS_H
|
||||
#define _HARDWARE_PLATFORM_DEFS_H
|
||||
|
||||
#define NUM_CORES 2u
|
||||
|
||||
#define NUM_DMA_CHANNELS 12u
|
||||
|
||||
#define NUM_GENERIC_TIMERS 1u
|
||||
#define NUM_ALARMS 4u
|
||||
|
||||
#define NUM_IRQS 32u
|
||||
#define NUM_USER_IRQS 6u
|
||||
#define FIRST_USER_IRQ (NUM_IRQS - NUM_USER_IRQS)
|
||||
#define VTABLE_FIRST_IRQ 16
|
||||
|
||||
#define NUM_SPIN_LOCKS 32u
|
||||
|
||||
#define XOSC_HZ 12000000u
|
||||
|
||||
#define NUM_SPIN_LOCKS 32u
|
||||
|
||||
#define NUM_BANK0_GPIOS 30
|
||||
|
||||
#ifndef _u
|
||||
#define _u(x) x ## u
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue