f4exb / sdrangel-docker

Running SDRangel in a Docker container
88 stars 40 forks source link

SDRangel: Add ettus UHD and SoapyUHD for USRP support #1

Closed erichahn closed 4 years ago

erichahn commented 5 years ago

TL;DR; Add UHD support, need help with modifying the dockerfile. Don't have an understanding of /opt/build vs /opt/install contexts with respect to all the folders that are created for building each package.

Working on adding uhd and SoapyUHD libraries to support interfacing with a b200 mini. I've been attempting to add the libraries to the dockerfile and need some help. I'll put these in a new branch if I ever get access but here's where I'm at. Currently failing on the soapyUHD build. I don't fully understand how to support building a dependency(soapysdr and uhd) and then building what's needed(soapyuhd).

> [soapyuhd 3/3] RUN git clone https://github.com/pothosware/SoapyUHD.git     && cd SoapyUHD     && mkdir build; cd build     && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR;/opt/install/uhd -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so -DUHD_INCLUDE_DIRS=/opt/install/uhd/include -DUHD_LIBRARIES=/opt/install/uhd/lib ../     && make -j8 install:
#75 0.564 Cloning into 'SoapyUHD'...
#75 1.081 CMake Error: The source directory "/opt/build/SoapyUHD/build" does not appear to contain CMakeLists.txt.
#75 1.081 Specify --help for usage, or press the help button on the CMake GUI.
#75 1.084 /bin/sh: 1: /opt/install/uhd: not found

Line 312 Add:

# UHD
FROM base AS uhd
ARG nb_cores
COPY --from=soapy --chown=sdr /opt/install /opt/install
RUN git clone git://github.com/EttusResearch/uhd.git \
    && cd uhd; cd host \
    && mkdir build; cd build \
    && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/uhd -DINSTALL_UDEV_RULES=OFF .. \
    && make -j${nb_cores} install
    # && cp /opt/install/uhd/lib/libuhd.so /opt/install/SoapySDR/lib/SoapySDR/modules0.7

# Soapy UHD
FROM base AS soapyuhd
ARG nb_cores
COPY --from=soapy --chown=sdr /opt/install /opt/install
COPY --from=uhd --chown=sdr /opt/build /opt/build
RUN git clone https://github.com/pothosware/SoapyUHD.git \
    && cd SoapyUHD \
    && mkdir build; cd build \
    && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR;/opt/install/uhd -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so -DUHD_INCLUDE_DIRS=/opt/install/uhd/include -DUHD_LIBRARIES=/opt/install/uhd/lib .. \
    && make -j${nb_cores} install

And then I guess copy the folders below.

FROM base AS base_deps
COPY --from=cm256cc --chown=sdr /opt/install /opt/install
COPY --from=mbelib --chown=sdr /opt/install /opt/install
COPY --from=serialdv --chown=sdr /opt/install /opt/install
COPY --from=dsdcc --chown=sdr /opt/install /opt/install
COPY --from=codec2 --chown=sdr /opt/install /opt/install
COPY --from=sdrplay --chown=sdr /opt/install /opt/install
COPY --from=airspy --chown=sdr /opt/install /opt/install
COPY --from=rtlsdr --chown=sdr /opt/install /opt/install
COPY --from=plutosdr --chown=sdr /opt/install /opt/install
COPY --from=bladerf --chown=sdr /opt/install /opt/install
COPY --from=hackrf --chown=sdr /opt/install /opt/install
COPY --from=limesdr --chown=sdr /opt/install /opt/install
COPY --from=airspyhf --chown=sdr /opt/install /opt/install
COPY --from=perseus --chown=sdr /opt/install /opt/install
COPY --from=xtrx --chown=sdr /opt/install /opt/install
COPY --from=libmirisdr --chown=sdr /opt/install /opt/install
COPY --from=soapy --chown=sdr /opt/install /opt/install
COPY --from=soapy_remote --chown=sdr /opt/install /opt/install
COPY --from=soapy_sdrplay --chown=sdr /opt/install /opt/install
COPY --from=uhd --chown=sdr /opt/install /opt/install
COPY --from=soapyuhd --chown=sdr /opt/install /opt/install
COPY --from=soapy_limesdr --chown=sdr /opt/install /opt/install

If I change the soapyuhd build to replace /opt/build with /opt/install I see the following:

------
 > [soapyuhd 3/3] RUN git clone https://github.com/pothosware/SoapyUHD.git     && cd SoapyUHD     && mkdir build; cd build     && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR;/opt/install/uhd -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so -DUHD_INCLUDE_DIRS=/opt/install/uhd/include -DUHD_LIBRARIES=/opt/install/uhd/lib ..     && make -j8 install:
#75 0.656 Cloning into 'SoapyUHD'...
#75 1.191 CMake Error: The source directory "/opt/build/SoapyUHD/build" does not appear to contain CMakeLists.txt.
#75 1.191 Specify --help for usage, or press the help button on the CMake GUI.
#75 1.194 /bin/sh: 1: /opt/install/uhd: Permission denied
------
executor failed running [/bin/sh -c git clone https://github.com/pothosware/SoapyUHD.git     && cd SoapyUHD     && mkdir build; cd build     && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR;/opt/install/uhd -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so -DUHD_INCLUDE_DIRS=/opt/install/uhd/include -DUHD_LIBRARIES=/opt/install/uhd/lib ..     && make -j${nb_cores} install]: exit code: 126
f4exb commented 5 years ago

/opt/build/SoapyUHD/build does not contain the CMakeLists.txt file since it should be one directory level up but with the given command line I do not see how this is possible. It is like if we had created the build directory inside /opt/build/SoapyUHD/build. I have to try it myself... more on this later.

erichahn commented 5 years ago

The prefix path list I had requires quotes around the list. && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH="/opt/install/SoapySDR;/opt/install/uhd" -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so -DUHD_INCLUDE_DIRS=/opt/install/uhd/include -DUHD_LIBRARIES=/opt/install/uhd/lib .. \

f4exb commented 5 years ago

I have something that builds. Not sure it actually works.

Line #90 you need python-mako in the global dependencies

# XTRX, UHD
RUN sudo apt-get update && sudo apt-get -y install python-cheetah \
    python-mako

The UHD part:

# UHD
FROM base AS uhd
ARG nb_cores
RUN git clone git://github.com/EttusResearch/uhd.git \
    && cd uhd/host \
    && mkdir build; cd build \
    && cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/uhd -DENABLE_PYTHON_API=OFF -DINSTALL_UDEV_RULES=OFF .. \
    && make -j${nb_cores} install

The SoapyUHD part. -DCMAKE_PREFIX_PATH is useless. Moreover the semicolon IS the issue. The point is to add UHD_DIR before cmake because it is taken from environment and not on the cmake line:

# Soapy UHD
FROM base AS soapy_uhd
ARG nb_cores
COPY --from=soapy --chown=sdr /opt/install /opt/install
COPY --from=uhd --chown=sdr /opt/install /opt/install
RUN git clone https://github.com/pothosware/SoapyUHD.git \
    && cd SoapyUHD \
    && mkdir build; cd build \
    && UHD_DIR=/opt/install/uhd cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so .. \
    && make -j${nb_cores} install

After the copy of libmirisdr add a line for UHD:

COPY --from=uhd --chown=sdr /opt/install /opt/install

Then at the end of the Soapy copies add these two lines:

COPY --from=soapy_uhd --chown=sdr /opt/install /opt/install
COPY --from=soapy_uhd --chown=sdr /opt/install/uhd/lib/uhd /opt/install/uhd/lib/uhd

I will commit something soon.

f4exb commented 5 years ago

Commit 99c1e08

erichahn commented 5 years ago

We're getting much closer

2019-05-16 01:40:02.023 (D) DeviceSoapySDRScan::scan: Install root: /opt/install/SoapySDR
2019-05-16 01:40:02.024 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libLMS7Support.so
2019-05-16 01:40:02.026 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libremoteSupport.so
2019-05-16 01:40:02.028 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libsdrPlaySupport.so
2019-05-16 01:40:02.030 (W) DeviceSoapySDRScan::scan: cannot load module /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libuhdSupport.so: dlopen() failed: libuhd.so.3.15.0: cannot open shared object file: No such file or directory
2019-05-16 01:40:02.030 (D) DeviceSoapySDRScan::scan: driver: lime
2019-05-16 01:40:02.031 (D) DeviceSoapySDRScan::scan: driver: remote
2019-05-16 01:40:02.135 (D) DeviceSoapySDRScan::scan: driver: sdrplay
2019-05-16 01:40:02.143 (D) SoapySDRInputPlugin::enumSampleSources: 0 SoapySDR devices. Enumerate these with Rx channel(s):
erichahn commented 5 years ago

Going to try and cp over the .so.3.15.0 library explicitly

erichahn commented 5 years ago

I copied both. Probably don't need to, wasn't sure how the symlinks would copy.

# Soapy UHD
FROM base AS soapy_uhd
ARG nb_cores
COPY --from=soapy --chown=sdr /opt/install /opt/install
COPY --from=uhd --chown=sdr /opt/install /opt/install
RUN git clone https://github.com/pothosware/SoapyUHD.git \
    && cd SoapyUHD \
    && mkdir build; cd build \
    && UHD_DIR=/opt/install/uhd cmake -Wno-dev -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR -DCMAKE_PREFIX_PATH=/opt/install/SoapySDR -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so .. \
    && make -j${nb_cores} install \
    && cp /opt/install/uhd/lib/libuhd.so /opt/install/SoapySDR/lib/SoapySDR/modules0.7 \
    && cp /opt/install/uhd/lib/libuhd.so.3.15.0 /opt/install/SoapySDR/lib/SoapySDR/modules0.7

Now need to download the uhd images before running software the first time.

2019-05-16 02:20:32.055 (D) DeviceSoapySDRScan::scan: Lib Version: v0.7.1-g5838bc91
2019-05-16 02:20:32.055 (D) DeviceSoapySDRScan::scan: API Version: v0.7.1
2019-05-16 02:20:32.055 (D) DeviceSoapySDRScan::scan: ABI Version: v0.7
2019-05-16 02:20:32.055 (D) DeviceSoapySDRScan::scan: Install root: /opt/install/SoapySDR
2019-05-16 02:20:32.056 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libLMS7Support.so
2019-05-16 02:20:32.057 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libremoteSupport.so
2019-05-16 02:20:32.057 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libsdrPlaySupport.so
2019-05-16 02:20:32.063 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libuhd.so
2019-05-16 02:20:32.064 (D) DeviceSoapySDRScan::scan: loaded module: /opt/install/SoapySDR/lib/SoapySDR/modules0.7/libuhdSupport.so
2019-05-16 02:20:32.064 (D) DeviceSoapySDRScan::scan: driver: lime
2019-05-16 02:20:32.064 (D) DeviceSoapySDRScan::scan: driver: remote
2019-05-16 02:20:32.166 (D) DeviceSoapySDRScan::scan: driver: sdrplay
2019-05-16 02:20:32.173 (D) DeviceSoapySDRScan::scan: driver: uhd
[INFO] [UHD] linux; GNU C++ version 7.4.0; Boost_106501; UHD_3.15.0.git-125-ge0e61a5a
[WARNING] [B200] EnvironmentError: IOError: Could not find path for image: usrp_b200_fw.hex

Using images directory: <no images directory located>

Set the environment variable 'UHD_IMAGES_DIR' appropriately or follow the below instructions to download the images package.

Please run:

 "/opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py"
erichahn commented 5 years ago

Downloaded the images, now getting usb permission issues. Tried copying over the usrp udev rules and reloading them. still having issues. Cannot run sdrangel in docker as sudo as it cannot connect to any x display. Not sure how to progress

f4exb commented 5 years ago

You should not run Docker commands as sudo. On the host add your user to the docker group (for that purpose use sudo...). Then you need to use the run.sh script to run the image. All details can be found in the readme: https://github.com/f4exb/sdrangel-docker/blob/master/sdrangel/readme.md

The udev rules have to be set up on the host. I have the whole collection stored here along with a script to make them effective: https://github.com/f4exb/sdrangel/tree/master/udev-rules I will have to add UHD support there eventually.

Also UHD library dependency has to be added to the export LD_LIBRARY_PATH=... in the start_gui.sh script (also in start_server.sh if you intend to run in headless mode). You can see XTRX dependency is already there. Note that this script is copied at image build time and hence should be correct when building the image.

For the firmware image I am not sure on how to handle this since I have no B200 to actually try it. I don't know how the B200 handles firmware image. In the case it has to be loaded at every device start I suppose it has to be included somewhere in the image. I think BladeRF does a similar thing and I am not sure BladeRF was ever tried in a Docker image, will have to check that.

erichahn commented 5 years ago

Going to need to modify the LD_LIBRARY_PATH to contain the following I believe: /opt/install/libsdrplay/lib:/opt/install/xtrx-images/lib:/opt/install/uhd/lib:/opt/install/uhd/lib/uhd/modules/:/opt/install/SoapySDR/lib

f4exb commented 5 years ago

/opt/install/libsdrplay/lib:/opt/install/xtrx-images/lib:/opt/install/uhd/lib is enough.

Apparently UHD is now scanned by Soapy:

...
2019-05-16 23:23:44.278 (D) DeviceSoapySDRScan::scan: driver: remote
2019-05-16 23:23:44.458 (D) DeviceSoapySDRScan::scan: driver: sdrplay
2019-05-16 23:23:44.466 (D) DeviceSoapySDRScan::scan: driver: uhd
ESC[0;32m[INFO] [UHD] ESC[0;39mlinux; GNU C++ version 7.3.0; Boost_106501; UHD_3.15.0.git-125-ge0e61a5a
...
erichahn commented 5 years ago

Still getting usb permission issues. Have correct group, correct rules applied on host and docker image. I placed the uhd firmware download immediately after the uhd install to ensure they're in the image before startup.

On Thu, May 16, 2019, 5:45 PM f4exb notifications@github.com wrote:

/opt/install/libsdrplay/lib:/opt/install/xtrx-images/lib:/opt/install/uhd/lib is enough.

Apparently UHD is now scanned by Soapy:

... 2019-05-16 23:23:44.278 (D) DeviceSoapySDRScan::scan: driver: remote 2019-05-16 23:23:44.458 (D) DeviceSoapySDRScan::scan: driver: sdrplay 2019-05-16 23:23:44.466 (D) DeviceSoapySDRScan::scan: driver: uhd ESC[0;32m[INFO] [UHD] ESC[0;39mlinux; GNU C++ version 7.3.0; Boost_106501; UHD_3.15.0.git-125-ge0e61a5a ...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/f4exb/sdrangel-docker/issues/1?email_source=notifications&email_token=ABLF6WKVCNYCV7YM3M3YX53PVXIX3A5CNFSM4HNC44BKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVTEUCI#issuecomment-493242889, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLF6WOTCGFN3YZAGDTK3OLPVXIX3ANCNFSM4HNC44BA .

f4exb commented 5 years ago

I have put this at the end of the UHD section. This should download and place firmware in the right place for devices that need firmware at run time (includes B200):

RUN /opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py -t usrp1
RUN /opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py -t b2xx
RUN /opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py -t e3xx_e310
RUN /opt/install/uhd/lib/uhd/utils/uhd_images_downloader.py -t e3xx_e320_fpga
f4exb commented 5 years ago

For USB permission issues you do not need anything in the image just in the host. I think the permissions are propagated through the --privileged flag on the Docker run command.

erichahn commented 5 years ago

Looks like the run script already includes that

f4exb commented 5 years ago

Are you now able to make it work or are there pending issues?

erichahn commented 5 years ago

After double checking all host permission, and for some reason ensuring the firmware has been loaded from the host side things appear to work. Privileged was being applied the whole time as I've been using the nvidia_linux image and start scripts.

High dpi issues still present. Xps 15 4k monitor. Can work around it for now.

Seems like everything freezes if I'm streaming data and add a new modulator. Current work around for me is adding them while data streaming is paused.

Other current issue is I can only select up to 15msps. Would like to select higher. Soapy issue?

On the bright side sdrangel is awesome and I'm going to keep working with it and sharing it with people.

On Fri, May 24, 2019, 5:35 AM f4exb notifications@github.com wrote:

Are you now able to make it work or are there pending issues?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/f4exb/sdrangel-docker/issues/1?email_source=notifications&email_token=ABLF6WKYKXJM6G3FM3RU3JLPW6ZHFA5CNFSM4HNC44BKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWEWKRI#issuecomment-495543621, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLF6WLW7FUNTKBV6Z4TOUTPW6ZHFANCNFSM4HNC44BA .

f4exb commented 5 years ago

Hello,

Brgds, Edouard.

f4exb commented 4 years ago

Original request implemented