Skip to content

Commit

Permalink
[chip] Add interface option
Browse files Browse the repository at this point in the history
The voyager board uses the "ftdi" interface while other boards use
the "hyper310" interface. This commit makes the interface
parameterisable. By setting
```
target:
  interface: "ftdi"
``
in the corresponding FI/SCA config, ot-sca can be used to analyze
the voyager board.

Signed-off-by: Pascal Nasahl <[email protected]>
  • Loading branch information
nasahlpa committed Jan 14, 2025
1 parent a5674d1 commit 643bbe7
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion capture/capture_aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion capture/capture_hmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion capture/capture_ibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion capture/capture_kmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion capture/capture_otbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion capture/capture_sha3.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion fault_injection/fi_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion fault_injection/fi_ibex.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion fault_injection/fi_otbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
3 changes: 2 additions & 1 deletion fault_injection/fi_rng.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def setup(cfg: dict, project: Path):
baudrate = cfg["target"].get("baudrate"),
port = cfg["target"].get("port"),
output_len = cfg["target"].get("output_len_bytes"),
usb_serial = cfg["target"].get("usb_serial")
usb_serial = cfg["target"].get("usb_serial"),
interface = cfg["target"].get("interface")
)
target = Target(target_cfg)

Expand Down
12 changes: 7 additions & 5 deletions target/chip.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ class Chip():
"""
def __init__(self, firmware, opentitantool_path,
boot_delay: Optional[int] = 1,
usb_serial: Optional[str] = None):
usb_serial: Optional[str] = None,
interface: Optional[str] = "hyper310"):
self.firmware = firmware
self.opentitantool = opentitantool_path
self.boot_delay = boot_delay
self.usb_serial = usb_serial
self.interface = interface
self._initialize_chip()

def _initialize_chip(self):
Expand All @@ -27,14 +29,14 @@ def _initialize_chip(self):
flash_process = Popen([self.opentitantool,
"--usb-serial=" + str(self.usb_serial),
"--rcfile=",
"--interface=hyper310",
"--interface=" + str(self.interface),
"--exec", "transport init",
"--exec", "bootstrap " + self.firmware, "no-op"],
stdout=PIPE, stderr=PIPE)
else:
flash_process = Popen([self.opentitantool,
"--rcfile=",
"--interface=hyper310",
"--interface=" + str(self.interface),
"--exec", "transport init",
"--exec", "bootstrap " + self.firmware, "no-op"],
stdout=PIPE, stderr=PIPE)
Expand All @@ -52,14 +54,14 @@ def reset_target(self, boot_delay: Optional[int] = 1):
if self.usb_serial is not None and self.usb_serial != "":
reset_process = Popen([self.opentitantool,
"--usb-serial=" + str(self.usb_serial),
"--interface=hyper310",
"--interface=" + str(self.interface),
"--exec", "transport init",
"--exec", "gpio write RESET false",
"--exec", "gpio write RESET true", "no-op"],
stdout=PIPE, stderr=PIPE)
else:
reset_process = Popen([self.opentitantool,
"--interface=hyper310",
"--interface=" + str(self.interface),
"--exec", "transport init",
"--exec", "gpio write RESET false",
"--exec", "gpio write RESET true", "no-op"],
Expand Down
4 changes: 3 additions & 1 deletion target/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class TargetConfig:
port: Optional[str] = None
read_timeout: Optional[int] = 1
usb_serial: Optional[str] = None
interface: Optional[str] = "hyper310"


class Target:
Expand Down Expand Up @@ -60,7 +61,8 @@ def _init_target(self):
elif self.target_cfg.target_type == "chip":
target = Chip(firmware = self.target_cfg.fw_bin,
opentitantool_path = "../objs/opentitantool",
usb_serial=self.target_cfg.usb_serial)
usb_serial = self.target_cfg.usb_serial,
interface = self.target_cfg.interface)
else:
raise RuntimeError("Error: Target not supported!")
return target
Expand Down

0 comments on commit 643bbe7

Please sign in to comment.