Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fpga] Enforce CW310 SAM3X Firmware #383

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions capture/capture_aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions capture/capture_hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions capture/capture_ibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions capture/capture_kmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions capture/capture_otbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions capture/capture_sha3.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init scope.
scope_type = cfg["capture"]["scope_select"]

Expand Down
3 changes: 3 additions & 0 deletions fault_injection/fi_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init FI gear.
fi_gear = FIGear(cfg)

Expand Down
3 changes: 3 additions & 0 deletions fault_injection/fi_ibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init FI gear.
fi_gear = FIGear(cfg)

Expand Down
3 changes: 3 additions & 0 deletions fault_injection/fi_otbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init FI gear.
fi_gear = FIGear(cfg)

Expand Down
3 changes: 3 additions & 0 deletions fault_injection/fi_rng.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
)
target = Target(target_cfg)

# Check target firmware.
target.check_fw_version("1.5")

# Init FI gear.
fi_gear = FIGear(cfg)

Expand Down
12 changes: 12 additions & 0 deletions target/cw_fpga.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,15 @@ def reset_target(self):
io.pin_set_state("USB_A14", 1)
# Add a small delay to allow OpenTitan to boot up.
time.sleep(0.1)

def check_fw_version(self, min_version: str):
"""Checks whether the SAM3X CW310 FW matches the expected version. """
major_min, minor_min = min_version.split(".")
target = cw.target(None, cw.targets.CW310)
fw = target.latest_fw
if fw["major"] < int(major_min) or fw["minor"] < int(minor_min):
print(f'Error: CW310 SAM3X FW is {str(fw["major"])}.{str(fw["minor"])} '
f'should be {min_version}. Check the CW310 manual for updating the firmware.')
return False
else:
return True
6 changes: 6 additions & 0 deletions target/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,9 @@ def is_done(self):
return self.target.target.is_done()
else:
return True

def check_fw_version(self, min_version: str):
"""Check if target CW is >= min:version. Only for CW310 FPGA."""
if self.target_cfg.target_type == "cw310":
if not self.target.check_fw_version(min_version):
raise RuntimeError("Error: Please upgrade target firmware!")
Loading