Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fpga] Enforce CW310 SAM3X Firmware
Browse files Browse the repository at this point in the history
As CW310 SAM3X firmware version below "1.5" have an UART flow control
bug, enforce that the version is at leaset "1.5". This ensures that
the communication over uJSON works flawless.

Signed-off-by: Pascal Nasahl <nasahlpa@lowrisc.org>
nasahlpa committed Dec 5, 2024
1 parent 58657c0 commit a196d00
Showing 12 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions capture/capture_aes.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions capture/capture_hmac.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions capture/capture_ibex.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions capture/capture_kmac.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions capture/capture_otbn.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions capture/capture_sha3.py
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions fault_injection/fi_crypto.py
Original file line number Diff line number Diff line change
@@ -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)

3 changes: 3 additions & 0 deletions fault_injection/fi_ibex.py
Original file line number Diff line number Diff line change
@@ -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)

3 changes: 3 additions & 0 deletions fault_injection/fi_otbn.py
Original file line number Diff line number Diff line change
@@ -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)

3 changes: 3 additions & 0 deletions fault_injection/fi_rng.py
Original file line number Diff line number Diff line change
@@ -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)

11 changes: 11 additions & 0 deletions target/cw_fpga.py
Original file line number Diff line number Diff line change
@@ -224,3 +224,14 @@ 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(".")
fw = self.target.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
@@ -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!")

0 comments on commit a196d00

Please sign in to comment.