Skip to content

Commit

Permalink
Changing CI ROM version from rust feature to environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
nquarton committed Nov 22, 2024
1 parent f6a7e97 commit b278314
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 138 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/fpga.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ on:
hw-version:
default: "latest"
type: string
rom-version:
default: "latest"
type: string
workflow_call:
description: 'Set true for workflow_call'
default: true
Expand Down Expand Up @@ -161,6 +164,9 @@ jobs:
run: |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="aarch64-linux-gnu-gcc"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=--sysroot=$FARGO_SYSROOT"
if [ "${{ inputs.rom-version }}" != "latest" ]; then
export CPTRA_CI_ROM_VERSION="${{ inputs.rom-version }}"
fi
if [ "${{ inputs.workflow_call }}" ]; then
FEATURES=fpga_realtime,${{ inputs.extra-features }}
Expand Down Expand Up @@ -428,7 +434,12 @@ jobs:
echo "Unexpected inputs.rom-logging: ${{ inputs.rom-logging }}"
exit 1
fi
echo CPTRA_ROM_TYPE=${CPTRA_ROM_TYPE}
if [[ "${{ inputs.workflow_call }}" && "${{ inputs.rom-version }}" != "latest" ]]; then
VARS+=" CPTRA_CI_ROM_VERSION="${{ inputs.rom-version }}""
fi
echo VARS=${VARS}
COMMON_ARGS=(
--cargo-metadata="${TEST_BIN}/target/nextest/cargo-metadata.json"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/fw-test-emu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ on:
rom-logging:
default: true
type: boolean
rom-version:
default: "latest"
type: string

jobs:
build_and_test:
Expand Down Expand Up @@ -57,6 +60,9 @@ jobs:
- name: Run tests
run: |
export CALIPTRA_PREBUILT_FW_DIR=/tmp/caliptra-test-firmware
if [ "${{ inputs.rom-version }}" != "latest" ]; then
export CPTRA_CI_ROM_VERSION="${{ inputs.rom-version }}"
fi
if [ "${{ inputs.rom-logging }}" == "true" ] || [ -z "${{ inputs.rom-logging }}" ]; then
export CPTRA_ROM_TYPE=ROM_WITH_UART
Expand Down
50 changes: 33 additions & 17 deletions .github/workflows/nightly-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-hw-1.0-etrng-log
extra-features: slow_tests,ci-rom-1.0
extra-features: slow_tests
hw-version: "1.0"
rom-version: "1.0"
rom-logging: true
fpga-itrng: false

Expand All @@ -76,8 +77,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-hw-1.0-etrng-nolog
extra-features: slow_tests,ci-rom-1.0
extra-features: slow_tests
hw-version: "1.0"
rom-version: "1.0"
rom-logging: false
fpga-itrng: false

Expand All @@ -88,8 +90,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-hw-1.0-itrng-log
extra-features: slow_tests,itrng,ci-rom-1.0
extra-features: slow_tests,itrng
hw-version: "1.0"
rom-version: "1.0"
rom-logging: true
fpga-itrng: true

Expand All @@ -100,8 +103,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-hw-1.0-itrng-nolog
extra-features: slow_tests,itrng,ci-rom-1.0
extra-features: slow_tests,itrng
hw-version: "1.0"
rom-version: "1.0"
rom-logging: false
fpga-itrng: true

Expand All @@ -112,8 +116,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-rom-1.1-etrng-log
extra-features: slow_tests,ci-rom-1.1
extra-features: slow_tests
hw-version: "latest"
rom-version: "1.1"
rom-logging: true
fpga-itrng: false

Expand All @@ -124,8 +129,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-rom-1.1-etrng-nolog
extra-features: slow_tests,ci-rom-1.1
extra-features: slow_tests
hw-version: "latest"
rom-version: "1.1"
rom-logging: false
fpga-itrng: false

Expand All @@ -136,8 +142,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-rom-1.1-itrng-log
extra-features: slow_tests,itrng,ci-rom-1.1
extra-features: slow_tests,itrng
hw-version: "latest"
rom-version: "1.1"
rom-logging: true
fpga-itrng: true

Expand All @@ -148,8 +155,9 @@ jobs:
uses: ./.github/workflows/fpga.yml
with:
artifact-suffix: -fpga-realtime-rom-1.1-itrng-nolog
extra-features: slow_tests,itrng,ci-rom-1.1
extra-features: slow_tests,itrng
hw-version: "latest"
rom-version: "1.1"
rom-logging: false
fpga-itrng: true

Expand Down Expand Up @@ -197,7 +205,7 @@ jobs:
with:
artifact-suffix: -fpga-realtime-latest-itrng-nolog
extra-features: slow_tests,itrng
hw-version: latest
hw-version: "latest"
rom-logging: false
fpga-itrng: true

Expand Down Expand Up @@ -248,8 +256,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.1-etrng-log
extra-features: ci-rom-1.1,slow_tests
extra-features: slow_tests
rom-logging: true
rom-version: "1.1"

sw-emulator-rom-1_1-full-suite-etrng-nolog:
name: sw-emulator Suite (etrng, nolog)
Expand All @@ -258,8 +267,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.1-etrng-nolog
extra-features: ci-rom-1.1,slow_tests
extra-features: slow_tests
rom-logging: false
rom-version: "1.1"

sw-emulator-rom-1_1-full-suite-itrng-log:
name: sw-emulator Suite (itrng, log)
Expand All @@ -268,8 +278,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.1-itrng-log
extra-features: ci-rom-1.1,slow_tests,itrng
extra-features: slow_tests,itrng
rom-logging: true
rom-version: "1.1"

sw-emulator-rom-1_1-full-suite-itrng-nolog:
name: sw-emulator Suite (itrng, nolog)
Expand All @@ -278,8 +289,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.1-itrng-nolog
extra-features: ci-rom-1.1,slow_tests,itrng
extra-features: slow_tests,itrng
rom-logging: false
rom-version: "1.1"

sw-emulator-hw-1_0-full-suite-etrng-log:
name: sw-emulator Suite (etrng, log)
Expand All @@ -288,8 +300,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.0-etrng-log
extra-features: hw-1.0,ci-rom-1.0,slow_tests
extra-features: hw-1.0,slow_tests
rom-logging: true
rom-version: "1.0"

sw-emulator-hw-1_0-full-suite-etrng-nolog:
name: sw-emulator Suite (etrng, nolog)
Expand All @@ -298,8 +311,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.0-etrng-nolog
extra-features: hw-1.0,ci-rom-1.0,slow_tests
extra-features: hw-1.0,slow_tests
rom-logging: false
rom-version: "1.0"

sw-emulator-hw-1_0-full-suite-itrng-log:
name: sw-emulator Suite (itrng, log)
Expand All @@ -308,8 +322,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.0-itrng-log
extra-features: hw-1.0,ci-rom-1.0,slow_tests,itrng
extra-features: hw-1.0,slow_tests,itrng
rom-logging: true
rom-version: "1.0"

sw-emulator-hw-1_0-full-suite-itrng-nolog:
name: sw-emulator Suite (itrng, nolog)
Expand All @@ -318,8 +333,9 @@ jobs:
uses: ./.github/workflows/fw-test-emu.yml
with:
artifact-suffix: -sw-emulator-hw-1.0-itrng-nolog
extra-features: hw-1.0,ci-rom-1.0,slow_tests,itrng
extra-features: hw-1.0,slow_tests,itrng
rom-logging: false
rom-version: "1.0"

create-release:
name: Create New Release
Expand Down
2 changes: 0 additions & 2 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ zerocopy.workspace = true
default = ["openssl"]
slow_tests = []
"hw-1.0" = []
"ci-rom-1.0" = []
"ci-rom-1.1" = []
openssl = ["caliptra-image-crypto/openssl"]
rustcrypto = ["caliptra-image-crypto/rustcrypto"]

Expand Down
71 changes: 37 additions & 34 deletions builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,43 +366,46 @@ pub fn build_firmware_elf(id: &FwId<'static>) -> io::Result<Arc<Vec<u8>>> {
/// a particular hardware version. DO NOT USE this for ROM-only tests.
pub fn rom_for_fw_integration_tests() -> io::Result<Cow<'static, [u8]>> {
let rom_from_env = firmware::rom_from_env();
if cfg!(all(feature = "hw-1.0", not(feature = "ci-rom-1.0"))) {
panic!("ci-rom-1.0 is required for hw-1.0");
if cfg!(feature = "hw-1.0") && std::env::var("CPTRA_CI_ROM_VERSION").as_deref() != Ok("1.0") {
panic!("CPTRA_CI_ROM_VERSION of \'1.0\' is expected for hw-1.0");
}
if cfg!(feature = "ci-rom-1.0") {
if rom_from_env == &firmware::ROM {
Ok(
include_bytes!("../../rom/ci_frozen_rom/1.0/caliptra-rom-1.0.3-e8e23d9.bin")
.as_slice()
.into(),
)
} else if rom_from_env == &firmware::ROM_WITH_UART {
Ok(include_bytes!(
"../../rom/ci_frozen_rom/1.0/caliptra-rom-with-log-1.0.3-e8e23d9.bin"
)
.as_slice()
.into())
} else {
Err(other_err(format!("Unexpected ROM fwid {rom_from_env:?}")))
match std::env::var("CPTRA_CI_ROM_VERSION").as_deref() {
Ok("1.0") => {
if rom_from_env == &firmware::ROM {
Ok(
include_bytes!("../../rom/ci_frozen_rom/1.0/caliptra-rom-1.0.3-e8e23d9.bin")
.as_slice()
.into(),
)
} else if rom_from_env == &firmware::ROM_WITH_UART {
Ok(include_bytes!(
"../../rom/ci_frozen_rom/1.0/caliptra-rom-with-log-1.0.3-e8e23d9.bin"
)
.as_slice()
.into())
} else {
Err(other_err(format!("Unexpected ROM fwid {rom_from_env:?}")))
}
}
} else if cfg!(feature = "ci-rom-1.1") {
if rom_from_env == &firmware::ROM {
Ok(
include_bytes!("../../rom/ci_frozen_rom/1.1/caliptra-rom-1.1.0-51ff0a8.bin")
.as_slice()
.into(),
)
} else if rom_from_env == &firmware::ROM_WITH_UART {
Ok(include_bytes!(
"../../rom/ci_frozen_rom/1.1/caliptra-rom-with-log-1.1.0-51ff0a8.bin"
)
.as_slice()
.into())
} else {
Err(other_err(format!("Unexpected ROM fwid {rom_from_env:?}")))
Ok("1.1") => {
if rom_from_env == &firmware::ROM {
Ok(
include_bytes!("../../rom/ci_frozen_rom/1.1/caliptra-rom-1.1.0-51ff0a8.bin")
.as_slice()
.into(),
)
} else if rom_from_env == &firmware::ROM_WITH_UART {
Ok(include_bytes!(
"../../rom/ci_frozen_rom/1.1/caliptra-rom-with-log-1.1.0-51ff0a8.bin"
)
.as_slice()
.into())
} else {
Err(other_err(format!("Unexpected ROM fwid {rom_from_env:?}")))
}
}
} else {
Ok(build_firmware_rom(rom_from_env)?.into())
Ok(version) => panic!("Unknown CI ROM version \'{}\'", version),
Err(_) => Ok(build_firmware_rom(rom_from_env)?.into()),
}
}

Expand Down
2 changes: 0 additions & 2 deletions fmc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,3 @@ itrng = ["caliptra-hw-model/itrng"]
verilator = ["caliptra-hw-model/verilator"]
fake-fmc = []
"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-cpu/hw-1.0", "caliptra-drivers/hw-1.0", "caliptra-registers/hw-1.0"]
"ci-rom-1.0" = ["caliptra-builder/ci-rom-1.0"]
"ci-rom-1.1" = ["caliptra-builder/ci-rom-1.1"]
9 changes: 4 additions & 5 deletions fmc/tests/fmc_integration_tests/test_rtalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,10 @@ fn test_fht_info() {
let data = hw.mailbox_execute(TEST_CMD_READ_FHT, &[]).unwrap().unwrap();
let fht = FirmwareHandoffTable::read_from_prefix(data.as_bytes()).unwrap();
assert_eq!(fht.ldevid_tbs_size, 552);
if cfg!(any(feature = "ci-rom-1.0", feature = "ci-rom-1.1")) {
assert_eq!(fht.fmcalias_tbs_size, 786);
} else {
assert_eq!(fht.fmcalias_tbs_size, 753);
}
match std::env::var("CPTRA_CI_ROM_VERSION").as_deref() {
Ok("1.0") | Ok("1.1") => assert_eq!(fht.fmcalias_tbs_size, 786),
_ => assert_eq!(fht.fmcalias_tbs_size, 753),
};
assert_eq!(fht.ldevid_tbs_addr, 0x50003C00);
assert_eq!(fht.fmcalias_tbs_addr, 0x50004000);
assert_eq!(fht.pcr_log_addr, 0x50004800);
Expand Down
4 changes: 1 addition & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ fips_self_test=[]
no-cfi = ["caliptra-image-verify/no-cfi", "caliptra-drivers/no-cfi"]
fpga_realtime = ["caliptra-drivers/fpga_realtime"]
"hw-1.0" = ["caliptra-builder/hw-1.0", "caliptra-drivers/hw-1.0", "caliptra-registers/hw-1.0", "caliptra-kat/hw-1.0","caliptra-cpu/hw-1.0"]
fips-test-hooks = ["caliptra-drivers/fips-test-hooks"]
"ci-rom-1.0" = ["caliptra-builder/ci-rom-1.0"]
"ci-rom-1.1" = ["caliptra-builder/ci-rom-1.1"]
fips-test-hooks = ["caliptra-drivers/fips-test-hooks"]
Loading

0 comments on commit b278314

Please sign in to comment.