Mirics based boards (BG7YZF or "Simple SDR")

All Open Source software

========= Oct 2023 ============
Getting it going on Manjaro - SUCCESS.
Manjaro dev system notes at the end of this file.
Snippet from settings.json, note hacked "type": "sdrplay",
{
    "version": 8,
    "sdrs": {
       "ae243dc9-7725-4c5d-8494-532234b42d8b": {
            "name": "miri_test1",
            "type": "sdrplay",
            "profiles": {
                "8a968a5a-122f-4872-869f-6b1d724671f6": {
                    "name": "7125lsb",
                    "center_freq": 7100000,
                    "samp_rate": 2000000,
                    "start_freq": 7125000,
                    "start_mod": "lsb"
                },
So, "feature.py" is modified to find, not sdrplay but soapyMiri.
And, git clone https://github.com/ericek111/SoapyMiri.git
is modified to link with:
git clone https://github.com/f4gkr/libmirisdr-rsp
and
https://github.com/pothosware/SoapySDR.git
Commenting out: line 429 SoapyMiri/Settings.cpp
/* mirisdr_set_bias(dev, enableBiasTee ? 1 : 0); */
and a few lines down /* mirisdr_set_hw_flavour(dev, flavourMap[value]); */
And line 449 /*  return mirisdr_get_bias(dev) ? "true" : "false"; */
 add:       return "false"; 
or download here: SoapyMiriRSP.tgz
and libmirisdr-rsp.tgz which is modified to 'be' a different package to
f4gkr/libmirisdr-rsp.

----
Then the OWRX python:
/usr/lib/python3.11/site-packages/OpenWebRX-1.3.0.dev0-py3.11.egg/owrx/
feature.py in section: def has_soapy_sdrplay(self):  six lines down
    return self._has_soapy_driver("soapyMiri")

/usr/lib/python3.11/site-packages/OpenWebRX-1.3.0.dev0-py3.11.egg/owrx/source/
sdrplay.py  line 22:  
 def getDriver(self):
        return "soapyMiri"

----------- And it all came good -----------
Blacklist from the kernel the Mirics and the RTLSDR devices:
/etc/modprobe.d/miri-blacklist.conf
blacklist sdr_msi3101
blacklist msi001
blacklist msi2500

/etc/modprobe.d/rtl-sdr-blacklist.conf
blacklist dvb_usb_rtl28xxu
blacklist e4000
blacklist rtl2832

Add udev rules to add user permissions to these devices:
/etc/udev/rules.d/66-mirics.rules
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",ATTRS{idVendor}=="1df7",ATTRS{idProduct}=="2500",MODE:="0666"

/etc/udev/rules.d/77-rtl-sdr.rules
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",ATTRS{idVendor}=="0bda",ATTRS{idProduct}=="2838",MODE:="0666"

reboot

Add or make sure /usr/local/lib is in /etc/ld.so.conf.d/*
Do: echo /usr/local/lib > /etc/ld.so.conf.d/usr-local.conf
git clone https://github.com/f4gkr/libmirisdr-rsp; su; cd pkg-dir; mkdir build; cd build; cmake ../; make install
git clone https://github.com/steve-m/librtlsdr.git; ditto
ldconfig
git clone https://github.com/pothosware/SoapySDR.git; ditto
ldconfig
git clone https://github.com/ericek111/SoapyMiri.git; ditto
ldconfig
test src]$ SoapySDRUtil --find
######################################################
##     Soapy SDR -- the SDR abstraction library     ##
######################################################

Found device 0
  driver = soapyMiri
  index = 0
  label = RSP1 :: 00000001
  manufacturer = SDRPlay
  product = RSP1
  serial = 00000001

git clone https://github.com/jketterl/csdr.git; su; python3 setup.py install
git clone https://github.com/jketterl/pycsdr.git
git clone https://github.com/jketterl/openwebrx.git
git clone https://github.com/jketterl/owrx_connector.git

Create settings directory:
mkdir /var/lib/openwebrx; chmod 777 /var/lib/openwebrx

Set adminstrator password
 /usr/bin/openwebrx admin adduser my-name
    enter password: (twice)

Run with: /usr/bin/openwebrx &
 and browse: http://localhost:8073

========= May 2023 ============
Discovered the Ham apps Linux DragonOS with OpenWebRx already
loaded, all one needs to do is start it.
 (systemctl enable openwerbx; systemctl start openwebrx)
Though, for the Mirics boards (BG7YZF or "Simple SDR")
the SDRPlay driver is installed and won't work.

So, what to do. Here's what I did:
On my "big box" 32Gb ram i3 8100 Z370 system, SSD & 4Tb disk,
I loaded Proxmox and have DragonOS as a virtual machine.
"OpenWebRX" will get I & Q samples over TCP/IP from the
underlying ProxMox 7.2, Debian GNU/Linux 11 (bullseye).
This way I can test out any Linux or Windows flavour app
that can "see" a Soapy Server.
On ProxMox:
You will need to blacklist the kernel Mirics driver.
do:
echo "blacklist sdr_msi3101
blacklist msi001
blacklist msi2500" > /etc/modprobe.d/miri-blacklist.conf
and reboot.

First install enough dev system.
apt install wodim git make cmake g++-10 pkg-config
apt install libusb-1.0-0-dev libfftw3-dev libavahi-client-dev

git clone https://github.com/ericek111/libmirisdr-5.git
git clone https://github.com/pothosware/SoapySDR.git
git clone https://github.com/ericek111/SoapyMiri.git
git clone https://github.com/pothosware/SoapyRemote.git
Make these in order and install.
cd ; mkdir build; cd build; cmake ..; make install
Test with: "SoapySDRUtil --make=driver=soapyMiri"
ls /usr/local/lib/systemd/system/SoapySDRServer.service
Start it:
systemctl enable SoapySDRServer; systemctl start SoapySDRServer
Then go to CubicSDR on DragonOS and it will discover:
Local Net
    Mirics MSi2500 default (e.g.VTX3D card)

And you are away to find it on OpenWebRX.
systemctl enable openwebrx; systemctl start openwebrx

Your /var/lib/openwebrx/settings.json will look like:
--
       "miri1ds0": {
            "name": "Miri ant A RSP1",
            "type": "soapy_remote",
            "antenna": "Antenna A",
            "profiles": {
                "20m0": {
                    "name": "20m0",
                    "center_freq": 14150000,
                    "rf_gain": 0,
                    "samp_rate": 500000,
                    "start_freq": 14070000,
                    "start_mod": "usb"
                },
                "FM88MHz0": {
                    "name": "88mhz2",
                    "center_freq": 88300000,
                    "samp_rate": 1300000,
                    "start_freq": 88000000,
                    "start_mod": "wfm"
                }
            },
            "remote": "proxmox:55132,remote:driver=soapyMiri"
--
or
            "remote": "localhost:55132,remote:driver=soapyMiri"

And of course, your /etc/hosts file on DragonOS will have "192.168.xx.xx proxmox".

Modded files here for your download:
libmirisdr-5jun23.tgz
settings.json_miri

I've been modifying things and have at last a setup where one can change
bands, eg. HF to VHF and back successfully.

--------- startup scripts ---------------
Edit /usr/local/sbin/openwebrx.rst
:
/usr/bin/pkill -u root SoapySDRServer
/usr/local/bin/SoapySDRServer --bind >/tmp/miri$$ 2>&1 &
/usr/bin/systemctl restart openwebrx
----
chmod +x /usr/local/sbin/openwebrx.rst
Enable "crontab"
export EDITOR=vi
Do: "crontab -e" and add:
3,33 * * * * /usr/local/sbin/openwebrx.rst

Next is to get FreeDV for the different modes as well as USB & LSB.

========= August 2022 ============
Notes for OpenWebRX Ver 1.3.0-dev to use the "Simple SDR".
The Mirics MSi3101 chipset on a board with a USB-C connector
and five SMA sockets for bands:
 0-30MHz, 30-60MHz, 50-120MHz, 250-1000MHz and 120-250MHz.

Often marked BG7YZF 

"perseussdr.py" was the easyest driver to "hack" to get going.

The "-z" option to the "miri_sdr" driver converts the output
to 32bit floating point data and scaled for the "S Meter".

BUGS:
=====  Changing frequency bands, caused it to stall, so
one needed a second SDR such as an RTL_SDR to switch to,
and then back to the Mirics for it to work on the new band.

Jan 2023: Fixed now with a delay, see: time.sleep(1.1)
          in miri2500sdr.py

INSTALL:
========  Install OpenWebRX with your package manager or
from the OpenWebRX Github site and then add/replace files..
Extract OWRXmirics2500.tgz for additions to "feature.py" etc..

Having extracted from "libmirisdr-4b.tgz"
do: cd libmirisdr-4b; mkdir build1; cd build1; cmake ../; make
And: make install


For users (not root) to have permissions to use the SDR boards,
add "66-mirics.rules" to "/etc/udev/rules.d/" and
do: udevadm control -R
to re-read the udev rules.

You may need to blacklist the kernel Mirics driver.
do: echo "blacklist sdr_msi3101
blacklist msi001
blacklist msi2500" > /etc/modprobe.d/miri-blacklist.conf
and reboot.

TEST:
=====  Run "miri_sdr -z -m 252 -f 477000000 -s 2000000 /tmp/junk"
stop it quickly as it generates a LARGE file.
Use: od -f /tmp/junk | more
to check the data format.

Tar files here for download:
http://www.unixservice.com.au/hamradio/websdr/libmirisdr-4b.tgz
http://www.unixservice.com.au/hamradio/websdr/owrx16bit1.tgz
http://www.unixservice.com.au/hamradio/websdr/OWRXmirics2500.tgz

================= 26/5/2021 ===============

============ OpenWebRX setup for SDRplay USB thing ========
1) Requires Ubuntu 20 as s/w is python3.

SDRplay_RSP_API-Linux-3.07.1.run from sdrplay.com provides an API for
all RSP1, RSP2 and uno USB devices. DOES NOT FIND RSP1 !!!! (see below, Pi image)

Download RSPTCPServer and build. Not needed, see Pi image below.

RSP_TCP connects to SDRplay API socket and provides RTL_SDR functions
on socket localhost:1234 also shows it found the SDRplay device.
https://github.com/SDRplay/RSPTCPServer.git

==== OpenWebRX on your internet facing Linux box ====
github.com/ketterl/openwebrx forked from github.com/ha7ilm/openwebrx (python2.7)
now supports python3.
======== As Ubuntu packages ============, as root
wget -O - https://repo.openwebrx.de/debian/key.gpg.txt | apt-key add
echo "deb https://repo.openwebrx.de/ubuntu/ hirsute main" > /etc/apt/sources.list.d/openwebrx.list
apt-get update
apt-get install openwebrx
# Set admin password
-----------------------

======== Run: systemctl start openwebrx ==========
Browse localhost:8073 and "No SDR receiver found"
AND can't get to "Settings".
======== Configuring ======
Edit /usr/lib/python3/dist-packages/owrx/config/defaults.py
Put in your callsign, lat & long etc. and change rtl_sdr
to rtl_tcp in "RTL-SDR USB Stick", samplerate 1024000
systemctl stop openwebrx; systemctl start openwebrx
And it's running!!!!!!!!!!! but no waterfall, needs Rx data.
==== Settings ===
/var/lib/openwebrx/settings.json

====== Pi =========
Booted SDRplay_RPi_HeadlessServer_V0.1.img.xz on RPi4B as per:
https://www.sdrplay.com/raspberry-pi-images/ pi/raspberry
Finds my SDRplay RSP1
prompt$ rsp_tcp version 1.1

API library version 3.07 found
detected RSP model 'RSP1' (hw ver 1)
listening...
----------------------

Find the Pi's IP address (DHCP), back on the OpenWebRx box,
note:       "remote": "192.168.20.142:1234"

/var/lib/openwebrx/settings.json 
{
    "version": 7,
    "sdrs": {
        "rtlsdr": {
            "name": "RSP-SDR USB SDRplay remote on the Pi",
            "type": "rtl_tcp",
            "profiles": {
                "70cm": {
                    "name": "70cm Repeaters",
                    "center_freq": 438800000,
                    "rf_gain": 29,
                    "samp_rate": 1024000,
                    "start_freq": 439275000,
                    "start_mod": "nfm"
                },
                "2m": {
                    "name": "2m",
                    "center_freq": 145000000,
                    "rf_gain": 29,
                    "samp_rate": 1024000,
                    "start_freq": 145725000,
                    "start_mod": "nfm"
                }
            },
            "remote": "192.168.20.142:1234"
        },
        "b5027342-dec6-4d82-83be-6c427e4451f5": {
            "name": "miri_test3",
            "type": "miri2500sdr",
            "profiles": {
                "e8a99d2b-65b8-4306-8f93-8058cabf7d52": {
                    "name": "miri 40m",
                    "center_freq": 7110000,
                    "samp_rate": 2048000,
                    "start_freq": 7136000,
                    "start_mod": "lsb"
                },
                "e8a99d2b-65b8-4306-8f93-8058cabf7d53": {
                    "name": "miri 20m",
                    "center_freq": 14210000,
                    "samp_rate": 2048000,
                    "start_freq": 14236000,
                    "start_mod": "usb"
                }
            }
        }
    },
    "receiver_name": "[VK2ZZZ]",
    "receiver_location": "Sydney, Australia",
    "receiver_asl": 40,
    "receiver_admin": "[email protected]",
    "receiver_gps": {
        "lat": -33.742077890426444,
        "lon": 150.6496391296387
    },
    "photo_title": "piXture, image rendered by X11",
    "photo_desc": "",
    "max_clients": 20,
    "receiver_keys": [
        ""
    ],
    "waterfall_scheme": "GoogleTurboWaterfall",
    "fft_fps": 9,
    "fft_size": 4096,
    "fft_voverlap_factor": 0.3,
    "waterfall_levels": {
        "min": -88.0,
        "max": -20.0
    },
    "waterfall_auto_levels": {
        "min": 3.0,
        "max": 10.0
    },
    "waterfall_auto_min_range": 50,
    "audio_compression": "adpcm",
    "fft_compression": "adpcm",
    "tuning_precision": 2,
    "google_maps_api_key": "",
    "map_position_retention_time": 7200
}
--------- end -------------------
Public access, when NBN is up: http://nepeanshed.org.au:8073		server2
(water damaged FTTC curb unit)

---------- RSP1 and using it's 12bit mode ----------
The old SDRplay RSP1 device was not "found" by SDRplay's driver on a Linux PC but their
HeadlessServer image on a Raspberry Pi 4B did find it. But only in
8bit data mode.  Check the "rsp_tcp" usage message, the "-b 16" option is there.
owrx16bit1.tgz in this directory has the changes for owrx_connector.
A settings.json file is in the sourcePython directory along with the changed Python.
Note the "16bit" : "512", line. 10bit data as positive integers, 0 - 1023 half is 512.
Use 2048 for 12bit SDRs.
You'll need to recompile rtl_tcp_connector and place in $PATH such as /usr/local/bin.
And, replace rtl_tcp.py in /usr/lib/python3/dist-packages/owrx/source/.
The FreeDV mode is in /usr/lib/python3/dist-packages/csdr/__init__.py line 216

---------- My other SDR, a HackRF One, research ---------------

git clone https://github.com/pothosware/SoapySDR.git
git clone https://github.com/pothosware/SoapyHackRF.git
git clone https://github.com/pothosware/SoapySDRPlay3.git
make etc.. cd SoapySDR

SoapySDRUtil --probe="driver=sdrplay"

================= Manjaro ===============
Odroid M1, to keep the power use down.
Manjaro-ARM-mate-om1-23.02.img.xz on SD card
Kernel: 6.1.12-1-MANJARO-ARM now after upgrade 6.5.3-1-MANJARO-ARM
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
======== dev system =====
 Should work on all Manjaro.
pamac install pacaur
pamac install yay
pamac install cmake
/etc/makepkg.conf BUILDDIR=/usr/tmp/makepkg
yay install pip; option 2
pacman -S wxwidgets; option 1
pacman -S python-setuptools

====== The End ======