diff --git a/cmake/pico_pre_load_toolchain.cmake b/cmake/pico_pre_load_toolchain.cmake index b41b386c..8b03c5f9 100644 --- a/cmake/pico_pre_load_toolchain.cmake +++ b/cmake/pico_pre_load_toolchain.cmake @@ -4,7 +4,7 @@ set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "") # Set a default build type if none was specified set(default_build_type "Release") -list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH) +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH PICO_SDK_PATH) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Defaulting build type to '${default_build_type}' since not specified.") diff --git a/pico_sdk_version.cmake b/pico_sdk_version.cmake index 772ab823..c294d325 100644 --- a/pico_sdk_version.cmake +++ b/pico_sdk_version.cmake @@ -1,15 +1,17 @@ -# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base -# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base -set(PICO_SDK_VERSION_MAJOR 2) -# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base -# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base -set(PICO_SDK_VERSION_MINOR 1) -# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base -# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base -set(PICO_SDK_VERSION_REVISION 2) -# PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base -# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base -set(PICO_SDK_VERSION_PRE_RELEASE_ID develop) +if (NOT DEFINED PICO_SDK_VERSION_MAJOR) + # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base + # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base + set(PICO_SDK_VERSION_MAJOR 2) + # PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base + # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base + set(PICO_SDK_VERSION_MINOR 1) + # PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base + # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base + set(PICO_SDK_VERSION_REVISION 2) + # PICO_BUILD_DEFINE: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base + # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_PRE_RELEASE_ID, Optional SDK pre-release version identifier, default=Current SDK pre-release identifier, type=string, group=pico_base + set(PICO_SDK_VERSION_PRE_RELEASE_ID develop) +endif() # PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base # PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base diff --git a/src/cmake/rp2_common.cmake b/src/cmake/rp2_common.cmake index c02f9e2c..d94d21f3 100644 --- a/src/cmake/rp2_common.cmake +++ b/src/cmake/rp2_common.cmake @@ -63,14 +63,14 @@ pico_add_subdirectory(rp2_common/hardware_watchdog) pico_add_subdirectory(rp2_common/hardware_xip_cache) pico_add_subdirectory(rp2_common/hardware_xosc) -if (PICO_RP2350 OR PICO_COMBINED_DOCS) +if (PICO_COMBINED_DOCS OR NOT PICO_RP2040) pico_add_subdirectory(rp2_common/hardware_powman) # Note in spite of the name this is usable on Arm as well as RISC-V: pico_add_subdirectory(rp2_common/hardware_riscv_platform_timer) pico_add_subdirectory(rp2_common/hardware_sha256) endif() -if (PICO_RP2350 OR PICO_COMBINED_DOCS) +if (PICO_COMBINED_DOCS OR NOT PICO_RP2040) pico_add_subdirectory(rp2_common/hardware_dcp) pico_add_subdirectory(rp2_common/hardware_rcp) endif() @@ -108,7 +108,7 @@ if (NOT PICO_BARE_METAL) pico_add_subdirectory(rp2_common/pico_printf) pico_add_subdirectory(rp2_common/pico_rand) - if (PICO_RP2350 OR PICO_COMBINED_DOCS) + if (PICO_COMBINED_DOCS OR NOT PICO_RP2040) pico_add_subdirectory(rp2_common/pico_sha256) endif() diff --git a/src/rp2040/hardware_regs/include/hardware/platform_defs.h b/src/rp2040/hardware_regs/include/hardware/platform_defs.h index 53798884..a877710d 100644 --- a/src/rp2040/hardware_regs/include/hardware/platform_defs.h +++ b/src/rp2040/hardware_regs/include/hardware/platform_defs.h @@ -46,6 +46,15 @@ #define HAS_SIO_DIVIDER 1 #define HAS_RP2040_RTC 1 + +#ifndef FPGA_CLK_SYS_HZ +#define FPGA_CLK_SYS_HZ (48 * MHZ) +#endif + +#ifndef FPGA_CLK_REF_HZ +#define FPGA_CLK_REF_HZ (12 * MHZ) +#endif + // PICO_CONFIG: XOSC_HZ, Crystal oscillator frequency in Hz, type=int, default=12000000, advanced=true, group=hardware_base // NOTE: The system and USB clocks are generated from the frequency using two PLLs. // If you override this define, or SYS_CLK_HZ/USB_CLK_HZ below, you will *also* need to add your own adjusted PLL set-up defines to diff --git a/src/rp2350/hardware_regs/include/hardware/platform_defs.h b/src/rp2350/hardware_regs/include/hardware/platform_defs.h index 25dc1d62..c919b94c 100644 --- a/src/rp2350/hardware_regs/include/hardware/platform_defs.h +++ b/src/rp2350/hardware_regs/include/hardware/platform_defs.h @@ -73,6 +73,16 @@ #define HAS_POWMAN_TIMER 1 #define HAS_RP2350_TRNG 1 #define HAS_HSTX 1 +#define HAS_PADS_BANK0_ISOLATION 1 +#define __RISCV_PMP_CHECKED 1 + +#ifndef FPGA_CLK_SYS_HZ +#define FPGA_CLK_SYS_HZ (48 * MHZ) +#endif + +#ifndef FPGA_CLK_REF_HZ +#define FPGA_CLK_REF_HZ (12 * MHZ) +#endif // PICO_CONFIG: XOSC_HZ, Crystal oscillator frequency in Hz, type=int, default=12000000, advanced=true, group=hardware_base // NOTE: The system and USB clocks are generated from the frequency using two PLLs. diff --git a/src/rp2_common/boot_bootrom_headers/include/boot/bootrom_constants.h b/src/rp2_common/boot_bootrom_headers/include/boot/bootrom_constants.h index 7f891f7e..e7fe6f63 100644 --- a/src/rp2_common/boot_bootrom_headers/include/boot/bootrom_constants.h +++ b/src/rp2_common/boot_bootrom_headers/include/boot/bootrom_constants.h @@ -255,11 +255,11 @@ typedef int (*bootrom_api_callback_generic_t)(uint32_t r0, uint32_t r1, uint32_t #define BOOTROM_NS_API_get_b_partition 7 #define BOOTROM_NS_API_COUNT 8 -#define OTP_CMD_ROW_BITS 0x0000ffffu +#define OTP_CMD_ROW_BITS _u(0x0000ffff) #define OTP_CMD_ROW_LSB _u(0) -#define OTP_CMD_WRITE_BITS 0x00010000u +#define OTP_CMD_WRITE_BITS _u(0x00010000) #define OTP_CMD_WRITE_LSB _u(16) -#define OTP_CMD_ECC_BITS 0x00020000u +#define OTP_CMD_ECC_BITS _u(0x00020000) #define OTP_CMD_ECC_LSB _u(17) #ifndef __ASSEMBLER__ diff --git a/src/rp2_common/hardware_clocks/clocks.c b/src/rp2_common/hardware_clocks/clocks.c index 1362a3a2..2bcaa574 100644 --- a/src/rp2_common/hardware_clocks/clocks.c +++ b/src/rp2_common/hardware_clocks/clocks.c @@ -270,12 +270,12 @@ static const uint8_t gpin0_src[CLK_COUNT] = { CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_REF CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_SYS CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_PERI -#if !PICO_RP2040 +#if HAS_HSTX CLOCKS_CLK_HSTX_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_HSTX #endif CLOCKS_CLK_USB_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_USB CLOCKS_CLK_ADC_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_ADC -#if PICO_RP2040 +#if HAS_RP2040_RTC CLOCKS_CLK_RTC_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_RTC #endif }; diff --git a/src/rp2_common/hardware_gpio/gpio.c b/src/rp2_common/hardware_gpio/gpio.c index 0a7bf90f..292041a1 100644 --- a/src/rp2_common/hardware_gpio/gpio.c +++ b/src/rp2_common/hardware_gpio/gpio.c @@ -46,7 +46,7 @@ void gpio_set_function(uint gpio, gpio_function_t fn) { // Zero all fields apart from fsel; we want this IO to do what the peripheral tells it. // This doesn't affect e.g. pullup/pulldown, as these are in pad controls. io_bank0_hw->io[gpio].ctrl = fn << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB; -#if !PICO_RP2040 +#if HAS_PADS_BANK0_ISOLATION // Remove pad isolation now that the correct peripheral is in control of the pad hw_clear_bits(&pads_bank0_hw->io[gpio], PADS_BANK0_GPIO0_ISO_BITS); #endif diff --git a/src/rp2_common/hardware_rtc/include/hardware/rtc.h b/src/rp2_common/hardware_rtc/include/hardware/rtc.h index 32317879..9e05c7af 100644 --- a/src/rp2_common/hardware_rtc/include/hardware/rtc.h +++ b/src/rp2_common/hardware_rtc/include/hardware/rtc.h @@ -8,7 +8,9 @@ #define _HARDWARE_RTC_H #include "pico.h" +#if HAS_RP2040_RTC #include "hardware/structs/rtc.h" +#endif /** \file hardware/rtc.h * \defgroup hardware_rtc hardware_rtc diff --git a/src/rp2_common/pico_bit_ops/CMakeLists.txt b/src/rp2_common/pico_bit_ops/CMakeLists.txt index a66a441f..f3e8e1a7 100644 --- a/src/rp2_common/pico_bit_ops/CMakeLists.txt +++ b/src/rp2_common/pico_bit_ops/CMakeLists.txt @@ -19,9 +19,10 @@ if (NOT TARGET pico_bit_ops) ${CMAKE_CURRENT_LIST_DIR}/bit_ops_aeabi.S ) - target_link_libraries(pico_bit_ops_pico INTERFACE pico_bootrom pico_bit_ops_headers) + target_link_libraries(pico_bit_ops_pico INTERFACE pico_bit_ops_headers) - if (NOT PICO_RP2350) + if (PICO_RP2040) + target_link_libraries(pico_bit_ops_pico INTERFACE pico_bootrom) # gcc pico_wrap_function(pico_bit_ops_pico __clzsi2) pico_wrap_function(pico_bit_ops_pico __clzsi2) diff --git a/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S b/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S index 65a1bb4c..88d0bc61 100644 --- a/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S +++ b/src/rp2_common/pico_bit_ops/bit_ops_aeabi.S @@ -5,7 +5,9 @@ */ #include "pico/asm_helper.S" +#if PICO_RP2040 #include "pico/bootrom.h" +#endif #include "pico/runtime_init.h" pico_default_asm_setup diff --git a/src/rp2_common/pico_bootrom/bootrom.c b/src/rp2_common/pico_bootrom/bootrom.c index 0c005351..516a9fb5 100644 --- a/src/rp2_common/pico_bootrom/bootrom.c +++ b/src/rp2_common/pico_bootrom/bootrom.c @@ -113,7 +113,7 @@ int rom_add_flash_runtime_partition(uint32_t start_offset, uint32_t size, uint32 } int rom_pick_ab_update_partition(uint32_t *workarea_base, uint32_t workarea_size, uint partition_a_num) { -#if PICO_RP2350 +#if !PICO_RP2040 // Generated from adding the following code into the bootrom // scan_workarea_t* scan_workarea = (scan_workarea_t*)workarea; // printf("VERSION_DOWNGRADE_ERASE_ADDR %08x\n", &(always->zero_init.version_downgrade_erase_flash_addr)); diff --git a/src/rp2_common/pico_btstack/CMakeLists.txt b/src/rp2_common/pico_btstack/CMakeLists.txt index 593b666f..5fb76fcf 100644 --- a/src/rp2_common/pico_btstack/CMakeLists.txt +++ b/src/rp2_common/pico_btstack/CMakeLists.txt @@ -6,7 +6,7 @@ endif () set(BTSTACK_TEST_PATH "src/bluetooth.h") if (NOT PICO_BTSTACK_PATH) - set(PICO_BTSTACK_PATH ${PROJECT_SOURCE_DIR}/lib/btstack) + set(PICO_BTSTACK_PATH ${PICO_SDK_PATH}/lib/btstack) if (PICO_CYW43_SUPPORTED AND NOT EXISTS ${PICO_BTSTACK_PATH}/${BTSTACK_TEST_PATH}) message(WARNING "btstack submodule has not been initialized; Pico W BLE support will be unavailable. hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") diff --git a/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c b/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c index 91315d19..88b7c945 100644 --- a/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c +++ b/src/rp2_common/pico_fix/rp2040_usb_device_enumeration/rp2040_usb_device_enumeration.c @@ -5,6 +5,7 @@ */ #include "pico.h" +#if PICO_RP2040_B0_SUPPORTED || PICO_RP2040_B1_SUPPORTED #include "pico/time.h" #include "hardware/structs/usb.h" #include "hardware/gpio.h" @@ -17,7 +18,6 @@ #define LS_K 0b10 #define LS_SE1 0b11 -#if PICO_RP2040_B0_SUPPORTED || PICO_RP2040_B1_SUPPORTED static void hw_enumeration_fix_wait_se0(void); static void hw_enumeration_fix_force_ls_j(void); static void hw_enumeration_fix_finish(void); diff --git a/src/rp2_common/pico_lwip/CMakeLists.txt b/src/rp2_common/pico_lwip/CMakeLists.txt index 7897754e..71da0017 100644 --- a/src/rp2_common/pico_lwip/CMakeLists.txt +++ b/src/rp2_common/pico_lwip/CMakeLists.txt @@ -6,7 +6,7 @@ endif () set(LWIP_TEST_PATH "src/Filelists.cmake") if (NOT PICO_LWIP_PATH) - set(PICO_LWIP_PATH ${PROJECT_SOURCE_DIR}/lib/lwip) + set(PICO_LWIP_PATH ${PICO_SDK_PATH}/lib/lwip) if (PICO_CYW43_SUPPORTED AND NOT EXISTS ${PICO_LWIP_PATH}/${LWIP_TEST_PATH}) message(WARNING "LWIP submodule has not been initialized; Pico W wireless support will be unavailable #hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") diff --git a/src/rp2_common/pico_mbedtls/CMakeLists.txt b/src/rp2_common/pico_mbedtls/CMakeLists.txt index 19fe4782..608b457e 100644 --- a/src/rp2_common/pico_mbedtls/CMakeLists.txt +++ b/src/rp2_common/pico_mbedtls/CMakeLists.txt @@ -6,7 +6,7 @@ endif() set(MBEDTLS_TEST_PATH "library/aes.c") if (NOT PICO_MBEDTLS_PATH) - set(PICO_MBEDTLS_PATH ${PROJECT_SOURCE_DIR}/lib/mbedtls) + set(PICO_MBEDTLS_PATH ${PICO_SDK_PATH}/lib/mbedtls) elseif (NOT EXISTS ${PICO_MBEDTLS_PATH}/${MBEDTLS_TEST_PATH}) message(WARNING "PICO_MBEDTLS_PATH specified but content not present.") endif() diff --git a/src/rp2_common/pico_multicore/multicore.c b/src/rp2_common/pico_multicore/multicore.c index 73a1a999..219f24a1 100644 --- a/src/rp2_common/pico_multicore/multicore.c +++ b/src/rp2_common/pico_multicore/multicore.c @@ -14,7 +14,7 @@ #include "hardware/structs/scb.h" #endif #include "hardware/structs/sio.h" -#include "hardware/regs/psm.h" +#include "hardware/structs/psm.h" #include "hardware/claim.h" #if !PICO_RP2040 diff --git a/src/rp2_common/pico_printf/printf_none.S b/src/rp2_common/pico_printf/printf_none.S index 0148f265..57cf3441 100644 --- a/src/rp2_common/pico_printf/printf_none.S +++ b/src/rp2_common/pico_printf/printf_none.S @@ -5,7 +5,6 @@ */ #include "pico/asm_helper.S" -#include "pico/bootrom/sf_table.h" pico_default_asm_setup diff --git a/src/rp2_common/pico_rand/CMakeLists.txt b/src/rp2_common/pico_rand/CMakeLists.txt index 9af7d470..24db85c2 100644 --- a/src/rp2_common/pico_rand/CMakeLists.txt +++ b/src/rp2_common/pico_rand/CMakeLists.txt @@ -7,8 +7,13 @@ target_sources(pico_rand INTERFACE target_include_directories(pico_rand_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) pico_mirrored_target_link_libraries(pico_rand INTERFACE - pico_unique_id hardware_clocks hardware_timer hardware_sync ) + +if (TARGET pico_unique_id) + pico_mirrored_target_link_libraries(pico_rand INTERFACE + pico_unique_id + ) +endif() \ No newline at end of file diff --git a/src/rp2_common/pico_rand/rand.c b/src/rp2_common/pico_rand/rand.c index 794c63e4..03b0e3d6 100644 --- a/src/rp2_common/pico_rand/rand.c +++ b/src/rp2_common/pico_rand/rand.c @@ -25,11 +25,19 @@ */ #include "pico/rand.h" +#if PICO_RAND_SEED_ENTROPY_SRC_BOARD_ID #include "pico/unique_id.h" +#endif +#if PICO_RAND_ENTROPY_SRC_TIME #include "pico/time.h" +#endif #include "hardware/clocks.h" +#if PICO_RAND_SEED_ENTROPY_SRC_ROSC || PICO_RAND_ENTROPY_SRC_ROSC #include "hardware/structs/rosc.h" +#endif +#if PICO_RAND_SEED_ENTROPY_SRC_BUS_PERF_COUNTER || PICO_RAND_ENTROPY_SRC_BUS_PERF_COUNTER #include "hardware/structs/busctrl.h" +#endif #include "hardware/sync.h" static bool rng_initialised = false; diff --git a/src/rp2_common/pico_runtime_init/CMakeLists.txt b/src/rp2_common/pico_runtime_init/CMakeLists.txt index 81f6ab47..60d1833e 100644 --- a/src/rp2_common/pico_runtime_init/CMakeLists.txt +++ b/src/rp2_common/pico_runtime_init/CMakeLists.txt @@ -13,7 +13,13 @@ pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE ) if (TARGET hardware_clocks) - pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE hardware_clocks hardware_timer hardware_vreg) + pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE hardware_clocks) +endif() +if (TARGET hardware_timer) + pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE hardware_timer) +endif() +if (TARGET hardware_vreg) + pico_mirrored_target_link_libraries(pico_runtime_init INTERFACE hardware_vreg) endif() # pico/runtime_init.h includes pico/runtime.h diff --git a/src/rp2_common/pico_runtime_init/runtime_init_clocks.c b/src/rp2_common/pico_runtime_init/runtime_init_clocks.c index 85d473b8..a86fe805 100644 --- a/src/rp2_common/pico_runtime_init/runtime_init_clocks.c +++ b/src/rp2_common/pico_runtime_init/runtime_init_clocks.c @@ -41,10 +41,10 @@ void __weak runtime_init_clocks(void) { // Note: These need setting *before* the ticks are started if (running_on_fpga()) { for (uint i = 0; i < CLK_COUNT; i++) { - clock_set_reported_hz(i, 48 * MHZ); + clock_set_reported_hz(i, FPGA_CLK_SYS_HZ); } // clk_ref is 12MHz in both RP2040 and RP2350 FPGA - clock_set_reported_hz(clk_ref, 12 * MHZ); + clock_set_reported_hz(clk_ref, FPGA_CLK_REF_HZ); // RP2040 has an extra clock, the rtc #if HAS_RP2040_RTC clock_set_reported_hz(clk_rtc, RTC_CLOCK_FREQ_HZ); diff --git a/src/rp2_common/pico_runtime_init/runtime_init_stack_guard.c b/src/rp2_common/pico_runtime_init/runtime_init_stack_guard.c index 27480f2c..964742eb 100644 --- a/src/rp2_common/pico_runtime_init/runtime_init_stack_guard.c +++ b/src/rp2_common/pico_runtime_init/runtime_init_stack_guard.c @@ -32,7 +32,7 @@ void runtime_init_per_core_install_stack_guard(void *stack_bottom) { | 0x10000000; // XN = disable instruction fetch; no other bits means no permissions #elif defined(__riscv) - #if !PICO_RP2350 +#if !__RISCV_PMP_CHECKED #error "Check PMP configuration for new platform" #endif // RISC-V PMP, RP2350 configuration of Hazard3: 8 non-hardwired regions, diff --git a/src/rp2_common/pico_stdio_uart/stdio_uart.c b/src/rp2_common/pico_stdio_uart/stdio_uart.c index 54cd86e0..2e2619c1 100644 --- a/src/rp2_common/pico_stdio_uart/stdio_uart.c +++ b/src/rp2_common/pico_stdio_uart/stdio_uart.c @@ -128,13 +128,13 @@ void stdio_uart_deinit_full(struct uart_inst *uart, int tx_pin, int rx_pin) { uart_instance = uart; stdio_set_driver_enabled(&stdio_uart, false); uart_deinit(uart_instance); -#if PICO_RP2040 - ((void)tx_pin); - ((void)rx_pin); -#else +#if HAS_PADS_BANK0_ISOLATION // Leave pads isolated if (tx_pin >= 0) hw_set_bits(&pads_bank0_hw->io[tx_pin], PADS_BANK0_GPIO0_ISO_BITS); if (rx_pin >= 0) hw_set_bits(&pads_bank0_hw->io[rx_pin], PADS_BANK0_GPIO0_ISO_BITS); +#else + ((void)tx_pin); + ((void)rx_pin); #endif } diff --git a/src/rp2_common/tinyusb/CMakeLists.txt b/src/rp2_common/tinyusb/CMakeLists.txt index 3e12439c..e4115f89 100644 --- a/src/rp2_common/tinyusb/CMakeLists.txt +++ b/src/rp2_common/tinyusb/CMakeLists.txt @@ -4,15 +4,19 @@ if (DEFINED ENV{PICO_TINYUSB_PATH} AND (NOT PICO_TINYUSB_PATH)) message("Using PICO_TINYUSB_PATH from environment ('${PICO_TINYUSB_PATH}')") endif () -set(TINYUSB_TEST_PATH "src/portable/raspberrypi/rp2040") +set(TINYUSB_TEST_PATH "hw/bsp/rp2040") if (NOT PICO_TINYUSB_PATH) - set(PICO_TINYUSB_PATH ${PROJECT_SOURCE_DIR}/lib/tinyusb) + set(PICO_TINYUSB_PATH ${PICO_SDK_PATH}/lib/tinyusb) if (NOT EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) - message(WARNING "TinyUSB submodule has not been initialized; USB support will be unavailable + if (EXISTS "${PICO_TINYUSB_PATH}/LICENSE") + message(WARNING "TinyUSB submodule has been initialized, but does not contain ${TINYUSB_TEST_PATH}; USB support will be unavailable") + else() + message(WARNING "TinyUSB submodule has not been initialized; USB support will be unavailable hint: try 'git submodule update --init' from your SDK directory (${PICO_SDK_PATH}).") + endif() endif() elseif (NOT EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) - message(WARNING "PICO_TINYUSB_PATH specified but content not present.") + message(WARNING "PICO_TINYUSB_PATH specified, but does not contain ${TINYUSB_TEST_PATH}; USB support will be unavailable") endif() if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) @@ -35,14 +39,18 @@ if (EXISTS ${PICO_TINYUSB_PATH}/${TINYUSB_TEST_PATH}) PICO_RP2040_USB_DEVICE_UFRAME_FIX=1 ) - # unmarked version used by stdio USB - target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration tinyusb_device_base) + if (TARGET tinyusb_device_base) + # unmarked version used by stdio USB + target_link_libraries(tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration tinyusb_device_base) - pico_add_library(tinyusb_device) - target_link_libraries(tinyusb_device INTERFACE tinyusb_device_unmarked) + pico_add_library(tinyusb_device) + target_link_libraries(tinyusb_device INTERFACE tinyusb_device_unmarked) + endif() - pico_add_library(tinyusb_host) - target_link_libraries(tinyusb_host INTERFACE tinyusb_host_base tinyusb_common) + if (TARGET tinyusb_host_base) + pico_add_library(tinyusb_host) + target_link_libraries(tinyusb_host INTERFACE tinyusb_host_base tinyusb_common) + endif() pico_add_library(tinyusb_board) target_include_directories(tinyusb_board INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include) diff --git a/test/cmsis_test/CMakeLists.txt b/test/cmsis_test/CMakeLists.txt index ca992eea..f6b095b4 100644 --- a/test/cmsis_test/CMakeLists.txt +++ b/test/cmsis_test/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET cmsis_core) + message("Skipping cmsis_test as cmsis_core is unavailable on this platform") + return() +endif() # todo remove check if (NOT PICO_RISCV) add_executable(cmsis_test cmsis_test.c) diff --git a/test/hardware_irq_test/CMakeLists.txt b/test/hardware_irq_test/CMakeLists.txt index 90ef50a2..f329e617 100644 --- a/test/hardware_irq_test/CMakeLists.txt +++ b/test/hardware_irq_test/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET hardware_dma) + message("Skipping hardware_irq_test as hardware_dma is unavailable on this platform") + return() +endif() add_executable(hardware_irq_test hardware_irq_test.c) target_link_libraries(hardware_irq_test PRIVATE pico_test hardware_irq hardware_dma) diff --git a/test/hardware_pwm_test/CMakeLists.txt b/test/hardware_pwm_test/CMakeLists.txt index c0e08a46..c26893cc 100644 --- a/test/hardware_pwm_test/CMakeLists.txt +++ b/test/hardware_pwm_test/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET hardware_pwm) + message("Skipping hardware_pwm_test as hardware_pwm is unavailable on this platform") + return() +endif() add_executable(hardware_pwm_test hardware_pwm_test.c) target_link_libraries(hardware_pwm_test PRIVATE pico_test hardware_pwm) diff --git a/test/hardware_sync_spin_lock_test/CMakeLists.txt b/test/hardware_sync_spin_lock_test/CMakeLists.txt index 36edf813..e81069aa 100644 --- a/test/hardware_sync_spin_lock_test/CMakeLists.txt +++ b/test/hardware_sync_spin_lock_test/CMakeLists.txt @@ -1,3 +1,8 @@ +if (NOT TARGET pico_multicore) + message("Skipping hardware_sync_spin_lock_test as pico_multicore is unavailable on this platform") + return() +endif() + add_executable(hardware_sync_spin_lock_test hardware_sync_spin_lock_test.c) target_link_libraries(hardware_sync_spin_lock_test PRIVATE pico_test hardware_sync pico_multicore) diff --git a/test/pico_divider_test/CMakeLists.txt b/test/pico_divider_test/CMakeLists.txt index b180b9d7..94d73100 100644 --- a/test/pico_divider_test/CMakeLists.txt +++ b/test/pico_divider_test/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT TARGET pico_divider) + message("Skipping pico_divider_test as pico_divider is unavailable on this platform") + return() +endif() PROJECT(pico_divider_test) if (PICO_ON_DEVICE) diff --git a/test/pico_float_test/CMakeLists.txt b/test/pico_float_test/CMakeLists.txt index 93845bb3..8bf0de20 100644 --- a/test/pico_float_test/CMakeLists.txt +++ b/test/pico_float_test/CMakeLists.txt @@ -1,3 +1,8 @@ +if (NOT TARGET pico_float) + message("Skipping pico_float_test as pico_float is unavailable on this platform") + return() +endif() + PROJECT(pico_float_test) diff --git a/test/pico_sha256_test/CMakeLists.txt b/test/pico_sha256_test/CMakeLists.txt index 8474f3ed..8dc6dd32 100644 --- a/test/pico_sha256_test/CMakeLists.txt +++ b/test/pico_sha256_test/CMakeLists.txt @@ -1,4 +1,5 @@ -if (NOT TARGET hardware_sha256) +if (NOT TARGET pico_sha256) + message("Skipping pico_sha256_test as pico_sha256 is unavailable on this platform") return() endif() diff --git a/test/pico_time_test/pico_time_test.c b/test/pico_time_test/pico_time_test.c index 8b23c5a4..9ed05e20 100644 --- a/test/pico_time_test/pico_time_test.c +++ b/test/pico_time_test/pico_time_test.c @@ -41,8 +41,8 @@ static struct timeout { alarm_id_t alarm_id; absolute_time_t target; absolute_time_t fired_at; - uint pool; uint fired_count; + uint8_t pool; bool cancelled; bool not_cancelled; // tried to cancel but it was done } timeouts[NUM_TIMEOUTS]; diff --git a/tools/Findpicotool.cmake b/tools/Findpicotool.cmake index e5bfaeaa..79a8d2ed 100644 --- a/tools/Findpicotool.cmake +++ b/tools/Findpicotool.cmake @@ -34,10 +34,20 @@ if (NOT TARGET picotool) ) endif() + if (NOT PICOTOOL_GIT_REPOSITORY_URL) + set(PICOTOOL_GIT_REPOSITORY_URL https://github.com/raspberrypi/picotool.git) + endif() + if (NOT PICOTOOL_GIT_BRANCH) + if (PICO_SDK_VERSION_PRE_RELEASE_ID) + set(PICOTOOL_GIT_BRANCH ${PICO_SDK_VERSION_PRE_RELEASE_ID}) + else() + set(PICOTOOL_GIT_BRANCH ${PICO_SDK_VERSION_STRING}) + endif() + endif() message("Downloading Picotool") FetchContent_Populate(picotool QUIET - GIT_REPOSITORY https://github.com/raspberrypi/picotool.git - GIT_TAG develop + GIT_REPOSITORY ${PICOTOOL_GIT_REPOSITORY_URL} + GIT_TAG ${PICOTOOL_GIT_BRANCH} SOURCE_DIR ${picotool_INSTALL_DIR}/picotool-src BINARY_DIR ${picotool_INSTALL_DIR}/picotool-build