• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2025 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15load("@pigweed//pw_build:merge_flags.bzl", "flags_from_dict")
16load("@rules_cc//cc:cc_library.bzl", "cc_library")
17load("@rules_rust//rust:defs.bzl", "rust_library")
18
19constraint_value(
20    name = "rp235x",
21    constraint_setting = "@pigweed//pw_build/constraints/chipset:chipset",
22    visibility = ["//visibility:public"],
23)
24
25cc_library(
26    name = "rp2350_linker_script",
27    linkopts = ["-T$(location rp2350.ld)"],
28    target_compatible_with = [":rp235x"],
29    deps = [
30        "rp2350.ld",
31    ],
32)
33
34platform(
35    name = "rp2350",
36    constraint_values = [
37        ":rp235x",
38        "//pw_build/constraints/arm:cortex-m33",
39        "@platforms//cpu:armv8-m",
40        "@platforms//os:none",
41        "@rust_crates//:no_std",
42    ],
43    flags = flags_from_dict({
44        "//pw_kernel/lib/unittest:unittest_runner": "//pw_kernel/lib/unittest:unittest_runner_cortex_m",
45        "//pw_kernel/subsys/console:console_backend": ":console_backend",
46        "//pw_kernel/target:linker_script": "//pw_kernel/target/rp:rp2350_linker_script",
47        "//pw_kernel/target:target_backend": ":target_rp2350",
48    }),
49)
50
51rust_library(
52    name = "console_backend",
53    srcs = ["console_backend.rs"],
54    target_compatible_with = select({
55        ":rp235x": [],
56        "//conditions:default": ["@platforms//:incompatible"],
57    }),
58    visibility = ["//visibility:public"],
59    deps = [
60        "//pw_kernel/kernel",
61        "//pw_kernel/lib/pw_status",
62        "@rust_crates//:embedded-io",
63        "@rust_crates//:rp235x-hal",
64    ],
65)
66
67rust_library(
68    name = "target_rp2350",
69    srcs = ["target_rp2350.rs"],
70    crate_name = "target_backend",
71    deps = [
72        ":console_backend",
73        "//pw_kernel/target:target_interface",
74        "@rust_crates//:cortex-m-rt",
75        "@rust_crates//:panic-halt",
76        "@rust_crates//:rp235x-hal",
77    ],
78)
79