From ab69bef242631752dee4ba8760b970a227218143 Mon Sep 17 00:00:00 2001 From: grvvy Date: Wed, 10 Jul 2024 15:30:26 -0600 Subject: [PATCH 1/3] ci: usb hub ppps handling overhaul --- Dockerfile | 22 +++++++++++++++++++--- Jenkinsfile | 8 ++++---- ci-scripts/configure-hubs.sh | 4 ---- ci-scripts/test-firmware-program.sh | 2 +- ci-scripts/test-host.sh | 2 +- ci-scripts/test-transfer.py | 8 ++++---- 6 files changed, 29 insertions(+), 17 deletions(-) delete mode 100755 ci-scripts/configure-hubs.sh diff --git a/Dockerfile b/Dockerfile index 40948e671..574994aad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,18 @@ -# Sandbox test environment for HackRF +# Environment for HackRF HIL testing with Jenkins CI FROM ubuntu:22.04 USER root -# Override interactive installations and install prerequisites +# Copy usb hub script from Jenkins' container +COPY --from=gsg-jenkins /startup/hubs.py /startup/hubs.py +COPY --from=gsg-jenkins /startup/.hubs /startup/.hubs +RUN ln -s /startup/hubs.py /usr/local/bin/hubs + +# Override interactive installations and install software dependencies ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y \ build-essential \ cmake \ + curl \ dfu-util \ gcc-arm-none-eabi \ git \ @@ -16,8 +22,18 @@ RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ python3-yaml \ + usbutils \ && rm -rf /var/lib/apt/lists/* -RUN pip3 install git+https://github.com/CapableRobot/CapableRobot_USBHub_Driver --upgrade + +# Install USB hub PPPS dependencies +RUN pip3 install python-dotenv git+https://github.com/CapableRobot/CapableRobot_USBHub_Driver --upgrade +RUN curl -L https://github.com/mvp/uhubctl/archive/refs/tags/v2.5.0.tar.gz > uhubctl-2.5.0.tar.gz \ + && mkdir uhubctl-2.5.0 \ + && tar -xvzf uhubctl-2.5.0.tar.gz -C uhubctl-2.5.0 --strip-components 1 \ + && rm uhubctl-2.5.0.tar.gz \ + && cd uhubctl-2.5.0 \ + && make \ + && make install # Inform Docker that the container is listening on port 8080 at runtime EXPOSE 8080 diff --git a/Jenkinsfile b/Jenkinsfile index 865deb2a7..1fb7e6921 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ pipeline { agent { dockerfile { - args '--group-add=46 --device-cgroup-rule="c 189:* rmw" -v /dev/bus/usb:/dev/bus/usb' + args '--group-add=20 --group-add=46 --device-cgroup-rule="c 189:* rmw" --device-cgroup-rule="c 166:* rmw" -v /dev/bus/usb:/dev/bus/usb -e TESTER=0000000000000000325866e629a25623 -e EUT=RunningFromRAM' } } stages { @@ -17,7 +17,7 @@ pipeline { } stage('Test') { steps { - sh './ci-scripts/configure-hubs.sh --off' + sh 'hubs all off' retry(3) { sh './ci-scripts/test-host.sh' } @@ -32,14 +32,14 @@ pipeline { retry(3) { sh 'python3 ci-scripts/test-transfer.py rx' } - sh './ci-scripts/configure-hubs.sh --off' + sh 'hubs all off' sh 'python3 ci-scripts/test-sgpio-debug.py' - sh './ci-scripts/configure-hubs.sh --reset' } } } post { always { + sh 'hubs all reset' cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: true, diff --git a/ci-scripts/configure-hubs.sh b/ci-scripts/configure-hubs.sh deleted file mode 100755 index 6273a37eb..000000000 --- a/ci-scripts/configure-hubs.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -e -usbhub --disable-i2c --hub D9D1 power state --port 1,2,3,4 $1 -usbhub --disable-i2c --hub 624C power state --port 1,2,3,4 $1 diff --git a/ci-scripts/test-firmware-program.sh b/ci-scripts/test-firmware-program.sh index 8184bdc42..a9e786a74 100755 --- a/ci-scripts/test-firmware-program.sh +++ b/ci-scripts/test-firmware-program.sh @@ -1,5 +1,5 @@ #!/bin/bash -usbhub --disable-i2c --hub D9D1 power state --port 2 --reset +hubs hackrf_dfu reset sleep 1s dfu-util --device 1fc9:000c --alt 0 --download firmware/hackrf_usb/build/hackrf_usb.dfu sleep 1s diff --git a/ci-scripts/test-host.sh b/ci-scripts/test-host.sh index ecaa3fb94..903fefd0b 100755 --- a/ci-scripts/test-host.sh +++ b/ci-scripts/test-host.sh @@ -1,5 +1,5 @@ #!/bin/bash -usbhub --disable-i2c --hub D9D1 power state --port 2 --reset +hubs hackrf_dfu reset sleep 1s host/build/hackrf-tools/src/hackrf_info EXIT_CODE="$?" diff --git a/ci-scripts/test-transfer.py b/ci-scripts/test-transfer.py index 0ca0f9396..815c2b816 100644 --- a/ci-scripts/test-transfer.py +++ b/ci-scripts/test-transfer.py @@ -2,9 +2,10 @@ import subprocess import time import sys +from os import environ -EUT = "RunningFromRAM" -TESTER = "0000000000000000325866e629a25623" +EUT = environ.get('EUT') +TESTER = environ.get('TESTER') PASS, FAIL = range(2) @@ -87,8 +88,7 @@ def check_signal(freq, bins): def main(): write_bytes() - tester_hub_on = subprocess.Popen(["usbhub", "--disable-i2c", "--hub", "624C", - "power", "state", "--port", "2", "--reset"]) + tester_hub_on = subprocess.Popen(["hubs", "hackrf", "reset"]) tester_hub_on.wait() time.sleep(1) eut_clkout_on = subprocess.Popen(["host/build/hackrf-tools/src/hackrf_clock", From 0212bf625a199d0b0bb713bc408f884426f68908 Mon Sep 17 00:00:00 2001 From: grvvy Date: Mon, 15 Jul 2024 13:47:00 -0600 Subject: [PATCH 2/3] ci: build docker image from master branch's Dockerfile --- Jenkinsfile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1fb7e6921..24886a8f6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,22 +1,22 @@ pipeline { - agent { - dockerfile { - args '--group-add=20 --group-add=46 --device-cgroup-rule="c 189:* rmw" --device-cgroup-rule="c 166:* rmw" -v /dev/bus/usb:/dev/bus/usb -e TESTER=0000000000000000325866e629a25623 -e EUT=RunningFromRAM' - } - } + agent any stages { - stage('Build (Host)') { + stage('Build Docker Image') { steps { - sh './ci-scripts/install-host.sh' + sh 'docker build -t hackrf $GIT_URL' } } - stage('Build (Firmware)') { - steps { - sh './ci-scripts/install-firmware.sh' + stage('Test Suite') { + agent { + docker { + image 'hackrf' + reuseNode true + args '--group-add=20 --group-add=46 --device-cgroup-rule="c 189:* rmw" --device-cgroup-rule="c 166:* rmw" -v /dev/bus/usb:/dev/bus/usb -e TESTER=0000000000000000325866e629a25623 -e EUT=RunningFromRAM' + } } - } - stage('Test') { steps { + sh './ci-scripts/install-host.sh' + sh './ci-scripts/install-firmware.sh' sh 'hubs all off' retry(3) { sh './ci-scripts/test-host.sh' @@ -34,12 +34,12 @@ pipeline { } sh 'hubs all off' sh 'python3 ci-scripts/test-sgpio-debug.py' + sh 'hubs all reset' } } } post { always { - sh 'hubs all reset' cleanWs(cleanWhenNotBuilt: false, deleteDirs: true, disableDeferredWipeout: true, From c9c6d76ef8aa274ea27f161787344d0ab4fc39ad Mon Sep 17 00:00:00 2001 From: grvvy Date: Wed, 17 Jul 2024 11:30:31 -0600 Subject: [PATCH 3/3] ci: use repository URL instead of relying on jenkins environment variables --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24886a8f6..043585f66 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ pipeline { stages { stage('Build Docker Image') { steps { - sh 'docker build -t hackrf $GIT_URL' + sh 'docker build -t hackrf https://github.com/greatscottgadgets/hackrf.git' } } stage('Test Suite') {