From 14a77a3edcd0c1d077225e51fc309b3b29d80b1a Mon Sep 17 00:00:00 2001 From: Armando Montanez Date: Mon, 18 Nov 2024 10:15:54 -0800 Subject: [PATCH 1/4] Add Bazel examples for Pico W Sets up a number of Pico W examples in the Bazel build. --- .bazelversion | 1 + .gitignore | 3 ++ MODULE.bazel | 44 +++++++++++++++ pico_w/BUILD.bazel | 17 ++++++ pico_w/bt/standalone/BUILD.bazel | 81 ++++++++++++++++++++++++++++ pico_w/wifi/BUILD.bazel | 32 +++++++++++ pico_w/wifi/access_point/BUILD.bazel | 60 +++++++++++++++++++++ pico_w/wifi/blink/BUILD.bazel | 58 ++++++++++++++++++++ pico_w/wifi/httpd/BUILD.bazel | 3 ++ pico_w/wifi/iperf/BUILD.bazel | 52 ++++++++++++++++++ pico_w/wifi/udp_beacon/BUILD.bazel | 51 ++++++++++++++++++ pico_w/wifi/wifi_scan/BUILD.bazel | 50 +++++++++++++++++ 12 files changed, 452 insertions(+) create mode 100644 .bazelversion create mode 100644 MODULE.bazel create mode 100644 pico_w/BUILD.bazel create mode 100644 pico_w/bt/standalone/BUILD.bazel create mode 100644 pico_w/wifi/BUILD.bazel create mode 100644 pico_w/wifi/access_point/BUILD.bazel create mode 100644 pico_w/wifi/blink/BUILD.bazel create mode 100644 pico_w/wifi/httpd/BUILD.bazel create mode 100644 pico_w/wifi/iperf/BUILD.bazel create mode 100644 pico_w/wifi/udp_beacon/BUILD.bazel create mode 100644 pico_w/wifi/wifi_scan/BUILD.bazel diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 000000000..bf035f2b6 --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.0.0rc2 diff --git a/.gitignore b/.gitignore index d499131c1..56de9b0da 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,8 @@ _deps cmake-* build build-* +bazel-* .DS_Store *.pdf +# Ignore for now to avoid churn. +MODULE.bazel.lock diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..785f9987c --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,44 @@ +module( + name = "pico-examples", + version = "0.0.1-20241114", +) + +bazel_dep(name = "pico-sdk", version = "2.1.0") +bazel_dep(name = "rules_platform", version = "0.1.0") +bazel_dep(name = "rules_cc", version = "0.1.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_python", version = "0.36.0") + +git_override( + module_name = "pico-sdk", + remote = "https://github.com/armandomontanez/pico-sdk.git", + commit = "fd64ca39f58317213033b9e46f19846c0541fc22", +) + +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", +) + + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain( + configure_coverage_tool = True, + python_version = "3.9", +) + +use_repo(python, "pythons_hub") +register_toolchains( + "@pythons_hub//:all", + dev_dependency = True, +) +register_toolchains( + "@rules_python//python/runtime_env_toolchains:all", + dev_dependency = True, +) diff --git a/pico_w/BUILD.bazel b/pico_w/BUILD.bazel new file mode 100644 index 000000000..1387655aa --- /dev/null +++ b/pico_w/BUILD.bazel @@ -0,0 +1,17 @@ +package(default_visibility = [":__subpackages__"]) + +platform( + name = "test_pico_w", + parents = ["@pico-sdk//bazel/platform:rp2040"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BOARD=pico_w", + ], +) + +platform( + name = "test_pico2_w", + parents = ["@pico-sdk//bazel/platform:rp2350"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BOARD=pico2_w", + ], +) diff --git a/pico_w/bt/standalone/BUILD.bazel b/pico_w/bt/standalone/BUILD.bazel new file mode 100644 index 000000000..510150652 --- /dev/null +++ b/pico_w/bt/standalone/BUILD.bazel @@ -0,0 +1,81 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") +load("@pico-sdk//bazel:pico_btstack_make_gatt_header.bzl", "pico_btstack_make_gatt_header") +load("@pico-sdk//bazel/util:transition.bzl", "extra_copts_for_all_deps") + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "btstack_config", + hdrs = ["btstack_config.h"], + includes = ["."], + # This is enabled, the error about a missing define is a false positive. + defines = ["ENABLE_BLE=1"], +) + +cc_library( + name = "lwip_config", + hdrs = ["lwipopts.h"], + includes = ["."], +) + +pico_btstack_make_gatt_header( + name = "temp_sensor", + src = "temp_sensor.gatt", +) + +cc_binary( + name = "picow_ble_temp_sensor_actual", + srcs = [ + "server.c", + "server_common.c", + "server_common.h", + ], + deps = [ + ":temp_sensor", + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_none", + "@pico-sdk//src/rp2_common/pico_btstack", + "@pico-sdk//src/rp2_common/pico_cyw43_driver:pico_btstack_cyw43", + "@pico-sdk//src/rp2_common/hardware_adc", + ], +) + +extra_copts_for_all_deps( + name = "picow_ble_temp_sensor", + src = ":picow_ble_temp_sensor_actual", + extra_copts = [ + # Doesn't use multicore, but links in the multicore lib. + # Needed to fix a cautious flash assertion. + "-DPICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT=0", + ], +) + +platform_data( + name = "picow_ble_temp_sensor_pico_w.elf", + platform = ":test_pico_w", + target = ":picow_ble_temp_sensor", +) + +platform_data( + name = "picow_ble_temp_sensor_pico2_w.elf", + platform = ":test_pico2_w", + target = ":picow_ble_temp_sensor", +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG=//pico_w/bt/standalone:btstack_config", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE=True", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG=//pico_w/bt/standalone:btstack_config", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE=True", + ], +) diff --git a/pico_w/wifi/BUILD.bazel b/pico_w/wifi/BUILD.bazel new file mode 100644 index 000000000..3d488616c --- /dev/null +++ b/pico_w/wifi/BUILD.bazel @@ -0,0 +1,32 @@ +load("@pico-sdk//bazel/util:sdk_define.bzl", "pico_sdk_define") +load("@bazel_skylib//rules:common_settings.bzl", "string_flag") + +package(default_visibility = [":__subpackages__"]) + +pico_sdk_define( + name = "WIFI_PASSWORD_DEFINE", + define_name = "WIFI_PASSWORD", + from_flag = ":WIFI_PASSWORD", +) + +pico_sdk_define( + name = "WIFI_SSID_DEFINE", + define_name = "WIFI_SSID", + from_flag = ":WIFI_SSID", +) + +string_flag( + name = "WIFI_SSID", + build_setting_default = "", +) + +string_flag( + name = "WIFI_PASSWORD", + build_setting_default = "", +) + +cc_library( + name = "lwipopts_examples_common", + hdrs = ["lwipopts_examples_common.h"], + includes = ["."], +) diff --git a/pico_w/wifi/access_point/BUILD.bazel b/pico_w/wifi/access_point/BUILD.bazel new file mode 100644 index 000000000..515d8da00 --- /dev/null +++ b/pico_w/wifi/access_point/BUILD.bazel @@ -0,0 +1,60 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "lwip_config", + hdrs = ["lwipopts.h"], + includes = ["."], + deps = ["//pico_w/wifi:lwipopts_examples_common"], +) + +cc_binary( + name = "access_point", + includes = [ + "dhcpserver", + "dnsserver", + ], + srcs = [ + "dhcpserver/dhcpserver.c", + "dhcpserver/dhcpserver.h", + "dnsserver/dnsserver.c", + "dnsserver/dnsserver.h", + "picow_access_point.c", + ], + deps = [ + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background", + "@pico-sdk//src/rp2_common/hardware_vreg", + "@pico-sdk//src/rp2_common/hardware_clocks", + + ], +) + +platform_data( + name = "access_point_pico_w.elf", + platform = ":test_pico_w", + target = ":access_point", +) + +platform_data( + name = "access_point_pico2_w.elf", + platform = ":test_pico2_w", + target = ":access_point", +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/access_point:lwip_config", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/access_point:lwip_config", + ], +) diff --git a/pico_w/wifi/blink/BUILD.bazel b/pico_w/wifi/blink/BUILD.bazel new file mode 100644 index 000000000..a9ed72b4b --- /dev/null +++ b/pico_w/wifi/blink/BUILD.bazel @@ -0,0 +1,58 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") +load("@pico-sdk//bazel/util:transition.bzl", "extra_copts_for_all_deps") + +package(default_visibility = ["//visibility:private"]) + +cc_binary( + name = "picow_blink", + srcs = [ + "picow_blink.c", + ], + deps = [ + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_none", + ], +) + +cc_binary( + name = "picow_blink_slow_clock_actual", + srcs = [ + "picow_blink_slow_clock.c", + ], + deps = [ + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_none", + ], +) + +extra_copts_for_all_deps( + name = "picow_blink_slow_clock", + src = ":picow_blink_slow_clock_actual", + extra_copts = [ + "-DCYW43_PIO_CLOCK_DIV_DYNAMIC=1", + ], +) + +platform_data( + name = "picow_blink_pico_w.elf", + platform = "//pico_w:test_pico_w", + target = ":picow_blink", +) + +platform_data( + name = "picow_blink_pico2_w.elf", + platform = "//pico_w/wifi:test_pico2_w", + target = ":picow_blink", +) + +platform_data( + name = "picow_blink_slow_clock_pico_w.elf", + platform = "//pico_w:test_pico_w", + target = ":picow_blink_slow_clock", +) + +platform_data( + name = "picow_blink_slow_clock_pico2_w.elf", + platform = "//pico_w/wifi:test_pico2_w", + target = ":picow_blink_slow_clock", +) diff --git a/pico_w/wifi/httpd/BUILD.bazel b/pico_w/wifi/httpd/BUILD.bazel new file mode 100644 index 000000000..b8c8383cc --- /dev/null +++ b/pico_w/wifi/httpd/BUILD.bazel @@ -0,0 +1,3 @@ +package(default_visibility = ["//visibility:private"]) + +# TODO: Need a way to convert the httpd content to headers from Bazel. diff --git a/pico_w/wifi/iperf/BUILD.bazel b/pico_w/wifi/iperf/BUILD.bazel new file mode 100644 index 000000000..e206c93ca --- /dev/null +++ b/pico_w/wifi/iperf/BUILD.bazel @@ -0,0 +1,52 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "lwip_config", + hdrs = ["lwipopts.h"], + includes = ["."], + deps = ["//pico_w/wifi:lwipopts_examples_common"], +) + +cc_binary( + name = "iperf", + srcs = ["picow_iperf.c"], + deps = [ + "//pico_w/wifi:WIFI_PASSWORD_DEFINE", + "//pico_w/wifi:WIFI_SSID_DEFINE", + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background", + "@pico-sdk//src/rp2_common/hardware_vreg", + "@pico-sdk//src/rp2_common/hardware_clocks", + "@pico-sdk//src/rp2_common/pico_lwip:pico_lwip_iperf", + ], +) + +platform_data( + name = "iperf_pico_w.elf", + platform = ":test_pico_w", + target = ":iperf", +) + +platform_data( + name = "iperf_pico2_w.elf", + platform = ":test_pico2_w", + target = ":iperf", +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/iperf:lwip_config", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/iperf:lwip_config", + ], +) diff --git a/pico_w/wifi/udp_beacon/BUILD.bazel b/pico_w/wifi/udp_beacon/BUILD.bazel new file mode 100644 index 000000000..c4b31a329 --- /dev/null +++ b/pico_w/wifi/udp_beacon/BUILD.bazel @@ -0,0 +1,51 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "lwip_config", + hdrs = ["lwipopts.h"], + includes = ["."], + deps = ["//pico_w/wifi:lwipopts_examples_common"], +) + +cc_binary( + name = "udp_beacon", + srcs = ["picow_udp_beacon.c"], + deps = [ + "//pico_w/wifi:WIFI_PASSWORD_DEFINE", + "//pico_w/wifi:WIFI_SSID_DEFINE", + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background", + "@pico-sdk//src/rp2_common/hardware_vreg", + "@pico-sdk//src/rp2_common/hardware_clocks", + ], +) + +platform_data( + name = "udp_beacon_pico_w.elf", + platform = ":test_pico_w", + target = ":udp_beacon", +) + +platform_data( + name = "udp_beacon_pico2_w.elf", + platform = ":test_pico2_w", + target = ":udp_beacon", +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/udp_beacon:lwip_config", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/udp_beacon:lwip_config", + ], +) diff --git a/pico_w/wifi/wifi_scan/BUILD.bazel b/pico_w/wifi/wifi_scan/BUILD.bazel new file mode 100644 index 000000000..b558130f3 --- /dev/null +++ b/pico_w/wifi/wifi_scan/BUILD.bazel @@ -0,0 +1,50 @@ +load("@rules_platform//platform_data:defs.bzl", "platform_data") + +package(default_visibility = ["//visibility:private"]) + +cc_library( + name = "lwip_config", + hdrs = ["lwipopts.h"], + includes = ["."], + deps = ["//pico_w/wifi:lwipopts_examples_common"], +) + +cc_binary( + name = "wifi_scan", + srcs = ["picow_wifi_scan.c"], + deps = [ + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background", + "@pico-sdk//src/rp2_common/hardware_vreg", + "@pico-sdk//src/rp2_common/hardware_clocks", + + ], +) + +platform_data( + name = "wifi_scan_pico_w.elf", + platform = ":test_pico_w", + target = ":wifi_scan", +) + +platform_data( + name = "wifi_scan_pico2_w.elf", + platform = ":test_pico2_w", + target = ":wifi_scan", +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/wifi_scan:lwip_config", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_LWIP_CONFIG=//pico_w/wifi/wifi_scan:lwip_config", + ], +) From 368b1136b332003ca5b05c2fc753dbb4cb4b960b Mon Sep 17 00:00:00 2001 From: Armando Montanez Date: Wed, 20 Nov 2024 12:59:36 -0800 Subject: [PATCH 2/4] Add many Bluetooth examples --- MODULE.bazel | 11 +++- pico_w/bt/BUILD.bazel | 65 +++++++++++++++++++ pico_w/bt/a2dp_sink_demo/BUILD.bazel | 8 +++ pico_w/bt/ancs_client_demo/BUILD.bazel | 5 ++ pico_w/bt/att_delayed_response/BUILD.bazel | 5 ++ pico_w/bt/avrcp_browsing_client/BUILD.bazel | 3 + pico_w/bt/btstack_examples.BUILD | 7 ++ pico_w/bt/dut_mode_classic/BUILD.bazel | 3 + pico_w/bt/gap_dedicated_bonding/BUILD.bazel | 3 + pico_w/bt/gap_inquiry/BUILD.bazel | 3 + pico_w/bt/gap_le_advertisements/BUILD.bazel | 3 + pico_w/bt/gap_link_keys/BUILD.bazel | 3 + pico_w/bt/gatt_battery_query/BUILD.bazel | 5 ++ pico_w/bt/gatt_browser/BUILD.bazel | 5 ++ pico_w/bt/gatt_counter/BUILD.bazel | 6 ++ .../gatt_device_information_query/BUILD.bazel | 5 ++ pico_w/bt/gatt_heart_rate_client/BUILD.bazel | 3 + pico_w/bt/gatt_streamer_server/BUILD.bazel | 5 ++ pico_w/bt/hfp_hf_demo/BUILD.bazel | 8 +++ pico_w/bt/hid_host_demo/BUILD.bazel | 3 + pico_w/bt/hid_keyboard_demo/BUILD.bazel | 3 + pico_w/bt/hid_mouse_demo/BUILD.bazel | 3 + pico_w/bt/hog_boot_host_demo/BUILD.bazel | 3 + pico_w/bt/hog_host_demo/BUILD.bazel | 5 ++ pico_w/bt/hog_keyboard_demo/BUILD.bazel | 6 ++ pico_w/bt/hog_mouse_demo/BUILD.bazel | 6 ++ pico_w/bt/hsp_ag_demo/BUILD.bazel | 4 ++ .../BUILD.bazel | 3 + .../BUILD.bazel | 5 ++ pico_w/bt/le_mitm/BUILD.bazel | 3 + pico_w/bt/le_streamer_client/BUILD.bazel | 3 + pico_w/bt/led_counter/BUILD.bazel | 3 + pico_w/bt/mod_player/BUILD.bazel | 9 +++ pico_w/bt/nordic_spp_le_counter/BUILD.bazel | 6 ++ pico_w/bt/nordic_spp_le_streamer/BUILD.bazel | 6 ++ pico_w/bt/pbap_client_demo/BUILD.bazel | 3 + pico_w/bt/picow_bt_example.bzl | 51 +++++++++++++++ pico_w/bt/sdp_bnep_query/BUILD.bazel | 3 + pico_w/bt/sdp_general_query/BUILD.bazel | 3 + pico_w/bt/sdp_rfcomm_query/BUILD.bazel | 7 ++ pico_w/bt/sine_player/BUILD.bazel | 8 +++ pico_w/bt/sm_pairing_central/BUILD.bazel | 5 ++ pico_w/bt/sm_pairing_peripheral/BUILD.bazel | 5 ++ pico_w/bt/spp_and_gatt_counter/BUILD.bazel | 5 ++ pico_w/bt/spp_and_gatt_streamer/BUILD.bazel | 11 ++++ pico_w/bt/spp_counter/BUILD.bazel | 3 + pico_w/bt/spp_flowcontrol/BUILD.bazel | 7 ++ pico_w/bt/spp_streamer/BUILD.bazel | 3 + pico_w/bt/spp_streamer_client/BUILD.bazel | 3 + pico_w/bt/ublox_spp_le_counter/BUILD.bazel | 6 ++ pico_w/wifi/blink/BUILD.bazel | 4 +- pico_w/wifi/wifi_scan/BUILD.bazel | 2 +- 52 files changed, 352 insertions(+), 4 deletions(-) create mode 100644 pico_w/bt/BUILD.bazel create mode 100644 pico_w/bt/a2dp_sink_demo/BUILD.bazel create mode 100644 pico_w/bt/ancs_client_demo/BUILD.bazel create mode 100644 pico_w/bt/att_delayed_response/BUILD.bazel create mode 100644 pico_w/bt/avrcp_browsing_client/BUILD.bazel create mode 100644 pico_w/bt/btstack_examples.BUILD create mode 100644 pico_w/bt/dut_mode_classic/BUILD.bazel create mode 100644 pico_w/bt/gap_dedicated_bonding/BUILD.bazel create mode 100644 pico_w/bt/gap_inquiry/BUILD.bazel create mode 100644 pico_w/bt/gap_le_advertisements/BUILD.bazel create mode 100644 pico_w/bt/gap_link_keys/BUILD.bazel create mode 100644 pico_w/bt/gatt_battery_query/BUILD.bazel create mode 100644 pico_w/bt/gatt_browser/BUILD.bazel create mode 100644 pico_w/bt/gatt_counter/BUILD.bazel create mode 100644 pico_w/bt/gatt_device_information_query/BUILD.bazel create mode 100644 pico_w/bt/gatt_heart_rate_client/BUILD.bazel create mode 100644 pico_w/bt/gatt_streamer_server/BUILD.bazel create mode 100644 pico_w/bt/hfp_hf_demo/BUILD.bazel create mode 100644 pico_w/bt/hid_host_demo/BUILD.bazel create mode 100644 pico_w/bt/hid_keyboard_demo/BUILD.bazel create mode 100644 pico_w/bt/hid_mouse_demo/BUILD.bazel create mode 100644 pico_w/bt/hog_boot_host_demo/BUILD.bazel create mode 100644 pico_w/bt/hog_host_demo/BUILD.bazel create mode 100644 pico_w/bt/hog_keyboard_demo/BUILD.bazel create mode 100644 pico_w/bt/hog_mouse_demo/BUILD.bazel create mode 100644 pico_w/bt/hsp_ag_demo/BUILD.bazel create mode 100644 pico_w/bt/le_credit_based_flow_control_mode_client/BUILD.bazel create mode 100644 pico_w/bt/le_credit_based_flow_control_mode_server/BUILD.bazel create mode 100644 pico_w/bt/le_mitm/BUILD.bazel create mode 100644 pico_w/bt/le_streamer_client/BUILD.bazel create mode 100644 pico_w/bt/led_counter/BUILD.bazel create mode 100644 pico_w/bt/mod_player/BUILD.bazel create mode 100644 pico_w/bt/nordic_spp_le_counter/BUILD.bazel create mode 100644 pico_w/bt/nordic_spp_le_streamer/BUILD.bazel create mode 100644 pico_w/bt/pbap_client_demo/BUILD.bazel create mode 100644 pico_w/bt/picow_bt_example.bzl create mode 100644 pico_w/bt/sdp_bnep_query/BUILD.bazel create mode 100644 pico_w/bt/sdp_general_query/BUILD.bazel create mode 100644 pico_w/bt/sdp_rfcomm_query/BUILD.bazel create mode 100644 pico_w/bt/sine_player/BUILD.bazel create mode 100644 pico_w/bt/sm_pairing_central/BUILD.bazel create mode 100644 pico_w/bt/sm_pairing_peripheral/BUILD.bazel create mode 100644 pico_w/bt/spp_and_gatt_counter/BUILD.bazel create mode 100644 pico_w/bt/spp_and_gatt_streamer/BUILD.bazel create mode 100644 pico_w/bt/spp_counter/BUILD.bazel create mode 100644 pico_w/bt/spp_flowcontrol/BUILD.bazel create mode 100644 pico_w/bt/spp_streamer/BUILD.bazel create mode 100644 pico_w/bt/spp_streamer_client/BUILD.bazel create mode 100644 pico_w/bt/ublox_spp_le_counter/BUILD.bazel diff --git a/MODULE.bazel b/MODULE.bazel index 785f9987c..ed44f05a0 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -26,7 +26,6 @@ register_toolchains( "@pico-sdk//bazel/toolchain:mac-aarch64-rp2350", ) - python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( configure_coverage_tool = True, @@ -42,3 +41,13 @@ register_toolchains( "@rules_python//python/runtime_env_toolchains:all", dev_dependency = True, ) + +new_git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") + +# TODO: Provide btstack as a proper Bazel module. +new_git_repository( + name = "btstack", + build_file = "//pico_w/bt:btstack_examples.BUILD", + commit = "2b49e57bd1fae85ac32ac1f41cdb7c794de335f6", # keep-in-sync-with-submodule: lib/btstack + remote = "https://github.com/bluekitchen/btstack.git", +) diff --git a/pico_w/bt/BUILD.bazel b/pico_w/bt/BUILD.bazel new file mode 100644 index 000000000..a1d45b3d9 --- /dev/null +++ b/pico_w/bt/BUILD.bazel @@ -0,0 +1,65 @@ +package(default_visibility = ["//pico_w/bt:__subpackages__"]) + +cc_library( + name = "lwip_config", + strip_include_prefix = "config", + hdrs = ["config/lwipopts.h"], +) + +cc_library( + name = "btstack_config", + strip_include_prefix = "config", + hdrs = ["config/btstack_config.h"], +) + +cc_library( + name = "freertos_config", + strip_include_prefix = "config", + hdrs = ["config/FreeRTOSConfig.h"], +) + +cc_library( + name = "picow_bt_example_common", + srcs = ["picow_bt_example_common.c"], + strip_include_prefix = ".", + hdrs = ["picow_bt_example_common.h"], + deps = [ + "@pico-sdk//src/rp2_common/pico_btstack", + "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_encoder", + "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_decoder", + "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_stdin", + "@pico-sdk//src/rp2_common/pico_cyw43_driver:pico_btstack_cyw43", + "@pico-sdk//src/rp2_common/pico_stdlib", + "@pico-sdk//src/rp2_common/pico_cyw43_arch", + ], +) + +cc_library( + name = "picow_bt_example_poll", + srcs = ["picow_bt_example_poll.c"], + deps = [ + ":picow_bt_example_common", + "@pico-sdk//src/rp2_common/pico_cyw43_driver:pico_btstack_cyw43", + "@pico-sdk//src/rp2_common/pico_stdlib", + ] +) + +platform( + name = "test_pico_w", + parents = ["//pico_w:test_pico_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG=//pico_w/bt:btstack_config", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE=True", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_CLASSIC=True", + ], +) + +platform( + name = "test_pico2_w", + parents = ["//pico_w:test_pico2_w"], + flags = [ + "--@pico-sdk//bazel/config:PICO_BTSTACK_CONFIG=//pico_w/bt:btstack_config", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE=True", + "--@pico-sdk//bazel/config:PICO_BT_ENABLE_CLASSIC=True", + ], +) diff --git a/pico_w/bt/a2dp_sink_demo/BUILD.bazel b/pico_w/bt/a2dp_sink_demo/BUILD.bazel new file mode 100644 index 000000000..51ae253e8 --- /dev/null +++ b/pico_w/bt/a2dp_sink_demo/BUILD.bazel @@ -0,0 +1,8 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + extra_defines = [ + "PICO_AUDIO_I2S_DATA_PIN=9", + "PICO_AUDIO_I2S_CLOCK_PIN_BASE=10", + ], +) diff --git a/pico_w/bt/ancs_client_demo/BUILD.bazel b/pico_w/bt/ancs_client_demo/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/ancs_client_demo/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/att_delayed_response/BUILD.bazel b/pico_w/bt/att_delayed_response/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/att_delayed_response/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/avrcp_browsing_client/BUILD.bazel b/pico_w/bt/avrcp_browsing_client/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/avrcp_browsing_client/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/btstack_examples.BUILD b/pico_w/bt/btstack_examples.BUILD new file mode 100644 index 000000000..c5774e463 --- /dev/null +++ b/pico_w/bt/btstack_examples.BUILD @@ -0,0 +1,7 @@ +exports_files( + glob([ + "**/example/*.c", + "**/example/*.gatt", + "**/example/*.h", + ]), +) diff --git a/pico_w/bt/dut_mode_classic/BUILD.bazel b/pico_w/bt/dut_mode_classic/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/dut_mode_classic/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gap_dedicated_bonding/BUILD.bazel b/pico_w/bt/gap_dedicated_bonding/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/gap_dedicated_bonding/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gap_inquiry/BUILD.bazel b/pico_w/bt/gap_inquiry/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/gap_inquiry/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gap_le_advertisements/BUILD.bazel b/pico_w/bt/gap_le_advertisements/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/gap_le_advertisements/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gap_link_keys/BUILD.bazel b/pico_w/bt/gap_link_keys/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/gap_link_keys/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gatt_battery_query/BUILD.bazel b/pico_w/bt/gatt_battery_query/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/gatt_battery_query/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/gatt_browser/BUILD.bazel b/pico_w/bt/gatt_browser/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/gatt_browser/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/gatt_counter/BUILD.bazel b/pico_w/bt/gatt_counter/BUILD.bazel new file mode 100644 index 000000000..d458337d5 --- /dev/null +++ b/pico_w/bt/gatt_counter/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# Needs battery_service.gatt. +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/bt/gatt_device_information_query/BUILD.bazel b/pico_w/bt/gatt_device_information_query/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/gatt_device_information_query/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/gatt_heart_rate_client/BUILD.bazel b/pico_w/bt/gatt_heart_rate_client/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/gatt_heart_rate_client/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/gatt_streamer_server/BUILD.bazel b/pico_w/bt/gatt_streamer_server/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/gatt_streamer_server/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/hfp_hf_demo/BUILD.bazel b/pico_w/bt/hfp_hf_demo/BUILD.bazel new file mode 100644 index 000000000..d1d7813e7 --- /dev/null +++ b/pico_w/bt/hfp_hf_demo/BUILD.bazel @@ -0,0 +1,8 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") +# TODO: Needs sco_demo_util.gatt. +# picow_bt_example( +# extra_defines = [ +# "PICO_AUDIO_I2S_DATA_PIN=9", +# "PICO_AUDIO_I2S_CLOCK_PIN_BASE=10", +# ], +# ) diff --git a/pico_w/bt/hid_host_demo/BUILD.bazel b/pico_w/bt/hid_host_demo/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/hid_host_demo/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/hid_keyboard_demo/BUILD.bazel b/pico_w/bt/hid_keyboard_demo/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/hid_keyboard_demo/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/hid_mouse_demo/BUILD.bazel b/pico_w/bt/hid_mouse_demo/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/hid_mouse_demo/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/hog_boot_host_demo/BUILD.bazel b/pico_w/bt/hog_boot_host_demo/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/hog_boot_host_demo/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/hog_host_demo/BUILD.bazel b/pico_w/bt/hog_host_demo/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/hog_host_demo/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/hog_keyboard_demo/BUILD.bazel b/pico_w/bt/hog_keyboard_demo/BUILD.bazel new file mode 100644 index 000000000..d458337d5 --- /dev/null +++ b/pico_w/bt/hog_keyboard_demo/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# Needs battery_service.gatt. +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/bt/hog_mouse_demo/BUILD.bazel b/pico_w/bt/hog_mouse_demo/BUILD.bazel new file mode 100644 index 000000000..d458337d5 --- /dev/null +++ b/pico_w/bt/hog_mouse_demo/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# Needs battery_service.gatt. +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/bt/hsp_ag_demo/BUILD.bazel b/pico_w/bt/hsp_ag_demo/BUILD.bazel new file mode 100644 index 000000000..3a68011d6 --- /dev/null +++ b/pico_w/bt/hsp_ag_demo/BUILD.bazel @@ -0,0 +1,4 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# TODO: Slightly more complicated. +# picow_bt_example() diff --git a/pico_w/bt/le_credit_based_flow_control_mode_client/BUILD.bazel b/pico_w/bt/le_credit_based_flow_control_mode_client/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/le_credit_based_flow_control_mode_client/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/le_credit_based_flow_control_mode_server/BUILD.bazel b/pico_w/bt/le_credit_based_flow_control_mode_server/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/le_credit_based_flow_control_mode_server/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/le_mitm/BUILD.bazel b/pico_w/bt/le_mitm/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/le_mitm/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/le_streamer_client/BUILD.bazel b/pico_w/bt/le_streamer_client/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/le_streamer_client/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/led_counter/BUILD.bazel b/pico_w/bt/led_counter/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/led_counter/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/mod_player/BUILD.bazel b/pico_w/bt/mod_player/BUILD.bazel new file mode 100644 index 000000000..f64eac124 --- /dev/null +++ b/pico_w/bt/mod_player/BUILD.bazel @@ -0,0 +1,9 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# TODO: Needs hxcmod.h? +# picow_bt_example( +# extra_defines = [ +# "PICO_AUDIO_I2S_DATA_PIN=9", +# "PICO_AUDIO_I2S_CLOCK_PIN_BASE=10", +# ], +# ) diff --git a/pico_w/bt/nordic_spp_le_counter/BUILD.bazel b/pico_w/bt/nordic_spp_le_counter/BUILD.bazel new file mode 100644 index 000000000..04cb486e1 --- /dev/null +++ b/pico_w/bt/nordic_spp_le_counter/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# TODO: Needs nordic_spp_service.gatt +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/bt/nordic_spp_le_streamer/BUILD.bazel b/pico_w/bt/nordic_spp_le_streamer/BUILD.bazel new file mode 100644 index 000000000..04cb486e1 --- /dev/null +++ b/pico_w/bt/nordic_spp_le_streamer/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# TODO: Needs nordic_spp_service.gatt +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/bt/pbap_client_demo/BUILD.bazel b/pico_w/bt/pbap_client_demo/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/pbap_client_demo/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/picow_bt_example.bzl b/pico_w/bt/picow_bt_example.bzl new file mode 100644 index 000000000..a4ce85bed --- /dev/null +++ b/pico_w/bt/picow_bt_example.bzl @@ -0,0 +1,51 @@ +load("@rules_cc//cc:defs.bzl", "cc_binary") +load("@rules_platform//platform_data:defs.bzl", "platform_data") +load("@pico-sdk//bazel/util:transition.bzl", "extra_copts_for_all_deps") +load("@pico-sdk//bazel:pico_btstack_make_gatt_header.bzl", "pico_btstack_make_gatt_header") + +def _single_example(*, name, extra_defines = [], extra_deps = [], has_gatt_header): + base_name = name + extra_deps = list(extra_deps) + if has_gatt_header: + pico_btstack_make_gatt_header( + name = base_name + "_gatt_header", + src = "@btstack//:example/{}.gatt".format(base_name), + ) + extra_deps.append(":{}".format(base_name + "_gatt_header")) + + cc_binary( + name = base_name, + deps = [ + "//pico_w/bt:picow_bt_example_poll", + ]+ extra_deps, + srcs = ["@btstack//:example/{}.c".format(base_name)], + ) + + extra_copts_for_all_deps( + name = base_name + "_extra_defines", + src = ":{}".format(base_name), + extra_copts = ["-D{}".format(define) for define in extra_defines], + ) + + platform_data( + name = base_name + "_pico_w.elf", + platform = "//pico_w/bt:test_pico_w", + target = ":{}_extra_defines".format(base_name), + ) + + platform_data( + name = base_name + "_pico2_w.elf", + platform = "//pico_w/bt:test_pico2_w", + target = ":{}_extra_defines".format(base_name), + ) + + +def picow_bt_example(*, extra_defines = [], extra_deps = [], has_gatt_header = False): + base_name = native.package_name().split("/")[-1] + _single_example( + name = base_name, + extra_deps = extra_deps, + has_gatt_header = has_gatt_header, + # lwip = True, + # async_context = "poll", + ) diff --git a/pico_w/bt/sdp_bnep_query/BUILD.bazel b/pico_w/bt/sdp_bnep_query/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/sdp_bnep_query/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/sdp_general_query/BUILD.bazel b/pico_w/bt/sdp_general_query/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/sdp_general_query/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/sdp_rfcomm_query/BUILD.bazel b/pico_w/bt/sdp_rfcomm_query/BUILD.bazel new file mode 100644 index 000000000..ee1796a81 --- /dev/null +++ b/pico_w/bt/sdp_rfcomm_query/BUILD.bazel @@ -0,0 +1,7 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + extra_deps = [ + "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_encoder", + ], +) diff --git a/pico_w/bt/sine_player/BUILD.bazel b/pico_w/bt/sine_player/BUILD.bazel new file mode 100644 index 000000000..51ae253e8 --- /dev/null +++ b/pico_w/bt/sine_player/BUILD.bazel @@ -0,0 +1,8 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + extra_defines = [ + "PICO_AUDIO_I2S_DATA_PIN=9", + "PICO_AUDIO_I2S_CLOCK_PIN_BASE=10", + ], +) diff --git a/pico_w/bt/sm_pairing_central/BUILD.bazel b/pico_w/bt/sm_pairing_central/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/sm_pairing_central/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/sm_pairing_peripheral/BUILD.bazel b/pico_w/bt/sm_pairing_peripheral/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/sm_pairing_peripheral/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/spp_and_gatt_counter/BUILD.bazel b/pico_w/bt/spp_and_gatt_counter/BUILD.bazel new file mode 100644 index 000000000..519b602df --- /dev/null +++ b/pico_w/bt/spp_and_gatt_counter/BUILD.bazel @@ -0,0 +1,5 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + has_gatt_header = True, +) diff --git a/pico_w/bt/spp_and_gatt_streamer/BUILD.bazel b/pico_w/bt/spp_and_gatt_streamer/BUILD.bazel new file mode 100644 index 000000000..293f84b32 --- /dev/null +++ b/pico_w/bt/spp_and_gatt_streamer/BUILD.bazel @@ -0,0 +1,11 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") +load("@pico-sdk//bazel:pico_btstack_make_gatt_header.bzl", "pico_btstack_make_gatt_header") + +pico_btstack_make_gatt_header( + name = "spp_and_gatt_streamer_hdr", + src = "@btstack//:example/spp_and_gatt_streamer.gatt", +) + +picow_bt_example( + extra_deps = [":spp_and_gatt_streamer_hdr"], +) diff --git a/pico_w/bt/spp_counter/BUILD.bazel b/pico_w/bt/spp_counter/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/spp_counter/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/spp_flowcontrol/BUILD.bazel b/pico_w/bt/spp_flowcontrol/BUILD.bazel new file mode 100644 index 000000000..2739c0083 --- /dev/null +++ b/pico_w/bt/spp_flowcontrol/BUILD.bazel @@ -0,0 +1,7 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example( + extra_deps = [ + "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_encoder", + ] +) diff --git a/pico_w/bt/spp_streamer/BUILD.bazel b/pico_w/bt/spp_streamer/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/spp_streamer/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/spp_streamer_client/BUILD.bazel b/pico_w/bt/spp_streamer_client/BUILD.bazel new file mode 100644 index 000000000..bcfb4094d --- /dev/null +++ b/pico_w/bt/spp_streamer_client/BUILD.bazel @@ -0,0 +1,3 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +picow_bt_example() diff --git a/pico_w/bt/ublox_spp_le_counter/BUILD.bazel b/pico_w/bt/ublox_spp_le_counter/BUILD.bazel new file mode 100644 index 000000000..2f44457c6 --- /dev/null +++ b/pico_w/bt/ublox_spp_le_counter/BUILD.bazel @@ -0,0 +1,6 @@ +load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") + +# TODO: Needs device_information_service.gatt. +# picow_bt_example( +# has_gatt_header = True, +# ) diff --git a/pico_w/wifi/blink/BUILD.bazel b/pico_w/wifi/blink/BUILD.bazel index a9ed72b4b..84554f0f7 100644 --- a/pico_w/wifi/blink/BUILD.bazel +++ b/pico_w/wifi/blink/BUILD.bazel @@ -41,7 +41,7 @@ platform_data( platform_data( name = "picow_blink_pico2_w.elf", - platform = "//pico_w/wifi:test_pico2_w", + platform = "//pico_w:test_pico2_w", target = ":picow_blink", ) @@ -53,6 +53,6 @@ platform_data( platform_data( name = "picow_blink_slow_clock_pico2_w.elf", - platform = "//pico_w/wifi:test_pico2_w", + platform = "//pico_w:test_pico2_w", target = ":picow_blink_slow_clock", ) diff --git a/pico_w/wifi/wifi_scan/BUILD.bazel b/pico_w/wifi/wifi_scan/BUILD.bazel index b558130f3..fabf6ab0a 100644 --- a/pico_w/wifi/wifi_scan/BUILD.bazel +++ b/pico_w/wifi/wifi_scan/BUILD.bazel @@ -14,7 +14,7 @@ cc_binary( srcs = ["picow_wifi_scan.c"], deps = [ "@pico-sdk//src/rp2_common/pico_stdlib", - "@pico-sdk//src/rp2_common/pico_cyw43_arch:pico_cyw43_arch_lwip_threadsafe_background", + "@pico-sdk//src/rp2_common/pico_cyw43_arch", "@pico-sdk//src/rp2_common/hardware_vreg", "@pico-sdk//src/rp2_common/hardware_clocks", From 021fa71ce43d3cd2777e05b05b40c23531b3d533 Mon Sep 17 00:00:00 2001 From: Armando Montanez Date: Wed, 20 Nov 2024 13:44:00 -0800 Subject: [PATCH 3/4] Remove unnecessary extra_deps --- pico_w/bt/sdp_rfcomm_query/BUILD.bazel | 6 +----- pico_w/bt/spp_flowcontrol/BUILD.bazel | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/pico_w/bt/sdp_rfcomm_query/BUILD.bazel b/pico_w/bt/sdp_rfcomm_query/BUILD.bazel index ee1796a81..bcfb4094d 100644 --- a/pico_w/bt/sdp_rfcomm_query/BUILD.bazel +++ b/pico_w/bt/sdp_rfcomm_query/BUILD.bazel @@ -1,7 +1,3 @@ load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") -picow_bt_example( - extra_deps = [ - "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_encoder", - ], -) +picow_bt_example() diff --git a/pico_w/bt/spp_flowcontrol/BUILD.bazel b/pico_w/bt/spp_flowcontrol/BUILD.bazel index 2739c0083..bcfb4094d 100644 --- a/pico_w/bt/spp_flowcontrol/BUILD.bazel +++ b/pico_w/bt/spp_flowcontrol/BUILD.bazel @@ -1,7 +1,3 @@ load("//pico_w/bt:picow_bt_example.bzl", "picow_bt_example") -picow_bt_example( - extra_deps = [ - "@pico-sdk//src/rp2_common/pico_btstack:pico_btstack_sbc_encoder", - ] -) +picow_bt_example() From 57f581398f4f2e620a843eb4dfd65cbc49802681 Mon Sep 17 00:00:00 2001 From: Armando Montanez Date: Thu, 21 Nov 2024 13:39:41 -0800 Subject: [PATCH 4/4] Increase configuration space --- pico_w/BUILD.bazel | 2 ++ pico_w/bt/BUILD.bazel | 10 +++++++ pico_w/bt/picow_bt_example.bzl | 49 ++++++++++++++++++++++++-------- pico_w/bt/standalone/BUILD.bazel | 3 +- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/pico_w/BUILD.bazel b/pico_w/BUILD.bazel index 1387655aa..2c8c1b72e 100644 --- a/pico_w/BUILD.bazel +++ b/pico_w/BUILD.bazel @@ -5,6 +5,7 @@ platform( parents = ["@pico-sdk//bazel/platform:rp2040"], flags = [ "--@pico-sdk//bazel/config:PICO_BOARD=pico_w", + "--@pico-sdk//bazel/config:PICO_MULTICORE_ENABLED=False", ], ) @@ -13,5 +14,6 @@ platform( parents = ["@pico-sdk//bazel/platform:rp2350"], flags = [ "--@pico-sdk//bazel/config:PICO_BOARD=pico2_w", + "--@pico-sdk//bazel/config:PICO_MULTICORE_ENABLED=False", ], ) diff --git a/pico_w/bt/BUILD.bazel b/pico_w/bt/BUILD.bazel index a1d45b3d9..922cf4649 100644 --- a/pico_w/bt/BUILD.bazel +++ b/pico_w/bt/BUILD.bazel @@ -44,6 +44,16 @@ cc_library( ] ) +cc_library( + name = "picow_bt_example_background", + srcs = ["picow_bt_example_background.c"], + deps = [ + ":picow_bt_example_common", + "@pico-sdk//src/rp2_common/pico_cyw43_driver:pico_btstack_cyw43", + "@pico-sdk//src/rp2_common/pico_stdlib", + ] +) + platform( name = "test_pico_w", parents = ["//pico_w:test_pico_w"], diff --git a/pico_w/bt/picow_bt_example.bzl b/pico_w/bt/picow_bt_example.bzl index a4ce85bed..09e1f19d0 100644 --- a/pico_w/bt/picow_bt_example.bzl +++ b/pico_w/bt/picow_bt_example.bzl @@ -3,22 +3,20 @@ load("@rules_platform//platform_data:defs.bzl", "platform_data") load("@pico-sdk//bazel/util:transition.bzl", "extra_copts_for_all_deps") load("@pico-sdk//bazel:pico_btstack_make_gatt_header.bzl", "pico_btstack_make_gatt_header") -def _single_example(*, name, extra_defines = [], extra_deps = [], has_gatt_header): +def _single_example(*, name, example_name, platform_flags = {}, extra_defines = [], extra_deps = [], has_gatt_header): base_name = name extra_deps = list(extra_deps) if has_gatt_header: pico_btstack_make_gatt_header( name = base_name + "_gatt_header", - src = "@btstack//:example/{}.gatt".format(base_name), + src = "@btstack//:example/{}.gatt".format(example_name), ) extra_deps.append(":{}".format(base_name + "_gatt_header")) cc_binary( name = base_name, - deps = [ - "//pico_w/bt:picow_bt_example_poll", - ]+ extra_deps, - srcs = ["@btstack//:example/{}.c".format(base_name)], + deps = extra_deps, + srcs = ["@btstack//:example/{}.c".format(example_name)], ) extra_copts_for_all_deps( @@ -29,23 +27,50 @@ def _single_example(*, name, extra_defines = [], extra_deps = [], has_gatt_heade platform_data( name = base_name + "_pico_w.elf", - platform = "//pico_w/bt:test_pico_w", + platform = ":{}_pico_w_platform".format(base_name), target = ":{}_extra_defines".format(base_name), ) platform_data( name = base_name + "_pico2_w.elf", - platform = "//pico_w/bt:test_pico2_w", + platform = ":{}_pico2_w_platform".format(base_name), target = ":{}_extra_defines".format(base_name), ) + native.platform( + name = base_name + "_pico_w_platform", + parents = ["//pico_w/bt:test_pico_w"], + flags = platform_flags, + ) + + native.platform( + name = base_name + "_pico2_w_platform", + parents = ["//pico_w/bt:test_pico2_w"], + flags = platform_flags, + ) def picow_bt_example(*, extra_defines = [], extra_deps = [], has_gatt_header = False): base_name = native.package_name().split("/")[-1] _single_example( - name = base_name, - extra_deps = extra_deps, + name = base_name + "_poll", + example_name = base_name, + extra_deps = extra_deps + [ + "//pico_w/bt:picow_bt_example_poll", + ], + has_gatt_header = has_gatt_header, + platform_flags = [ + "--@pico-sdk//bazel/config:PICO_ASYNC_CONTEXT_IMPL=poll", + ], + ) + + _single_example( + name = base_name + "_threadsafe_background", + example_name = base_name, + extra_deps = extra_deps + [ + "//pico_w/bt:picow_bt_example_background", + ], has_gatt_header = has_gatt_header, - # lwip = True, - # async_context = "poll", + platform_flags = [ + "--@pico-sdk//bazel/config:PICO_ASYNC_CONTEXT_IMPL=threadsafe_background", + ], ) diff --git a/pico_w/bt/standalone/BUILD.bazel b/pico_w/bt/standalone/BUILD.bazel index 510150652..ef7a97f4f 100644 --- a/pico_w/bt/standalone/BUILD.bazel +++ b/pico_w/bt/standalone/BUILD.bazel @@ -46,7 +46,8 @@ extra_copts_for_all_deps( extra_copts = [ # Doesn't use multicore, but links in the multicore lib. # Needed to fix a cautious flash assertion. - "-DPICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT=0", + # TODO: Test on device, shouldn't be needed anymore. + # "-DPICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT=0", ], )