Skip to content

Commit

Permalink
chore: add pico 2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jalmeroth committed Sep 6, 2024
1 parent 86a4a56 commit 76c630b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
3 changes: 3 additions & 0 deletions misc/rp2350-openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source [find interface/cmsis-dap.cfg]
adapter speed 5000
source [find target/rp2350.cfg]
27 changes: 18 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

option( DH_DEBUG "Enable Debug builds" OFF )
option( DH_PICO_2 "Enable building for Pico 2 boards" OFF )

# define some vars required for pico-sdk
set(PICO_BOARD "pico")
set(PICO_COMPILER "pico_arm_gcc")
set(PICO_PLATFORM "rp2040")
if(NOT DH_PICO_2)
set(PICO_BOARD "pico")
set(PICO_COMPILER "pico_arm_cortex_m0plus_gcc")
set(PICO_PLATFORM "rp2040")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m0plus -mtune=cortex-m0plus")
else()
set(PICO_BOARD "pico2")
set(PICO_COMPILER "pico_arm_cortex_m33_gcc")
set(PICO_PLATFORM "rp2350-arm-s")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-m33 -mtune=cortex-m33")
endif()

set(PICO_PIO_USB_PATH "$ENV{PICO_PIO_USB_PATH}/src")
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
set(PICO_TINYUSB_PATH $ENV{PICO_TINYUSB_PATH})
Expand All @@ -13,19 +25,16 @@ set(PICO_TINYUSB_PATH $ENV{PICO_TINYUSB_PATH})
set(CMAKE_BUILD_TYPE "Release")
# set(CMAKE_BUILD_TYPE "Debug")
# set(LOG 3)
option( DH_DEBUG "Enable Debug builds" OFF )

# FIXME: if clang is installed, discovery of compiler fails on some systems
set(CMAKE_TOOLCHAIN_FILE "${PICO_SDK_PATH}/cmake/preload/toolchains/${PICO_COMPILER}.cmake")

# initialize the SDK based on PICO_SDK_PATH
# note: this must happen before project()
include(${PICO_SDK_PATH}/external/pico_sdk_import.cmake)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Ofast -Wall -mcpu=cortex-m0plus -mtune=cortex-m0plus -funroll-loops"
)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -Wall -funroll-loops")
if(DH_DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDH_DEBUG=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDH_DEBUG=1")
endif()
message(CMAKE_C_FLAGS="${CMAKE_C_FLAGS}")

Expand Down

0 comments on commit 76c630b

Please sign in to comment.