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

sgpio debug ci test #1398

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pipeline {
retry(3) {
sh 'python3 ci-scripts/test-transfer.py rx'
}
sh './ci-scripts/configure-hubs.sh --off'
sh 'python3 ci-scripts/test-sgpio-debug.py'
sh './ci-scripts/configure-hubs.sh --reset'
}
}
Expand Down
3 changes: 2 additions & 1 deletion ci-scripts/test-firmware-program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
usbhub --disable-i2c --hub D9D1 power state --port 2 --reset
sleep 1s
dfu-util --device 1fc9:000c --alt 0 --download firmware/hackrf_usb/build/hackrf_usb.dfu
sleep 1s
EXIT_CODE="$?"
if [ "$EXIT_CODE" == "0" ]
then
Expand All @@ -16,6 +17,6 @@ then
echo "dfu-util installation failed! Exiting.."
exit $EXIT_CODE
else
echo "god have mercy on your soul"
echo "Unhandled exception"
exit $EXIT_CODE
fi
59 changes: 59 additions & 0 deletions ci-scripts/test-sgpio-debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/python3
import os
import sys
import subprocess
from pathlib import Path

FILENAME = "/tmp/rx_100kB_" + str(os.getpid())


def program_device():
# build new firmware with SGPIO_DEBUG mode enabled
print("Programming device..")
fw_dir = os.getcwd() + "/firmware/hackrf_usb/build"
del_dir = subprocess.run(["rm", "-rf", "firmware/hackrf_usb/build"])
mk_dir = subprocess.run(["mkdir", "firmware/hackrf_usb/build"])
cmake = subprocess.run(["cmake", "-D", "SGPIO_DEBUG=1", ".."],
cwd=fw_dir, stdout=subprocess.DEVNULL)
make = subprocess.run(["make"],
cwd=fw_dir, stdout=subprocess.DEVNULL)
program = subprocess.run(["./ci-scripts/test-firmware-program.sh"],
stdout=subprocess.DEVNULL)


def capture():
print("Capturing data..")
rx_100kB = subprocess.run(["host/build/hackrf-tools/src/hackrf_transfer",
"-r", FILENAME, "-d", "RunningFromRAM",
"-n", "50000", "-s", "20000000"],
capture_output=True, encoding="UTF-8")
print(rx_100kB.stdout)
print(rx_100kB.stderr)
print("Wrote data to file: " + FILENAME)


def check():
rx_data = Path(FILENAME).read_bytes()
# file should be 100k bytes when using 50k samples
if len(rx_data) != 100000:
print("SGPIO debug test failed.")
sys.exit(1)

# check that each byte = prev_byte + 1 except at wraparound bounds
for i in range(1, len(rx_data)):
if rx_data[i-1] != rx_data[i] - 1:
if not (rx_data[i] == 0 and rx_data[i-1] == 255):
print("SGPIO debug test failed.")
sys.exit(1)
print("SGPIO debug test passed.")


def main():
program_device()
capture()
check()


if __name__ == "__main__":
main()

Loading