diff --git a/.github/workflows/size-analysis.yml b/.github/workflows/size-analysis.yml deleted file mode 100644 index b8a6a5c..0000000 --- a/.github/workflows/size-analysis.yml +++ /dev/null @@ -1,121 +0,0 @@ -# Licensed under the Apache-2.0 license - -name: Binary Size Analysis - -on: - pull_request: - branches: - - main - paths: - - 'src/**' - - 'Cargo.toml' - - 'Cargo.lock' - -jobs: - size-analysis: - runs-on: ubuntu-22.04 - - permissions: - contents: read - - steps: - - name: Checkout PR - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install packages - run: | - sudo apt-get update -qy - sudo apt-get install -qy build-essential curl gcc-multilib gcc-riscv64-unknown-elf git - - - name: Install cargo-bloat - run: cargo install cargo-bloat --locked - - - name: Build current branch - run: | - cargo build --release --target thumbv7em-none-eabihf - - - name: Analyze current branch size - run: | - # Use cargo bloat directly since xtask bloat may not be available - cargo bloat --release --target thumbv7em-none-eabihf > target/pr-bloat-report.txt || echo "Bloat analysis failed" - - - name: Checkout main branch - run: | - git checkout main - - - name: Build main branch - run: | - cargo build --release --target thumbv7em-none-eabihf - - - name: Analyze main branch size - run: | - # Use cargo bloat directly since xtask bloat may not be available - cargo bloat --release --target thumbv7em-none-eabihf > target/main-bloat-report.txt || echo "Bloat analysis failed" - - - name: Generate size comparison report - id: size-comparison - run: | - # Create a comprehensive comparison - echo "## 📊 Binary Size Analysis" > size_report.md - echo "" >> size_report.md - - # Get binary sizes - PR_SIZE=$(stat -c%s target/thumbv7em-none-eabihf/release/aspeed-ddk 2>/dev/null || echo "0") - git checkout - - MAIN_SIZE=$(stat -c%s target/thumbv7em-none-eabihf/release/aspeed-ddk 2>/dev/null || echo "0") - - # Calculate difference - SIZE_DIFF=$((PR_SIZE - MAIN_SIZE)) - - echo "### Size Comparison" >> size_report.md - echo "- **Main branch**: $(numfmt --to=iec $MAIN_SIZE)" >> size_report.md - echo "- **PR branch**: $(numfmt --to=iec $PR_SIZE)" >> size_report.md - echo "- **Difference**: $(numfmt --to=iec $SIZE_DIFF)" >> size_report.md - echo "" >> size_report.md - - if [ $SIZE_DIFF -gt 10240 ]; then - echo "âš ī¸ **Warning**: Binary size increased by more than 10KB" >> size_report.md - echo "size_warning=true" >> $GITHUB_OUTPUT - elif [ $SIZE_DIFF -gt 0 ]; then - echo "â„šī¸ Binary size increased slightly" >> size_report.md - elif [ $SIZE_DIFF -lt 0 ]; then - echo "✅ Binary size decreased!" >> size_report.md - fi - - echo "" >> size_report.md - echo "### Top Functions (Current PR)" >> size_report.md - echo '```' >> size_report.md - head -20 target/pr-bloat-report.txt >> size_report.md 2>/dev/null || echo "No function data available" >> size_report.md - echo '```' >> size_report.md - - - name: Output size analysis to workflow summary - run: | - echo "## 📊 Binary Size Analysis" >> $GITHUB_STEP_SUMMARY - cat size_report.md >> $GITHUB_STEP_SUMMARY - - - name: Output size analysis to console - run: | - echo "=== Binary Size Analysis ===" - cat size_report.md - - - name: Check for significant size increase - run: | - # Extract size difference from the report - if grep -q "âš ī¸ Binary size increased by more than 10KB" size_report.md; then - echo "::error::Binary size increased by more than 10KB! Please review." - exit 1 - elif grep -q "🚨 Binary size increased significantly" size_report.md; then - echo "::warning::Binary size increased significantly. Consider optimization." - fi - - - name: Upload detailed reports - uses: actions/upload-artifact@v4 - with: - name: size-analysis-detailed - path: | - target/pr-bloat-report.txt - target/main-bloat-report.txt - size_report.md - retention-days: 7 diff --git a/Cargo.lock b/Cargo.lock index 7f52300..8b2d32c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,7 +65,6 @@ dependencies = [ "ast1060-pac", "bitflags", "cortex-m", - "cortex-m-rt", "critical-section", "embedded-hal 1.0.0", "embedded-hal 1.0.0-alpha.1", @@ -75,13 +74,30 @@ dependencies = [ "hex-literal", "nb 1.1.0", "openprot-hal-blocking", - "panic-halt", "paste", "proposed-traits", "static_cell", "zerocopy", ] +[[package]] +name = "aspeed-ddk-tests-hw" +version = "0.1.0" +dependencies = [ + "aspeed-ddk", + "ast1060-pac", + "cortex-m", + "cortex-m-rt", + "embedded-hal 1.0.0", + "embedded-hal 1.0.0-alpha.1", + "embedded-io", + "fugit", + "hex-literal", + "openprot-hal-blocking", + "panic-halt", + "proposed-traits", +] + [[package]] name = "ast1060-pac" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7e69586..e44414a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ # Licensed under the Apache-2.0 license [workspace] -members = ["xtask"] +members = ["xtask", "tests-hw"] exclude = [] resolver = "2" @@ -22,10 +22,6 @@ i2c_master = [] i2c_target = [] i3c_master = [] i3c_target = [] -test-rsa = [] -test-ecdsa = [] -test-hmac = [] -test-hash = [] spi_dma = [] spi_dma_write = [] spi_dma_irq = [] @@ -48,6 +44,4 @@ openprot-hal-blocking = { git="https://github.com/OpenPRoT/openprot" } zerocopy = { version = "0.8.25", features = ["derive"] } critical-section = "1.2" cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] } -cortex-m-rt = { version = "0.7.5", features = ["device"] } -panic-halt = "1.0.0" diff --git a/anthony-rocha-2026-02-12.patch b/anthony-rocha-2026-02-12.patch deleted file mode 100644 index 1e79a36..0000000 --- a/anthony-rocha-2026-02-12.patch +++ /dev/null @@ -1,321 +0,0 @@ -From 048e272b0d6ffc2a5a8e870c7316b08df33bda7c Mon Sep 17 00:00:00 2001 -From: Anthony Rocha -Date: Thu, 12 Feb 2026 11:19:36 -0800 -Subject: [PATCH] refactor(i3c): conditionally export ISR handlers with - isr-handlers feature - ---- - .gitignore | 3 + - BUILD.bazel | 165 +++++++++++++++++++++++++++++ - Cargo.toml | 5 +- - src/i3c/ast1060_i3c.rs | 41 ++++++- - src/lib.rs | 1 + - src/tests/functional/i2c_test.rs | 1 + - src/tests/functional/timer_test.rs | 1 + - 7 files changed, 209 insertions(+), 8 deletions(-) - create mode 100644 BUILD.bazel - -diff --git a/.gitignore b/.gitignore -index 3a5a215..7128458 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -6,3 +6,6 @@ - # Bloat analysis reports - target/bloat-reports/ - target/*-bloat-reports/ -+ -+# Auto-generated Bazel build file (regenerate via crate_universe) -+BUILD.bazel -diff --git a/BUILD.bazel b/BUILD.bazel -new file mode 100644 -index 0000000..1ed5729 ---- /dev/null -+++ b/BUILD.bazel -@@ -0,0 +1,165 @@ -+############################################################################### -+# @generated -+# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To -+# regenerate this file, run the following: -+# -+# bazel mod show_repo 'opentitan_pigweed' -+############################################################################### -+ -+load( -+ "@rules_rust//cargo:defs.bzl", -+ "cargo_build_script", -+ "cargo_toml_env_vars", -+) -+ -+load("@rules_rust//rust:defs.bzl", "rust_library") -+ -+# buildifier: disable=bzl-visibility -+load("@rules_rust//crate_universe/private:selects.bzl", "selects") -+ -+package(default_visibility = ["//visibility:public"]) -+ -+cargo_toml_env_vars( -+ name = "cargo_toml_env_vars", -+ src = "Cargo.toml", -+) -+ -+rust_library( -+ name = "aspeed_ddk", -+ deps = [ -+ "@oot_crates_no_std__aspeed-ddk-0.1.0//:build_script_build", -+ "@oot_crates_no_std__ast1060-pac-0.1.0//:ast1060_pac", -+ "@oot_crates_no_std__cortex-m-0.7.7//:cortex_m", -+ "@oot_crates_no_std__cortex-m-rt-0.7.5//:cortex_m_rt", -+ "@oot_crates_no_std__critical-section-1.2.0//:critical_section", -+ "@oot_crates_no_std__embedded-hal-1.0.0//:embedded_hal", -+ "@oot_crates_no_std__embedded-hal-1.0.0-alpha.1//:embedded_hal", -+ "@oot_crates_no_std__embedded-io-0.6.1//:embedded_io", -+ "@oot_crates_no_std__fugit-0.3.9//:fugit", -+ "@oot_crates_no_std__heapless-0.8.0//:heapless", -+ "@oot_crates_no_std__hex-literal-0.4.1//:hex_literal", -+ "@oot_crates_no_std__nb-1.1.0//:nb", -+ "@oot_crates_no_std__openprot-hal-blocking-0.1.0//:openprot_hal_blocking", -+ "@oot_crates_no_std__panic-halt-1.0.0//:panic_halt", -+ "@oot_crates_no_std__proposed-traits-0.1.0//:proposed_traits", -+ "@oot_crates_no_std__zerocopy-0.8.39//:zerocopy", -+ ], -+ proc_macro_deps = [ -+ "@oot_crates_no_std__paste-1.0.15//:paste", -+ ], -+ aliases = { -+ "@oot_crates_no_std__embedded-hal-1.0.0-alpha.1//:embedded_hal": "embedded_hal_old", -+ }, -+ compile_data = glob( -+ allow_empty = True, -+ include = ["**"], -+ exclude = [ -+ "**/* *", -+ ".tmp_git_root/**/*", -+ "BUILD", -+ "BUILD.bazel", -+ "WORKSPACE", -+ "WORKSPACE.bazel", -+ ], -+ ), -+ crate_features = [ -+ "default", -+ ], -+ crate_root = "src/lib.rs", -+ edition = "2021", -+ rustc_env_files = [ -+ ":cargo_toml_env_vars", -+ ], -+ rustc_flags = [ -+ "--cap-lints=allow", -+ ], -+ srcs = glob( -+ allow_empty = True, -+ include = ["**/*.rs"], -+ ), -+ tags = [ -+ "cargo-bazel", -+ "crate-name=aspeed-ddk", -+ "manual", -+ "noclippy", -+ "norustfmt", -+ ], -+ target_compatible_with = select({ -+ "@rules_rust//rust/platform:aarch64-apple-darwin": [], -+ "@rules_rust//rust/platform:aarch64-unknown-linux-gnu": [], -+ "@rules_rust//rust/platform:riscv32imc-unknown-none-elf": [], -+ "@rules_rust//rust/platform:thumbv6m-none-eabi": [], -+ "@rules_rust//rust/platform:thumbv7em-none-eabi": [], -+ "@rules_rust//rust/platform:thumbv7m-none-eabi": [], -+ "@rules_rust//rust/platform:thumbv8m.main-none-eabi": [], -+ "@rules_rust//rust/platform:x86_64-apple-darwin": [], -+ "@rules_rust//rust/platform:x86_64-unknown-linux-gnu": [], -+ "//conditions:default": ["@platforms//:incompatible"], -+ }), -+ version = "0.1.0", -+) -+ -+cargo_build_script( -+ name = "_bs", -+ compile_data = glob( -+ allow_empty = True, -+ include = ["**"], -+ exclude = [ -+ "**/* *", -+ "**/*.rs", -+ ".tmp_git_root/**/*", -+ "BUILD", -+ "BUILD.bazel", -+ "WORKSPACE", -+ "WORKSPACE.bazel", -+ ], -+ ), -+ crate_features = [ -+ "default", -+ ], -+ crate_name = "build_script_build", -+ crate_root = "build.rs", -+ data = glob( -+ allow_empty = True, -+ include = ["**"], -+ exclude = [ -+ "**/* *", -+ ".tmp_git_root/**/*", -+ "BUILD", -+ "BUILD.bazel", -+ "WORKSPACE", -+ "WORKSPACE.bazel", -+ ], -+ ), -+ link_deps = [ -+ "@oot_crates_no_std__cortex-m-0.7.7//:cortex_m", -+ "@oot_crates_no_std__cortex-m-rt-0.7.5//:cortex_m_rt", -+ ], -+ edition = "2021", -+ pkg_name = "aspeed-ddk", -+ rustc_env_files = [ -+ ":cargo_toml_env_vars", -+ ], -+ rustc_flags = [ -+ "--cap-lints=allow", -+ ], -+ srcs = glob( -+ allow_empty = True, -+ include = ["**/*.rs"], -+ ), -+ tags = [ -+ "cargo-bazel", -+ "crate-name=aspeed-ddk", -+ "manual", -+ "noclippy", -+ "norustfmt", -+ ], -+ version = "0.1.0", -+ visibility = ["//visibility:private"], -+) -+ -+alias( -+ name = "build_script_build", -+ actual = ":_bs", -+ tags = ["manual"], -+) -diff --git a/Cargo.toml b/Cargo.toml -index c667777..5b2cf39 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -17,6 +17,7 @@ edition = "2021" - [features] - default = [] - std = [] -+isr-handlers = [] # Export ISR handlers with #[no_mangle] - disable for kernel integration - i2c_target = [] - i3c_master = [] - i3c_target = [] -@@ -45,7 +46,3 @@ openprot-hal-blocking = { git="https://github.com/OpenPRoT/openprot" } - zerocopy = { version = "0.8.25", features = ["derive"] } - cortex-m-rt = { version = "0.7.5", features = ["device"] } - panic-halt = "1.0.0" -- --[patch."https://github.com/AspeedTech-BMC/ast1060-pac.git"] --ast1060-pac = { path = "ast1060-pac" } -- -diff --git a/src/i3c/ast1060_i3c.rs b/src/i3c/ast1060_i3c.rs -index 233b875..b3d6a7c 100644 ---- a/src/i3c/ast1060_i3c.rs -+++ b/src/i3c/ast1060_i3c.rs -@@ -230,21 +230,54 @@ fn dispatch_irq(bus: usize) { - }); - } - -+/// I3C bus 0 interrupt handler - call this from your ISR -+#[inline] -+pub fn i3c_irq_handler() { -+ dispatch_irq(0); -+} -+ -+/// I3C bus 1 interrupt handler - call this from your ISR -+#[inline] -+pub fn i3c1_irq_handler() { -+ dispatch_irq(1); -+} -+ -+/// I3C bus 2 interrupt handler - call this from your ISR -+#[inline] -+pub fn i3c2_irq_handler() { -+ dispatch_irq(2); -+} -+ -+/// I3C bus 3 interrupt handler - call this from your ISR -+#[inline] -+pub fn i3c3_irq_handler() { -+ dispatch_irq(3); -+} -+ -+// ISR exports - only when isr-handlers feature is enabled -+// For kernel integration, disable this feature and define ISRs in target code -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn i3c() { -- dispatch_irq(0); -+ i3c_irq_handler(); - } -+ -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn i3c1() { -- dispatch_irq(1); -+ i3c1_irq_handler(); - } -+ -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn i3c2() { -- dispatch_irq(2); -+ i3c2_irq_handler(); - } -+ -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn i3c3() { -- dispatch_irq(3); -+ i3c3_irq_handler(); - } - - #[repr(u32)] -diff --git a/src/lib.rs b/src/lib.rs -index 34c72a7..fa9de7a 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -16,6 +16,7 @@ pub mod rsa; - pub mod spi; - pub mod spimonitor; - pub mod syscon; -+#[cfg(feature = "isr-handlers")] - pub mod tests; - pub mod timer; - pub mod uart; -diff --git a/src/tests/functional/i2c_test.rs b/src/tests/functional/i2c_test.rs -index 2f33a50..c138b22 100644 ---- a/src/tests/functional/i2c_test.rs -+++ b/src/tests/functional/i2c_test.rs -@@ -220,6 +220,7 @@ static mut I2C0_INSTANCE: Option< - > = None; - - #[cfg(feature = "i2c_target")] -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn i2c() { - unsafe { -diff --git a/src/tests/functional/timer_test.rs b/src/tests/functional/timer_test.rs -index 43a1744..89a526a 100644 ---- a/src/tests/functional/timer_test.rs -+++ b/src/tests/functional/timer_test.rs -@@ -12,6 +12,7 @@ use embedded_io::Write; - static mut UART_PTR: Option<&'static mut UartController<'static>> = None; - static mut TIMER_INSTANCE: Option> = None; - -+#[cfg(feature = "isr-handlers")] - #[no_mangle] - pub extern "C" fn timer() { - unsafe { --- -2.34.1 - diff --git a/src/hash_owned.rs b/src/hash_owned.rs index a238b60..d0ec10e 100644 --- a/src/hash_owned.rs +++ b/src/hash_owned.rs @@ -215,69 +215,3 @@ macro_rules! impl_owned_digest { impl_owned_digest!(Sha2_256); impl_owned_digest!(Sha2_384); impl_owned_digest!(Sha2_512); - -#[cfg(test)] -mod tests { - use super::*; - use crate::hace_controller::HaceController; - use openprot_hal_blocking::digest::owned::{DigestInit, DigestOp}; - - #[test] - fn test_owned_digest_pattern() { - // This test demonstrates the owned pattern usage - // Note: In a real test, you'd need actual hardware or mocking - - // Example of what digest operations would look like on real hardware: - // let controller = HaceController::new(hace_peripheral); - // let context = controller.init(Sha2_256::default())?; - // let context = context.update(b"hello")?; - // let context = context.update(b" world")?; - // let (digest, controller) = context.finalize()?; - // // Controller is now recovered for reuse - - // This test verifies compilation - assert!(true); - } - - #[test] - fn test_session_storage_pattern() { - // Demonstrate controller storage pattern - impossible with scoped API - // This simulates what a server would do to store controller wrappers - // Note: Only one can be active at a time due to shared hardware context - - struct SimpleSessionManager { - session_sha256: Option>, - session_sha384: Option>, - controller: Option, - } - - impl SimpleSessionManager { - fn new(controller: HaceController) -> Self { - Self { - session_sha256: None, - session_sha384: None, - controller: Some(controller), - } - } - - // Multiple controller wrappers can be stored (but only one can be active at a time) - fn create_sha256_session(&mut self) -> Result<(), Infallible> { - let controller = self.controller.take().unwrap(); - let context = controller.init(Sha2_256::default())?; - self.session_sha256 = Some(context); - Ok(()) - } - - fn update_sha256_session(&mut self, data: &[u8]) -> Result<(), Infallible> { - let context = self.session_sha256.take().unwrap(); - let updated_context = context.update(data)?; - self.session_sha256 = Some(updated_context); - Ok(()) - } - } - - // This test verifies the pattern compiles correctly - // In real usage, you'd have actual hardware initialization - assert!(true); - } -} diff --git a/src/i2c_core/slave.rs b/src/i2c_core/slave.rs index 661432b..427a254 100644 --- a/src/i2c_core/slave.rs +++ b/src/i2c_core/slave.rs @@ -136,11 +136,11 @@ impl Ast1060I2c<'_> { // Enable slave mode and save address byte in packet mode (I2CC00 bit 20) // This makes the hardware include the destination address byte in the receive buffer // which is required for MCTP-over-SMBus (DSP0237) packet format. - self.regs() - .i2cc00() - .modify(|r, w| unsafe { - w.bits(r.bits() | constants::AST_I2CC_SLAVE_EN | constants::AST_I2CC_SLAVE_PKT_SAVE_ADDR) - }); + self.regs().i2cc00().modify(|r, w| unsafe { + w.bits( + r.bits() | constants::AST_I2CC_SLAVE_EN | constants::AST_I2CC_SLAVE_PKT_SAVE_ADDR, + ) + }); // Configure slave mode let mut cmd = 0u32; diff --git a/src/lib.rs b/src/lib.rs index 0a0a6db..26b2dc7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ // Licensed under the Apache-2.0 license -#![cfg_attr(not(test), no_std)] +#![no_std] pub mod astdebug; pub mod common; pub mod ecdsa; @@ -17,7 +17,6 @@ pub mod rsa; pub mod spi; pub mod spimonitor; pub mod syscon; -pub mod tests; pub mod timer; pub mod uart; pub mod uart_core; diff --git a/src/tests/functional/mod.rs b/src/tests/functional/mod.rs deleted file mode 100644 index 525c77a..0000000 --- a/src/tests/functional/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed under the Apache-2.0 license - -pub mod ecdsa_test; -pub mod gpio_test; -pub mod hash_test; -pub mod hmac_test; -pub mod i2c_core_test; -pub mod i2c_master_slave_test; -pub mod i2c_test; -pub mod i3c_test; -pub mod rsa_test; -pub mod rsa_test_vec; -pub mod spim_test; -pub mod timer_test; diff --git a/src/tests/mod.rs b/src/tests/mod.rs deleted file mode 100644 index 04e9599..0000000 --- a/src/tests/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -// Licensed under the Apache-2.0 license - -pub mod functional; diff --git a/src/uart_core/hal_impl.rs b/src/uart_core/hal_impl.rs index 265d800..32e3707 100644 --- a/src/uart_core/hal_impl.rs +++ b/src/uart_core/hal_impl.rs @@ -154,8 +154,3 @@ impl UartController<'_> { } } } - -#[cfg(test)] -mod tests { - // Unit tests would go here if we had a mock UART -} diff --git a/tests-hw/Cargo.toml b/tests-hw/Cargo.toml new file mode 100644 index 0000000..098a7ff --- /dev/null +++ b/tests-hw/Cargo.toml @@ -0,0 +1,42 @@ +# Licensed under the Apache-2.0 license + +[package] +name = "aspeed-ddk-tests-hw" +version = "0.1.0" +edition.workspace = true +rust-version.workspace = true +publish = false + +[[bin]] +name = "aspeed-ddk-tests-hw" +path = "src/main.rs" + +[features] +default = ["test-rsa", "test-ecdsa", "test-hmac", "test-hash"] +isr-handlers = ["aspeed-ddk/isr-handlers"] +i2c_master = ["aspeed-ddk/i2c_master"] +i2c_target = ["aspeed-ddk/i2c_target"] +i3c_master = ["aspeed-ddk/i3c_master"] +i3c_target = ["aspeed-ddk/i3c_target"] +test-rsa = [] +test-ecdsa = [] +test-hmac = [] +test-hash = [] +spi_dma = ["aspeed-ddk/spi_dma"] +spi_dma_write = ["aspeed-ddk/spi_dma_write"] +spi_dma_irq = ["aspeed-ddk/spi_dma_irq"] +spi_monitor = ["aspeed-ddk/spi_monitor"] + +[dependencies] +aspeed-ddk = { path = ".." } +ast1060-pac = { git = "https://github.com/OpenPRoT/ast1060-pac.git", branch = "main", features = ["rt"] } +cortex-m = { version = "0.7.7", features = ["critical-section-single-core"] } +cortex-m-rt = { version = "0.7.5", features = ["device"] } +panic-halt = "1.0.0" +embedded-hal = "1.0.0" +embedded-hal-old = { git = "https://github.com/rust-embedded/embedded-hal.git", rev = "599d44fdc7e709cb9ae6580ec11c0b7f7f102", package = "embedded-hal" } +embedded-io = "0.6.1" +fugit = "0.3.7" +hex-literal = "0.4" +proposed-traits = { git = "https://github.com/rusty1968/proposed_traits.git", package = "proposed-traits", rev = "85641310df5a5276c67f81621b104322cff0286c" } +openprot-hal-blocking = { git = "https://github.com/OpenPRoT/openprot" } diff --git a/build.rs b/tests-hw/build.rs similarity index 87% rename from build.rs rename to tests-hw/build.rs index 1527a46..b854984 100644 --- a/build.rs +++ b/tests-hw/build.rs @@ -24,6 +24,14 @@ fn main() { .unwrap() .write_all(include_bytes!("memory.x")) .unwrap(); + + // Copy link.x to the output directory so the linker can find our + // custom linker script before the one provided by cortex-m-rt. + File::create(out.join("link.x")) + .unwrap() + .write_all(include_bytes!("link.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); // By default, Cargo will re-run a build script whenever diff --git a/link.x b/tests-hw/link.x similarity index 100% rename from link.x rename to tests-hw/link.x diff --git a/memory.x b/tests-hw/memory.x similarity index 100% rename from memory.x rename to tests-hw/memory.x diff --git a/src/tests/functional/ecdsa_test.rs b/tests-hw/src/ecdsa_test.rs similarity index 98% rename from src/tests/functional/ecdsa_test.rs rename to tests-hw/src/ecdsa_test.rs index c1ccc7f..9e4f8d2 100644 --- a/src/tests/functional/ecdsa_test.rs +++ b/tests-hw/src/ecdsa_test.rs @@ -1,7 +1,7 @@ // Licensed under the Apache-2.0 license -use crate::ecdsa::{PublicKey, Scalar48, Secp384r1Curve, Signature}; -use crate::uart_core::UartController; +use aspeed_ddk::ecdsa::{PublicKey, Scalar48, Secp384r1Curve, Signature}; +use aspeed_ddk::uart_core::UartController; use embedded_io::Write; use proposed_traits::digest::DigestAlgorithm; use proposed_traits::ecdsa::{Curve, EcdsaVerify}; diff --git a/src/tests/functional/gpio_test.rs b/tests-hw/src/gpio_test.rs similarity index 96% rename from src/tests/functional/gpio_test.rs rename to tests-hw/src/gpio_test.rs index c289a3b..54329c6 100644 --- a/src/tests/functional/gpio_test.rs +++ b/tests-hw/src/gpio_test.rs @@ -4,10 +4,10 @@ use ast1060_pac::Peripherals; use embedded_hal::digital::{InputPin, OutputPin, StatefulOutputPin}; use embedded_io::Write; -use crate::common::DummyDelay; -use crate::gpio::{gpioa, gpioh, gpiol, gpiom, Floating, GpioExt}; -use crate::pinctrl; -use crate::uart_core::UartController; +use aspeed_ddk::common::DummyDelay; +use aspeed_ddk::gpio::{gpioa, gpioh, gpiol, gpiom, Floating, GpioExt}; +use aspeed_ddk::pinctrl; +use aspeed_ddk::uart_core::UartController; use embedded_hal::delay::DelayNs; pub fn test_gpioa(uart: &mut UartController<'_>) { diff --git a/src/tests/functional/hash_test.rs b/tests-hw/src/hash_test.rs similarity index 95% rename from src/tests/functional/hash_test.rs rename to tests-hw/src/hash_test.rs index 9f3f062..8db58f6 100644 --- a/src/tests/functional/hash_test.rs +++ b/tests-hw/src/hash_test.rs @@ -1,15 +1,15 @@ // Licensed under the Apache-2.0 license -use crate::hace_controller::HaceController; -use crate::hash::{IntoHashAlgo, Sha256, Sha384, Sha512}; -use crate::uart_core::UartController; +use aspeed_ddk::hace_controller::HaceController; +use aspeed_ddk::hash::{IntoHashAlgo, Sha256, Sha384, Sha512}; +use aspeed_ddk::uart_core::UartController; use core::any::TypeId; use embedded_io::Write; use proposed_traits::digest::{DigestAlgorithm, DigestInit, DigestOp}; fn print_hex_array(uart: &mut UartController, data: &[u8], bytes_per_line: usize) { for (i, b) in data.iter().enumerate() { - if i.is_multiple_of(bytes_per_line) { + if i % bytes_per_line == 0 { writeln!(uart, "\r").unwrap(); } else { write!(uart, " ").unwrap(); diff --git a/src/tests/functional/hmac_test.rs b/tests-hw/src/hmac_test.rs similarity index 95% rename from src/tests/functional/hmac_test.rs rename to tests-hw/src/hmac_test.rs index 2cd065d..ce8c343 100644 --- a/src/tests/functional/hmac_test.rs +++ b/tests-hw/src/hmac_test.rs @@ -1,15 +1,15 @@ // Licensed under the Apache-2.0 license -use crate::hace_controller::HaceController; -use crate::hmac::{IntoHashAlgo, Sha256, Sha384, Sha512}; -use crate::uart_core::UartController; +use aspeed_ddk::hace_controller::HaceController; +use aspeed_ddk::hmac::{IntoHashAlgo, Sha256, Sha384, Sha512}; +use aspeed_ddk::uart_core::UartController; use core::any::TypeId; use embedded_io::Write; use proposed_traits::mac::{MacAlgorithm, MacInit, MacOp}; fn print_hex_array(uart: &mut UartController, data: &[u8], bytes_per_line: usize) { for (i, b) in data.iter().enumerate() { - if i.is_multiple_of(bytes_per_line) { + if i % bytes_per_line == 0 { writeln!(uart, "\r").unwrap(); } else { write!(uart, " ").unwrap(); diff --git a/src/tests/functional/i2c_core_test.rs b/tests-hw/src/i2c_core_test.rs similarity index 99% rename from src/tests/functional/i2c_core_test.rs rename to tests-hw/src/i2c_core_test.rs index 6b23d00..dd12e3f 100644 --- a/src/tests/functional/i2c_core_test.rs +++ b/tests-hw/src/i2c_core_test.rs @@ -12,12 +12,12 @@ //! output is handled at this test layer via the UART controller passed to //! each test function. This keeps the driver portable and testable. -use crate::i2c_core::{ +use aspeed_ddk::i2c_core::{ Ast1060I2c, ClockConfig, Controller, I2cConfig, I2cController, I2cError, I2cSpeed, I2cXferMode, SlaveConfig, }; -use crate::pinctrl; -use crate::uart_core::UartController; +use aspeed_ddk::pinctrl; +use aspeed_ddk::uart_core::UartController; use ast1060_pac::Peripherals; use embedded_io::Write; diff --git a/src/tests/functional/i2c_master_slave_test.rs b/tests-hw/src/i2c_master_slave_test.rs similarity index 99% rename from src/tests/functional/i2c_master_slave_test.rs rename to tests-hw/src/i2c_master_slave_test.rs index b63eadd..a19057f 100644 --- a/src/tests/functional/i2c_master_slave_test.rs +++ b/tests-hw/src/i2c_master_slave_test.rs @@ -47,12 +47,12 @@ //! - **Slave tests**: Start slave EVB first with `run_slave_tests()`, //! then initiate transactions from external master -use crate::i2c_core::{ +use aspeed_ddk::i2c_core::{ Ast1060I2c, ClockConfig, Controller, I2cConfig, I2cController, I2cSpeed, I2cXferMode, SlaveConfig, SlaveEvent, }; -use crate::pinctrl; -use crate::uart_core::UartController; +use aspeed_ddk::pinctrl; +use aspeed_ddk::uart_core::UartController; use ast1060_pac::Peripherals; use embedded_io::Write; diff --git a/src/tests/functional/i2c_test.rs b/tests-hw/src/i2c_test.rs similarity index 96% rename from src/tests/functional/i2c_test.rs rename to tests-hw/src/i2c_test.rs index 7a79752..213bfc6 100644 --- a/src/tests/functional/i2c_test.rs +++ b/tests-hw/src/i2c_test.rs @@ -1,11 +1,11 @@ // Licensed under the Apache-2.0 license -use crate::common::{NoOpLogger, UartLogger}; -use crate::i2c::ast1060_i2c::Ast1060I2c; -use crate::i2c::common::{I2cConfigBuilder, I2cSpeed, I2cXferMode}; -use crate::i2c::i2c_controller::{HardwareInterface, I2cController}; -use crate::pinctrl; -use crate::uart_core::{UartConfig, UartController}; +use aspeed_ddk::common::{NoOpLogger, UartLogger}; +use aspeed_ddk::i2c::ast1060_i2c::Ast1060I2c; +use aspeed_ddk::i2c::common::{I2cConfigBuilder, I2cSpeed, I2cXferMode}; +use aspeed_ddk::i2c::i2c_controller::{HardwareInterface, I2cController}; +use aspeed_ddk::pinctrl; +use aspeed_ddk::uart_core::{UartConfig, UartController}; use ast1060_pac::Peripherals; #[cfg(feature = "i2c_target")] use cortex_m::peripheral::NVIC; diff --git a/src/tests/functional/i3c_test.rs b/tests-hw/src/i3c_test.rs similarity index 93% rename from src/tests/functional/i3c_test.rs rename to tests-hw/src/i3c_test.rs index c80b4c0..151f7b4 100644 --- a/src/tests/functional/i3c_test.rs +++ b/tests-hw/src/i3c_test.rs @@ -1,20 +1,20 @@ // Licensed under the Apache-2.0 license -use crate::common::{DummyDelay, UartLogger}; -use crate::i3c::config::I3cConfig; -use crate::i3c::config::I3cTargetConfig; -use crate::i3c::constants::I3C_MSG_READ; -use crate::i3c::constants::I3C_MSG_STOP; -use crate::i3c::constants::I3C_MSG_WRITE; -use crate::i3c::controller::I3cController; -use crate::i3c::hardware::Ast1060I3c; -use crate::i3c::hardware::HardwareCore; -use crate::i3c::hardware::HardwareTarget; -use crate::i3c::hardware::HardwareTransfer; -use crate::i3c::ibi::{i3c_ibi_workq_consumer, IbiWork}; -use crate::i3c::types::I3cMsg; -use crate::pinctrl; -use crate::uart_core::{UartConfig, UartController}; +use aspeed_ddk::common::{DummyDelay, UartLogger}; +use aspeed_ddk::i3c::config::I3cConfig; +use aspeed_ddk::i3c::config::I3cTargetConfig; +use aspeed_ddk::i3c::constants::I3C_MSG_READ; +use aspeed_ddk::i3c::constants::I3C_MSG_STOP; +use aspeed_ddk::i3c::constants::I3C_MSG_WRITE; +use aspeed_ddk::i3c::controller::I3cController; +use aspeed_ddk::i3c::hardware::Ast1060I3c; +use aspeed_ddk::i3c::hardware::HardwareCore; +use aspeed_ddk::i3c::hardware::HardwareTarget; +use aspeed_ddk::i3c::hardware::HardwareTransfer; +use aspeed_ddk::i3c::ibi::{i3c_ibi_workq_consumer, IbiWork}; +use aspeed_ddk::i3c::types::I3cMsg; +use aspeed_ddk::pinctrl; +use aspeed_ddk::uart_core::{UartConfig, UartController}; use core::ptr::read_volatile; use embedded_hal::delay::DelayNs; diff --git a/src/main.rs b/tests-hw/src/main.rs similarity index 82% rename from src/main.rs rename to tests-hw/src/main.rs index f8296e8..3dfebdb 100644 --- a/src/main.rs +++ b/tests-hw/src/main.rs @@ -10,33 +10,66 @@ use aspeed_ddk::watchdog::WdtController; use ast1060_pac::Peripherals; use ast1060_pac::{Wdt, Wdt1}; +#[cfg(feature = "test-ecdsa")] use aspeed_ddk::ecdsa::AspeedEcdsa; +#[cfg(any(feature = "test-hash", feature = "test-hmac"))] use aspeed_ddk::hace_controller::HaceController; use aspeed_ddk::i2c_core; +#[cfg(feature = "test-rsa")] use aspeed_ddk::rsa::AspeedRsa; use aspeed_ddk::spi; -use aspeed_ddk::syscon::{ClockId, ResetId, SysCon}; +#[cfg(any( + feature = "test-hash", + feature = "test-hmac", + feature = "test-rsa", + feature = "test-ecdsa" +))] +use aspeed_ddk::syscon::ClockId; +#[cfg(any(feature = "test-hash", feature = "test-hmac"))] +use aspeed_ddk::syscon::ResetId; +use aspeed_ddk::syscon::SysCon; use fugit::MillisDurationU32 as MilliSeconds; -use aspeed_ddk::tests::functional::ecdsa_test::run_ecdsa_tests; -use aspeed_ddk::tests::functional::hash_test::run_hash_tests; -use aspeed_ddk::tests::functional::hmac_test::run_hmac_tests; -use aspeed_ddk::tests::functional::i2c_core_test::run_i2c_core_tests; +#[cfg(feature = "test-ecdsa")] +mod ecdsa_test; +mod gpio_test; +#[cfg(feature = "test-hash")] +mod hash_test; +#[cfg(feature = "test-hmac")] +mod hmac_test; +mod i2c_core_test; #[cfg(any(feature = "i2c_master", feature = "i2c_target"))] -use aspeed_ddk::tests::functional::i2c_master_slave_test; +mod i2c_master_slave_test; #[cfg(any(feature = "i2c_master", feature = "i2c_target"))] -use aspeed_ddk::tests::functional::i2c_test; +mod i2c_test; #[cfg(any(feature = "i3c_master", feature = "i3c_target"))] -use aspeed_ddk::tests::functional::i3c_test; -use aspeed_ddk::tests::functional::rsa_test::run_rsa_tests; -use aspeed_ddk::tests::functional::timer_test::run_timer_tests; -use aspeed_ddk::tests::functional::{gpio_test, spim_test}; +mod i3c_test; +#[cfg(feature = "test-rsa")] +mod rsa_test; +#[cfg(feature = "test-rsa")] +mod rsa_test_vec; +mod spim_test; +mod timer_test; + +#[cfg(feature = "test-ecdsa")] +use ecdsa_test::run_ecdsa_tests; +#[cfg(feature = "test-hash")] +use hash_test::run_hash_tests; +#[cfg(feature = "test-hmac")] +use hmac_test::run_hmac_tests; +use i2c_core_test::run_i2c_core_tests; use panic_halt as _; +#[cfg(feature = "test-rsa")] +use rsa_test::run_rsa_tests; +use timer_test::run_timer_tests; -// Import owned API traits and types +// Import owned API traits and types (used by the owned-digest hash tests) +#[cfg(feature = "test-hash")] use aspeed_ddk::hash_owned::{Sha2_256, Sha2_384, Sha2_512}; +#[cfg(feature = "test-hash")] use openprot_hal_blocking::digest::owned::{DigestInit, DigestOp}; +#[cfg(any(feature = "test-hash", feature = "test-hmac"))] use proposed_traits::system_control::ResetControl; use core::ptr::{read_volatile, write_volatile}; @@ -128,6 +161,7 @@ macro_rules! debug_halt { } /// Test the owned digest API demonstrating move-based resource management +#[cfg(feature = "test-hash")] fn test_owned_digest_api(uart: &mut UartController<'_>) { writeln!(uart, "\r\nRunning owned digest API tests...\r\n").unwrap(); @@ -157,6 +191,7 @@ fn test_owned_digest_api(uart: &mut UartController<'_>) { } /// Validate digest against known test vector +#[cfg(feature = "test-hash")] fn validate_digest( actual: &[u32], expected: &[u8], @@ -210,6 +245,7 @@ fn validate_digest( } /// Test owned SHA256 API demonstrating move semantics +#[cfg(feature = "test-hash")] fn test_owned_sha256(uart: &mut UartController<'_>, hace: ast1060_pac::Hace) { let controller = HaceController::new(hace); @@ -240,6 +276,7 @@ fn test_owned_sha256(uart: &mut UartController<'_>, hace: ast1060_pac::Hace) { } /// Test owned SHA384 API demonstrating controller recovery +#[cfg(feature = "test-hash")] fn test_owned_sha384(uart: &mut UartController<'_>, hace: ast1060_pac::Hace) { let controller = HaceController::new(hace); @@ -275,6 +312,7 @@ fn test_owned_sha384(uart: &mut UartController<'_>, hace: ast1060_pac::Hace) { } /// Test owned SHA512 API demonstrating cancellation +#[cfg(feature = "test-hash")] fn test_owned_sha512(uart: &mut UartController<'_>, hace: ast1060_pac::Hace) { let controller = HaceController::new(hace); @@ -325,20 +363,22 @@ fn main() -> ! { let mut uart_controller = UartController::new(uart_regs); uart_controller.init(&UartConfig::default()).unwrap(); - let hace = peripherals.hace; let scu = peripherals.scu; - let secure = peripherals.secure; writeln!(uart_controller, "\r\nHello, world!!\r\n").unwrap(); let delay = DummyDelay; + #[allow(unused_mut, unused_variables)] let mut syscon = SysCon::new(delay.clone(), scu); - // Enable HACE (Hash and Crypto Engine) - let _ = syscon.enable_clock(ClockId::ClkYCLK as u8); - let reset_id = ResetId::RstHACE; - let _ = syscon.reset_deassert(&reset_id); + // Enable HACE (Hash and Crypto Engine) when hash/hmac tests are active + #[cfg(any(feature = "test-hash", feature = "test-hmac"))] + { + let _ = syscon.enable_clock(ClockId::ClkYCLK as u8); + let reset_id = ResetId::RstHACE; + let _ = syscon.reset_deassert(&reset_id); + } spi::spitest::show_spi_regiters(&mut uart_controller); let test_spicontroller = false; @@ -367,25 +407,43 @@ fn main() -> ! { gpio_test::test_gpio_bmc_reset(&mut uart_controller); } - #[allow(unused_mut, unused_variables)] - let mut hace_controller = HaceController::new(hace); + #[cfg(any(feature = "test-hash", feature = "test-hmac"))] + { + let hace = peripherals.hace; + #[allow(unused_mut, unused_variables)] + let mut hace_controller = HaceController::new(hace); - run_hash_tests(&mut uart_controller, &mut hace_controller); - run_hmac_tests(&mut uart_controller, &mut hace_controller); + #[cfg(feature = "test-hash")] + run_hash_tests(&mut uart_controller, &mut hace_controller); + #[cfg(feature = "test-hmac")] + run_hmac_tests(&mut uart_controller, &mut hace_controller); + } // Test the owned digest API + #[cfg(feature = "test-hash")] test_owned_digest_api(&mut uart_controller); - // Enable RSA and ECC - let _ = syscon.enable_clock(ClockId::ClkRSACLK as u8); + // Enable RSA and ECC when RSA/ECDSA tests are active + #[cfg(any(feature = "test-rsa", feature = "test-ecdsa"))] + { + let secure = peripherals.secure; + let _ = syscon.enable_clock(ClockId::ClkRSACLK as u8); + + #[cfg(feature = "test-ecdsa")] + { + #[allow(unused_mut, unused_variables)] + let mut ecdsa = AspeedEcdsa::new(&secure, delay.clone()); + run_ecdsa_tests(&mut uart_controller, &mut ecdsa); + } - #[allow(unused_mut, unused_variables)] - let mut ecdsa = AspeedEcdsa::new(&secure, delay.clone()); - run_ecdsa_tests(&mut uart_controller, &mut ecdsa); + #[cfg(feature = "test-rsa")] + { + #[allow(unused_mut, unused_variables)] + let mut rsa = AspeedRsa::new(&secure, delay); + run_rsa_tests(&mut uart_controller, &mut rsa); + } + } - #[allow(unused_mut, unused_variables)] - let mut rsa = AspeedRsa::new(&secure, delay); - run_rsa_tests(&mut uart_controller, &mut rsa); gpio_test::test_gpioa(&mut uart_controller); let i2c_test_hw = false; diff --git a/src/tests/functional/rsa_test.rs b/tests-hw/src/rsa_test.rs similarity index 97% rename from src/tests/functional/rsa_test.rs rename to tests-hw/src/rsa_test.rs index 8012af7..c1d34fd 100644 --- a/src/tests/functional/rsa_test.rs +++ b/tests-hw/src/rsa_test.rs @@ -1,8 +1,8 @@ // Licensed under the Apache-2.0 license -use crate::rsa::{RsaDigest, RsaPrivateKey, RsaPublicKey, RsaSignatureData}; -use crate::tests::functional::rsa_test_vec::RSA_VERIFY_TV; -use crate::uart_core::UartController; +use crate::rsa_test_vec::RSA_VERIFY_TV; +use aspeed_ddk::rsa::{RsaDigest, RsaPrivateKey, RsaPublicKey, RsaSignatureData}; +use aspeed_ddk::uart_core::UartController; use embedded_io::Write; use proposed_traits::rsa::{PaddingMode, RsaSign, RsaVerify}; diff --git a/src/tests/functional/rsa_test_vec.rs b/tests-hw/src/rsa_test_vec.rs similarity index 100% rename from src/tests/functional/rsa_test_vec.rs rename to tests-hw/src/rsa_test_vec.rs diff --git a/src/tests/functional/spim_test.rs b/tests-hw/src/spim_test.rs similarity index 94% rename from src/tests/functional/spim_test.rs rename to tests-hw/src/spim_test.rs index fe9ff82..d35be0c 100644 --- a/src/tests/functional/spim_test.rs +++ b/tests-hw/src/spim_test.rs @@ -2,14 +2,18 @@ use ast1060_pac::{Spipf, Spipf1, Spipf2, Spipf3}; -use crate::astdebug; -use crate::spimonitor::{RegionInfo, SpiMonitor, SpiMonitorInit, SpimExtMuxSel}; -use crate::uart_core::UartController; +use aspeed_ddk::astdebug; +use aspeed_ddk::spimonitor::{RegionInfo, SpiMonitor, SpiMonitorInit, SpimExtMuxSel}; +use aspeed_ddk::uart_core::UartController; use embedded_io::Write; +#[allow(dead_code)] pub const SPIM1_BASE: usize = 0x7e79_1000; +#[allow(dead_code)] pub const SPIM2_BASE: usize = 0x7e79_2000; +#[allow(dead_code)] pub const SPIM3_BASE: usize = 0x7e79_3000; +#[allow(dead_code)] pub const SPIM4_BASE: usize = 0x7e79_4000; //follow DTS configuration examples @@ -66,6 +70,7 @@ pub fn test_spim0(uart: &mut UartController<'_>) { // print spim pointer value } +#[allow(dead_code)] pub fn test_spim1() { let allow_cmds: [u8; 27] = [ 0x03, 0x13, 0x0b, 0x0c, 0x6b, 0x6c, 0x01, 0x05, 0x35, 0x06, 0x04, 0x20, 0x21, 0x9f, 0x5a, @@ -91,6 +96,7 @@ pub fn test_spim1() { spi_monitor1.ext_mux_config(SpimExtMuxSel::SpimExtMuxSel0); } +#[allow(dead_code)] pub fn test_spim2() { let allow_cmds: [u8; 27] = [ 0x03, 0x13, 0x0b, 0x0c, 0x6b, 0x6c, 0x01, 0x05, 0x35, 0x06, 0x04, 0x20, 0x21, 0x9f, 0x5a, @@ -116,6 +122,7 @@ pub fn test_spim2() { spi_monitor2.ext_mux_config(SpimExtMuxSel::SpimExtMuxSel0); } +#[allow(dead_code)] pub fn test_spim3(uart: &mut UartController<'_>) { uart.write_all(b"\r\n####### SPIM3 setup #######\r\n") .unwrap(); diff --git a/src/tests/functional/timer_test.rs b/tests-hw/src/timer_test.rs similarity index 94% rename from src/tests/functional/timer_test.rs rename to tests-hw/src/timer_test.rs index 344dfd2..d0c25d4 100644 --- a/src/tests/functional/timer_test.rs +++ b/tests-hw/src/timer_test.rs @@ -1,7 +1,7 @@ // Licensed under the Apache-2.0 license -use crate::timer::{TimerController, TimerType}; -use crate::uart_core::UartController; +use aspeed_ddk::timer::{TimerController, TimerType}; +use aspeed_ddk::uart_core::UartController; use ast1060_pac::Timer; use cortex_m::peripheral::NVIC; use embedded_hal_old::timer::CountDown; diff --git a/xtask/src/test.rs b/xtask/src/test.rs index 5003bf7..c40801d 100644 --- a/xtask/src/test.rs +++ b/xtask/src/test.rs @@ -36,14 +36,13 @@ fn run_unit_tests() -> Result<()> { let status = Command::new("cargo") .current_dir(&*PROJECT_ROOT) - // FIXME: Temporarily exclude `aspeed-ddk` since it's a no_std bare-metal crate. - // Once an emulator is available or host-side unit tests are added for aspeed-ddk, - // this exclusion should be removed. .args([ "test", "--workspace", "--exclude", "aspeed-ddk", + "--exclude", + "aspeed-ddk-tests-hw", "--target", "x86_64-unknown-linux-gnu", ]) @@ -62,14 +61,13 @@ fn run_integration_tests() -> Result<()> { let status = Command::new("cargo") .current_dir(&*PROJECT_ROOT) - // FIXME: Temporarily exclude `aspeed-ddk` since it's a no_std bare-metal crate. - // Once an emulator is available or host-side unit tests are added for aspeed-ddk, - // this exclusion should be removed. .args([ "test", "--workspace", "--exclude", "aspeed-ddk", + "--exclude", + "aspeed-ddk-tests-hw", "--target", "x86_64-unknown-linux-gnu", ]) @@ -153,9 +151,12 @@ fn run_hardware_test_suite(uart: &str, suite: &str) -> Result<()> { .current_dir(&*PROJECT_ROOT) .args([ "build", + "-p", + "aspeed-ddk-tests-hw", "--release", "--target", "thumbv7em-none-eabihf", + "--no-default-features", "--features", &feature, ]) @@ -166,19 +167,24 @@ fn run_hardware_test_suite(uart: &str, suite: &str) -> Result<()> { } // Generate UART boot image - // let binary_path = PROJECT_ROOT.join("target/thumbv7em-none-eabihf/release/aspeed-ddk"); - let elf_path = PROJECT_ROOT.join("target/thumbv7em-none-eabihf/release/aspeed-ddk"); + let elf_path = PROJECT_ROOT.join("target/thumbv7em-none-eabihf/release/aspeed-ddk-tests-hw"); assert!(elf_path.exists(), "ELF file not found: {:?}", elf_path); println!("ELF binary path: {:?}", elf_path); let bin_path = PROJECT_ROOT.join(format!("target/{}-test-{}.bin", suite, "release")); println!("Binary path: {:?}", bin_path); let _status = Command::new("cargo") + .current_dir(&*PROJECT_ROOT) .args([ "objcopy", + "-p", + "aspeed-ddk-tests-hw", "--target", "thumbv7em-none-eabihf", "--release", + "--no-default-features", + "--features", + &feature, "--", "-O", "binary",