pax_global_header 0000666 0000000 0000000 00000000064 14655147036 0014525 g ustar 00root root 0000000 0000000 52 comment=efe2103f9b28458a1615ff096054479743ade236
pico-sdk-2.0.0/ 0000775 0000000 0000000 00000000000 14655147036 0013235 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/.bazelignore 0000664 0000000 0000000 00000000205 14655147036 0015534 0 ustar 00root root 0000000 0000000 # Don't accidentally pick up external CMake deps with Bazel build files.
build
# Don't treat submodules as part of this project.
lib
pico-sdk-2.0.0/.bazelrc 0000664 0000000 0000000 00000000566 14655147036 0014667 0 ustar 00root root 0000000 0000000 # Required for new toolchain resolution API.
build --incompatible_enable_cc_toolchain_resolution
build --@rules_cc//cc/toolchains:experimental_enable_rule_based_toolchains
# Silence all C/C++ warnings in external code.
common --per_file_copt=external/.*@-w
common --host_per_file_copt=external/.*@-w
# Produce useful output when the build fails.
common --verbose_failures
pico-sdk-2.0.0/.bazelversion 0000664 0000000 0000000 00000000006 14655147036 0015735 0 ustar 00root root 0000000 0000000 7.2.1
pico-sdk-2.0.0/.github/ 0000775 0000000 0000000 00000000000 14655147036 0014575 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/.github/pull_request_template.md 0000664 0000000 0000000 00000000400 14655147036 0021530 0 ustar 00root root 0000000 0000000 _Instructions: (please delete)_
- _please do not submit against `master`, use `develop` instead_
- _please make sure there is an associated issue for your PR, and reference it via "Fixes #num" in the description_
- _please enter a detailed description_
pico-sdk-2.0.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14655147036 0016632 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/.github/workflows/choco_packages.config 0000664 0000000 0000000 00000000435 14655147036 0022754 0 ustar 00root root 0000000 0000000
pico-sdk-2.0.0/.github/workflows/cmake.yml 0000664 0000000 0000000 00000003477 14655147036 0020450 0 ustar 00root root 0000000 0000000 name: CMake
on:
push:
branches-ignore:
- 'iar/**'
pull_request:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# cannot specify filter for pull_request in on: above, so do it here
if: github.repository_owner == 'raspberrypi' && (github.event_name != 'pull_request' || !startsWith(github.head_ref, 'iar/'))
runs-on: [self-hosted, Linux, X64]
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{github.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPICO_SDK_TESTS_ENABLED=1
- name: Build
working-directory: ${{github.workspace}}/build
shell: bash
# Execute the build. You can specify a specific target with "--target "
run: cmake --build . --config $BUILD_TYPE --parallel $(nproc)
pico-sdk-2.0.0/.github/workflows/macOS.yml 0000664 0000000 0000000 00000002462 14655147036 0020363 0 ustar 00root root 0000000 0000000 name: Build on macOS
on:
workflow_dispatch:
push:
branches:
- 'develop'
- 'master'
- 'test_workflow'
jobs:
build:
runs-on: macos-12
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init
- name: Install dependencies
run: |
brew install cmake
brew install --cask gcc-arm-embedded
- name: Build Project
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"
shell: bash
run: |
mkdir build
cd build
cmake .. -G "Unix Makefiles" -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w
cmake --build .
- name: Build Native
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"
shell: bash
run: |
mkdir build_native
cd build_native
cmake .. -G "Unix Makefiles" -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_PLATFORM=host
cmake --build .
pico-sdk-2.0.0/.github/workflows/multi-gcc.yml 0000664 0000000 0000000 00000024122 14655147036 0021242 0 ustar 00root root 0000000 0000000
name: Multi GCC
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'test_workflow'
jobs:
build:
if: github.repository_owner == 'raspberrypi'
runs-on: [self-hosted, Linux, X64]
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init
- name: GCC 6.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6_2-2016q4 -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 6.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6_2-2016q4 -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 6.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6-2017-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 6.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-6-2017-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 7.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2017-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 7.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2017-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 7.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2018-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 7.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-7-2018-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 8.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2018-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 8.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2018-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 8.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2019-q3-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 8.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-8-2019-q3-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 9.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2019-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 9.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2019-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 9.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2020-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 9.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-9-2020-q2-update -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 10.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10-2020-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 10.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10-2020-q4-major -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 10.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.10 -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 10.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.10 -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 11.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 11.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 11.3.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 11.3.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 12.2.1 Debug
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
- name: GCC 12.2.1 Release
if: always()
shell: bash
run: cd ${{github.workspace}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Release -DPICO_TOOLCHAIN_PATH=/opt/arm/arm-gnu-toolchain-12.2.rel1-x86_64-arm-none-eabi -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)
pico-sdk-2.0.0/.github/workflows/scripts/ 0000775 0000000 0000000 00000000000 14655147036 0020321 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/.github/workflows/scripts/generate_multi_gcc_workflow.py 0000775 0000000 0000000 00000004304 14655147036 0026451 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
import os
from collections import OrderedDict
import subprocess
import re
toolchain_dir = "/opt/arm"
toolchains = os.listdir(toolchain_dir)
gcc_versions = OrderedDict()
for toolchain in toolchains:
fullpath = os.path.join(toolchain_dir, toolchain)
gcc_path = os.path.join(fullpath, "bin/arm-none-eabi-gcc")
version = subprocess.run([gcc_path, "--version"], capture_output=True)
stdout = version.stdout.decode('utf-8')
stderr = version.stderr.decode('utf-8')
assert(len(stderr) == 0)
# Version should be on first line
version_line = stdout.split("\n")[0]
m = re.search("(\d+\.\d+\.\d+)", version_line)
assert(m is not None)
version = m.group(1)
if version in gcc_versions:
raise Exception("Already have version {} in versions current path {}, this path {}".format(version, gcc_versions[version], fullpath))
gcc_versions[version] = fullpath
# Sort by major version
gcc_versions_sorted = OrderedDict(sorted(gcc_versions.items(), key=lambda item: int(item[0].replace(".", ""))))
# Create output
output = '''
name: Multi GCC
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'test_workflow'
jobs:
build:
if: github.repository_owner == 'raspberrypi'
runs-on: [self-hosted, Linux, X64]
steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"
- name: Checkout repo
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init
'''
for gcc_version, toolchain_path in gcc_versions_sorted.items():
for build_type in ["Debug", "Release"]:
output += "\n"
output += " - name: GCC {} {}\n".format(gcc_version, build_type)
output += " if: always()\n"
output += " shell: bash\n"
output += " run: cd ${{{{github.workspace}}}}; mkdir -p build; rm -rf build/*; cd build; cmake ../ -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE={} -DPICO_TOOLCHAIN_PATH={} -DPICO_BOARD=pico_w; make --output-sync=target --no-builtin-rules --no-builtin-variables -j$(nproc)\n".format(build_type, toolchain_path)
print(output)
pico-sdk-2.0.0/.github/workflows/windows.yml 0000664 0000000 0000000 00000001630 14655147036 0021047 0 ustar 00root root 0000000 0000000 name: Build on Windows
on:
workflow_dispatch:
push:
branches:
- 'develop'
- 'master'
- 'test_workflow'
jobs:
build:
runs-on: windows-2022
steps:
- name: Clean workspace
shell: bash
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}/pico-sdk"
- name: Checkout repo
uses: actions/checkout@v3
- name: Checkout submodules
run: git submodule update --init
- name: Install dependencies
run: choco install .github/workflows/choco_packages.config
- name: Build Project
# bash required otherwise this mysteriously (no error) fails at "Generating cyw43_bus_pio_spi.pio.h"
shell: bash
run: |
mkdir build
cd build
cmake .. -G Ninja -DPICO_SDK_TESTS_ENABLED=1 -DCMAKE_BUILD_TYPE=Debug -DPICO_BOARD=pico_w
cmake --build .
pico-sdk-2.0.0/.gitignore 0000664 0000000 0000000 00000000241 14655147036 0015222 0 ustar 00root root 0000000 0000000 .idea
.vscode
cmake-*
.DS_Store
build
build-*
bazel-*
# Ignore until https://github.com/bazelbuild/bazel/issues/20369 is fixed.
MODULE.bazel.lock
__pycache__/
pico-sdk-2.0.0/.gitmodules 0000664 0000000 0000000 00000000735 14655147036 0015417 0 ustar 00root root 0000000 0000000 [submodule "tinyusb"]
path = lib/tinyusb
url = https://github.com/hathach/tinyusb.git
[submodule "lib/cyw43-driver"]
path = lib/cyw43-driver
url = https://github.com/georgerobotics/cyw43-driver.git
[submodule "lib/lwip"]
path = lib/lwip
url = https://github.com/lwip-tcpip/lwip.git
[submodule "lib/mbedtls"]
path = lib/mbedtls
url = https://github.com/Mbed-TLS/mbedtls.git
[submodule "lib/btstack"]
path = lib/btstack
url = https://github.com/bluekitchen/btstack.git
pico-sdk-2.0.0/BUILD.bazel 0000664 0000000 0000000 00000000000 14655147036 0015101 0 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/CMakeLists.txt 0000664 0000000 0000000 00000005233 14655147036 0016000 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.13...3.27)
# Note: this CMakeLists.txt can be used as a top-level CMakeLists.txt for the SDK itself. For all other uses
# it is included as a subdirectory via the pico_sdk_init() method provided by pico_sdk_init.cmake
if (NOT TARGET _pico_sdk_inclusion_marker)
add_library(_pico_sdk_inclusion_marker INTERFACE)
# This is a no-op unless we are the top-level CMakeLists.txt
include(pico_sdk_init.cmake)
project(pico_sdk C CXX ASM)
string(REGEX MATCH "Clang" PICO_C_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
string(REGEX MATCH "GNU" PICO_C_COMPILER_IS_GNU "${CMAKE_C_COMPILER_ID}")
string(REGEX MATCH "IAR" PICO_C_COMPILER_IS_IAR "${CMAKE_C_COMPILER_ID}")
pico_register_common_scope_var(PICO_C_COMPILER_IS_CLANG)
pico_register_common_scope_var(PICO_C_COMPILER_IS_GNU)
pico_register_common_scope_var(PICO_C_COMPILER_IS_IAR)
pico_register_common_scope_var(PICO_SDK_VERSION_MAJOR)
pico_register_common_scope_var(PICO_SDK_VERSION_MINOR)
pico_register_common_scope_var(PICO_SDK_VERSION_REVISION)
pico_register_common_scope_var(PICO_SDK_VERSION_PRE_RELEASE_ID)
pico_register_common_scope_var(PICO_SDK_VERSION_STRING)
message("Build type is ${CMAKE_BUILD_TYPE}")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
if (PICO_DEOPTIMIZED_DEBUG)
message("Using fully de-optimized debug build (set PICO_DEOPTIMIZED_DEBUG=0 to optimize)")
else()
message("Using regular optimized debug build (set PICO_DEOPTIMIZED_DEBUG=1 to de-optimize)")
endif()
endif()
pico_is_top_level_project(PICO_SDK_TOP_LEVEL_PROJECT)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
set(PICO_SDK 1 PARENT_SCOPE)
endif()
# allow customization
add_sub_list_dirs(PICO_SDK_PRE_LIST_DIRS)
add_sub_list_files(PICO_SDK_PRE_LIST_FILES)
# needed by certain functions
set(PICO_TOOLS_DIR "${CMAKE_CURRENT_LIST_DIR}/tools" CACHE INTERNAL "")
add_subdirectory(tools)
add_subdirectory(src)
# allow customization
add_sub_list_dirs(PICO_SDK_POST_LIST_DIRS)
add_sub_list_files(PICO_SDK_POST_LIST_FILES)
if (PICO_SDK_TOP_LEVEL_PROJECT AND NOT DEFINED PICO_SDK_TESTS_ENABLED)
set(PICO_SDK_TESTS_ENABLED 1)
endif()
if (PICO_SDK_TESTS_ENABLED)
add_subdirectory(test)
endif ()
set(PICO_SDK_TESTS_ENABLED "${PICO_SDK_TESTS_ENABLED}" CACHE INTERNAL "Enable build of SDK tests")
# add docs at the end, as we gather documentation dirs as we go
add_subdirectory(docs)
if (NOT PICO_SDK_TOP_LEVEL_PROJECT)
pico_promote_common_scope_vars()
endif()
endif()
pico-sdk-2.0.0/CONTRIBUTING.md 0000664 0000000 0000000 00000004361 14655147036 0015472 0 ustar 00root root 0000000 0000000 # Contributing to Raspberry Pi Pico C/C++ SDK
## How to Report a Bug
We use GitHub to host code, track [issues](https://github.com/raspberrypi/pico-sdk/issues) and feature requests, and to accept [pull requests](https://github.com/raspberrypi/pico-sdk/pulls). If you find think you have found a bug in the SDK please report it by [opening a new issue](https://github.com/raspberrypi/pico-sdk/issues/new). Please include as much detail as possible, and ideally some code to reproduce the problem.
## How to Contribute Code
In order to contribute new or updated code, you must first create a GitHub account and fork the original repository to your own account. You can make changes, save them in your repository, then [make a pull request](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against this repository. The pull request will appear [in the repository](https://github.com/raspberrypi/pico-sdk/pulls) where it can be assessed by the maintainers, and if appropriate, merged with the official repository.
**NOTE:** Development takes place on the `develop` branch in this repository. Please open your [pull request](https://github.com/raspberrypi/pico-sdk/pulls) (PR) against the [`develop`](https://github.com/raspberrypi/pico-sdk/tree/develop) branch, pull requests against the `master` branch will automatically CI fail checks and will not be accepted. You will be asked to rebase your PR against `develop` and if you do not do so, your PR will be closed.
While we are happy to take contributions, big or small, changes in the SDK may have knock-on effects in other places so it is possible that apparently benign pull requests that make seemingly small changes could be refused.
### Code Style
If you are contributing new or updated code please match the existing code style, particularly:
* Use 4 spaces for indentation rather than tabs.
* Braces are required for everything except single line `if` statements.
* Opening braces should not be placed on a new line.
### Licensing
Code in this repository is lisensed under the [BSD-3 License](LICENSE.TXT). By contributing content to this repository you are agreeing to place your contributions under this licence.
pico-sdk-2.0.0/LICENSE.TXT 0000664 0000000 0000000 00000002721 14655147036 0014722 0 ustar 00root root 0000000 0000000 Copyright 2020 (c) 2020 Raspberry Pi (Trading) Ltd.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. pico-sdk-2.0.0/MODULE.bazel 0000664 0000000 0000000 00000014534 14655147036 0015250 0 ustar 00root root 0000000 0000000 module(
name = "pico-sdk",
version = "2.0.0",
)
bazel_dep(name = "platforms", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.6.1")
bazel_dep(name = "rules_python", version = "0.22.1")
bazel_dep(name = "picotool", version = "2.0.0")
# Note: rules_cc is special-cased repository; a dependency on rules_cc in a
# module will not ensure that the root Bazel module has that same version of
# rules_cc. For that reason, this primarily acts as a FYI. You'll still need
# to explicitly list this dependency in your own project's MODULE.bazel file.
bazel_dep(name = "rules_cc", version = "0.0.9")
# rules_cc v0.0.10 is not yet cut, so manually pull in the desired version.
# This does not apply to dependent projects, so it needs to be copied to your
# project's MODULE.bazel too.
archive_override(
module_name = "rules_cc",
integrity = "sha256-zdQo/pQWKdIAPKSflBxOSWZNwCbc86T7SechKZo/3Xw=",
strip_prefix = "rules_cc-1acf5213b6170f1f0133e273cb85ede0e732048f",
urls = "https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.tar.gz",
)
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "arm_gcc_linux-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "6cd1bbc1d9ae57312bcd169ae283153a9572bd6a8e4eeae2fedfbc33b115fdbb",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_win-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "51d933f00578aa28016c5e3c84f94403274ea7915539f8e56c13e2196437d18f",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-mingw-w64-i686-arm-none-eabi.zip",
)
http_archive(
name = "arm_gcc_mac-x86_64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz",
)
http_archive(
name = "arm_gcc_mac-aarch64",
build_file = "//bazel/toolchain:gcc_arm_none_eabi.BUILD",
sha256 = "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
url = "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz",
)
http_archive(
name = "clang_linux-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "e12ee0db9226f5b4a4400c5eb2c0f757d7056181b651622b5453acb00105fd87",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/linux-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
)
http_archive(
name = "clang_win-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "8c41e8b507f4dfede80842f98a716cac209f552064088fa1b7f4c64a1e547534",
type = "zip",
# Windows doesn't like `:` in the produced filename, so replace it with `%3A`.
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/windows-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799".replace("git_revision:", "git_revision%3A"),
)
http_archive(
name = "clang_mac-x86_64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "1d92f52609d3c1e958fd56f5e9a68ab99b2042ddcc6e90a5eb5009cf7ac4897d",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-amd64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
)
http_archive(
name = "clang_mac-aarch64",
build_file = "//bazel/toolchain:clang.BUILD",
sha256 = "53184680db7e0043a8fba1556c7644b8f5e6c8cdffa4436a92a8e8adb0f45b8d",
type = "zip",
url = "https://chrome-infra-packages.appspot.com/dl/fuchsia/third_party/clang/mac-arm64/+/git_revision:248c53429427034f45705af60d47f3b1090c4799",
)
# TODO: Provide tinyusb as a proper Bazel module.
http_archive(
name = "tinyusb",
build_file = "//src/rp2_common/tinyusb:tinyusb.BUILD",
sha256 = "d64728aef58b80d5ce3747cad133f520da46e2b7ea3aadfda0e981aba6b658b3",
strip_prefix = "tinyusb-4232642899362fa5e9cf0dc59bad6f1f6d32c563",
url = "https://github.com/hathach/tinyusb/archive/4232642899362fa5e9cf0dc59bad6f1f6d32c563.tar.gz",
)
# TODO: Provide btstack as a proper Bazel module.
http_archive(
name = "btstack",
build_file = "//src/rp2_common/pico_btstack:btstack.BUILD",
sha256 = "64e86d9cf82b346e743fe1d4818b9380712b17abdb3f2c3524e92464b5ef3d19",
strip_prefix = "btstack-2b49e57bd1fae85ac32ac1f41cdb7c794de335f6",
url = "https://github.com/bluekitchen/btstack/archive/2b49e57bd1fae85ac32ac1f41cdb7c794de335f6.tar.gz",
)
# TODO: Provide btstack as a proper Bazel module.
http_archive(
name = "cyw43-driver",
build_file = "//src/rp2_common/pico_cyw43_driver:cyw43-driver.BUILD",
sha256 = "0fcc7707fef95dd562d5572604713266613a27caeeae2f10afeccee9592a53ce",
strip_prefix = "cyw43-driver-faf36381bad1f668a30172b6336c9a970966ef4c",
url = "https://github.com/georgerobotics/cyw43-driver/archive/faf36381bad1f668a30172b6336c9a970966ef4c.tar.gz",
)
# TODO: Provide lwip as a proper Bazel module.
http_archive(
name = "lwip",
build_file = "//src/rp2_common/pico_lwip:lwip.BUILD",
sha256 = "72856d557f72911cf6826ef745c23c54822df83a474557823241164a1d1361aa",
strip_prefix = "lwip-0a0452b2c39bdd91e252aef045c115f88f6ca773",
url = "https://github.com/lwip-tcpip/lwip/archive/0a0452b2c39bdd91e252aef045c115f88f6ca773.tar.gz",
)
register_toolchains(
"//bazel/toolchain:linux-x86_64-rp2040",
"//bazel/toolchain:linux-x86_64-rp2350",
"//bazel/toolchain:win-x86_64-rp2040",
"//bazel/toolchain:win-x86_64-rp2350",
"//bazel/toolchain:mac-x86_64-rp2040",
"//bazel/toolchain:mac-x86_64-rp2350",
"//bazel/toolchain:mac-aarch64-rp2040",
"//bazel/toolchain:mac-aarch64-rp2350",
# Require users to opt-in to the Pico SDK's toolchains.
dev_dependency = True,
)
pico-sdk-2.0.0/README.md 0000664 0000000 0000000 00000020627 14655147036 0014523 0 ustar 00root root 0000000 0000000 # Raspberry Pi Pico SDK
The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system
necessary to write programs for the RP-series microcontroller-based devices such as the Raspberry Pi Pico or Raspberry Pi Pico 2
in C, C++ or assembly language.
The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
A single program runs on the device at a time and starts with a conventional `main()` method. Standard C/C++ libraries are supported along with
C-level libraries/APIs for accessing all of the RP-series microcontroller's hardware including PIO (Programmable IO).
Additionally, the SDK provides higher level libraries for dealing with timers, synchronization, Wi-Fi and Bluetooth networking, USB and multicore programming. These libraries should be comprehensive enough that your application code rarely, if at all, needs to access hardware registers directly. However, if you do need or prefer to access the raw hardware registers, you will also find complete and fully-commented register definition headers in the SDK. There's no need to look up addresses in the datasheet.
The SDK can be used to build anything from simple applications, fully-fledged runtime environments such as MicroPython, to low level software
such as the RP-series microcontroller's on-chip bootrom itself.
The design goal for entire SDK is to be simple but powerful.
Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in [pico-extras](https://github.com/raspberrypi/pico-extras).
# Documentation
See [Getting Started with the Raspberry Pi Pico-Series](https://rptl.io/pico-get-started) for information on how to setup your
hardware, IDE/environment and how to build and debug software for the Raspberry Pi Pico and other RP-series microcontroller based devices.
See [Connecting to the Internet with Raspberry Pi Pico W](https://rptl.io/picow-connect) to learn more about writing
applications for your Raspberry Pi Pico W that connect to the internet.
See [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
SDK, to explore more advanced features, and for complete PDF-based API documentation.
See [Online Raspberry Pi Pico SDK API docs](https://rptl.io/pico-doxygen) for HTML-based API documentation.
# Example code
See [pico-examples](https://github.com/raspberrypi/pico-examples) for example code you can build.
# Getting the latest SDK code
The [master](https://github.com/raspberrypi/pico-sdk/tree/master/) branch of `pico-sdk` on GitHub contains the
_latest stable release_ of the SDK. If you need or want to test upcoming features, you can try the
[develop](https://github.com/raspberrypi/pico-sdk/tree/develop/) branch instead.
# Quick-start your own project
## Using Visual Studio Code
You can install the [Raspberry Pi Pico Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=raspberry-pi.raspberry-pi-pico) in VS Code.
## Unix command line
These instructions are extremely terse, and Linux-based only. For detailed steps,
instructions for other platforms, and just in general, we recommend you see [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk)
1. Install CMake (at least version 3.13), and a GCC cross compiler
```
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
```
1. Set up your project to point to use the Raspberry Pi Pico SDK
* Either by cloning the SDK locally (most common) :
1. `git clone` this Raspberry Pi Pico SDK repository
1. Copy [pico_sdk_import.cmake](https://github.com/raspberrypi/pico-sdk/blob/master/external/pico_sdk_import.cmake)
from the SDK into your project directory
2. Set `PICO_SDK_PATH` to the SDK location in your environment, or pass it (`-DPICO_SDK_PATH=`) to cmake later.
3. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13...3.27)
# initialize the SDK based on PICO_SDK_PATH
# note: this must happen before project()
include(pico_sdk_import.cmake)
project(my_project)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
# rest of your project
```
* Or with the Raspberry Pi Pico SDK as a submodule :
1. Clone the SDK as a submodule called `pico-sdk`
1. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13...3.27)
# initialize pico-sdk from submodule
# note: this must happen before project()
include(pico-sdk/pico_sdk_init.cmake)
project(my_project)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
# rest of your project
```
* Or with automatic download from GitHub :
1. Copy [pico_sdk_import.cmake](https://github.com/raspberrypi/pico-sdk/blob/master/external/pico_sdk_import.cmake)
from the SDK into your project directory
1. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13)
# initialize pico-sdk from GIT
# (note this can come from environment, CMake cache etc)
set(PICO_SDK_FETCH_FROM_GIT on)
# pico_sdk_import.cmake is a single file copied from this SDK
# note: this must happen before project()
include(pico_sdk_import.cmake)
project(my_project)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
# rest of your project
```
* Or by cloning the SDK locally, but without copying `pico_sdk_import.cmake`:
1. `git clone` this Raspberry Pi Pico SDK repository
2. Setup a `CMakeLists.txt` like:
```cmake
cmake_minimum_required(VERSION 3.13)
# initialize the SDK directly
include(/path/to/pico-sdk/pico_sdk_init.cmake)
project(my_project)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
# rest of your project
```
1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico-Series C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
About the simplest you can do is a single source file (e.g. hello_world.c)
```c
#include
#include "pico/stdlib.h"
int main() {
stdio_init_all();
printf("Hello, world!\n");
return 0;
}
```
And add the following to your `CMakeLists.txt`:
```cmake
add_executable(hello_world
hello_world.c
)
# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(hello_world pico_stdlib)
# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(hello_world)
```
Note this example uses the default UART for _stdout_;
if you want to use the default USB see the [hello-usb](https://github.com/raspberrypi/pico-examples/tree/master/hello_world/usb) example.
1. Setup a CMake build directory.
For example, if not using an IDE:
```
$ mkdir build
$ cd build
$ cmake ..
```
When building for a board other than the Raspberry Pi Pico, you should pass `-DPICO_BOARD=board_name` to the `cmake` command above, e.g. `cmake -DPICO_BOARD=pico2 ..` or `cmake -DPICO_BOARD=pico_w ..` to configure the SDK and build options accordingly for that particular board.
Specifying `PICO_BOARD=` sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
cases also enables the use of additional libraries (e.g. wireless support when building for `PICO_BOARD=pico_w`) which cannot
be built without a board which provides the requisite hardware functionality.
For a list of boards defined in the SDK itself, look in [this directory](src/boards/include/boards) which has a
header for each named board.
1. Make your target from the build directory you created.
```sh
$ make hello_world
```
1. You now have `hello_world.elf` to load via a debugger, or `hello_world.uf2` that can be installed and run on your Raspberry Pi Pico-series device via drag and drop.
# RISC-V support on RP2350
See [Raspberry Pi Pico-series C/C++ SDK](https://rptl.io/pico-c-sdk) for information on setting up a build environment for RISC-V on RP2350. pico-sdk-2.0.0/WORKSPACE 0000664 0000000 0000000 00000000000 14655147036 0014504 0 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/ 0000775 0000000 0000000 00000000000 14655147036 0014332 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/BUILD.bazel 0000664 0000000 0000000 00000004144 14655147036 0016213 0 ustar 00root root 0000000 0000000 load("@rules_python//python:defs.bzl", "py_binary")
package(default_visibility = ["//visibility:public"])
py_binary(
name = "generate_version_header",
srcs = ["generate_version_header.py"],
visibility = ["//:__subpackages__"],
)
# This isn't actually generated, it just uses the same name
# to make it show up easier in searches.
#
# Rather than generating lists of headers to match CMake, the Bazel build
# opts to have a static header that transitively include two known headers.
# By default, empty header files are included, and users/platforms are expected
# to specify an appropriate `cc_library` to replace them.
#
# You tell bazel which `cc_library` provides the respective headers by
# configuring these `label_flag`s:
#
# # Specify the library that provides "pico_config_extra_headers.h"
# --@pico-sdk//bazel/config:PICO_CONFIG_EXTRA_HEADER=//my_proj:my_custom_headers
#
# # Specify the library that provides "pico_config_platform_headers.h"
# --@pico-sdk//bazel/config:PICO_CONFIG_PLATFORM_HEADER=//my_proj:my_custom_platform_headers
cc_library(
name = "generate_config_header",
hdrs = ["include/pico/config_autogen.h"],
includes = ["include"],
visibility = ["//:__subpackages__"],
deps = [
"//bazel/config:PICO_CONFIG_EXTRA_HEADER",
"//bazel/config:PICO_CONFIG_PLATFORM_HEADER",
],
)
genrule(
name = "empty_extra_headers_file",
outs = ["generated_extra_include/pico_config_extra_headers.h"],
cmd = "echo > $@",
cmd_bat = "copy NUL $@",
visibility = ["//visibility:private"],
)
cc_library(
name = "no_extra_headers",
hdrs = ["generated_extra_include/pico_config_extra_headers.h"],
includes = ["generated_extra_include"],
visibility = ["//visibility:private"],
)
# An empty stub, useful for label_flag flags that need to point to a library,
# but for some purposes the library needs to be a no-op.
cc_library(
name = "empty_cc_lib",
)
# A library incompatible with everything. Use to mark an invalid configuration.
cc_library(
name = "incompatible_cc_lib",
target_compatible_with = ["@platforms//:incompatible"],
)
pico-sdk-2.0.0/bazel/README.md 0000664 0000000 0000000 00000012174 14655147036 0015616 0 ustar 00root root 0000000 0000000 # Bazel build
## Using the Pico SDK in a Bazel project.
### Add pico-sdk as a dependency
First, in your `MODULE.bazel` file, add a dependency on the Pico SDK:
```python
bazel_dep(
name = "pico-sdk",
version = "2.0.0",
)
```
Second, in the same file you'll need to add an explicit dependency on
`rules_cc`, as it's a special-cased Bazel module:
```python
# Note: rules_cc is special-cased repository; a dependency on rules_cc in a
# module will not ensure that the root Bazel module has that same version of
# rules_cc. For that reason, this primarily acts as a FYI. You'll still need
# to explicitly list this dependency in your own project's MODULE.bazel file.
bazel_dep(name = "rules_cc", version = "0.0.9")
# rules_cc v0.0.10 is not yet cut, so manually pull in the desired version.
# This does not apply to dependent projects, so it needs to be copied to your
# project's MODULE.bazel too.
archive_override(
module_name = "rules_cc",
urls = "https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.zip",
strip_prefix = "rules_cc-1acf5213b6170f1f0133e273cb85ede0e732048f",
integrity = "sha256-NddP6xi6LzsIHT8bMSVJ2NtoURbN+l3xpjvmIgB6aSg=",
)
```
### Register toolchains
These toolchains tell Bazel how to compile for ARM cores. Add the following
to the `MODULE.bazel` for your project:
```python
register_toolchains(
"@pico-sdk//bazel/toolchain:linux-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:linux-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:win-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:win-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:mac-x86_64-rp2040",
"@pico-sdk//bazel/toolchain:mac-x86_64-rp2350",
"@pico-sdk//bazel/toolchain:mac-aarch64-rp2040",
"@pico-sdk//bazel/toolchain:mac-aarch64-rp2350",
)
```
### Enable required .bazelrc flags
To use the toolchains provided by the Pico SDK, you'll need to enable a few
new features. In your project's `.bazelrc`, add the following
```
# Required for new toolchain resolution API.
build --incompatible_enable_cc_toolchain_resolution
build --@rules_cc//cc/toolchains:experimental_enable_rule_based_toolchains
```
### Ready to build!
You're now ready to start building Pico Projects in Bazel! When building,
don't forget to specify `--platforms` so Bazel knows you're targeting the
Raspberry Pi Pico:
```console
$ bazelisk build --platforms=@pico-sdk//bazel/platform:rp2040 //...
```
## SDK configuration
An exhaustive list of build system configuration options is available in
`//bazel/config:BUILD.bazel`.
### Selecting a different board
A different board can be selected specifying `--@pico-sdk//bazel/config:PICO_BOARD`:
```console
$ bazelisk build --platforms=//bazel/platform:rp2040 --@pico-sdk//bazel/config:PICO_BOARD=pico_w //...
```
If you have a bespoke board definition, you can configure the Pico SDK to use it
by pointing `--@pico-sdk//bazel/config:PICO_CONFIG_HEADER` to a `cc_library`
that defines `PICO_BOARD` and either a `PICO_CONFIG_HEADER` define or a
`pico/config_autogen.h` header. Make sure any required `includes`, `hdrs`, and
`deps` are also provided.
## Generating UF2 firmware images
Creation of UF2 images can be done as explicit build steps on a per-binary
rule basis, or through an aspect. Running a wildcard build with the
`pico_uf2_aspect` enabled is the easiest way to create a UF2 for every ELF
firmware image.
```console
$ bazelisk build --platforms=@pico-sdk//bazel/platform:rp2040 \
--aspects @pico-sdk//tools:uf2_aspect.bzl%pico_uf2_aspect \
--output_groups=+pico_uf2_files \
//...
```
## Building the Pico SDK itself
### First time setup
You'll need Bazel (v7.0.0 or higher) or Bazelisk (a self-updating Bazel
launcher) to build the Pico SDK.
We strongly recommend you set up
[Bazelisk](https://bazel.build/install/bazelisk).
You will also need a working compiler configured if you wish to build Picotool
or pioasm.
* Linux: `sudo apt-get install build-essential` or similar.
* macOS: `xcode-select --install`
* Windows: [Install MSVC](https://visualstudio.microsoft.com/vs/features/cplusplus/)
### Building
To build all of the Pico SDK, run the following command:
```console
$ bazelisk build --platforms=//bazel/platform:rp2040 //...
```
## Known issues and limitations
The Bazel build for the Pico SDK is relatively new, but most features and
configuration options available in the CMake build are also available in Bazel.
You are welcome and encouraged to file issues for any problems and limitations
you encounter along the way.
Currently, the following features are not supported:
* The pioasm parser cannot be built from source via Bazel.
* Windows MSVC wildcard build (`bazel build //...`) does not work when targeting
host.
* Bazel does not yet provide RISC-V support for Pico 2/RP2350.
* Pico W wireless libraries have link issues.
## Contributing
When making changes to the Bazel build, please run the Bazel validation script
to ensure all supported configurations build properly:
```console
$ ./tools/run_all_bazel_checks.py
```
If you need to check against a local version of Picotool, you can run the script
with `--picotool-dir`:
```console
$ ./tools/run_all_bazel_checks.py --picotool-dir=/path/to/picotool
```
pico-sdk-2.0.0/bazel/config/ 0000775 0000000 0000000 00000000000 14655147036 0015577 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/config/BUILD.bazel 0000664 0000000 0000000 00000024251 14655147036 0017461 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "int_flag", "string_flag")
package(default_visibility = ["//visibility:public"])
# PICO_BAZEL_CONFIG: PICO_TOOLCHAIN, The toolchain to use, type=string, default=gcc, group=build
string_flag(
name = "PICO_TOOLCHAIN",
build_setting_default = "gcc",
values = [
"gcc",
"clang",
],
)
# PICO_BAZEL_CONFIG: PICO_BOARD, Board name being built for, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
string_flag(
name = "PICO_BOARD",
build_setting_default = "pico",
)
# PICO_BAZEL_CONFIG: PICO_BARE_METAL, Flag to exclude anything except base headers from the build, type=bool, default=0, group=build
bool_flag(
name = "PICO_BARE_METAL",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_NO_GC_SECTIONS, Disable `-ffunction-sections` `-fdata-sections` and `--gc-sections`, type=bool, default=0, advanced=true, group=pico_standard_link
bool_flag(
name = "PICO_NO_GC_SECTIONS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2_FILE, Boot stage 2 file to use; this should point to a filegroup with the .S file to use, type=string, group=build
label_flag(
name = "PICO_DEFAULT_BOOT_STAGE2_FILE",
build_setting_default = "//src/rp2_common:build_selected_boot2",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BOOT_STAGE2, Simpler alternative to specifying PICO_DEFAULT_BOOT_STAGE2_FILE where the latter is set to src/rp2_common/boot_stage2/{PICO_DEFAULT_BOOT_STAGE2}.S, type=string, default=compile_time_choice, group=build
string_flag(
name = "PICO_DEFAULT_BOOT_STAGE2",
build_setting_default = "compile_time_choice",
)
# PICO_BAZEL_CONFIG: PICO_BOOT_STAGE2_LINK_IMAGE, [Bazel only] The final boot_stage2 image target to link in. Use this to fully override/replace boot_stage2, default=@pico-sdk//src/rp2_common:boot_stage2, group=build
label_flag(
name = "PICO_BOOT_STAGE2_LINK_IMAGE",
build_setting_default = "//src/rp2_common:boot_stage2",
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_EXCEPTIONS, Enable CXX exception handling, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_EXCEPTIONS",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_RTTI, Enable CXX rtti, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_RTTI",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CXX_ENABLE_CXA_ATEXIT, Enable cxa-atexit, type=bool, default=0, group=pico_cxx_options
bool_flag(
name = "PICO_CXX_ENABLE_CXA_ATEXIT",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_UART, Option to globally enable stdio UART for all targets by default, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_UART",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_USB, Option to globally enable stdio USB for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_USB",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_SEMIHOSTING, Option to globally enable stdio semi-hosting for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_SEMIHOSTING",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_RTT, Option to globally enable stdio RTT for all targets by default, type=bool, default=0, group=pico_stdlib
bool_flag(
name = "PICO_STDIO_RTT",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_MULTICORE_ENABLED, OPTION: Enable multicore handling, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_MULTICORE_ENABLED",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_DOUBLE_IMPL, The default implementation for pico_double to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. dcp is only supported on rp2350, type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_DOUBLE_IMPL",
build_setting_default = "auto",
values = [
"auto",
"compiler",
"dcp",
"rp2040",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_FLOAT_IMPL, The default implementation for pico_float to link. auto selects an appropriate default for the current platform. rp2040 is only supported on the rp2040. vfp and dcp are only supported on rp2350, type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_FLOAT_IMPL",
build_setting_default = "auto",
values = [
"auto",
"compiler",
"dcp",
"rp2040",
"vfp",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_DIVIDER_IMPL, The default implementation for pico_divider to link. hardware uses accelerated divide instructions while compiler allows the compiler to decide how to handle divide instructions. auto uses the platform default (hardware on RP2040 and compiler on RP2350), type=string, default=auto, group=build
string_flag(
name = "PICO_DEFAULT_DIVIDER_IMPL",
build_setting_default = "auto",
values = [
"auto",
"hardware",
"compiler",
],
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_PRINTF_IMPL, The default implementation for pico_printf to link. compiler lets the compiler control printf behavior while pico provides a pico-specific implementation, type=string, default=double, group=build
string_flag(
name = "PICO_DEFAULT_PRINTF_IMPL",
build_setting_default = "pico",
values = [
"pico",
"compiler",
"none",
],
)
# PICO_BAZEL_CONFIG: PICO_BINARY_INFO_ENABLED, Whether to include binary info in final firmware, type=bool, default=1, group=pico_stdlib
bool_flag(
name = "PICO_BINARY_INFO_ENABLED",
build_setting_default = True,
)
# PICO_BAZEL_CONFIG: PICO_CMSIS_PATH, Label of a cc_ibrary providing CMSIS core, default="included stub CORE only impl", group=build
label_flag(
name = "PICO_CMSIS_PATH",
build_setting_default = "//src/rp2_common/cmsis:cmsis_core",
)
# PICO_BAZEL_CONFIG: PICO_USE_DEFAULT_MAX_PAGE_SIZE, Don't shrink linker max page to 4096, type=bool, default=0, advanced=true, group=pico_standard_link
bool_flag(
name = "PICO_USE_DEFAULT_MAX_PAGE_SIZE",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS, Maximum number of milliseconds to wait during initialization for a CDC connection from the host (negative means indefinite) during initialization, type=int, default=0, group=pico_stdio_usb
int_flag(
name = "PICO_STDIO_USB_CONNECT_WAIT_TIMEOUT_MS",
build_setting_default = 0,
)
# PICO_BAZEL_CONFIG: PICO_TINYUSB_LIB, [Bazel only] The library that provides TinyUSB, default=@tinyusb//:tinyusb, group=build
label_flag(
name = "PICO_TINYUSB_LIB",
build_setting_default = "@tinyusb//:tinyusb",
)
# TODO: Bazel build for mbedtls at @mbedtls//:mbedtls.
# PICO_BAZEL_CONFIG: PICO_MBEDTLS_LIB, [Bazel only] The library that provides mbedtls, default=@mbedtls//:mbedtls, group=build
label_flag(
name = "PICO_MBEDTLS_LIB",
build_setting_default = "//bazel:incompatible_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_BINARY_INFO, [Bazel only] The library that provides custom_pico_binary_info to link into all binaries, default=//src/rp2_common/pico_standard_binary_info:default_binary_info, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_BINARY_INFO",
build_setting_default = "//src/rp2_common/pico_standard_binary_info:default_binary_info",
)
# PICO_BAZEL_CONFIG: PICO_BAZEL_BUILD_TYPE, The type of build (e.g. Debug or Release) to embed in binary info, type=string, default=pico, group=build
string_flag(
name = "PICO_BAZEL_BUILD_TYPE",
build_setting_default = "Debug",
)
# PICO_BAZEL_CONFIG: PICO_DEFAULT_LINKER_SCRIPT, [Bazel only] The library that provides a linker script to link into all binaries, default=//src/rp2_common/pico_crt0:default_linker_script, group=pico_standard_link
label_flag(
name = "PICO_DEFAULT_LINKER_SCRIPT",
build_setting_default = "//src/rp2_common/pico_crt0:default_linker_script",
)
# PICO_BAZEL_CONFIG: PICO_NO_TARGET_NAME, Don't define PICO_TARGET_NAME, type=bool, default=0, group=build
bool_flag(
name = "PICO_NO_TARGET_NAME",
build_setting_default = False,
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_EXTRA_HEADER, [Bazel only] The cc_library that provides "pico_config_extra_headers.h", default=//bazel:no_extra_headers, group=pico_base
label_flag(
name = "PICO_CONFIG_EXTRA_HEADER",
build_setting_default = "//bazel:no_extra_headers",
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_PLATFORM_HEADER, [Bazel only] The cc_library that provides "pico_config_platform_headers.h" and defines PICO_BOARD, default=//src/common/pico_base_headers:default_platform_headers, group=pico_base
label_flag(
name = "PICO_CONFIG_PLATFORM_HEADER",
build_setting_default = "//src/boards:default",
)
# PICO_BAZEL_CONFIG: PICO_CONFIG_HEADER, [Bazel only] The cc_library that defines PICO_CONFIG_HEADER or pico/config_autogen.h and other SDK critical defines (overrides PICO_BOARD setting), default=//bazel:generate_config_header, group=pico_base
label_flag(
name = "PICO_CONFIG_HEADER",
build_setting_default = "//bazel:generate_config_header",
)
# PICO_BAZEL_CONFIG: PICO_CLIB, [Bazel only] The flavor of libc porting layer to use. auto infers the correct value to use from PICO_TOOLCHAIN, group=pico_standard_link
string_flag(
name = "PICO_CLIB",
build_setting_default = "auto",
values = [
"auto",
"llvm_libc",
"newlib",
"picolibc",
],
)
# PICO_BAZEL_CONFIG: PICO_BTSTACK_CONFIG, [Bazel only] The cc_library that provides btstack_config.h, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_BTSTACK_CONFIG",
build_setting_default = "//bazel:empty_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_LWIP_CONFIG, [Bazel only] The cc_library that provides lwipopts.h, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_LWIP_CONFIG",
build_setting_default = "//bazel:empty_cc_lib",
)
# PICO_BAZEL_CONFIG: PICO_FREERTOS_LIB, [Bazel only] The cc_library that provides FreeRTOS, default=//bazel:empty_cc_lib, group=wireless
label_flag(
name = "PICO_FREERTOS_LIB",
build_setting_default = "//bazel:empty_cc_lib",
)
pico-sdk-2.0.0/bazel/constraint/ 0000775 0000000 0000000 00000000000 14655147036 0016516 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/constraint/BUILD.bazel 0000664 0000000 0000000 00000012552 14655147036 0020401 0 ustar 00root root 0000000 0000000 package(default_visibility = ["//visibility:public"])
# This constraint represents the dimension that guides the Pico SDK build. This
# constraint will only ever enumerate specific MCUs (and the host), and does NOT
# cover the differences from board-to-board.
constraint_setting(
name = "sdk_target",
default_constraint_value = "host",
)
# This constraint value is used to guide the host build.
constraint_value(
name = "host",
constraint_setting = ":sdk_target",
)
# This constraint value is used to guide parts of the build that are specific
# to the rp2040.
constraint_value(
name = "rp2040",
constraint_setting = ":sdk_target",
)
# This constraint value is used to guide parts of the build that are specific
# to the rp2350.
constraint_value(
name = "rp2350",
constraint_setting = ":sdk_target",
)
constraint_setting(
name = "wireless_support",
default_constraint_value = "no_wireless",
)
constraint_value(
name = "no_wireless",
constraint_setting = ":wireless_support",
)
constraint_value(
name = "cyw43_wireless",
constraint_setting = ":wireless_support",
)
config_setting(
name = "is_pico_w",
flag_values = {"//bazel/config:PICO_BOARD": "pico_w"},
)
config_setting(
name = "pico_toolchain_clang_enabled",
flag_values = {"//bazel/config:PICO_TOOLCHAIN": "clang"},
)
config_setting(
name = "pico_toolchain_gcc_enabled",
flag_values = {"//bazel/config:PICO_TOOLCHAIN": "gcc"},
)
config_setting(
name = "pico_baremetal_enabled",
flag_values = {"//bazel/config:PICO_BARE_METAL": "True"},
)
config_setting(
name = "pico_no_gc_sections_enabled",
flag_values = {"//bazel/config:PICO_NO_GC_SECTIONS": "True"},
)
config_setting(
name = "pico_cxx_enable_exceptions_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_EXCEPTIONS": "True"},
)
config_setting(
name = "pico_cxx_enable_rtti_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_RTTI": "True"},
)
config_setting(
name = "pico_cxx_enable_cxa_atexit_enabled",
flag_values = {"//bazel/config:PICO_CXX_ENABLE_RTTI": "True"},
)
config_setting(
name = "pico_stdio_uart_enabled",
flag_values = {"//bazel/config:PICO_STDIO_UART": "True"},
)
config_setting(
name = "pico_stdio_usb_enabled",
flag_values = {"//bazel/config:PICO_STDIO_USB": "True"},
)
config_setting(
name = "pico_stdio_semihosting_enabled",
flag_values = {"//bazel/config:PICO_STDIO_SEMIHOSTING": "True"},
)
config_setting(
name = "pico_stdio_rtt_enabled",
flag_values = {"//bazel/config:PICO_STDIO_RTT": "True"},
)
config_setting(
name = "pico_multicore_enabled",
flag_values = {"//bazel/config:PICO_MULTICORE_ENABLED": "True"},
)
config_setting(
name = "pico_float_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "auto"},
)
config_setting(
name = "pico_float_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "compiler"},
)
config_setting(
name = "pico_float_dcp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "dcp"},
)
config_setting(
name = "pico_float_rp2040_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "rp2040"},
)
config_setting(
name = "pico_float_vfp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_FLOAT_IMPL": "vfp"},
)
config_setting(
name = "pico_double_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "auto"},
)
config_setting(
name = "pico_double_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "compiler"},
)
config_setting(
name = "pico_double_dcp_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "dcp"},
)
config_setting(
name = "pico_double_rp2040_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DOUBLE_IMPL": "rp2040"},
)
config_setting(
name = "pico_divider_hardware_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "hardware"},
)
config_setting(
name = "pico_divider_auto_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_DIVIDER_IMPL": "auto"},
)
config_setting(
name = "pico_printf_pico_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico"},
)
config_setting(
name = "pico_printf_compiler_enabled",
flag_values = {"//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "compiler"},
)
config_setting(
name = "pico_use_default_max_page_size_enabled",
flag_values = {"//bazel/config:PICO_USE_DEFAULT_MAX_PAGE_SIZE": "True"},
)
config_setting(
name = "pico_no_target_name_enabled",
flag_values = {"//bazel/config:PICO_NO_TARGET_NAME": "True"},
)
config_setting(
name = "pico_clib_llvm_libc_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "llvm_libc"},
)
config_setting(
name = "pico_clib_newlib_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "newlib"},
)
config_setting(
name = "pico_clib_picolibc_enabled",
flag_values = {"//bazel/config:PICO_CLIB": "picolibc"},
)
config_setting(
name = "pico_btstack_config_unset",
flag_values = {"//bazel/config:PICO_BTSTACK_CONFIG": "//bazel:empty_cc_lib"},
)
config_setting(
name = "pico_lwip_config_unset",
flag_values = {"//bazel/config:PICO_LWIP_CONFIG": "//bazel:empty_cc_lib"},
)
config_setting(
name = "pico_freertos_unset",
flag_values = {"//bazel/config:PICO_FREERTOS_LIB": "//bazel:empty_cc_lib"},
)
pico-sdk-2.0.0/bazel/defs.bzl 0000664 0000000 0000000 00000007313 14655147036 0015770 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@rules_cc//cc:defs.bzl", "cc_library")
def _pico_generate_pio_header_impl(ctx):
generated_headers = []
for f in ctx.files.srcs:
out = ctx.actions.declare_file(
"{}_pio_generated/{}.h".format(ctx.label.name, f.basename),
)
generated_headers.append(out)
ctx.actions.run(
executable = ctx.executable._pioasm_tool,
arguments = [
"-o",
"c-sdk",
f.path,
out.path,
],
inputs = [f],
outputs = [out],
)
cc_ctx = cc_common.create_compilation_context(
headers = depset(direct = generated_headers),
includes = depset(direct = [generated_headers[0].dirname]),
)
return [
DefaultInfo(files = depset(direct = generated_headers)),
CcInfo(compilation_context = cc_ctx),
]
pico_generate_pio_header = rule(
implementation = _pico_generate_pio_header_impl,
doc = """Generates a .h header file for each listed pio source.
Each source file listed in `srcs` will be available as `[pio file name].h` on
the include path if you depend on this rule from a `cc_library`.
pico_generate_pio_header(
name = "my_fun_pio",
srcs = ["my_fun_pio.pio"],
)
# This library can #include "my_fun_pio.pio.h".
cc_library(
name = "libfoo",
deps = [":my_fun_pio"],
srcs = ["libfoo.c"],
)
""",
attrs = {
"srcs": attr.label_list(mandatory = True, allow_files = True),
"_pioasm_tool": attr.label(
default = "@pico-sdk//tools/pioasm:pioasm",
cfg = "exec",
executable = True,
),
},
provides = [CcInfo],
)
# Because the syntax for target_compatible_with when used with config_setting
# rules is both confusing and verbose, provide some helpers that make it much
# easier and clearer to express compatibility.
#
# Context: https://github.com/bazelbuild/bazel/issues/12614
def compatible_with_config(config_label):
"""Expresses compatibility with a config_setting."""
return select({
config_label: [],
"//conditions:default": ["@platforms//:incompatible"],
})
def incompatible_with_config(config_label):
"""Expresses incompatibility with a config_setting."""
return select({
config_label: ["@platforms//:incompatible"],
"//conditions:default": [],
})
def compatible_with_rp2():
"""Expresses a rule is compatible with the rp2 family."""
return incompatible_with_config("//bazel/constraint:host")
def compatible_with_pico_w():
"""Expresses a rule is compatible a Pico W."""
return select({
"@pico-sdk//bazel/constraint:cyw43_wireless": [],
"@pico-sdk//bazel/constraint:is_pico_w": [],
"//conditions:default": ["@platforms//:incompatible"],
})
def pico_board_config(name, platform_includes, **kwargs):
"""A helper macro for declaring a Pico board to use with PICO_CONFIG_HEADER.
This generates pico_config_platform_headers.h using the list of
includes provided in `platform_includes`, and the final artifact is
a cc_library that you can configure //bazel/config:PICO_CONFIG_HEADER to
point to.
"""
_hdr_dir = "{}_generated_includes".format(name)
_hdr_path = "{}/pico_config_platform_headers.h".format(_hdr_dir)
write_file(
name = "{}_platform_headers_file".format(name),
out = _hdr_path,
content = ['#include "{}"'.format(inc) for inc in platform_includes],
)
kwargs.setdefault("hdrs", [])
kwargs["hdrs"].append(_hdr_path)
kwargs.setdefault("includes", [])
kwargs["includes"].append(_hdr_dir)
cc_library(
name = name,
**kwargs
)
pico-sdk-2.0.0/bazel/generate_version_header.py 0000664 0000000 0000000 00000002733 14655147036 0021560 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python3
"""Generate a version header for the Bazel build.
Splits a semantic version string into major, minor, and patch and uses the
provided template to produce a working version header.
"""
import argparse
import re
import sys
def _parse_args():
parser = argparse.ArgumentParser(
description=__doc__,
)
parser.add_argument(
"--version-string",
required=True,
help="SDK version string",
)
parser.add_argument(
"--template",
type=argparse.FileType("r"),
required=True,
help="Path to version.h.in",
)
parser.add_argument(
"-o",
"--output",
type=argparse.FileType("wb"),
default=sys.stdout.buffer,
help="Output file path. Defaults to stdout.",
)
return parser.parse_args()
_EXPANSION_REGEX = re.compile(r"(?:\$\{)([a-zA-Z]\w*)(?:\})")
def generate_version_header(version_string, template, output):
version_parts = version_string.split('.')
defines = {
"PICO_SDK_VERSION_MAJOR": version_parts[0],
"PICO_SDK_VERSION_MINOR": version_parts[1],
"PICO_SDK_VERSION_REVISION": version_parts[2].split('-')[0],
"PICO_SDK_VERSION_STRING": version_string,
}
output.write(
_EXPANSION_REGEX.sub(
lambda val: str(defines.get(val.group(1))),
template.read(),
).encode()
)
if __name__ == "__main__":
sys.exit(generate_version_header(**vars(_parse_args())))
pico-sdk-2.0.0/bazel/include/ 0000775 0000000 0000000 00000000000 14655147036 0015755 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/include/pico/ 0000775 0000000 0000000 00000000000 14655147036 0016707 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/include/pico/config_autogen.h 0000664 0000000 0000000 00000001077 14655147036 0022054 0 ustar 00root root 0000000 0000000 // Rather than auto-generating as part of the build, this header
// is checked in directly.
//
// You can change what is included by configuring these `label_flag`s:
// --@pico-sdk//bazel/config:PICO_CONFIG_EXTRA_HEADER=//my_proj:my_custom_headers
// --@pico-sdk//bazel/config:PICO_CONFIG_PLATFORM_HEADER=//my_proj:my_custom_headers
// This header must be provided by //bazel/config:PICO_CONFIG_EXTRA_HEADER:
#include "pico_config_extra_headers.h"
// This header must be provided by //bazel/config:PICO_CONFIG_PLATFORM_HEADER:
#include "pico_config_platform_headers.h"
pico-sdk-2.0.0/bazel/platform/ 0000775 0000000 0000000 00000000000 14655147036 0016156 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/platform/BUILD.bazel 0000664 0000000 0000000 00000000536 14655147036 0020040 0 ustar 00root root 0000000 0000000 package(default_visibility = ["//visibility:public"])
platform(
name = "rp2040",
constraint_values = [
"@pico-sdk//bazel/constraint:rp2040",
"@platforms//cpu:armv6-m",
],
)
platform(
name = "rp2350",
constraint_values = [
"@pico-sdk//bazel/constraint:rp2350",
"@platforms//cpu:armv8-m",
],
)
pico-sdk-2.0.0/bazel/toolchain/ 0000775 0000000 0000000 00000000000 14655147036 0016312 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/toolchain/BUILD.bazel 0000664 0000000 0000000 00000024010 14655147036 0020165 0 ustar 00root root 0000000 0000000 load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature")
load("@rules_cc//cc/toolchains:toolchain.bzl", "cc_toolchain")
load("configurable_feature.bzl", "configurable_toolchain_feature")
package(default_visibility = ["//visibility:public"])
cc_args(
name = "armv6m-none-eabi",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = ["--target=armv6m-none-eabi"],
)
cc_args(
name = "armv8m.main-none-eabi",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = ["--target=armv8m.main-none-eabi"],
)
cc_args(
name = "cortex-m0",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-mcpu=cortex-m0plus",
"-mthumb",
],
)
cc_args(
name = "cortex-m33",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-mcpu=cortex-m33",
"-march=armv8-m.main+fp+dsp",
"-mfloat-abi=softfp",
"-mthumb",
"-mcmse",
],
)
cc_args(
name = "no-canonical-system-headers",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = ["-fno-canonical-system-headers"],
)
cc_args(
name = "no-canonical-prefixes",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = ["-no-canonical-prefixes"],
)
cc_args(
name = "nostdlibxx",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = ["-nostdlib++"],
)
cc_args(
name = "nostartfiles",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = ["-nostartfiles"],
)
cc_args_list(
name = "bazel_no_absolute_paths",
args = select({
"//bazel/constraint:pico_toolchain_clang_enabled": [],
"//conditions:default": [":no-canonical-system-headers"],
}) + [":no-canonical-prefixes"],
)
cc_args(
name = "opt_debug_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
"@rules_cc//cc/toolchains/actions:link_actions",
],
args = [
"-Og", # TODO: Make this configurable.
"-g3",
],
)
configurable_toolchain_feature(
name = "gc_sections",
copts = [
"-ffunction-sections",
"-fdata-sections",
],
disable_if = "//bazel/constraint:pico_no_gc_sections_enabled",
linkopts = ["-Wl,--gc-sections"],
)
configurable_toolchain_feature(
name = "cxx_no_exceptions",
cxxopts = [
"-fno-exceptions",
"-fno-unwind-tables",
],
disable_if = "//bazel/constraint:pico_cxx_enable_exceptions_enabled",
)
configurable_toolchain_feature(
name = "cxx_no_rtti",
cxxopts = ["-fno-rtti"],
disable_if = "//bazel/constraint:pico_cxx_enable_rtti_enabled",
)
configurable_toolchain_feature(
name = "cxx_no_cxa_atexit",
cxxopts = ["-fno-use-cxa-atexit"],
disable_if = "//bazel/constraint:pico_cxx_enable_cxa_atexit_enabled",
)
configurable_toolchain_feature(
name = "override_max_page_size",
disable_if = "//bazel/constraint:pico_use_default_max_page_size_enabled",
linkopts = ["-Wl,-z,max-page-size=4096"],
)
# TODO: Make this shim unnecessary.
cc_args_list(
name = "all_opt_debug_args",
args = [":opt_debug_args"],
)
cc_feature(
name = "override_debug",
args = [":all_opt_debug_args"],
enabled = True,
overrides = "@rules_cc//cc/toolchains/features:dbg",
)
# TODO: https://github.com/bazelbuild/rules_cc/issues/224 - This is required for
# now, but hopefully will eventually go away.
cc_feature(
name = "legacy_features",
args = [],
enabled = True,
feature_name = "force_legacy_features",
implies = [
"@rules_cc//cc/toolchains/features/legacy:archiver_flags",
"@rules_cc//cc/toolchains/features/legacy:build_interface_libraries",
"@rules_cc//cc/toolchains/features/legacy:dynamic_library_linker_tool",
"@rules_cc//cc/toolchains/features/legacy:strip_debug_symbols",
"@rules_cc//cc/toolchains/features/legacy:linkstamps",
"@rules_cc//cc/toolchains/features/legacy:output_execpath_flags",
"@rules_cc//cc/toolchains/features/legacy:runtime_library_search_directories",
"@rules_cc//cc/toolchains/features/legacy:library_search_directories",
"@rules_cc//cc/toolchains/features/legacy:libraries_to_link",
"@rules_cc//cc/toolchains/features/legacy:force_pic_flags",
"@rules_cc//cc/toolchains/features/legacy:user_link_flags",
"@rules_cc//cc/toolchains/features/legacy:legacy_link_flags",
"@rules_cc//cc/toolchains/features/legacy:linker_param_file",
"@rules_cc//cc/toolchains/features/legacy:fission_support",
"@rules_cc//cc/toolchains/features/legacy:sysroot",
],
)
HOSTS = (
("linux", "x86_64"),
("win", "x86_64"),
("mac", "x86_64"),
("mac", "aarch64"),
)
_HOST_OS_CONSTRAINTS = {
"linux": "@platforms//os:linux",
"win": "@platforms//os:windows",
"mac": "@platforms//os:macos",
}
_HOST_CPU_CONSTRAINTS = {
"x86_64": "@platforms//cpu:x86_64",
"aarch64": "@platforms//cpu:aarch64",
}
[cc_toolchain(
name = "arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
action_type_configs = [
"@arm_gcc_{}-{}//:arm-none-eabi-ar".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-gcc".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-g++".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-ld".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-objcopy".format(host_os, host_cpu),
"@arm_gcc_{}-{}//:arm-none-eabi-strip".format(host_os, host_cpu),
],
args = select({
"//bazel/constraint:rp2040": [":cortex-m0"],
"//bazel/constraint:rp2350": [":cortex-m33"],
"//conditions:default": [],
}) + [
":bazel_no_absolute_paths",
],
compiler = "gcc", # Useful for distinguishing gcc vs clang.
cxx_builtin_include_directories = [
"%sysroot%/arm-none-eabi/include/newlib-nano",
"%sysroot%/arm-none-eabi/include/c++/13.2.1",
"%sysroot%/arm-none-eabi/include/c++/13.2.1/arm-none-eabi",
"%sysroot%/arm-none-eabi/include/c++/13.2.1/backward",
"%sysroot%/lib/gcc/arm-none-eabi/13.2.1/include",
"%sysroot%/lib/gcc/arm-none-eabi/13.2.1/include-fixed",
"%sysroot%/arm-none-eabi/include",
],
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
sysroot = "external/arm_gcc_{}-{}".format(host_os, host_cpu),
tags = ["manual"], # Don't try to build this in wildcard builds.
toolchain_features = [
"@pico-sdk//bazel/toolchain:legacy_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
"@pico-sdk//bazel/toolchain:cxx_no_cxa_atexit",
"@pico-sdk//bazel/toolchain:override_max_page_size",
],
) for host_os, host_cpu in HOSTS]
[cc_toolchain(
name = "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
action_type_configs = [
"@clang_{}-{}//:llvm-ar".format(host_os, host_cpu),
"@clang_{}-{}//:clang".format(host_os, host_cpu),
"@clang_{}-{}//:clang++".format(host_os, host_cpu),
"@clang_{}-{}//:lld".format(host_os, host_cpu),
"@clang_{}-{}//:llvm-objcopy".format(host_os, host_cpu),
"@clang_{}-{}//:llvm-strip".format(host_os, host_cpu),
],
args = select({
"//bazel/constraint:rp2040": [
":armv6m-none-eabi",
":cortex-m0",
],
"//bazel/constraint:rp2350": [
":armv8m.main-none-eabi",
":cortex-m33",
],
"//conditions:default": [],
}) + [
":bazel_no_absolute_paths",
":nostdlibxx",
":nostartfiles",
],
compiler = "clang", # Useful for distinguishing gcc vs clang.
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
tags = ["manual"], # Don't try to build this in wildcard builds.
toolchain_features = [
"@pico-sdk//bazel/toolchain:legacy_features",
"@pico-sdk//bazel/toolchain:override_debug",
"@pico-sdk//bazel/toolchain:gc_sections",
"@pico-sdk//bazel/toolchain:cxx_no_exceptions",
"@pico-sdk//bazel/toolchain:cxx_no_rtti",
"@pico-sdk//bazel/toolchain:cxx_no_cxa_atexit",
"@pico-sdk//bazel/toolchain:override_max_page_size",
],
) for host_os, host_cpu in HOSTS]
[toolchain(
name = "{}-{}-rp2040".format(host_os, host_cpu),
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
target_compatible_with = [
"@pico-sdk//bazel/constraint:rp2040",
],
toolchain = select({
"//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
"//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
}),
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
) for host_os, host_cpu in HOSTS]
[toolchain(
name = "{}-{}-rp2350".format(host_os, host_cpu),
exec_compatible_with = [
_HOST_CPU_CONSTRAINTS[host_cpu],
_HOST_OS_CONSTRAINTS[host_os],
],
target_compatible_with = [
"@pico-sdk//bazel/constraint:rp2350",
],
toolchain = select({
"//bazel/constraint:pico_toolchain_clang_enabled": "clang_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
"//conditions:default": ":arm_gcc_{}-{}_toolchain_cortex-m".format(host_os, host_cpu),
}),
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
) for host_os, host_cpu in HOSTS]
pico-sdk-2.0.0/bazel/toolchain/clang.BUILD 0000664 0000000 0000000 00000010617 14655147036 0020164 0 ustar 00root root 0000000 0000000 load("@rules_cc//cc/toolchains:action_type_config.bzl", "cc_action_type_config")
load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
package(default_visibility = ["//visibility:public"])
cc_tool(
name = "llvm-ar_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-ar.exe",
"//conditions:default": "//:bin/llvm-ar",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "llvm-ar",
action_types = ["@rules_cc//cc/toolchains/actions:ar_actions"],
tools = [":llvm-ar_tool"],
)
cc_tool(
name = "clang_tool",
src = select({
"@platforms//os:windows": "//:bin/clang.exe",
"//conditions:default": "//:bin/clang",
}),
data = glob([
"include/armv*-unknown-none-eabi/**",
"lib/clang/*/include/**",
]) + select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "clang",
action_types = [
"@rules_cc//cc/toolchains/actions:assembly_actions",
"@rules_cc//cc/toolchains/actions:c_compile",
],
tools = [":clang_tool"],
)
cc_tool(
name = "clang++_tool",
src = select({
"@platforms//os:windows": "//:bin/clang++.exe",
"//conditions:default": "//:bin/clang++",
}),
data = glob([
"include/armv*-unknown-none-eabi/**",
"include/c++/**",
"lib/clang/*/include/**",
]) + select({
# Windows doesn't have llvm.exe.
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "clang++",
action_types = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"],
tools = [":clang++_tool"],
)
# This tool is actually just clang++ under the hood, but this specifies a
# different set of data files to pull into the sandbox at runtime.
cc_tool(
name = "lld_tool",
src = select({
"@platforms//os:windows": "//:bin/clang++.exe",
"//conditions:default": "//:bin/clang++",
}),
data = glob([
"lib/armv*-unknown-none-eabi/**",
"lib/clang/*/lib/armv*-unknown-none-eabi/**",
]) + select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "lld",
action_types = ["@rules_cc//cc/toolchains/actions:link_actions"],
tools = [":lld_tool"],
)
cc_tool(
name = "llvm-objcopy_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-objcopy.exe",
"//conditions:default": "//:bin/llvm-objcopy",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "llvm-objcopy",
action_types = ["@rules_cc//cc/toolchains/actions:objcopy_embed_data"],
tools = [":llvm-objcopy_tool"],
)
cc_tool(
name = "llvm-strip_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-strip.exe",
"//conditions:default": "//:bin/llvm-strip",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
cc_action_type_config(
name = "llvm-strip",
action_types = ["@rules_cc//cc/toolchains/actions:strip"],
tools = [":llvm-strip_tool"],
)
cc_tool(
name = "llvm-objdump_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-objdump.exe",
"//conditions:default": "//:bin/llvm-objdump",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
# There is not yet a well-known action type for llvm-objdump.
cc_tool(
name = "llvm-profdata_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-profdata.exe",
"//conditions:default": "//:bin/llvm-profdata",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
# There is not yet a well-known action type for llvm-profdata.
cc_tool(
name = "llvm-cov_tool",
src = select({
"@platforms//os:windows": "//:bin/llvm-cov.exe",
"//conditions:default": "//:bin/llvm-cov",
}),
data = select({
"@platforms//os:windows": [],
"//conditions:default": ["//:bin/llvm"],
}),
)
# There is not yet a well-known action type for llvm-cov.
pico-sdk-2.0.0/bazel/toolchain/configurable_feature.bzl 0000664 0000000 0000000 00000003207 14655147036 0023200 0 ustar 00root root 0000000 0000000 load("@rules_cc//cc/toolchains:args.bzl", "cc_args")
load("@rules_cc//cc/toolchains:args_list.bzl", "cc_args_list")
load("@rules_cc//cc/toolchains:feature.bzl", "cc_feature")
def configurable_toolchain_feature(name, copts = [], cxxopts = [], linkopts = [], enable_if = None, disable_if = None):
if enable_if != None and disable_if != None:
fail("Cannot specify both enable_if and disable_if")
if enable_if == None and disable_if == None:
fail("Must specify at least one of enable_if and disable_if")
if enable_if == None:
enable_if = "//conditions:default"
if disable_if == None:
disable_if = "//conditions:default"
all_args = []
if copts:
cc_args(
name = name + "_cc_args",
actions = ["@rules_cc//cc/toolchains/actions:compile_actions"],
args = copts,
)
all_args.append(name + "_cc_args")
if cxxopts:
cc_args(
name = name + "_cxx_args",
actions = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"],
args = cxxopts,
)
all_args.append(name + "_cxx_args")
if linkopts:
cc_args(
name = name + "_link_args",
actions = ["@rules_cc//cc/toolchains/actions:link_actions"],
args = linkopts,
)
all_args.append(name + "_link_args")
cc_args_list(
name = name + "_args",
args = all_args,
)
cc_feature(
name = name,
feature_name = name,
args = [":{}_args".format(name)],
enabled = select({
disable_if: False,
enable_if: True,
}),
)
pico-sdk-2.0.0/bazel/toolchain/gcc_arm_none_eabi.BUILD 0000664 0000000 0000000 00000010075 14655147036 0022470 0 ustar 00root root 0000000 0000000 load("@rules_cc//cc/toolchains:action_type_config.bzl", "cc_action_type_config")
load("@rules_cc//cc/toolchains:tool.bzl", "cc_tool")
package(default_visibility = ["//visibility:public"])
cc_tool(
name = "arm-none-eabi-ar_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-ar.exe",
"//conditions:default": "//:bin/arm-none-eabi-ar",
}),
)
cc_action_type_config(
name = "arm-none-eabi-ar",
action_types = ["@rules_cc//cc/toolchains/actions:ar_actions"],
tools = [":arm-none-eabi-ar_tool"],
)
cc_tool(
name = "arm-none-eabi-g++_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe",
"//conditions:default": "//:bin/arm-none-eabi-g++",
}),
data = glob([
"**/*.spec",
"**/*.specs",
"arm-none-eabi/include/**",
"lib/gcc/arm-none-eabi/*/include/**",
"lib/gcc/arm-none-eabi/*/include-fixed/**",
"libexec/**",
]),
)
cc_action_type_config(
name = "arm-none-eabi-g++",
action_types = ["@rules_cc//cc/toolchains/actions:cpp_compile_actions"],
tools = [":arm-none-eabi-g++_tool"],
)
cc_tool(
name = "arm-none-eabi-gcc_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-gcc.exe",
"//conditions:default": "//:bin/arm-none-eabi-gcc",
}),
data = glob([
"**/*.spec",
"**/*.specs",
"arm-none-eabi/include/**",
"lib/gcc/arm-none-eabi/*/include/**",
"lib/gcc/arm-none-eabi/*/include-fixed/**",
"libexec/**",
]) +
# The assembler needs to be explicitly added. Note that the path is
# intentionally different here as `as` is called from arm-none-eabi-gcc.
# `arm-none-eabi-as` will not suffice for this context.
select({
"@platforms//os:windows": ["//:arm-none-eabi/bin/as.exe"],
"//conditions:default": ["//:arm-none-eabi/bin/as"],
}),
)
cc_action_type_config(
name = "arm-none-eabi-gcc",
action_types = [
"@rules_cc//cc/toolchains/actions:assembly_actions",
"@rules_cc//cc/toolchains/actions:c_compile",
],
tools = [":arm-none-eabi-gcc_tool"],
)
# This tool is actually just g++ under the hood, but this specifies a
# different set of data files to pull into the sandbox at runtime.
cc_tool(
name = "arm-none-eabi-ld_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-g++.exe",
"//conditions:default": "//:bin/arm-none-eabi-g++",
}),
data = glob([
"**/*.a",
"**/*.ld",
"**/*.o",
"**/*.spec",
"**/*.specs",
"**/*.so",
"libexec/**",
]),
)
cc_action_type_config(
name = "arm-none-eabi-ld",
action_types = ["@rules_cc//cc/toolchains/actions:link_actions"],
tools = [":arm-none-eabi-ld_tool"],
)
cc_tool(
name = "arm-none-eabi-objcopy_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-objcopy.exe",
"//conditions:default": "//:bin/arm-none-eabi-objcopy",
}),
)
cc_action_type_config(
name = "arm-none-eabi-objcopy",
action_types = ["@rules_cc//cc/toolchains/actions:objcopy_embed_data"],
tools = [":arm-none-eabi-objcopy_tool"],
)
cc_tool(
name = "arm-none-eabi-strip_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-strip.exe",
"//conditions:default": "//:bin/arm-none-eabi-strip",
}),
)
cc_action_type_config(
name = "arm-none-eabi-strip",
action_types = ["@rules_cc//cc/toolchains/actions:strip"],
tools = [":arm-none-eabi-strip_tool"],
)
cc_tool(
name = "arm-none-eabi-objdump_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-objdump.exe",
"//conditions:default": "//:bin/arm-none-eabi-objdump",
}),
)
# There is not yet a well-known action type for objdump.
cc_tool(
name = "arm-none-eabi-gcov_tool",
src = select({
"@platforms//os:windows": "//:bin/arm-none-eabi-gcov.exe",
"//conditions:default": "//:bin/arm-none-eabi-gcov",
}),
)
# There is not yet a well-known action type for gcov.
pico-sdk-2.0.0/bazel/toolchain/objcopy.bzl 0000664 0000000 0000000 00000002612 14655147036 0020471 0 ustar 00root root 0000000 0000000 load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "OBJ_COPY_ACTION_NAME")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cpp_toolchain", "use_cc_toolchain")
def _objcopy_to_bin_impl(ctx):
cc_toolchain = find_cpp_toolchain(ctx)
feature_configuration = cc_common.configure_features(
ctx = ctx,
cc_toolchain = cc_toolchain,
requested_features = ctx.features,
unsupported_features = ctx.disabled_features,
)
objcopy_tool_path = cc_common.get_tool_for_action(
feature_configuration = feature_configuration,
action_name = OBJ_COPY_ACTION_NAME,
)
ctx.actions.run(
inputs = depset(
direct = [ctx.file.src],
transitive = [cc_toolchain.all_files],
),
executable = objcopy_tool_path,
outputs = [ctx.outputs.out],
arguments = [
ctx.file.src.path,
"-Obinary",
ctx.outputs.out.path,
],
)
objcopy_to_bin = rule(
implementation = _objcopy_to_bin_impl,
attrs = {
"src": attr.label(
allow_single_file = True,
mandatory = True,
doc = "File to use as input to objcopy command",
),
"out": attr.output(
mandatory = True,
doc = "Destination file for objcopy command",
),
},
fragments = ["cpp"],
toolchains = use_cc_toolchain(),
)
pico-sdk-2.0.0/bazel/util/ 0000775 0000000 0000000 00000000000 14655147036 0015307 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/bazel/util/BUILD.bazel 0000664 0000000 0000000 00000000066 14655147036 0017167 0 ustar 00root root 0000000 0000000 package(default_visibility = ["//visibility:public"])
pico-sdk-2.0.0/bazel/util/multiple_choice_flag.bzl 0000664 0000000 0000000 00000002341 14655147036 0022156 0 ustar 00root root 0000000 0000000 def declare_flag_choices(flag, choices):
"""Declares a `config_setting` for each known choice for the provided flag.
The name of each config setting uses the name of the `config_setting` is:
[flag label name]_[choice]
This can be used with select_choice() to map `config_setting`s to values.
Args:
flag: The flag that guides the declared `config_setting`s.
pkg: The package that declare_flag_choices() was declared in.
choice_map: A mapping of distinct choices to
"""
flag_name = flag.split(":")[1]
[
native.config_setting(
name = "{}_{}".format(flag_name, choice),
flag_values = {flag: choice},
)
for choice in choices
]
def flag_choice(flag, pkg, choice_map):
"""Creates a `select()` based on choices declared by `declare_choices()`.
Args:
flag: The flag that guides the select.
pkg: The package that `declare_flag_choices()` was called in.
choice_map: A mapping of distinct choices to the final intended value.
"""
return {
"{}:{}_{}".format(
pkg.split(":")[0],
flag.split(":")[1],
choice,
): val
for choice, val in choice_map.items()
}
pico-sdk-2.0.0/bazel/util/sdk_define.bzl 0000664 0000000 0000000 00000002203 14655147036 0020110 0 ustar 00root root 0000000 0000000 load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
def _pico_sdk_define_impl(ctx):
val = ctx.attr.from_flag[BuildSettingInfo].value
if type(val) == "string":
# Strings need quotes.
val = "\"{}\"".format(val)
elif type(val) == "bool":
# Convert bools to 0 or 1.
val = 1 if val else 0
cc_ctx = cc_common.create_compilation_context(
defines = depset(
direct = ["{}={}".format(ctx.attr.define_name, val)],
),
)
return [CcInfo(compilation_context = cc_ctx)]
pico_sdk_define = rule(
implementation = _pico_sdk_define_impl,
doc = """A simple rule that offers a skylib flag as a define.
These can be listed in the `deps` attribute of a `cc_library` to get access
to the value of a define.
Example:
bool_flag(
name = "my_flag",
build_setting_default = False,
)
pico_sdk_define(
name = "flag_define",
define_name = "MY_FLAG_DEFINE",
from_flag = ":my_flag",
)
""",
attrs = {
"define_name": attr.string(mandatory = True),
"from_flag": attr.label(mandatory = True),
},
)
pico-sdk-2.0.0/bazel/util/transition.bzl 0000664 0000000 0000000 00000013165 14655147036 0020220 0 ustar 00root root 0000000 0000000 def declare_transtion(attrs, flag_overrides = None, append_to_flags = None, executable = True):
"""A helper that drastically simplifies declaration of a transition.
A transition in Bazel is a way to force changes to the way the build is
evaluated for all dependencies of a given rule.
Imagine the following simple dependency graph:
->: depends on
a -> b -> c
Normally, if you set `defines` on a, they couldn't apply to b or c because
they are dependencies of a. There's no way for b or c to know about a's
settings, because they don't even know a exists!
We can fix this via a transition! If we put a transition in front of `a`
that sets --copts=-DFOO=42, we're telling Bazel to build a and all of its
dependencies under that configuration.
Note: Flags must be referenced as e.g. `//command_line_option:copt` in
transitions.
`declare_transition()` eliminates the frustrating amount of boilerplate. All
you need to do is provide a set of attrs, and then a `flag_overrides`
dictionary that tells `declare_transition()` which attrs to pull flag values
from. The common `src` attr tells the transition which build rule to apply
the transition to.
"""
def _flag_override_impl(settings, attrs):
final_overrides = {}
if flag_overrides != None:
final_overrides = {
key: str(getattr(attrs, value))
for key, value in flag_overrides.items()
}
if append_to_flags != None:
for flag, field in append_to_flags.items():
accumulated_flags = final_overrides.get(flag, settings.get(flag, []))
accumulated_flags.extend(
[str(val) for val in getattr(attrs, field)],
)
final_overrides[flag] = accumulated_flags
return final_overrides
output_flags = []
if flag_overrides != None:
output_flags.extend(flag_overrides.keys())
if append_to_flags != None:
output_flags.extend(append_to_flags.keys())
_transition = transition(
implementation = _flag_override_impl,
inputs = append_to_flags.keys() if append_to_flags != None else [],
outputs = output_flags,
)
def _symlink_artifact_impl(ctx):
out = ctx.actions.declare_file(ctx.label.name)
if executable:
ctx.actions.symlink(output = out, target_file = ctx.executable.src)
return [DefaultInfo(files = depset([out]), executable = out)]
ctx.actions.symlink(
output = out,
target_file = ctx.attr.src[0][DefaultInfo].files.to_list()[0],
)
return [DefaultInfo(files = depset([out]))]
return rule(
implementation = _symlink_artifact_impl,
executable = executable,
attrs = {
"src": attr.label(
cfg = _transition,
executable = executable,
mandatory = True,
),
} | attrs,
)
# This transition is applied before building the boot_stage2 image.
rp2040_bootloader_binary = declare_transtion(
attrs = {
"_malloc": attr.label(default = "//bazel:empty_cc_lib"),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
# We don't want --custom_malloc to ever apply to the bootloader, so
# always explicitly override it here.
"//command_line_option:custom_malloc": "_malloc",
},
)
# This transition sets SDK configuration options required to build test binaries
# for the kitchen_sink suite of tests.
kitchen_sink_test_binary = declare_transtion(
attrs = {
"bt_stack_config": attr.label(mandatory = True),
"lwip_config": attr.label(mandatory = True),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG": "bt_stack_config",
"@pico-sdk//bazel/config:PICO_LWIP_CONFIG": "lwip_config",
},
)
# This transition sets SDK configuration options required to build test binaries
# for the pico_float_test suite of tests.
pico_float_test_binary = declare_transtion(
attrs = {
"pico_printf_impl": attr.string(),
"extra_copts": attr.string_list(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
flag_overrides = {
"@pico-sdk//bazel/config:PICO_DEFAULT_PRINTF_IMPL": "pico_printf_impl",
},
append_to_flags = {
"//command_line_option:copt": "extra_copts",
},
)
# This is a general purpose transition that applies the listed copt flags to
# all transitive dependencies.
extra_copts_for_all_deps = declare_transtion(
attrs = {
"extra_copts": attr.string_list(),
# This could be shared, but we don't in order to make it clearer that
# a transition is in use.
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
append_to_flags = {
"//command_line_option:copt": "extra_copts",
},
)
pico-sdk-2.0.0/cmake/ 0000775 0000000 0000000 00000000000 14655147036 0014315 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/Platform/ 0000775 0000000 0000000 00000000000 14655147036 0016101 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/Platform/PICO.cmake 0000664 0000000 0000000 00000000242 14655147036 0017633 0 ustar 00root root 0000000 0000000 # this is included because toolchain file sets SYSTEM_NAME=PICO
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
set(CMAKE_EXECUTABLE_SUFFIX .elf) pico-sdk-2.0.0/cmake/generic_board.cmake 0000664 0000000 0000000 00000004005 14655147036 0020101 0 ustar 00root root 0000000 0000000 # For boards without their own cmake file, we look for a header file
# PICO_CMAKE_CONFIG: PICO_BOARD_HEADER_DIRS, List of directories to look for .h in. This may be specified the user environment, type=list, group=build
if (DEFINED ENV{PICO_BOARD_HEADER_DIRS})
set(PICO_BOARD_HEADER_DIRS $ENV{PICO_BOARD_HEADER_DIRS})
message("Using PICO_BOARD_HEADER_DIRS from environment ('${PICO_BOARD_HEADER_DIRS}')")
endif()
set(PICO_BOARD_HEADER_DIRS ${PICO_BOARD_HEADER_DIRS} CACHE STRING "PICO board header directories" FORCE)
list(APPEND PICO_BOARD_HEADER_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards/include/boards)
pico_find_in_paths(PICO_BOARD_HEADER_FILE PICO_BOARD_HEADER_DIRS ${PICO_BOARD}.h)
if (EXISTS ${PICO_BOARD_HEADER_FILE})
message("Using board configuration from ${PICO_BOARD_HEADER_FILE}")
list(APPEND PICO_CONFIG_HEADER_FILES ${PICO_BOARD_HEADER_FILE})
# we parse the header file to configure the defaults
file(STRINGS ${PICO_BOARD_HEADER_FILE} HEADER_FILE_CONTENTS)
while(HEADER_FILE_CONTENTS)
list(POP_FRONT HEADER_FILE_CONTENTS LINE)
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
if (LINE MATCHES "^[ \t\]*//[ \t\]*pico_cmake_set_default[ \t\]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t\]*=[ \t\]*(.*)")
if (NOT DEFINED "${CMAKE_MATCH_1}")
set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}")
endif()
endif()
endwhile()
else()
set(msg "Unable to find definition of board '${PICO_BOARD}' (specified by PICO_BOARD):\n")
list(JOIN PICO_BOARD_HEADER_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.h in ${DIRS} (additional paths specified by PICO_BOARD_HEADER_DIRS)\n")
list(JOIN PICO_BOARD_CMAKE_DIRS ", " DIRS)
string(CONCAT msg ${msg} " Looked for ${PICO_BOARD}.cmake in ${DIRS} (additional paths specified by PICO_BOARD_CMAKE_DIRS)")
message(FATAL_ERROR ${msg})
endif()
pico-sdk-2.0.0/cmake/pico_pre_load_platform.cmake 0000664 0000000 0000000 00000016075 14655147036 0022033 0 ustar 00root root 0000000 0000000 # PICO_BOARD is the root of config as it can define PICO_PLATFORM and other build vars
# PICO_CMAKE_CONFIG: PICO_BOARD, Board name being built for. This may be specified in the user environment, type=string, default=pico or pico2, group=build, docref=cmake-platform-board-config
if (DEFINED ENV{PICO_BOARD} AND NOT PICO_BOARD)
set(PICO_BOARD $ENV{PICO_BOARD})
message("Initializing PICO_BOARD from environment ('${PICO_BOARD}')")
endif()
# PICO_CMAKE_CONFIG: PICO_PLATFORM, Platform to build for e.g. rp2040/rp2350/rp2350-arm-s/rp2350-riscv/host. This may be specified in the user environment, type=string, default=based on PICO_BOARD or environment value, group=build, docref=cmake-platform-board-config
if (DEFINED ENV{PICO_PLATFORM} AND NOT PICO_PLATFORM)
set(PICO_PLATFORM $ENV{PICO_PLATFORM})
message("Initializing PICO_PLATFORM from environment ('${PICO_PLATFORM}')")
endif()
set(PICO_SAVED_PLATFORM "${PICO_PLATFORM}")
# If PICO_PLATFORM is specified byt not PICO_BOARD, we'll make a stab at defaulting
if (NOT PICO_DEFAULT_BOARD_rp2040)
set(PICO_DEFAULT_BOARD_rp2040 "pico")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350)
set(PICO_DEFAULT_BOARD_rp2350 "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350-arm-s)
set(PICO_DEFAULT_BOARD_rp2350-arm-s "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_rp2350-riscv)
set(PICO_DEFAULT_BOARD_rp2350-riscv "pico2")
endif()
if (NOT PICO_DEFAULT_BOARD_host)
set(PICO_DEFAULT_BOARD_host "none")
endif()
if (NOT PICO_DEFAULT_PLATFORM)
set(PICO_DEFAULT_PLATFORM "rp2040")
endif()
if (NOT PICO_BOARD)
if (NOT PICO_PLATFORM)
# if we have neither BOARD nor PLATFORM default PLATFORM silently, so we don't end up with a board of "none"
# on platform that does have a default board (we want default PLATFORM and BOARD in that case)
set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
# set PICO_SAVED_PLATFORM so we don't print "Defaulting" again below
set(PICO_SAVED_PLATFORM ${PICO_DEFAULT_PLATFORM})
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
endif()
if (PICO_DEFAULT_BOARD_${PICO_PLATFORM})
set(PICO_BOARD ${PICO_DEFAULT_BOARD_${PICO_PLATFORM}})
else()
set(PICO_BOARD "none")
endif()
pico_message("Defaulting target board (PICO_BOARD) to '${PICO_BOARD}' since not specified.")
else()
message("Target board (PICO_BOARD) is '${PICO_BOARD}'.")
endif()
set(PICO_BOARD ${PICO_BOARD} CACHE STRING "PICO target board (e.g. pico, pico2)" FORCE)
# PICO_CMAKE_CONFIG: PICO_BOARD_CMAKE_DIRS, List of directories to look for .cmake in. This may be specified in the user environment, type=list, group=build
if (DEFINED ENV{PICO_BOARD_CMAKE_DIRS})
set(PICO_BOARD_CMAKE_DIRS $ENV{PICO_BOARD_CMAKE_DIRS})
message("Using PICO_BOARD_CMAKE_DIRS from environment ('${PICO_BOARD_CMAKE_DIRS}')")
endif()
list(APPEND PICO_BOARD_CMAKE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src/boards)
pico_find_in_paths(PICO_BOARD_CMAKE_FILE PICO_BOARD_CMAKE_DIRS ${PICO_BOARD}.cmake)
if (EXISTS "${PICO_BOARD_CMAKE_FILE}")
message("Using CMake board configuration from ${PICO_BOARD_CMAKE_FILE}")
include(${PICO_BOARD_CMAKE_FILE} board_config)
else()
include(generic_board)
endif()
list(APPEND PICO_INCLUDE_DIRS ${PICO_SDK_PATH}/src/boards/include) # so boards/foo.h can be explicitly included
# PICO_CMAKE_CONFIG: PICO_DEFAULT_RP2350_PLATFORM, Default actual platform to build for if rp2350 is specified for PICO_PLATFORM e.g. rp2350-arm-s/rp2350-riscv, type=string, default=rp2350-arm-s, group=build
if (DEFINED ENV{PICO_DEFAULT_RP2350_PLATFORM} AND NOT PICO_DEFAULT_RP2350_PLATFORM)
set(PICO_DEFAULT_RP2350_PLATFORM $ENV{PICO_DEFAULT_RP2350_PLATFORM})
endif()
if (NOT PICO_DEFAULT_RP2350_PLATFORM)
set(PICO_DEFAULT_RP2350_PLATFORM "rp2350-arm-s")
endif()
if (NOT COMMAND pico_expand_pico_platform)
function(pico_expand_pico_platform FUNC DO_MESSAGE)
if (${FUNC} STREQUAL "rp2350")
if (DO_MESSAGE)
message("Auto-converting non-specific PICO_PLATFORM='rp2350' to 'rp2350-arm-s'")
endif()
set(${FUNC} "${PICO_DEFAULT_RP2350_PLATFORM}" PARENT_SCOPE)
endif()
endfunction()
endif()
if (NOT PICO_PLATFORM)
set(PICO_PLATFORM ${PICO_DEFAULT_PLATFORM})
pico_message("Defaulting platform (PICO_PLATFORM) to '${PICO_PLATFORM}' since not specified.")
else()
if (NOT PICO_SAVED_PLATFORM)
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})
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
pico_expand_pico_platform(PICO_SAVED_PLATFORM 0)
set(PICO_PLATFORM ${PICO_SAVED_PLATFORM})
message("Pico Platform (PICO_PLATFORM) is '${PICO_PLATFORM}'.")
else()
message(FATAL_ERROR "PICO_PLATFORM is specified to be '${PICO_SAVED_PLATFORM}', but PICO_BOARD='${PICO_BOARD}' uses \
'${PICO_PLATFORM}' which is incompatible. You need to delete the CMake cache or build directory and reconfigure to proceed. \
The best practice is to use separate build directories for different platforms.")
endif()
endif()
endif()
unset(PICO_SAVED_PLATFORM)
if (PICO_PREVIOUS_PLATFORM AND NOT PICO_PREVIOUS_PLATFORM STREQUAL PICO_PLATFORM)
message(FATAL_ERROR "PICO_PLATFORM has been modified from '${PICO_SAVED_PLATFORM}' to '${PICO_PLATFORM}.\
You need to delete the CMake cache or build directory and reconfigure to proceed.\
The best practice is to use separate build directories for different platforms.")
endif()
set(PICO_PLATFORM ${PICO_PLATFORM} CACHE STRING "PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" FORCE)
set(PICO_PREVIOUS_PLATFORM ${PICO_PLATFORM} CACHE STRING "Saved PICO Build platform (e.g. rp2040, rp2350, rp2350-riscv, host)" INTERNAL)
# PICO_CMAKE_CONFIG: PICO_CMAKE_PRELOAD_PLATFORM_FILE, Custom CMake file to use to set up the platform environment, type=string, group=build
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_FILE} CACHE INTERNAL "")
if (NOT PICO_CMAKE_PRELOAD_PLATFORM_DIR)
set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/platforms")
endif()
set(PICO_CMAKE_PRELOAD_PLATFORM_DIR "${PICO_CMAKE_PRELOAD_PLATFORM_DIR}" CACHE INTERNAL "")
if (NOT PICO_CMAKE_PRELOAD_PLATFORM_FILE)
set(PICO_CMAKE_PRELOAD_PLATFORM_FILE ${PICO_CMAKE_PRELOAD_PLATFORM_DIR}/${PICO_PLATFORM}.cmake CACHE INTERNAL "")
endif ()
if (NOT EXISTS "${PICO_CMAKE_PRELOAD_PLATFORM_FILE}")
message(FATAL_ERROR "${PICO_CMAKE_PRELOAD_PLATFORM_FILE} does not exist. \
Either specify a valid PICO_PLATFORM (or PICO_CMAKE_PRELOAD_PLATFORM_FILE).")
endif ()
include(${PICO_CMAKE_PRELOAD_PLATFORM_FILE})
pico-sdk-2.0.0/cmake/pico_pre_load_toolchain.cmake 0000664 0000000 0000000 00000007417 14655147036 0022167 0 ustar 00root root 0000000 0000000 # PICO_CMAKE_CONFIG: PICO_TOOLCHAIN_PATH, Path to search for compiler, type=string, default=none (i.e. search system paths), group=build, docref=cmake-toolchain-config
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)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Defaulting build type to '${default_build_type}' since not specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build, options are: 'Debug', 'Release', 'MinSizeRel', 'RelWithDebInfo'." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Default")
error("Default build type is NOT supported")
endif()
if (NOT (DEFINED PICO_COMPILER OR DEFINED CMAKE_TOOLCHAIN_FILE))
if (DEFINED PICO_DEFAULT_COMPILER)
pico_message("Defaulting compiler (PICO_COMPILER) to '${PICO_DEFAULT_COMPILER}' since not specified.")
set(PICO_COMPILER ${PICO_DEFAULT_COMPILER})
endif()
endif ()
# PICO_CMAKE_CONFIG: PICO_COMPILER, Specifies the compiler family to use, type=string, group=build, default=PICO_DEFAULT_COMPILER which is set based on PICO_PLATFORM, docref=cmake-toolchain-config
# If PICO_COMPILER is specified, set toolchain file to ${PICO_COMPILER}.cmake.
if (DEFINED PICO_COMPILER)
# maintain backwards compatibility with RP2040 SDK compilers
set(ORIG_PICO_COMPILER "${PICO_COMPILER}")
if (PICO_COMPILER STREQUAL "pico_arm_gcc")
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_COMPILER "pico_arm_cortex_m0plus_gcc")
elseif(PICO_PLATFORM STREQUAL "rp2350")
set(PICO_COMPILER "pico_arm_cortex_m33_gcc")
endif()
elseif(PICO_COMPILER STREQUAL "pico_arm_clang")
if (PICO_PLATFORM STREQUAL "rp2040")
set(PICO_COMPILER "pico_arm_cortex_m0plus_clang")
elseif(PICO_PLATFORM STREQUAL "rp2350-arm-s")
set(PICO_COMPILER "pico_arm_cortex_m33_clang")
elseif(PICO_PLATFORM STREQUAL "rp2350-arm-ns")
set(PICO_COMPILER "pico_arm_cortex_m33_clang")
endif()
endif()
if (NOT PICO_COMPILER STREQUAL ORIG_PICO_COMPILER)
message("Accepting PICO_COMPILER value '${ORIG_PICO_COMPILER}' for compatibility, but using '${PICO_COMPILER}' instead")
endif()
if (NOT DEFINED PICO_TOOLCHAIN_DIR)
set(PICO_TOOLCHAIN_DIR "${CMAKE_CURRENT_LIST_DIR}/preload/toolchains")
endif()
set(toolchain_file "${PICO_TOOLCHAIN_DIR}/${PICO_COMPILER}.cmake")
if (EXISTS "${toolchain_file}")
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}")
else ()
# todo improve message
message(FATAL_ERROR "Toolchain file \"${PICO_COMPILER}.cmake\" does not exist, please\
select one from \"cmake/toolchains\" folder.")
endif ()
message("Configuring toolchain based on PICO_COMPILER '${PICO_COMPILER}'")
endif ()
if (PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE)
if (NOT "${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}" STREQUAL "${CMAKE_TOOLCHAIN_FILE}")
message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE was previously defined to ${PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE}, and now\
is being changed to ${CMAKE_TOOLCHAIN_FILE}. You\
need to delete the CMake cache and reconfigure if you want to switch compiler.\
The best practice is to use separate build directories for different platforms or compilers.")
endif ()
endif ()
set(PICO_PREVIOUS_CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE} CACHE INTERNAL "Saved CMAKE_TOOLCHAIN_FILE" FORCE)
unset(PICO_COMPILER CACHE)
pico-sdk-2.0.0/cmake/pico_utils.cmake 0000664 0000000 0000000 00000001276 14655147036 0017477 0 ustar 00root root 0000000 0000000 function(pico_message param)
if (${ARGC} EQUAL 1)
message("${param}")
return()
endif ()
if (NOT ${ARGC} EQUAL 2)
message(FATAL_ERROR "Expect at most 2 arguments")
endif ()
message("${param}" "${ARGV1}")
endfunction()
macro(assert VAR MSG)
if (NOT ${VAR})
message(FATAL_ERROR "${MSG}")
endif ()
endmacro()
function(pico_find_in_paths OUT PATHS NAME)
foreach(PATH IN LISTS ${PATHS})
if (EXISTS ${PATH}/${NAME})
get_filename_component(FULLNAME ${PATH}/${NAME} ABSOLUTE)
set(${OUT} ${FULLNAME} PARENT_SCOPE)
return()
endif()
endforeach()
set(${OUT} "" PARENT_SCOPE)
endfunction() pico-sdk-2.0.0/cmake/preload/ 0000775 0000000 0000000 00000000000 14655147036 0015743 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/preload/platforms/ 0000775 0000000 0000000 00000000000 14655147036 0017752 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/preload/platforms/combined-docs.cmake 0000664 0000000 0000000 00000000114 14655147036 0023456 0 ustar 00root root 0000000 0000000 set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
set(PICO_CHIP rp2350)
pico-sdk-2.0.0/cmake/preload/platforms/host.cmake 0000664 0000000 0000000 00000000000 14655147036 0021717 0 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/preload/platforms/rp2040.cmake 0000664 0000000 0000000 00000000116 14655147036 0021701 0 ustar 00root root 0000000 0000000 set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m0plus_gcc")
set(PICO_CHIP rp2040)
pico-sdk-2.0.0/cmake/preload/platforms/rp2350-arm-s.cmake 0000664 0000000 0000000 00000000114 14655147036 0022720 0 ustar 00root root 0000000 0000000 set(PICO_DEFAULT_COMPILER "pico_arm_cortex_m33_gcc")
set(PICO_CHIP rp2350)
pico-sdk-2.0.0/cmake/preload/platforms/rp2350-riscv.cmake 0000664 0000000 0000000 00000000103 14655147036 0023025 0 ustar 00root root 0000000 0000000 set(PICO_DEFAULT_COMPILER "pico_riscv_gcc")
set(PICO_CHIP rp2350)
pico-sdk-2.0.0/cmake/preload/toolchains/ 0000775 0000000 0000000 00000000000 14655147036 0020106 5 ustar 00root root 0000000 0000000 pico-sdk-2.0.0/cmake/preload/toolchains/pico_arm_clang_arm.cmake 0000664 0000000 0000000 00000003514 14655147036 0024707 0 ustar 00root root 0000000 0000000 # NOTE: THIS IS A WIP ONLY PICO_ARM_GCC IS CURRENTLY SUPPORTED
# todo there is probably a more "cmake" way of doing this going thru the standard path with our "PICO" platform
# i.e. CMakeInformation and whatnot
include(${CMAKE_CURRENT_LIST_DIR}/util/find_compiler.cmake)
# include our Platform/PICO.cmake
set(CMAKE_SYSTEM_NAME PICO)
set(CMAKE_SYSTEM_PROCESSOR cortex-m0plus)
# Find ARMClang.
pico_find_compiler(PICO_COMPILER_CC armclang)
pico_find_compiler(PICO_COMPILER_CXX armclang)
pico_find_compiler(PICO_COMPILER_ASM armasm)
set(PICO_COMPILER_ASM "${PICO_COMPILER_ASM}" CACHE INTERNAL "")
pico_find_compiler(PICO_OBJCOPY llvm-objcopy)
pico_find_compiler(PICO_OBJDUMP llvm-objdump)
# Specify the cross compiler.
set(CMAKE_C_COMPILER ${PICO_COMPILER_CC} CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER ${PICO_COMPILER_CXX} CACHE FILEPATH "C++ compiler")
set(CMAKE_C_OUTPUT_EXTENSION .o)
# todo should we be including CMakeASMInformation anyway - i guess that is host side
set(CMAKE_ASM_COMPILER ${PICO_COMPILER_ASM} CACHE FILEPATH "ASM compiler")
set(CMAKE_ASM_COMPILE_OBJECT " -o