From 44d91fce19bb43378918afa21ab96f83c3498832 Mon Sep 17 00:00:00 2001 From: Luigi Cruz Date: Fri, 11 Dec 2020 00:27:05 -0300 Subject: [PATCH] add hackrf support --- ansible/roles/grub/tasks/main.yaml | 1 + ansible/roles/hackrf/meta/main.yaml | 5 +++++ ansible/roles/hackrf/tasks/00_dep.yaml | 11 ++++++++++ ansible/roles/hackrf/tasks/01_base.yaml | 27 ++++++++++++++++++++++++ ansible/roles/hackrf/tasks/02_soapy.yaml | 20 ++++++++++++++++++ ansible/roles/hackrf/tasks/main.yaml | 4 ++++ build_grub.sh | 2 +- 7 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/hackrf/meta/main.yaml create mode 100644 ansible/roles/hackrf/tasks/00_dep.yaml create mode 100644 ansible/roles/hackrf/tasks/01_base.yaml create mode 100644 ansible/roles/hackrf/tasks/02_soapy.yaml create mode 100644 ansible/roles/hackrf/tasks/main.yaml diff --git a/ansible/roles/grub/tasks/main.yaml b/ansible/roles/grub/tasks/main.yaml index 7024e36..21ea6e4 100644 --- a/ansible/roles/grub/tasks/main.yaml +++ b/ansible/roles/grub/tasks/main.yaml @@ -12,6 +12,7 @@ shell: | set -e grub-install --target=x86_64-efi + sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& net.ifnames=0 biosdevname=0/' /etc/default/grub GRUB_DISABLE_OS_PROBER=true update-grub - name: Install Linux firmware diff --git a/ansible/roles/hackrf/meta/main.yaml b/ansible/roles/hackrf/meta/main.yaml new file mode 100644 index 0000000..0b01db5 --- /dev/null +++ b/ansible/roles/hackrf/meta/main.yaml @@ -0,0 +1,5 @@ +--- +dependencies: + - role: pisdr + - role: gnuradio + - role: soapysdr \ No newline at end of file diff --git a/ansible/roles/hackrf/tasks/00_dep.yaml b/ansible/roles/hackrf/tasks/00_dep.yaml new file mode 100644 index 0000000..34dcff9 --- /dev/null +++ b/ansible/roles/hackrf/tasks/00_dep.yaml @@ -0,0 +1,11 @@ +--- +- name: Install Dependencies + apt: + name: "{{ item }}" + loop: + - libusb-1.0-0-dev + - pkg-config + - libfftw3-dev + - ninja-build + - cmake + - build-essential \ No newline at end of file diff --git a/ansible/roles/hackrf/tasks/01_base.yaml b/ansible/roles/hackrf/tasks/01_base.yaml new file mode 100644 index 0000000..10098f1 --- /dev/null +++ b/ansible/roles/hackrf/tasks/01_base.yaml @@ -0,0 +1,27 @@ +--- +- name: Git checkout + git: + repo: "https://github.com/mossmann/hackrf.git" + dest: "{{ install_dir }}/hackrf" + version: master + recursive: yes + depth: 1 + +- name: Build + shell: | + set -e + cd {{ install_dir }}/hackrf/host + mkdir -p build + cd build + cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=/etc/pisdr/optimizations.cmake \ + -DINSTALL_UDEV_RULES=ON ../ + ninja install + ldconfig + echo "$(pwd)" >> {{ config_dir }}/build.dirs + +- name: Install UDEV Rules + shell: | + set -e + cd {{ install_dir }}/LimeSuite/udev-rules + ./install.sh + echo "/etc/udev/rules.d/53-hackrf.rules" >> {{ config_dir }}/udev.paths \ No newline at end of file diff --git a/ansible/roles/hackrf/tasks/02_soapy.yaml b/ansible/roles/hackrf/tasks/02_soapy.yaml new file mode 100644 index 0000000..18e99e3 --- /dev/null +++ b/ansible/roles/hackrf/tasks/02_soapy.yaml @@ -0,0 +1,20 @@ +--- +- name: Git checkout + git: + repo: https://github.com/pothosware/SoapyHackRF.git + dest: "{{ install_dir }}/SoapyHackRF" + version: master + recursive: yes + depth: 1 + +- name: Build + shell: | + set -e + cd {{ install_dir }}/SoapyHackRF + mkdir -p build + cd build + cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=/etc/pisdr/optimizations.cmake \ + -DCMAKE_CXX_FLAGS=-latomic ../ + ninja install + ldconfig + echo "$(pwd)" >> {{ config_dir }}/build.dirs \ No newline at end of file diff --git a/ansible/roles/hackrf/tasks/main.yaml b/ansible/roles/hackrf/tasks/main.yaml new file mode 100644 index 0000000..daaefae --- /dev/null +++ b/ansible/roles/hackrf/tasks/main.yaml @@ -0,0 +1,4 @@ +--- +- include_tasks: 00_dep.yaml +- include_tasks: 01_base.yaml +- include_tasks: 02_soapy.yaml \ No newline at end of file diff --git a/build_grub.sh b/build_grub.sh index 1bcadfb..eb44703 100755 --- a/build_grub.sh +++ b/build_grub.sh @@ -10,7 +10,7 @@ LOOP_DEV="/dev/loop5" printf "Creating image file... " if [ "$(lsblk | grep $(basename $LOOP_DEV))" ]; then - losetup -d $LOOP_DEV + losetup -d $LOOP_DEV || true fi rm -fr $GRUB_IMG printf "(OK)\n"