Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1

test --@pigweed//pw_kernel:enable_tests=true
test --platform_suffix=test
test --test_tag_filters=-fpga,-disabled

# Remote execution config definitions
# ===================================
Expand Down Expand Up @@ -108,8 +109,21 @@ test:stress_k_ast1060_evb --test_env=AST1060_EVB_PI_HOST
# Platform setup for building //target/veer/* artifacts.
common:k_veer --platforms=//target/veer:veer
build:k_veer --build_tag_filters=-do_not_build,-kernel_doc_test
# Usage: VCK190_FPGA_HOST=<host> bazel test --config=k_veer //target/veer/unittest_runner:fpga_test
test:k_veer --test_env=VCK190_FPGA_HOST

# Caliptra VCK190 FPGA board via SSH.
# Host-side test binaries compile for the VCK190's ARM cores (//toolchain/aarch64_linux)
# while MCU firmware images transition to //target/veer:veer with target_type=fpga.
# Usage: bazel test --config=fpga --test_env=VCK190_FPGA_HOST=<host> //target/veer/...
# (or set `test:fpga --test_env=VCK190_FPGA_HOST=<host>` in .bazelrc-site).
common:fpga --platforms=//toolchain/aarch64_linux
build:fpga --build_tag_filters=-do_not_build,-kernel_doc_test
test:fpga --local_test_jobs=1
test:fpga --run_under=//target/veer/tooling/fpga:run_remote
test:fpga --strategy=TestRunner=local
test:fpga --test_env=SSH_AUTH_SOCK
test:fpga --test_env=VCK190_FPGA_HOST
test:fpga --test_tag_filters=fpga,-disabled,-do_not_build,-do_not_run_test,-kernel_doc_test
test:fpga --test_timeout=600

# Site-local overrides. Kept last so developer machine-specific settings (e.g. a
# local QEMU source override via --override_repository) take precedence. This
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions target/veer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@pigweed//pw_build:merge_flags.bzl", "flags_from_dict")
load("@pigweed//pw_kernel:flags.bzl", "KERNEL_DEVICE_COMMON_FLAGS")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
load("@rules_rust//rust:defs.bzl", "rust_library")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH")

platform(
Expand Down Expand Up @@ -89,19 +89,6 @@ rust_library(
],
)

rust_binary(
name = "caliptra_emulator",
srcs = ["caliptra_emulator_main.rs"],
edition = "2021",
visibility = [":__subpackages__"],
deps = [
"//third_party/caliptra/caliptra-mcu-sw:emulator_lib",
"//third_party/caliptra/caliptra-mcu-sw:mcu_testing_common",
"//third_party/caliptra/caliptra-sw:caliptra_emu_cpu",
"@rust_caliptra_crates_host//:clap",
],
)

rust_library(
name = "console",
srcs = ["console.rs"],
Expand Down
32 changes: 0 additions & 32 deletions target/veer/caliptra_emulator_main.rs

This file was deleted.

41 changes: 41 additions & 0 deletions target/veer/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"""Common definitions used by all veer targets.
"""

load("@pigweed//pw_kernel/tooling:system_image.bzl", "system_image")
load("//target:unittest_image.bzl", "unittest_image")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_mcu_image")

TARGET_COMPATIBLE_WITH = select({
"//target/veer:target_veer": [],
"//conditions:default": ["@platforms//:incompatible"],
Expand All @@ -30,3 +34,40 @@ def veer_system_config(name, src, **kwargs):
tools = [tool],
**kwargs
)

def veer_system_image(name, visibility = None, tags = None, **kwargs):
"""Defines a Pigweed `system_image` plus its signed `<name>_image_emulator` and `<name>_image_fpga` `caliptra_mcu_image` targets."""
system_image(
name = name,
tags = tags,
visibility = visibility,
**kwargs
)
_veer_mcu_images(name, visibility, tags)

def veer_unittest_image(name, visibility = None, tags = None, **kwargs):
"""Like `veer_system_image`, but wraps the kernel with `unittest_image` so `#[unittest::test]` cases are compiled in."""
unittest_image(
name = name,
tags = tags,
visibility = visibility,
**kwargs
)
_veer_mcu_images(name, visibility, tags)

def _veer_mcu_images(name, visibility, tags):
"""Defines the signed `<name>_image_emulator` and `<name>_image_fpga` targets for image `:<name>`."""
caliptra_mcu_image(
name = name + "_image_emulator",
image = ":" + name,
interface = "emulator",
tags = tags,
visibility = visibility,
)
caliptra_mcu_image(
name = name + "_image_fpga",
image = ":" + name,
interface = "fpga",
tags = tags,
visibility = visibility,
)
19 changes: 14 additions & 5 deletions target/veer/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ use kernel::{self as _};
#[unsafe(no_mangle)]
#[allow(non_snake_case)]
pub unsafe extern "C" fn pw_assert_HandleFailure() -> ! {
use kernel::Arch as _;
Arch::panic()
#[cfg(any(feature = "emulator", feature = "fpga"))]
exit(1);

#[cfg(not(any(feature = "emulator", feature = "fpga")))]
{
use kernel::Arch as _;
Arch::panic()
}
}

#[riscv_rt::entry]
Expand All @@ -30,9 +36,12 @@ pub fn exit(code: u32) -> ! {

#[cfg(feature = "emulator")]
unsafe {
// SAFETY: writing to this address will cause the emulator to exit.
let exitcode = core::ptr::with_exposed_provenance_mut::<u32>(0x1000_2000);
exitcode.write_volatile(code);
// SAFETY: 0x1000_1041 is the emulator UART TX register. Writing 0xff
// (pass) or 0x01 (fail) signals ExitStatus to ModelEmulated
// (matching caliptra-mcu-sw/platforms/emulator/rom/src/io.rs::exit_emulator).
let tx = core::ptr::with_exposed_provenance_mut::<u8>(0x1000_1041);
let byte: u8 = if code == 0 { 0xff } else { 0x01 };
tx.write_volatile(byte);
}

#[cfg(feature = "fpga")]
Expand Down
27 changes: 8 additions & 19 deletions target/veer/ipc/user/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Licensed under the Apache-2.0 license
# SPDX-License-Identifier: Apache-2.0

load("@pigweed//pw_kernel/tooling:system_image.bzl", "system_image")
load("@pigweed//pw_kernel/tooling:target_codegen.bzl", "target_codegen")
load("@pigweed//pw_kernel/tooling:target_linker_script.bzl", "target_linker_script")
load("@pigweed//pw_kernel/tooling/panic_detector:rust_binary_no_panics_test.bzl", "rust_binary_no_panics_test")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_runner", "caliptra_test")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config", "veer_system_image")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_on_device_test")

package(default_visibility = ["//visibility:public"])

system_image(
veer_system_image(
name = "ipc",
apps = ["@pigweed//pw_kernel/tests/ipc/user:ipc"],
kernel = ":target",
Expand Down Expand Up @@ -65,22 +64,12 @@ rust_binary(
],
)

caliptra_runner(
name = "ipc_runner_emulator",
interface = "emulator",
tags = ["manual"],
target = ":ipc",
)

caliptra_test(
name = "ipc_runner_emulator_test",
caliptra_on_device_test(
name = "ipc_test",
timeout = "long",
interface = "emulator",
# caliptra_runner.py hardcodes --i3c-port=65534, so caliptra emulator
# tests cannot run in parallel without an EADDRINUSE collision.
tags = [
interfaces = [
"emulator",
"exclusive",
"fpga",
],
target = ":ipc",
mcu_image = ":ipc",
)
30 changes: 9 additions & 21 deletions target/veer/syscall_latency/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
# SPDX-License-Identifier: Apache-2.0

load("@pigweed//pw_kernel/tooling:rust_app.bzl", "rust_app")
load("@pigweed//pw_kernel/tooling:system_image.bzl", "system_image")
load("@pigweed//pw_kernel/tooling:target_codegen.bzl", "target_codegen")
load("@pigweed//pw_kernel/tooling:target_linker_script.bzl", "target_linker_script")
load("@pigweed//pw_kernel/tooling/panic_detector:rust_binary_no_panics_test.bzl", "rust_binary_no_panics_test")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_runner", "caliptra_test")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config", "veer_system_image")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_on_device_test")

rust_app(
name = "syscall_latency",
Expand Down Expand Up @@ -36,7 +35,7 @@ rust_app(
],
)

system_image(
veer_system_image(
name = "measure_syscall_latency",
apps = [
":syscall_latency",
Expand Down Expand Up @@ -93,26 +92,15 @@ rust_binary_no_panics_test(
tags = ["kernel"],
)

caliptra_runner(
name = "measure_syscall_latency_emulator",
interface = "emulator",
tags = ["manual"],
target = ":measure_syscall_latency",
)

caliptra_test(
name = "measure_syscall_latency_emulator_test",
caliptra_on_device_test(
name = "measure_syscall_latency_test",
timeout = "long",
interface = "emulator",
# DISABLED: this test hits a pw_kernel terminal exception in kernel mode
# (mcause=1, epc=0) on process exit.
#
# caliptra_runner.py hardcodes --i3c-port=65534, so caliptra emulator
# tests cannot run in parallel without an EADDRINUSE collision.
tags = [
"disabled",
interfaces = [
"emulator",
"exclusive",
"fpga",
],
target = ":measure_syscall_latency",
mcu_image = ":measure_syscall_latency",
tags = ["disabled"],
)
28 changes: 9 additions & 19 deletions target/veer/tests/interrupts/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Licensed under the Apache-2.0 license
# SPDX-License-Identifier: Apache-2.0

load("@pigweed//pw_kernel/tooling:system_image.bzl", "system_image")
load("@pigweed//pw_kernel/tooling:target_codegen.bzl", "target_codegen")
load("@pigweed//pw_kernel/tooling:target_linker_script.bzl", "target_linker_script")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_runner", "caliptra_test")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config", "veer_system_image")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_on_device_test")

system_image(
veer_system_image(
name = "interrupts",
kernel = ":target",
platform = "//target/veer",
Expand Down Expand Up @@ -49,21 +48,12 @@ rust_binary(
],
)

caliptra_runner(
name = "interrupts_runner_emulator",
interface = "emulator",
tags = ["manual"],
target = ":interrupts",
)

caliptra_test(
name = "emulator_test",
interface = "emulator",
# caliptra_runner.py hardcodes --i3c-port=65534, so caliptra emulator
# tests cannot run in parallel without an EADDRINUSE collision.
tags = [
# target.rs triggers McuRootBus::PRIMARY_FLASH_CTRL_ERROR_IRQ via the
# emulator-only primary flash controller at 0x2000_8000.
caliptra_on_device_test(
name = "interrupts_test",
interfaces = [
"emulator",
"exclusive",
],
target = ":interrupts",
mcu_image = ":interrupts",
)
26 changes: 9 additions & 17 deletions target/veer/threads/kernel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Licensed under the Apache-2.0 license
# SPDX-License-Identifier: Apache-2.0

load("@pigweed//pw_kernel/tooling:system_image.bzl", "system_image")
load("@pigweed//pw_kernel/tooling:target_codegen.bzl", "target_codegen")
load("@pigweed//pw_kernel/tooling:target_linker_script.bzl", "target_linker_script")
load("@pigweed//pw_kernel/tooling/panic_detector:rust_binary_no_panics_test.bzl", "rust_binary_no_panics_test")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_runner", "caliptra_test")
load("//target/veer:defs.bzl", "TARGET_COMPATIBLE_WITH", "veer_system_config", "veer_system_image")
load("//target/veer/tooling:caliptra_runner.bzl", "caliptra_on_device_test")

system_image(
veer_system_image(
name = "threads",
kernel = ":target",
platform = "//target/veer",
Expand Down Expand Up @@ -58,19 +57,12 @@ rust_binary(
],
)

caliptra_runner(
name = "threads_runner_emulator",
interface = "emulator",
tags = ["manual"],
target = ":threads",
)

caliptra_test(
name = "threads_runner_emulator_test",
interface = "emulator",
tags = [
caliptra_on_device_test(
name = "threads_test",
interfaces = [
"emulator",
"manual",
"fpga",
],
target = ":threads",
mcu_image = ":threads",
tags = ["manual"],
)
Loading
Loading