# 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. """Bazel macros for flashing an rp2040 binary.""" load("@bazel_skylib//rules:native_binary.bzl", "native_binary") def _flash_rp2( name, chip, binary, **kwargs): data = [binary] args = ["--chip", chip, "$(rootpath " + binary + ")"] native_binary( name = name, src = str(Label("//targets/rp2040/py:flash")), args = args, data = data, # Note: out is mandatory in older bazel-skylib versions. out = name + ".exe", **kwargs ) def flash_rp2040( name, rp2040_binary, **kwargs): """Flash the binary to a connected rp2040 device. Args: name: The name of this flash_rp2040 rule. rp2040_binary: The binary target to flash. **kwargs: Forwarded to the underlying native_binary rule. """ _flash_rp2(name, "RP2040", rp2040_binary, **kwargs) def flash_rp2350( name, rp2350_binary, **kwargs): """Flash the binary to a connected rp2350 device. Args: name: The name of this flash_rp2350 rule. rp2350_binary: The binary target to flash. **kwargs: Forwarded to the underlying native_binary rule. """ _flash_rp2(name, "RP2350", rp2350_binary, **kwargs)