Skip to content

Commit 4242010

Browse files
authored
Misc cleanup (#2569)
* miscellaneous cleanup: * cleanup some #ifdefs which were slightly hacky when RP2350 was added; use HAS_ flags in preference to PICO_RP2040/RP2350 * make some dependencies more explicit - i.e. compile if the user doesn't want to include certain libraries * cleanup some directory A -> directory B relative path names in CMakeLists.txt to be SDK root -> directory B
1 parent 4003a64 commit 4242010

File tree

34 files changed

+143
-54
lines changed

34 files changed

+143
-54
lines changed

cmake/pico_pre_load_toolchain.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(PICO_TOOLCHAIN_PATH "${PICO_TOOLCHAIN_PATH}" CACHE INTERNAL "")
44
# Set a default build type if none was specified
55
set(default_build_type "Release")
66

7-
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH)
7+
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PREFIX_PATH PICO_SDK_PATH)
88

99
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1010
message(STATUS "Defaulting build type to '${default_build_type}' since not specified.")

pico_sdk_version.cmake

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
2-
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
3-
set(PICO_SDK_VERSION_MAJOR 2)
4-
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
5-
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
6-
set(PICO_SDK_VERSION_MINOR 1)
7-
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
8-
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
9-
set(PICO_SDK_VERSION_REVISION 2)
10-
# 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
11-
# 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
12-
set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
1+
if (NOT DEFINED PICO_SDK_VERSION_MAJOR)
2+
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
3+
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MAJOR, SDK major version number, type=int, default=Current SDK major version, group=pico_base
4+
set(PICO_SDK_VERSION_MAJOR 2)
5+
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
6+
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_MINOR, SDK minor version number, type=int, default=Current SDK minor version, group=pico_base
7+
set(PICO_SDK_VERSION_MINOR 1)
8+
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
9+
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_REVISION, SDK version revision, type=int, default=Current SDK revision, group=pico_base
10+
set(PICO_SDK_VERSION_REVISION 2)
11+
# 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
12+
# 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
13+
set(PICO_SDK_VERSION_PRE_RELEASE_ID develop)
14+
endif()
1315

1416
# PICO_BUILD_DEFINE: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base
1517
# PICO_CMAKE_CONFIG: PICO_SDK_VERSION_STRING, SDK version string, type=string, default=Current SDK version string, group=pico_base

src/cmake/rp2_common.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ pico_add_subdirectory(rp2_common/hardware_watchdog)
6363
pico_add_subdirectory(rp2_common/hardware_xip_cache)
6464
pico_add_subdirectory(rp2_common/hardware_xosc)
6565

66-
if (PICO_RP2350 OR PICO_COMBINED_DOCS)
66+
if (PICO_COMBINED_DOCS OR NOT PICO_RP2040)
6767
pico_add_subdirectory(rp2_common/hardware_powman)
6868
# Note in spite of the name this is usable on Arm as well as RISC-V:
6969
pico_add_subdirectory(rp2_common/hardware_riscv_platform_timer)
7070
pico_add_subdirectory(rp2_common/hardware_sha256)
7171
endif()
7272

73-
if (PICO_RP2350 OR PICO_COMBINED_DOCS)
73+
if (PICO_COMBINED_DOCS OR NOT PICO_RP2040)
7474
pico_add_subdirectory(rp2_common/hardware_dcp)
7575
pico_add_subdirectory(rp2_common/hardware_rcp)
7676
endif()
@@ -108,7 +108,7 @@ if (NOT PICO_BARE_METAL)
108108
pico_add_subdirectory(rp2_common/pico_printf)
109109
pico_add_subdirectory(rp2_common/pico_rand)
110110

111-
if (PICO_RP2350 OR PICO_COMBINED_DOCS)
111+
if (PICO_COMBINED_DOCS OR NOT PICO_RP2040)
112112
pico_add_subdirectory(rp2_common/pico_sha256)
113113
endif()
114114

src/rp2040/hardware_regs/include/hardware/platform_defs.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@
4646

4747
#define HAS_SIO_DIVIDER 1
4848
#define HAS_RP2040_RTC 1
49+
50+
#ifndef FPGA_CLK_SYS_HZ
51+
#define FPGA_CLK_SYS_HZ (48 * MHZ)
52+
#endif
53+
54+
#ifndef FPGA_CLK_REF_HZ
55+
#define FPGA_CLK_REF_HZ (12 * MHZ)
56+
#endif
57+
4958
// PICO_CONFIG: XOSC_HZ, Crystal oscillator frequency in Hz, type=int, default=12000000, advanced=true, group=hardware_base
5059
// NOTE: The system and USB clocks are generated from the frequency using two PLLs.
5160
// 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

src/rp2350/hardware_regs/include/hardware/platform_defs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@
7373
#define HAS_POWMAN_TIMER 1
7474
#define HAS_RP2350_TRNG 1
7575
#define HAS_HSTX 1
76+
#define HAS_PADS_BANK0_ISOLATION 1
77+
#define __RISCV_PMP_CHECKED 1
78+
79+
#ifndef FPGA_CLK_SYS_HZ
80+
#define FPGA_CLK_SYS_HZ (48 * MHZ)
81+
#endif
82+
83+
#ifndef FPGA_CLK_REF_HZ
84+
#define FPGA_CLK_REF_HZ (12 * MHZ)
85+
#endif
7686

7787
// PICO_CONFIG: XOSC_HZ, Crystal oscillator frequency in Hz, type=int, default=12000000, advanced=true, group=hardware_base
7888
// NOTE: The system and USB clocks are generated from the frequency using two PLLs.

src/rp2_common/boot_bootrom_headers/include/boot/bootrom_constants.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,11 @@ typedef int (*bootrom_api_callback_generic_t)(uint32_t r0, uint32_t r1, uint32_t
255255
#define BOOTROM_NS_API_get_b_partition 7
256256
#define BOOTROM_NS_API_COUNT 8
257257

258-
#define OTP_CMD_ROW_BITS 0x0000ffffu
258+
#define OTP_CMD_ROW_BITS _u(0x0000ffff)
259259
#define OTP_CMD_ROW_LSB _u(0)
260-
#define OTP_CMD_WRITE_BITS 0x00010000u
260+
#define OTP_CMD_WRITE_BITS _u(0x00010000)
261261
#define OTP_CMD_WRITE_LSB _u(16)
262-
#define OTP_CMD_ECC_BITS 0x00020000u
262+
#define OTP_CMD_ECC_BITS _u(0x00020000)
263263
#define OTP_CMD_ECC_LSB _u(17)
264264

265265
#ifndef __ASSEMBLER__

src/rp2_common/hardware_clocks/clocks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ static const uint8_t gpin0_src[CLK_COUNT] = {
270270
CLOCKS_CLK_REF_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_REF
271271
CLOCKS_CLK_SYS_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_SYS
272272
CLOCKS_CLK_PERI_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_PERI
273-
#if !PICO_RP2040
273+
#if HAS_HSTX
274274
CLOCKS_CLK_HSTX_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_HSTX
275275
#endif
276276
CLOCKS_CLK_USB_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_USB
277277
CLOCKS_CLK_ADC_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_ADC
278-
#if PICO_RP2040
278+
#if HAS_RP2040_RTC
279279
CLOCKS_CLK_RTC_CTRL_AUXSRC_VALUE_CLKSRC_GPIN0, // CLK_RTC
280280
#endif
281281
};

src/rp2_common/hardware_gpio/gpio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void gpio_set_function(uint gpio, gpio_function_t fn) {
4646
// Zero all fields apart from fsel; we want this IO to do what the peripheral tells it.
4747
// This doesn't affect e.g. pullup/pulldown, as these are in pad controls.
4848
io_bank0_hw->io[gpio].ctrl = fn << IO_BANK0_GPIO0_CTRL_FUNCSEL_LSB;
49-
#if !PICO_RP2040
49+
#if HAS_PADS_BANK0_ISOLATION
5050
// Remove pad isolation now that the correct peripheral is in control of the pad
5151
hw_clear_bits(&pads_bank0_hw->io[gpio], PADS_BANK0_GPIO0_ISO_BITS);
5252
#endif

src/rp2_common/hardware_rtc/include/hardware/rtc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#define _HARDWARE_RTC_H
99

1010
#include "pico.h"
11+
#if HAS_RP2040_RTC
1112
#include "hardware/structs/rtc.h"
13+
#endif
1214

1315
/** \file hardware/rtc.h
1416
* \defgroup hardware_rtc hardware_rtc

src/rp2_common/pico_bit_ops/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ if (NOT TARGET pico_bit_ops)
1919
${CMAKE_CURRENT_LIST_DIR}/bit_ops_aeabi.S
2020
)
2121

22-
target_link_libraries(pico_bit_ops_pico INTERFACE pico_bootrom pico_bit_ops_headers)
22+
target_link_libraries(pico_bit_ops_pico INTERFACE pico_bit_ops_headers)
2323

24-
if (NOT PICO_RP2350)
24+
if (PICO_RP2040)
25+
target_link_libraries(pico_bit_ops_pico INTERFACE pico_bootrom)
2526
# gcc
2627
pico_wrap_function(pico_bit_ops_pico __clzsi2)
2728
pico_wrap_function(pico_bit_ops_pico __clzsi2)

0 commit comments

Comments
 (0)