| # Copyright 2024 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| load("@pigweed//pw_build:merge_flags.bzl", "flags_from_dict") |
| load("@pigweed//targets/rp2040:transition.bzl", "RP2_SYSTEM_FLAGS") |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| # This is an incomplete platform, do NOT try to pass this |
| # as a --platforms flag value. Use :rp2040 or :rp2350. |
| platform( |
| name = "rp2_common", |
| constraint_values = [ |
| "@freertos//:disable_task_statics", |
| "@pigweed//pw_build/constraints/rtos:freertos", |
| "@pigweed//pw_build/constraints/chipset:rp2040", # TODO: https://pwbug.dev/343487589 - Use Pico SDK constraints. |
| "@pigweed//pw_cpu_exception:enabled", |
| "@pigweed//pw_interrupt_cortex_m:backend", |
| "@platforms//os:none", |
| ], |
| flags = flags_from_dict(RP2_SYSTEM_FLAGS | { |
| "//apps/production:threads": "//targets/rp2:production_app_threads", |
| "//system:system": "//targets/rp2:system", |
| "@freertos//:freertos_config": "//targets/rp2:freertos_config", |
| "@pico-sdk//bazel/config:PICO_CLIB": "llvm_libc", |
| "@pico-sdk//bazel/config:PICO_TOOLCHAIN": "clang", |
| "@pigweed//pw_build:default_module_config": "//system:module_config", |
| "@pigweed//pw_system:extra_platform_libs": "//targets/rp2:extra_platform_libs", |
| "@pigweed//pw_system:io_backend": "@pigweed//pw_system:sys_io_target_io", |
| "@pigweed//pw_thread_freertos:config_override": "//targets/rp2:thread_config_overrides", |
| "@pigweed//pw_toolchain:cortex-m_toolchain_kind": "clang", |
| "@pigweed//pw_unit_test:config_override": "//targets/rp2:64k_unit_tests", |
| "@pigweed//pw_unit_test:main": "//targets/rp2:unit_test_rpc_main", |
| }), |
| ) |
| |
| platform( |
| name = "rp2040", |
| constraint_values = [ |
| "@freertos//:port_ARM_CM0", |
| "@pico-sdk//bazel/constraint:rp2040", |
| # For toolchain selection. |
| "@platforms//cpu:armv6-m", |
| "@pw_toolchain//constraints/arm_mcpu:cortex-m0", |
| ], |
| parents = [":rp2_common"], |
| ) |
| |
| platform( |
| name = "rp2350", |
| constraint_values = [ |
| "@freertos//:port_ARM_CM33_NTZ", |
| "@pico-sdk//bazel/constraint:rp2350", |
| # For toolchain selection. |
| "@platforms//cpu:armv8-m", |
| "@pw_toolchain//constraints/arm_mcpu:cortex-m33", |
| ], |
| parents = [":rp2_common"], |
| ) |
| |
| cc_library( |
| name = "extra_platform_libs", |
| deps = [ |
| "@pico-sdk//src/rp2_common/pico_stdlib:pico_stdlib", |
| "@pigweed//pw_tokenizer:linker_script", |
| ] + select({ |
| "@pigweed//pw_toolchain/cc/current_toolchain:compiler_is_clang": [ |
| "@pigweed//pw_libcxx", |
| ], |
| "//conditions:default": [], |
| }), |
| alwayslink = 1, |
| ) |
| |
| cc_library( |
| name = "freertos_config", |
| hdrs = [ |
| "config/FreeRTOSConfig.h", |
| ], |
| includes = ["config"], |
| deps = ["@pigweed//third_party/freertos:config_assert"], |
| ) |
| |
| cc_library( |
| name = "thread_config_overrides", |
| defines = [ |
| "PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED=1", |
| ], |
| ) |
| |
| cc_library( |
| name = "system", |
| srcs = [ |
| "led.cc", |
| "system.cc", |
| ], |
| hdrs = [ |
| "enviro_pins.h", |
| ], |
| implementation_deps = [ |
| "//device:bme688", |
| "//device:ltr559", |
| "//device:pico_board", |
| "//device:pico_pwm_gpio", |
| "//modules/buttons:manager", |
| "//system:headers", |
| "//system:worker", |
| "@pico-sdk//src/rp2_common/cmsis:cmsis_core", |
| "@pico-sdk//src/rp2_common/hardware_adc", |
| "@pico-sdk//src/rp2_common/hardware_exception:hardware_exception", |
| "@pico-sdk//src/rp2_common/pico_stdlib:pico_stdlib", |
| "@pigweed//pw_channel", |
| "@pigweed//pw_channel:rp2_stdio_channel", |
| "@pigweed//pw_cpu_exception:entry_backend_impl", |
| "@pigweed//pw_digital_io_rp2040", |
| "@pigweed//pw_i2c_rp2040", |
| "@pigweed//pw_multibuf:simple_allocator", |
| "@pigweed//pw_system:async", |
| "@pigweed//third_party/freertos:support", |
| ], |
| deps = ["//system:headers"], |
| alwayslink = 1, |
| ) |
| |
| cc_library( |
| name = "production_app_threads", |
| srcs = ["production_app_threads.cc"], |
| implementation_deps = ["@pigweed//pw_thread_freertos:thread"], |
| deps = ["//apps/production:threads_headers"], |
| ) |
| |
| cc_library( |
| name = "unit_test_rpc_main", |
| testonly = True, |
| srcs = ["unit_test_rpc_main.cc"], |
| deps = [ |
| "//system:worker", |
| "//system", |
| "@pigweed//pw_log", |
| "@pigweed//pw_system:async", |
| "@pigweed//pw_unit_test:rpc_service", |
| |
| # These should be provided by pw_system:async. |
| "@pigweed//pw_assert:assert_backend_impl", |
| "@pigweed//pw_assert:check_backend_impl", |
| "@pigweed//pw_log:backend_impl", |
| "@pigweed//pw_system:extra_platform_libs", |
| ], |
| ) |
| |
| # Several tests store `TestWorker` thread contexts in their unit test object. |
| # Since these thread stacks are currently 32k, the test objects may be large. |
| cc_library( |
| name = "64k_unit_tests", |
| defines = [ |
| "PW_UNIT_TEST_CONFIG_MEMORY_POOL_SIZE=65536", |
| ], |
| ) |