Ben Stienstra

Linux, Unix, network, radio and more...

User Tools

Site Tools


airspy_in_nspawn_chroot

systemd-nspawn - Airspy Mini (USB) in container

Prerequisites

  • Fedora 26 host (Debian in container).
  • Find USB device and alias:
    # Bus and device number
    lsusb |grep Airspy
    Bus 001 Device 002: ID 1d50:60a1 OpenMoko, Inc. Airspy
    
    # Get device alias
    file /dev/bus/usb/001/002
    /dev/bus/usb/001/002: character special (189/1)
    
    grep 189 /proc/devices
    189 usb_device
  • Create plugdev group on host, GID must be the same on host and within container (ex. GID 46).
  • Create udev rule on host for USB device:
    cat /etc/udev/rules.d/airspy.rules 
    ATTR{idVendor}=="1d50", ATTR{idProduct}=="60a1", SYMLINK+="airspy-%k", MODE="660", GROUP="plugdev"

Create container

  • Install debootstrap:
    sudo dnf install debootstrap
  • Install Debian in container:
    sudo debootstrap --arch=amd64 stable /var/lib/machines/debian
  • Create user, set root password and install dbus:
    sudo systemd-nspawn -D /var/lib/machines/debian
     user=airspyuser
     useradd -d /home/$user -m -s /bin/bash $user
     passwd $user
     passwd root
    
     apt install dbus
    
     exit # or ctr-]]]
  • Enable systemd machines service:
    sudo systemctl enable machines.target
  • Edit service:
    sudo systemctl edit systemd-nspawn@debian.service
    ExecStart=
    ExecStart=/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=try-guest --bind=/dev/bus --network-veth --network-bridge=virbr0 -U --settings=override --private-users=0 --private-users-chown --machine=%i
    
    DeviceAllow=char-usb_device rwm
  • Start container:
    sudo systemctl start systemd-nspawn@debian.service
  • Log in as root:
    sudo machinectl login debian

Configure Debian

  • Configure networking:
    cat << EOF > /etc/network/interfaces.d/host0
    auto host0
    allow-hotplug host0
    iface host0 inet dhcp
    EOF
    
    echo "debian" /etc/hostname
    
    ifup host0
  • Install Airspy library and tools:
    su -
    user=<username>
    apt install usbutils git cmake libusb-1.0 libusb-dev g++ pkg-config sudo man less
    usermod -a -G plugdev,dialout,sudo $user
    exit
    
    # Log in as user
    git clone https://github.com/airspy/airspyone_host.git
    cd airspyone_host/
    
    mkdir build
    cd build
    cmake ../ -DINSTALL_UDEV_RULES=ON
    make
    sudo make install
    sudo ldconfig
    
    
    $ /usr/local/bin/airspy_info
    airspy_lib_version: 1.0.9
    
    Found AirSpy board 1
    Board ID Number: 0 (AIRSPY)
    Firmware Version: AirSpy MINI v1.0.0-rc9-0-ga56adfd 2016-06-12
    Part ID Number: 0x6906002B 0x00000030
    Serial Number: 0x04A464C83729260B
    Supported sample rates:
    	6.000000 MSPS
    	3.000000 MSPS
    Close board 1
airspy_in_nspawn_chroot.txt · Last modified: 2017/11/12 15:51 by admin