Use RTL-SDR with Zybo Zynq SoC board

Running RTL-SDR on Zybo Zynq
Help us grow. Share with your friends!

The well-known RTL-SDR found itself to become quite popular over the past few years. Even today, RTL-SDR works like a gateway to the world of digital radios. The open-source RTL-SDR setup works with almost any single-board computer having a USB 2.0 port and Linux operating system. Indeed, it also works with Windows. Rather, our main focus for today would be Linux. If your SoC runs Linux and has USB port, you can operate RTL-SDR with it. Today, we will be interfacing the RTL-SDR with the Zybo Zynq SoC board.

Our regular readers know that, several of my past articles revolve around setting up Linux on the Zynq SoC on Zybo board and working our way through it. Correspondingly, my previous article demonstrated how easily one could run Ubuntu on almost any Zynq or Zynq Ultrascale board.

Enabling the USB

Since, we are working with the Zynq SoC; we have the liberty additional logic to go along with the processing system. For example, one could add an FFT accelerator or even a QPSK demodulator to offload the heavy DSP computation to dedicated logic. All these fancy things are quite possible but I will keep those for some other day.

You can always have the PL system setup in Vivado but ignore it for the time being. Export the hardware .xsa file and get ready to build Petalinux. Well, we still need to complete a crucial step before we build the OS.

Enable USB in the kernel

We need to enable the drivers responsible for making USB work correctly. Now, kernel configuration is the best place to find the option to enable those drivers.

petalinux-config -c kernel

Find the following and enable each option by pressing ‘y’:

Device Drivers > USB Support
Device Drivers > USB Support > USB ULPI PHY interface support
Device Drivers > USB support > EHCI HCD (USB 2.0) support
Device Drivers > USB support > ChipIdea Highspeed Dual Role Controller
Device Drivers > USB support > ChipIdea device controller
Device Drivers > USB support > ChipIdea host controller
Device Drivers > USB support > USB Gadget Support

Now, after enabling the necessary USB drivers you may exit and run the following command.

petalinux-build -c device-tree

This invokes the device tree builder. We still need to make manual entries into the device tree for the USB to appear in the Linux OS.

Go to this path and open the system-user.dtsi file.

gedit /path/to/project/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

Add the following lines:

/include/ "system-conf.dtsi"
/ {
       usb_phy0: usb_phy@0 {
       compatible = "ulpi-phy";
       #phy-cells = <0>;
       reg = <0xe0002000 0x1000>;
       view-port = <0x0170>;
       drv-vbus;
   };
};

&usb0 {
   dr_mode = "host";
   usb-phy = <&usb_phy0>;
};

Once done, Save the file and proceed to the next step.

petalinux-build

petalinux-package --boot --force --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot

Package the whole thing and load the following 3 files onto the FAT partition of your SD card.

  • BOOT.bin
  • boot.scr
  • image.ub

Instead of extracting the rootfs.tar.gz built with Petalinux, we will copy the Ubuntu rootfs on to the ext4 partition as we did in this article. With this, you should have your SD card ready to boot.

Boot the system

Load the SD card on the Zybo board or whatever Zynq/ZynqUS board that you might have. Power on the system! If everything has gone right, we should be flooded with the Linux boot messages.

Correspondingly, run the following commands to verify that the kernel has loaded USB drivers.

ubuntu@zynq:~$ dmesg | grep usb
[ 0.368839] usbcore: registered new interface driver usbfs
[ 0.373103] usbcore: registered new interface driver hub
[ 0.377201] usbcore: registered new device driver usb
[ 1.411097] usbcore: registered new interface driver usb-storage
[ 1.416094] chipidea-usb2 e0002000.usb: e0002000.usb supply vbus not found, using dummy regulator
[ 1.473234] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.04
[ 1.480226] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 1.486135] usb usb1: Product: EHCI Host Controller
[ 1.489727] usb usb1: Manufacturer: Linux 5.4.0-xilinx-v2020.2 ehci_hcd
[ 1.495031] usb usb1: SerialNumber: ci_hdrc.0
[ 1.611335] usbcore: registered new interface driver usbhid
[ 1.615663] usbhid: USB HID core driver
[ 1.863038] usb 1-1: new high-speed USB device number 2 using ci_hdrc
[ 2.075272] usb 1-1: New USB device found, idVendor=0bda, idProduct=2838, bcdDevice= 1.00
[ 2.082177] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2.088044] usb 1-1: Product: RTL2838UHIDIR
[ 2.090966] usb 1-1: Manufacturer: Realtek
[ 2.093794] usb 1-1: SerialNumber: 00000001

Please note that I have already plugged in my RTL-SDR which is why it gets listed here. With nothing plugged into the USB port, the SDR shouldn’t show up in these messages.

Apparently, the Linux kernel has successfully loaded the USB drivers necessary to make RTL SDR work properly.

Finally, from here onwards, follow the steps on the official RTL-SDR page to install RTL-SDR drivers. Furthermore, installation steps are rather standard as you would follow on any other Linux system.

Apparently, chances of having problems at this stage are quite low. Hopefully, the process goes smoothly.

The power problem

RTL-SDR dongle draws a good amount of power from the USB. Whenever I plugged in the SDR, the board would go into a continuous boot loop. Clearly, this was a power problem. The SDR drew all the power while leaving none for our Zynq SoC. I could no longer power up the board with the USB port of my PC. That meant I had to plug the USB into the wall charger. Yet, the power problem persisted!

Looking closely at the schematic of the Zybo board, I had to tweak some wiring.

Short all the three pins of the jumper

I still powered the board via USB charger plugged into the wall. Additionally, I also shorted all the three pins of the power select header. Surprisingly, this solved my power problem and allowed me to operate RTL-SDR successfully.

Operating the SDR

My entire Zynq setup is headless. There’s no way to visually observe the data coming from the RTL-SDR. Fortunately, we have rtl_tcp that allows an external client to connect to the board and suck the data coming out of the SDR.

rtl_tcp -a 192.168.1.50

Make sure that the IP address in this command matches to that of your ethernet interface.

Coming back to my main PC, I fired up the SDR# and connected to this IP.

What a surprise, I had data coming in live from the RTL SDR running on Zybo!

RTL SDR running on Zynq Zybo board

RTL SDR running on Zynq Zybo board

Running rtl_tcp will occupy some 30-40Mbps bandwidth depending on the sampling rate. On the other hand, I found that the CPU usage stayed below 6% while streaming data over TCP/IP. Now, this leaves plentiful computing power left to do any kind of signal processing we may wish to do on the incoming data. Imagine having dedicated demodulation hardware on the FPGA. That would leave the CPU untouched and in turn make signal processing much more efficient.

So that’s how you interface RTL-SDR with the Zybo Zynq board. Why just limit ourselves to RTL-SDR and Zybo? With this procedure, you could interface any SDR with USB to any Zynq/Zynq UltraScale system such as the Kria SoM.

nuclearrambo

Salil is an electronics enthusiast working on various RF and Microwave systems. In his free time he writes on the blog, talks over ham radio or builds circuits. He has Yaesu FT2900R VHF transceiver, FT450D HF transceiver and a TYT UV8000E Handheld transceiver.

You may also like...

4 Responses

  1. Anna says:

    Interesting post, thanks for sharing.

  2. Tom Cipollone says:

    Salil, this looks like excellent work! I have been working with polyphase channelizers in Matlab using the RTL-SDR, attached to the PC. I have a zybo dev board as well as a ZCU104 dev board which is the one that I wish to use, the way that you did. I already have built an image for it with a Petalinux kernel, so I could probably do it again (he says 🙂 ).

    One thing that I wanted to ask, and this might have been answered in the above post, was how you chose the frequency to demodulate? You did say that you were able to load standard RTL-SDR drivers and then use rtl_tcp, which I have never used, to observe what the zybo board was receiving. However, were you able to HEAR a demodulated FM station? That is what I really want to know.

    Thank You
    Tom

    • nuclearrambo says:

      No I did not hear the demodulated station directly from Zybo because I had not loaded the audio drivers for Zybo. You can setup rtl_tcl and hear it on a different machine with software like SDR++ / SDR#.

  1. October 9, 2022

    […] Use RTL-SDR with Zybo Zynq SoC board […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.