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

Fix for extra power cycle between firmware flashes on Linux platforms #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
41 changes: 30 additions & 11 deletions ectf_tools/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import logging
import socket
import select
from sys import platform
from enum import Enum
from pathlib import Path
from rich.progress import Progress
Expand Down Expand Up @@ -87,18 +88,28 @@ def get_serial_port():

def verify_resp(ser: Serial, expected: BootloaderResponseCode):
resp = ser.read(1)
while resp == b"":
resp = ser.read(1)
if platform == "linux" or platform == "linux2":
while (resp == b"\x00") or (resp == b""):
resp = ser.read(1)
else:
while resp == b"":
resp = ser.read(1)

assert BootloaderResponseCode(resp) == expected


def verify_sec_resp(ser: Serial, print_out: bool = True, logger: logging.Logger = None):
resp = ser.read(1)
while (resp == b"") or (
not ord(resp) in (secure_bl_success_codes + secure_bl_error_codes)
):
resp = ser.read(1)
if platform == "linux" or platform == "linux2":
while (resp == b"\x00") or (resp == b"") or (
not ord(resp) in (secure_bl_success_codes + secure_bl_error_codes)
):
resp = ser.read(1)
else:
while (resp == b"") or (
not ord(resp) in (secure_bl_success_codes + secure_bl_error_codes)
):
resp = ser.read(1)

logger = logger or get_logger()

Expand All @@ -115,11 +126,19 @@ def verify_mode_change_resp(
ser: Serial, dev_num: int, print_out: bool = True, logger: logging.Logger = None
):
resp = ser.read(1)
while (resp == b"") or (
not ord(resp)
in (secure_bl_mode_change_success_codes + secure_bl_mode_change_error_codes)
):
resp = ser.read(1)
if platform == "linux" or platform == "linux2":
while (resp == b"\x00") or (resp == b"") or (
not ord(resp)
in (secure_bl_mode_change_success_codes + secure_bl_mode_change_error_codes)
):
resp = ser.read(1)
else:
while (resp == b"") or (
not ord(resp)
in (secure_bl_mode_change_success_codes + secure_bl_mode_change_error_codes)
):
resp = ser.read(1)


logger = logger or get_logger()

Expand Down