Skip to content

Commit

Permalink
inefficient on cpu but whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
grg-haas committed Jun 17, 2024
1 parent f78f0b1 commit 178fcd5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
6 changes: 4 additions & 2 deletions scripts/ci/plat/cva6/flash-firmware.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ set -x

## ROM phase
TTYDEV=$(find_tty 0)
start_record_tty "$TTYDEV" 115200 "$LOGFILE" cva6-tty

# Wait for bootrom break
power_on
wait_tty "$TTYDEV" 115200 "Hit any key to enter update mode"
./scripts/ci/utils/wait_for.py "$LOGFILE" "Hit any key to enter update mode"
echo 'a' > "$TTYDEV"
sleep 1

Expand All @@ -38,7 +39,7 @@ dd if="$FIRMWARE_FILENAME" of="$TTYDEV" bs=1 status=progress
## Uboot phase (TFTP)

# Wait for uboot prompt and send firmware image
wait_tty "$TTYDEV" 115200 "Hit any key to stop autoboot"
./scripts/ci/utils/wait_for.py "$LOGFILE" "Hit any key to stop autoboot"
echo 'a' > "$TTYDEV"

rm "$TFTP_DIR/fw_payload.bin"
Expand All @@ -47,5 +48,6 @@ echo "setenv serverip $HOST_IP" > "$TTYDEV"
echo "setenv ipaddr $BOARD_IP" > "$TTYDEV"
echo "tftp fw_payload.bin" > "$TTYDEV"

stop_record_tty cva6-tty
power_off

9 changes: 0 additions & 9 deletions scripts/ci/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ function configure_tty {
}
export -f configure_tty

function wait_tty {
if [[ "$#" -ne 3 ]]; then
echo "usage: wait_tty [tty_file] [baud] [pattern]"
exit 1
fi

configure_tty "$1" "$2" ; cat "$1" | ./scripts/ci/utils/wait_for.py "$3"
}

function start_record_tty {
if [[ "$#" -ne 4 ]]; then
echo "usage: start_record_tty [tty_file] [baud] [output_filename] [id]"
Expand Down
24 changes: 12 additions & 12 deletions scripts/ci/utils/wait_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import sys
import os

if len(sys.argv) != 2:
print('usage: wait_for.py [pattern]')
if len(sys.argv) != 3:
print('usage: wait_for.py [file] [pattern]')
exit(1)

pattern = sys.argv[1].encode('utf-8')
file = open(sys.argv[1], 'rb', buffering=0)
file.seek(0, os.SEEK_END)
pattern = sys.argv[2].encode('utf-8')

index = 0
while True:
if index == len(pattern):
exit(0)

n = os.read(sys.stdin.fileno(), 1)
if n is None:
exit(1)

print(n.decode('utf-8'), end='')
if n[0] == pattern[index]:
index += 1
else:
index = 0
n = os.read(file.fileno(), 1)
if n is not None and len(n) > 0:
print(n.decode('utf-8'), end='')
if n[0] == pattern[index]:
index += 1
else:
index = 0

0 comments on commit 178fcd5

Please sign in to comment.