Skip to content

Commit a196d00

Browse files
committed
[fpga] Enforce CW310 SAM3X Firmware
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>
1 parent 58657c0 commit a196d00

12 files changed

+47
-0
lines changed

capture/capture_aes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def setup(cfg: dict, project: Path):
106106
)
107107
target = Target(target_cfg)
108108

109+
# Check target firmware.
110+
target.check_fw_version("1.5")
111+
109112
# Init scope.
110113
scope_type = cfg["capture"]["scope_select"]
111114

capture/capture_hmac.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ def setup(cfg: dict, project: Path):
106106
)
107107
target = Target(target_cfg)
108108

109+
# Check target firmware.
110+
target.check_fw_version("1.5")
111+
109112
# Init scope.
110113
scope_type = cfg["capture"]["scope_select"]
111114

capture/capture_ibex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def setup(cfg: dict, project: Path):
9494
)
9595
target = Target(target_cfg)
9696

97+
# Check target firmware.
98+
target.check_fw_version("1.5")
99+
97100
# Init scope.
98101
scope_type = cfg["capture"]["scope_select"]
99102

capture/capture_kmac.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def setup(cfg: dict, project: Path):
110110
)
111111
target = Target(target_cfg)
112112

113+
# Check target firmware.
114+
target.check_fw_version("1.5")
115+
113116
# Init scope.
114117
scope_type = cfg["capture"]["scope_select"]
115118

capture/capture_otbn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ def setup(cfg: dict, project: Path):
120120
)
121121
target = Target(target_cfg)
122122

123+
# Check target firmware.
124+
target.check_fw_version("1.5")
125+
123126
# Init scope.
124127
scope_type = cfg["capture"]["scope_select"]
125128

capture/capture_sha3.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ def setup(cfg: dict, project: Path):
9595
)
9696
target = Target(target_cfg)
9797

98+
# Check target firmware.
99+
target.check_fw_version("1.5")
100+
98101
# Init scope.
99102
scope_type = cfg["capture"]["scope_select"]
100103

fault_injection/fi_crypto.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
5252
)
5353
target = Target(target_cfg)
5454

55+
# Check target firmware.
56+
target.check_fw_version("1.5")
57+
5558
# Init FI gear.
5659
fi_gear = FIGear(cfg)
5760

fault_injection/fi_ibex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
5252
)
5353
target = Target(target_cfg)
5454

55+
# Check target firmware.
56+
target.check_fw_version("1.5")
57+
5558
# Init FI gear.
5659
fi_gear = FIGear(cfg)
5760

fault_injection/fi_otbn.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
5252
)
5353
target = Target(target_cfg)
5454

55+
# Check target firmware.
56+
target.check_fw_version("1.5")
57+
5558
# Init FI gear.
5659
fi_gear = FIGear(cfg)
5760

fault_injection/fi_rng.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def setup(cfg: dict, project: Path):
5252
)
5353
target = Target(target_cfg)
5454

55+
# Check target firmware.
56+
target.check_fw_version("1.5")
57+
5558
# Init FI gear.
5659
fi_gear = FIGear(cfg)
5760

target/cw_fpga.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,14 @@ def reset_target(self):
224224
io.pin_set_state("USB_A14", 1)
225225
# Add a small delay to allow OpenTitan to boot up.
226226
time.sleep(0.1)
227+
228+
def check_fw_version(self, min_version: str):
229+
"""Checks whether the SAM3X CW310 FW matches the expected version. """
230+
major_min, minor_min = min_version.split(".")
231+
fw = self.target.target.latest_fw()
232+
if fw["major"] < int(major_min) or fw["minor"] < int(minor_min):
233+
print(f'Error: CW310 SAM3X FW is {str(fw["major"])}.{str(fw["minor"])}'
234+
f'should be {min_version}. Check the CW310 manual for updating the firmware.')
235+
return False
236+
else:
237+
return True

target/targets.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ def is_done(self):
126126
return self.target.target.is_done()
127127
else:
128128
return True
129+
130+
def check_fw_version(self, min_version: str):
131+
"""Check if target CW is >= min:version. Only for CW310 FPGA."""
132+
if self.target_cfg.target_type == "cw310":
133+
if not self.target.check_fw_version(min_version):
134+
raise RuntimeError("Error: Please upgrade target firmware!")

0 commit comments

Comments
 (0)