Skip to content

Commit

Permalink
SDK 2.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kilograham committed Aug 8, 2024
1 parent 45984e2 commit efe2103
Show file tree
Hide file tree
Showing 933 changed files with 349,994 additions and 66,341 deletions.
4 changes: 4 additions & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Don't accidentally pick up external CMake deps with Bazel build files.
build
# Don't treat submodules as part of this project.
lib
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.2
7.2.1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
cmake-*
.DS_Store
build
build-*

bazel-*

# Ignore until https://github.com/bazelbuild/bazel/issues/20369 is fixed.
MODULE.bazel.lock
__pycache__/
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
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")
Expand All @@ -38,6 +43,9 @@ if (NOT TARGET _pico_sdk_inclusion_marker)
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)

Expand Down
101 changes: 72 additions & 29 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module(name = "pico-sdk", version = "1.6.0-rc1")

bazel_dep(name = "platforms", version = "0.0.8")
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
Expand All @@ -15,84 +19,123 @@ bazel_dep(name = "rules_cc", version = "0.0.9")
# project's MODULE.bazel too.
archive_override(
module_name = "rules_cc",
urls = "https://github.com/bazelbuild/rules_cc/archive/1acf5213b6170f1f0133e273cb85ede0e732048f.zip",
integrity = "sha256-zdQo/pQWKdIAPKSflBxOSWZNwCbc86T7SechKZo/3Xw=",
strip_prefix = "rules_cc-1acf5213b6170f1f0133e273cb85ede0e732048f",
integrity = "sha256-NddP6xi6LzsIHT8bMSVJ2NtoURbN+l3xpjvmIgB6aSg=",
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",
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",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi",
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",
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",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-mingw-w64-i686-arm-none-eabi",
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",
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",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-x86_64-arm-none-eabi",
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",
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",
strip_prefix = "arm-gnu-toolchain-13.2.Rel1-darwin-arm64-arm-none-eabi",
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",
url = "https://github.com/hathach/tinyusb/archive/86c416d4c0fb38432460b3e11b08b9de76941bf5.zip",
strip_prefix = "tinyusb-86c416d4c0fb38432460b3e11b08b9de76941bf5",
build_file = "//src/rp2_common/tinyusb:tinyusb.BUILD",
sha256 = "ac57109bba00d26ffa33312d5f334990ec9a9a4d82bf890ed8b825b4610d1da2",
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",
url = "https://github.com/bluekitchen/btstack/archive/72ef1732c954d938091467961e41f4aa9b976b34.zip",
strip_prefix = "btstack-72ef1732c954d938091467961e41f4aa9b976b34",
build_file = "//src/rp2_common/pico_btstack:btstack.BUILD",
sha256 = "f45d72b5d404dd2f8e311287de6f2ba3561fc8ae956737eeb611b277aadc2391",
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",
url = "https://github.com/georgerobotics/cyw43-driver/archive/8ef38a6d32c54f850bff8f189bdca19ded33792a.zip",
strip_prefix = "cyw43-driver-8ef38a6d32c54f850bff8f189bdca19ded33792a",
build_file = "//src/rp2_common/pico_cyw43_driver:cyw43-driver.BUILD",
sha256 = "0b44a19ea58537ee954357606cde5ed20c3a42be77adfebb07b7c0e4740f6228",
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",
url = "https://github.com/lwip-tcpip/lwip/archive/239918ccc173cb2c2a62f41a40fd893f57faf1d6.zip",
strip_prefix = "lwip-239918ccc173cb2c2a62f41a40fd893f57faf1d6",
build_file = "//src/rp2_common/pico_lwip:lwip.BUILD",
sha256 = "7ee9e02f2719c0422377e1fcce5a21716ca2e2e855cca56695f9ef7cb020e5dd",
sha256 = "72856d557f72911cf6826ef745c23c54822df83a474557823241164a1d1361aa",
strip_prefix = "lwip-0a0452b2c39bdd91e252aef045c115f88f6ca773",
url = "https://github.com/lwip-tcpip/lwip/archive/0a0452b2c39bdd91e252aef045c115f88f6ca773.tar.gz",
)

register_toolchains(
"//bazel/toolchain:arm_gcc_linux-x86_64",
"//bazel/toolchain:arm_gcc_win-x86_64",
"//bazel/toolchain:arm_gcc_mac-x86_64",
"//bazel/toolchain:arm_gcc_mac-aarch64",
"//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,
)
47 changes: 28 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# 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 RP2040-based devices such as the Raspberry Pi Pico
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 RP2040's hardware include PIO (Programmable IO).
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, USB (TinyUSB) and multi-core programming
along with various utilities.
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, to fully fledged runtime environments such as MicroPython, to low level software
such as RP2040's on-chip bootrom itself.
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](https://rptl.io/pico-get-started) for information on how to setup your
hardware, IDE/environment and for how to build and debug software for the Raspberry Pi Pico
and other RP2040-based devices.
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 C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
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.
Expand All @@ -42,10 +42,16 @@ _latest stable release_ of the SDK. If you need or want to test upcoming feature

# 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 C/C++ SDK](https://rptl.io/pico-c-sdk)
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 GCC cross compiler
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
```
Expand Down Expand Up @@ -137,7 +143,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
# rest of your project
```
1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
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)
Expand All @@ -146,7 +152,7 @@ instructions for other platforms, and just in general, we recommend you see [Ras
#include "pico/stdlib.h"
int main() {
setup_default_uart();
stdio_init_all();
printf("Hello, world!\n");
return 0;
}
Expand Down Expand Up @@ -176,12 +182,11 @@ instructions for other platforms, and just in general, we recommend you see [Ras
$ 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=pico_w ..`
to configure the SDK and build options accordingly for that particular board.
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.
Doing so sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain
Specifying `PICO_BOARD=<booardname>` 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 functionality.
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.
Expand All @@ -191,4 +196,8 @@ instructions for other platforms, and just in general, we recommend you see [Ras
$ 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 via drag and drop.
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.
Empty file added WORKSPACE
Empty file.
6 changes: 6 additions & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,9 @@ cc_library(
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"],
)
Loading

0 comments on commit efe2103

Please sign in to comment.