jopohl / urh

Universal Radio Hacker: Investigate Wireless Protocols Like A Boss
GNU General Public License v3.0
10.77k stars 862 forks source link

Add device support for XTRX #584

Open zhovner opened 5 years ago

zhovner commented 5 years ago

XTRX is a versatile and powerfull SDR https://www.crowdsupply.com/fairwaves/xtrx It would be nice to add it to URH.

They have two modes:

Here it the sources: https://github.com/xtrx-sdr And first start howto https://github.com/xtrx-sdr/images

zhovner commented 5 years ago

I've already started to port libxtrx into URH here https://github.com/zhovner/urh/ But I have no idea what i'm actually doing with all of this Cython stuff and try to figure out by looking at another *.pyx and *.pxd lib's and copy&pasting in same manner.

This example application that using libxtrx https://github.com/xtrx-sdr/libxtrx/tree/master/examples/xtrx_fft can be used as reference.

I would appreciate any help.

zhovner commented 5 years ago

Little quick start guide for those who maybe want to join me. @JessieAMorris @ducnguyenAstro @ccsh23 @ynour @mpbraendli

  1. Install XTRX libraries and headers. You should have them at following path: /usr/local/lib/libxtrx.so
    sources at /usr/include/libxtrx/

  2. Install URH with all dependencies

  3. Clone my fork in separate directory https://github.com/zhovner/urh/

Hardware support in URH made by Cython wrappers of original C libraries. Here is the manual of this technique https://cython.readthedocs.io/en/latest/src/tutorial/clibraries.html

Here is an example for HackRF (libhackrf):

I write some XTRX wrappers:

To build this Cython wrapper into binary use this script: urh/src/urh/cythonext/build.py
In my fork it builds only XTRX lib ignoring others.

For the current moment I can build it successfully but not sure if it even works :)

zhovner commented 5 years ago

I can now successfully initialize XTRX using my wrappers. Real breakthrough for me.

$ python3 ./tests/device/TestXTRX.py 

WARN:   xtrxllpciev0_discovery:238 [PCIE] XTRX PCIe driver isn't loaded
DEBUG:  xtrxllusb3380v0_discovery:788 [USB3] usb3380: Found `usb3380://2/2/5` speed 480Mbit

XTRX Found
JessieAMorris commented 5 years ago

Nice. Have you committed your changes on your branch? I've been adding some of the auxiliary stuff that was missing, i.e. device config, etc. Mostly still working on getting familiar with the urh codebase still.

zhovner commented 5 years ago

Have you committed your changes on your branch?

Yes. At this moment we need to work at xtrx.pyx to add all necessary functions. I think the good first step is to implement receive only functionality.

JessieAMorris commented 5 years ago

I've made a good start on that. I have device listing and device opening working at this point. I'm working on frequency setting, gain, etc. as well.

JessieAMorris commented 5 years ago

Not sure if you want to give me permissions to push to your fork or if I should just fork yours.

JessieAMorris commented 5 years ago

For now, I've just created a fork to be able to push my code and so you can see what I've done so far: https://github.com/JessieAMorris/urh

I did have to go into the options menu in urh and enable the XTRX portion to get it to show up in the devices.

zhovner commented 5 years ago

Not sure if you want to give me permissions to push to your fork or if I should just fork yours.

I've grant you access to my repo. Fell free to merge.

JessieAMorris commented 5 years ago

@zhovner I just pushed up my changes. I have a working (I think) spectrum analyzer now. I'm not sure if the data is accurate yet, but it is showing something that seems reasonable ish. I think I need to figure out gain options next.

Error handling still seems to be pretty poor. It seems like the XTRX can get into a funky state pretty easily. I've found that setting the sample rate is needed before tuning the radio and subsequent sample rate changes are iffy at best.

I've found that the test_xtrx command in the libxtrx/build/ director (in the actual libxtrx project) seems to reset it and get into a healthy state.

zhovner commented 5 years ago

Great, will test in few days.

zhovner commented 5 years ago

I've record a screencast of testing spectrum analyzer with RTL-SDR and XTRX for comparison.

RTL-SDR: https://files.catbox.moe/zwsob8.mp4 XTRX: https://files.catbox.moe/2sysxl.mp4

Looks like XTRX does not receive any data. Sometimes it shows some static signal when i press Start button, but no new signal after. But at least it found a correct device identifier :)

JessieAMorris commented 5 years ago

Yeah, I can believe that. I need to take a closer look at the data that the xtrx is outputting and make sure that I'm formatting it correctly for urh. I probably won't have any time until tomorrow to look at that.

m4ver1cks commented 5 years ago

I have been able to use XTRX in URH via gnuradio. image

I'm using Manjaro so some steps could be different. 0º You need to install gnuradio-osmosdr from xtrx branch and ensure that you are using the correct drivers. Yo can ensure launching the osmocom_fft and if in the line that shows all drivers loaded (in my computer "built-in source types: file osmosdr fcd rtl rtl_tcp uhd hackrf rfspace airspy soapy redpitaya xtrx") have the string xtrx you are lucky. 1º I download the code from GIT. 2º I copy the files hackrf_recv.py and hack_send.py to xtrx_recv.py and xtrx_send.py (The files are located in the following folder : /urh/src/urh/dev/gr/scripts) 3º Modify some lines in each new files. Replace "hackrf" to "xtrx", Replace 433000 to 433000000. 4º Modify the file dev/BackendHandler.py and add xtrx in the list of the hardware ( DEVICE_NAMES = ("AirSpy R2", "AirSpy Mini", "BladeRF", "FUNcube", "HackRF", "LimeSDR", "PlutoSDR", "RTL-SDR", "RTL-TCP", "SDRPlay", "SoundCard", "USRP", "xtrx")) 5º Install the package python2-pyzmq

JessieAMorris commented 5 years ago

I just pushed my fixes to @zhovner's master branch.