Skip to content

Guide to configure rasberry pi, hackrf one and soapy sdr to control the device remotely.

License

Notifications You must be signed in to change notification settings

redeltaglio/rasberry-remote-stash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARM devices, passive and active remote hamradio stash.

  • https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-64-bit

  • download lite version

  • dd if=file.img of=/dev/mmcblk0 bs=1M conv=fsync status=progress

  • mount boot partition and touch ssh

  • mount rootfs partition and edit /etc/dhcpcd.conf to enable static IPv4.

  • ssh to the device using user pi and password raspberry

  • Set locale:

    • raspi-config: Localization Options [en_US.UTF-8, es_ES.UTF-8] ; Timezone [Europe/Madrid];

      # cat > /etc/default/locale
      LANG=en_US.UTF-8
      LANGUAGE=en_US.UTF-8
      LC_NUMERIC=es_ES.UTF-8
      LC_TIME=es_ES.UTF-8
      LC_MONETARY=es_ES.UTF-8
      LC_PAPER=es_ES.UTF-8
      LC_NAME=es_ES.UTF-8
      LC_ADDRESS=es_ES.UTF-8
      LC_TELEPHONE=es_ES.UTF-8
      LC_MEASUREMENT=es_ES.UTF-8
      LC_IDENTIFICATION=es_ES.UTF-8
      ^EOF
      # locale-gen
    • set keyboard with: localectl set-keymap es

    • Reboot.

  • update it with sudo apt update && sudo apt upgrade

  • set the hostname: sudo raspi-config

In case you are updating the hackrf one by remote remember that you can remove USB power using:

# disable external wake-up; do this only once
echo disabled > /sys/bus/usb/devices/usb1/power/wakeup 

echo on > /sys/bus/usb/devices/usb1/power/level       # turn on
echo suspend > /sys/bus/usb/devices/usb1/power/level  # turn off

Rasbian update

Rasbian is a Linux distribution and, as all the others, got it personal cheat sheet to a correct administration.

root@IOT-01-RASB:/home/taglio# rpi-update 
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Backing up firmware
 *** Backing up modules 5.10.17-v7+
#############################################################
WARNING: This update bumps to rpi-5.10.y linux tree
See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=288234
'rpi-update' should only be used if there is a specific
reason to do so - for example, a request by a Raspberry Pi
engineer or if you want to help the testing effort
and are comfortable with restoring if there are regressions.

DO NOT use 'rpi-update' as part of a regular update process.

##############################################################
Would you like to proceed? (y/N)

 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168  100   168    0     0    126      0  0:00:01  0:00:01 --:--:--   126
100  120M  100  120M    0     0  1744k      0  0:01:10  0:01:10 --:--:-- 1920k
 *** Updating firmware
 *** Updating kernel modules
 *** depmod 5.10.46-v8+
 *** depmod 5.10.46-v7+
 *** depmod 5.10.46-v7l+
 *** depmod 5.10.46+
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to f29ab05611eef385d17675c77190df0b87a0d456
 *** A reboot is needed to activate the new firmware
root@IOT-01-RASB:/home/taglio# 

Then a reboot is needed and we can visualize the new installed firmware doing the classical:

taglio@IOT-01-RASB:~ $ uname -a
Linux IOT-01-RASB 5.10.46-v7+ #1432 SMP Fri Jul 2 21:16:37 BST 2021 armv7l GNU/Linux
taglio@IOT-01-RASB:~ $ 

Next:

root@IOT-01-RASB:/home/taglio# apt dist-upgrade
...
root@IOT-01-RASB:/home/taglio# apt autoremove
...
root@IOT-01-RASB:/home/taglio#

One good trick to pass from plain RaspiOS to RaspiOS-Lite in the case you've done a project error:

root@IOT-01-RASB:/home/taglio#  apt purge xserver* lightdm* raspberrypi-ui-mods
...
root@IOT-01-RASB:/home/taglio# apt autoremove
...
root@IOT-01-RASB:/home/taglio#

Install git:

# apt install git

Disable bluetooth and wireless:

# echo dtoverlay=disable-bt >> /boot/config.txt
# echo dtoverlay=pi3-disable-wifi >> /boot/config.txt
# systemctl disable bluetooth.service
# systemctl disable wpa_supplicant.service

Disable others services:

# systemctl disable avahi-daemon.service

Add your user and add your identity:

# useradd -m taglio
# for i in $(cat /etc/group | grep pi | sed /^pi.*/d | cut -d : -f1); do a+=$(printf "%s," $i); done
# eval usermod -G $(echo $a | sed "s|,$||") taglio 
# passwd taglio
# exit
taglio@trimurti:~/Bin$ ssh-copy-id -i /home/taglio/.ssh/id_ed25519.pub ham-01-rasb.red.ama
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/taglio/.ssh/id_ed25519.pub"
The authenticity of host 'ham-01-rasb.red.ama (172.16.18.254)' can't be established.
ECDSA key fingerprint is SHA256:RH32lmukVHv3SUcK/ninNAoKMXW8+swlWVJ4eb/ZVCY.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
taglio@ham-01-rasb.red.ama's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'ham-01-rasb.red.ama'"
and check to make sure that only the key(s) you wanted were added.

taglio@trimurti:~/Bin$

Configure ssh to forward agent, identities and X11 to the HAM raspberry. Verify it:

taglio@trimurti:~$ cat /etc/ssh/ssh_config.d/ham.conf 
Host ham*
	AddKeysToAgent ask
	IdentityFile ~/.ssh/id_ed25519
	ForwardAgent yes
	ForwardX11 yes
	
taglio@trimurti:~$  ssh-add -L
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDGNNdXk7F17jGtt8xN51bR8toCET/my2mjQX4FkBVt8AwqEFoZg7AQcI9QReIyIOskiG7PXKD6YFk2bE5lc8QoHPeJCD1NHN/V0iflteeP4ZhtG/HH6NIGwEMsTsoxM8Uk4gU+kBWfFnmpRixXlCZjgKmRK0QdBdqX/0CVIDA0Z8ZO7W6dzXo+aje/kd/hD/T9jdAom0B+keXjaWRuZtIZ75v7hSBrG8K1azG9rvMX9zJHUwq8NXc7/ut90UGFFKvGgBt1kwc/Q1NiRbZujJ31+eKJJVXCp+IYl9SwVchl0FFQeR6ylWSO/rpt75yDgZYqpiTcdQ3lTbhX+rfUNX9veC7XJ6qTIoqP9kzUDZocSdNpLFOloor9LciGMJ1E7DJtqs7ZizlQVPRfOyP0EeO8Y9+JGUfQWOgb7w1OIsmJU54dFPVM20cxzsq71KOGS/LCvnqHl+UAhD6V+HSKkWpQCNbhk8q7IhjDqKEJ2LhfW2FHCANQJ7GyWRbVK/keHLk= taglio@telecom.lobby
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIZfNTAqRcC2VizgFX++yZLRAWaZi9iRMHuoVis4T38w taglio@telecom.lobby
taglio@trimurti:~$ 

Configure pam_ssh_agent_auth onto the HAM raspberry for password less operations with sudo:

# apt install libpam-ssh-agent-auth
# cp /home/taglio/.ssh/authorized_keys /etc/ssh/authorized_keys
# chown root:root /etc/ssh/authorized_keys ; chmod 0644 /etc/ssh/authorized_keys

Configure pam.d sudo file:

# cat /etc/pam.d/sudo
auth sufficient /usr/lib/aarch64-linux-gnu/security/pam_ssh_agent_auth.so file=/etc/ssh/authorized_keys

@include common-auth
@include common-account
@include common-session-noninteractive
#

Configure and restart sshd:

# cat /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
AddressFamily inet
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem	sftp	/usr/lib/openssh/sftp-server
# /etc/init.d/ssh restart
Restarting ssh (via systemctl): ssh.service.
#

Add ssh-add to login and logout file read by bash shell, also edit with visudo and add Defaults env_keep += SSH_AUTH_SOCK:

$ echo ssh-add -v >> .profile
$ echo ssh-add -D >> .bash_logout

Delete pi user:

# userdel pi
# rm -rf /home/pi

Add fortune and uprecords to motd:

# cat /dev/null> /etc/motd
# apt install fortune uptimed
# rm /etc/profile.d/{sshpwd.sh,wifi-check.sh}
# echo 'echo " "'  > /etc/profile.d/00uptimed.sh
# echo "uprecords" >> /etc/profile.d/00uptimed.sh
# echo 'echo " "'  > /etc/profile.d/01fortune.sh
# echo "/usr/games/fortune -a" >> /etc/profile.d/01fortune.sh

External SB X-Fi Surround 5.1 Pro

Linux kernel driver and driver interface API is provided by ALSA software framework. It directly interact with hardware devices like our USB soundcard.

Blacklist the board card:

# echo blacklist snd_bcm2835 > /etc/modprobe.d/bcm2835.conf
# rmmod snd_bcm2835

Disable vn4 driver audio:

# sed -i "s|dtoverlay=vc4-kms-v3d|dtoverlay=vc4-kms-v3d,audio=off|" /boot/config.txt
# reboot

Verify:

taglio@HAM-01-RASPB:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
taglio@HAM-01-RASPB:~ $ 

If you don't want to disable Raspberry 3 default devices the output will be:

taglio@HAM-01-RASB:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
taglio@HAM-01-RASB:~ $ 

Card id is 1.

Verify the kernel driver that manage the SB X-Fi Surround 5.1 Pro:

taglio@HAM-01-RASB:~ $ cat /proc/asound/modules
 1 snd_usb_audio
taglio@HAM-01-RASB:~ $

Verify module options:

taglio@HAM-01-RASB:~ $ modinfo snd_usb_audio | grep -v alias
filename:       /lib/modules/5.15.24-v7+/kernel/sound/usb/snd-usb-audio.ko
license:        GPL
description:    USB Audio
author:         Takashi Iwai <tiwai@suse.de>
srcversion:     E73A30484EDD3D310F8DAB2
depends:        mc,snd-usbmidi-lib,snd-pcm,snd,snd-hwdep
intree:         Y
name:           snd_usb_audio
vermagic:       5.15.24-v7+ SMP mod_unload modversions ARMv7 p2v8 
parm:           index:Index value for the USB audio adapter. (array of int)
parm:           id:ID string for the USB audio adapter. (array of charp)
parm:           enable:Enable USB audio adapter. (array of bool)
parm:           vid:Vendor ID for the USB audio device. (array of int)
parm:           pid:Product ID for the USB audio device. (array of int)
parm:           device_setup:Specific device setup (if needed). (array of int)
parm:           ignore_ctl_error:Ignore errors from USB controller for mixer interfaces. (bool)
parm:           autoclock:Enable auto-clock selection for UAC2 devices (default: yes). (bool)
parm:           lowlatency:Enable low latency playback (default: yes). (bool)
parm:           delayed_register:Quirk for delayed registration, given by id:iface, e.g. 0123abcd:4. (array of charp)
parm:           implicit_fb:Apply generic implicit feedback sync mode. (array of bool)
parm:           quirk_flags:Driver quirk bit flags. (array of uint)
parm:           use_vmalloc:Use vmalloc for PCM intermediate buffers (default: yes). (bool)
parm:           skip_validation:Skip unit descriptor validation (default: no). (bool)
taglio@HAM-01-RASB:~ $ 

ALSA creates concepts about ALSA Card and ALSA Device. Card refers to the hardware that can have multiple capabilities like sending sound to a speaker or receiving sound from a microphone or from another source, in our case our stash.

Therefore an ALSA Card will have one ALSA device to send sound and another to receive sound. This is why in the output of aplay -l we see that the program call subdevices.

One system could have more than one card this is why ALSA use what is called the ALSA Card id. An id could by identified by an integer or a name.

A device is identified by the couple ALSA Card id, ALSA Device id; device id is always numeric.

ALSA applications works only at device level. Applications are also adressed with:

ALSA interface:ALSA Card id, ALSA Device id

ALSA interface is an access protocol that come with to interfaces built that are:

  • hw, provides direct communication to the hardware device.
  • plughw, provides translation from a standardized protocol to one which is supported by the device.

To find the ALSA Card id:

taglio@HAM-01-RASB:~ $ cat /proc/asound/cards
 1 [Pro            ]: USB-Audio - SB X-Fi Surround 5.1 Pro
                      Creative Technology Ltd SB X-Fi Surround 5.1 Pro at usb-3f980000.usb-1.2, full 
taglio@HAM-01-RASB:~ $ 

In our case of study we find the two numeric and letters ids:

  • 1
  • Pro

To find the Devices created by ALSA kernel module:

taglio@HAM-01-RASB:~ $ ls -l /proc/asound/card*
-r--r--r--  1 root root 0 feb 21 22:33 /proc/asound/cards

/proc/asound/card1:
total 0
-r--r--r-- 1 root root 0 feb 21 22:41 id
dr-xr-xr-x 4 root root 0 feb 21 22:33 pcm0c
dr-xr-xr-x 4 root root 0 feb 21 22:33 pcm0p
dr-xr-xr-x 4 root root 0 feb 21 22:33 pcm1p
-r--r--r-- 1 root root 0 feb 21 22:41 stream0
-r--r--r-- 1 root root 0 feb 21 22:41 stream1
-r--r--r-- 1 root root 0 feb 21 22:41 usbbus
-r--r--r-- 1 root root 0 feb 21 22:41 usbid
-r--r--r-- 1 root root 0 feb 21 22:41 usbmixer
taglio@HAM-01-RASB:~ $ 

A pcm folder represent a device. pcm[0-9]c represent a capture device. pcm[0-9]p represent a playback device. Be careful because in my understanding connected to a capture or playback device there could be more that one jack, female connector.

The acronym pcm refers to pulse-code modulation.

Our card has got 3 ALSA Devices, to identify the devices id do:

taglio@HAM-01-RASB:~ $ cat /proc/asound/card1/pcm0c/info 
card: 1
device: 0
subdevice: 0
stream: CAPTURE
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1
taglio@HAM-01-RASB:~ $ cat /proc/asound/card1/pcm0p/info 
card: 1
device: 0
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1
taglio@HAM-01-RASB:~ $ cat /proc/asound/card1/pcm1p/info 
card: 1
device: 1
subdevice: 0
stream: PLAYBACK
id: USB Audio
name: USB Audio #1
subname: subdevice #0
class: 0
subclass: 0
subdevices_count: 1
subdevices_avail: 1
taglio@HAM-01-RASB:~ $ 

Playback device is to send and Capture is receive. But ALSA create a series of concept devices called Virtual Device, the differences are that a physical device got an hardware behind and that got an hardware address. Virtual Devices are addressed by name and are created by plugins.

To list all hardware and virtual devices created by default use:

aglio@HAM-01-RASB:~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
lavrate
    Rate Converter Plugin Using Libav/FFmpeg Library
samplerate
    Rate Converter Plugin Using Samplerate Library
speexrate
    Rate Converter Plugin Using Speex Resampler
jack
    JACK Audio Connection Kit
oss
    Open Sound System
pulse
    PulseAudio Sound Server
upmix
    Plugin for channel upmix (4,6,8)
vdownmix
    Plugin for channel downmix (stereo) with a simple spacialization
default
softvol
hw:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    Direct hardware device without any conversions
hw:CARD=Pro,DEV=1
    SB X-Fi Surround 5.1 Pro, USB Audio #1
    Direct hardware device without any conversions
plughw:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    Hardware device with all software conversions
plughw:CARD=Pro,DEV=1
    SB X-Fi Surround 5.1 Pro, USB Audio #1
    Hardware device with all software conversions
sysdefault:CARD=Pro
    SB X-Fi Surround 5.1 Pro, USB Audio
    Default Audio Device
front:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    Front output / input
surround21:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    IEC958 (S/PDIF) Digital Audio Output
iec958:CARD=Pro,DEV=1
    SB X-Fi Surround 5.1 Pro, USB Audio #1
    IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=Pro,DEV=0
    SB X-Fi Surround 5.1 Pro, USB Audio
    Direct sample mixing device
dmix:CARD=Pro,DEV=1
    SB X-Fi Surround 5.1 Pro, USB Audio #1
    Direct sample mixing device
usbstream:CARD=Pro
    SB X-Fi Surround 5.1 Pro
    USB Stream Output
taglio@HAM-01-RASB:~ $ 

ALSA Plugins that can be programmed are:

  • adpcm: software encoder, quadrature encoding, from analog to digital.

  • alaw: an algorithm to optimize a limited channel, a limited hardware for digitalization of analog signals.

  • asym: combines half-duplex PCM plugins like dsnoop and dmix into one full-duplex device.

  • copy: copy samples from a master PCM to a slave PCM.

  • dmix: provides for direct mixing of multiple streams.

  • dshare: provides sharing channels.

  • dsnoop: splits one capture stream to more.

  • file: stores contents of a PCM stream to file or pipes the stream to a command, and optionally uses an existing file as an input data source.

  • hooks: used to call some 'hook' function when this plugin is opened, modified or closed. Typically, it is used to change control values for a certain state specially for the PCM.

  • hw: communicates directly with the ALSA kernel driver. It is a raw communication without any conversions.

  • iec958

  • jack: redirect sampling from pcm to jack audio server.

  • ladspa: use ladspa with ALSA applications.

  • lfloat: converts linear to float samples and float to linear samples from master linear<->float conversion PCM to given slave PCM.

  • linear: converts linear samples from master linear conversion PCM to given slave PCM.

  • mulaw: converts Mu-Law samples to linear or linear to Mu-Law samples from master Mu-Law conversion PCM to given slave PCM.

  • multi: onverts multiple streams to one.

  • null: discards contents of a PCM stream using /dev/null or creates a stream with zero samples. using /dev/full.

  • plug: converts channels, rate and format on request.

  • rate: converts a stream rate. The input and output formats must be linear.

  • route: converts channels and applies volume during the conversion. The format and rate must match for both of them.

  • share: converts multiple streams to one.

  • shm: communicates with aserver via shared memory. It is a raw communication without any conversions, but it can be expected worse performance.

  • softvol: applies the software volume attenuation. The format, rate and channels must match for both of source and destination.

At least some output from alsa-info:

!!Loaded sound module options
!!---------------------------

!!Module: snd_usb_audio
	autoclock : Y
	delayed_register : (null),(null),(null),(null),(null),(null),(null),(null)
	device_setup : 0,0,0,0,0,0,0,0
	enable : Y,Y,Y,Y,Y,Y,Y,Y
	id : (null),(null),(null),(null),(null),(null),(null),(null)
	ignore_ctl_error : N
	implicit_fb : N,N,N,N,N,N,N,N
	index : -2,-1,-1,-1,-1,-1,-1,-1
	lowlatency : Y
	pid : -1,-1,-1,-1,-1,-1,-1,-1
	quirk_alias : (null),(null),(null),(null),(null),(null),(null),(null)
	quirk_flags : 0,0,0,0,0,0,0,0
	skip_validation : N
	use_vmalloc : Y
	vid : -1,-1,-1,-1,-1,-1,-1,-1


!!USB Mixer information
!!---------------------
--startcollapse--

USB Mixer: usb_id=0x041e3263, ctrlif=0, ctlerr=0
Card: Creative Technology Ltd SB X-Fi Surround 5.1 Pro at usb-3f980000.usb-1.2, full 
--endcollapse--


!!ALSA Device nodes
!!-----------------

crw-rw---- 1 root audio 116, 32 Feb 21 17:12 /dev/snd/controlC1
crw-rw---- 1 root audio 116, 36 Feb 21 17:12 /dev/snd/hwC1D0
crw-rw---- 1 root audio 116, 56 Feb 21 17:12 /dev/snd/pcmC1D0c
crw-rw---- 1 root audio 116, 48 Feb 21 17:44 /dev/snd/pcmC1D0p
crw-rw---- 1 root audio 116, 49 Feb 21 17:12 /dev/snd/pcmC1D1p
crw-rw---- 1 root audio 116,  1 Feb 21 17:12 /dev/snd/seq
crw-rw---- 1 root audio 116, 33 Feb 21 17:12 /dev/snd/timer

/dev/snd/by-id:
total 0
drwxr-xr-x 2 root root  60 Feb 21 17:12 .
drwxr-xr-x 4 root root 220 Feb 21 17:12 ..
lrwxrwxrwx 1 root root  12 Feb 21 17:12 usb-Creative_Technology_Ltd_SB_X-Fi_Surround_5.1_Pro_000000BM-00 -> ../controlC1

/dev/snd/by-path:
total 0
drwxr-xr-x 2 root root  60 Feb 21 17:12 .
drwxr-xr-x 4 root root 220 Feb 21 17:12 ..
lrwxrwxrwx 1 root root  12 Feb 21 17:12 platform-3f980000.usb-usb-0:1.2:1.0 -> ../controlC1


!!Aplay/Arecord output
!!--------------------

APLAY

**** List of PLAYBACK Hardware Devices ****
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 1: USB Audio [USB Audio #1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

ARECORD

**** List of CAPTURE Hardware Devices ****
card 1: Pro [SB X-Fi Surround 5.1 Pro], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

!!Amixer output
!!-------------

!!-------Mixer controls for card Pro

Card hw:1 'Pro'/'Creative Technology Ltd SB X-Fi Surround 5.1 Pro at usb-3f980000.usb-1.2, full '
  Mixer name	: 'USB Mixer'
  Components	: 'USB041e:3263'
  Controls      : 3
  Simple ctrls  : 0


!!Alsactl output
!!--------------

--startcollapse--
state.Pro {
	control.1 {
		iface PCM
		name 'Playback Channel Map'
		value.0 0
		value.1 0
		comment {
			access read
			type INTEGER
			count 2
			range '0 - 36'
		}
	}
	control.2 {
		iface PCM
		device 1
		name 'Playback Channel Map'
		value.0 0
		value.1 0
		comment {
			access read
			type INTEGER
			count 2
			range '0 - 36'
		}
	}
	control.3 {
		iface PCM
		name 'Capture Channel Map'
		value.0 0
		value.1 0
		comment {
			access read
			type INTEGER
			count 2
			range '0 - 36'
		}
	}
}
--endcollapse--

Edit .asoundrc to specify a software mixer because this usb soundcard doesn't have one:

pcm.!default {
    type            plug
    slave.pcm       "softvol"   #make use of softvol
}

pcm.softvol {
    type            softvol
    slave {
        pcm        "dmix"      #redirect the output to dmix (instead of "hw:0,0")
    }
    control {
        name        "Master"       #override the PCM slider to set the softvol volume level globally
        card        1
    }
}

Install pulseaudio:

# apt install pulseaudio
# usermod -a -G pulse,pulse-access taglio

Cross compile armv7l binaries using a x86_64 workstation

Various options regarding toolchains to do cross compiling for obvious timing reasons and hardware performances of the little ARM device.

But you can ever build your personal toolchain using:

And you can use, if present, containers or virtual machines programmed by the software teams of every project that we need if they have released.

Why we need cross compile?

Because we want to follow the cutting edge speaking about ours radio ham programs. Because we want to use a lot of programs, some heavy, that aren't included into the package repository of RaspiOS. Because, at least but not last, time compile directly into the arm device is very long and resources are limited.

Install dependencies:

$ sudo apt install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev python3-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip patch libstdc++6 rsync git

Download with git, launch bootstrap script and configure. Also find a free partition in your disk pool and create a directory for staging files, in my case:

$ git clone https://github.com/crosstool-ng/crosstool-ng.git
...
$ cd crosstool-ng ; ./bootstrap
...
$ echo export RASTA="/media/taglio/BACK/raspi/x-tools" >> "${HOME}"/.bashrc ; source "${HOME}"/.profile
$ mkdir "${RASTA}" ; ./configure --prefix="${RASTA}"

Next make and make install:

$ make ; make install

Add /opt/crosstool-ng/bin to the PATH environment variable:

$ echo -e 'if [ -d "${RASTA}/bin" ] ; then
    PATH="${RASTA}/bin:$PATH"
fi
' >> "${HOME}"/.profile
$ source ~/.profile

Because of multiarch support the Debian installed in the ARM device got library in uncommon directories we've got to patch crosstool-ng doing some work. After some versions checks:

taglio@HAM-01-RASB:~ $ sudo apt install binutils-source
...
taglio@HAM-01-RASB:~ $ ls -l /usr/src/binutils/patches/
total 256
-rw-r--r-- 1 root root   972 mar  6  2021 001_ld_makefile_patch.patch
-rw-r--r-- 1 root root  1273 mar  6  2021 002_gprof_profile_arcs.patch
-rw-r--r-- 1 root root   539 mar  6  2021 003_gprof_see_also_monitor.patch
-rw-r--r-- 1 root root   505 mar  6  2021 006_better_file_error.patch
-rw-r--r-- 1 root root   622 mar  6  2021 013_bash_in_ld_testsuite.patch
-rw-r--r-- 1 root root   978 mar  6  2021 014_hash_style-both.patch
-rw-r--r-- 1 root root  1011 mar  6  2021 014_hash_style-gnu.patch
-rw-r--r-- 1 root root   625 mar  6  2021 127_x86_64_i386_biarch.patch
-rw-r--r-- 1 root root   989 mar  6  2021 128_build_id.patch
-rw-r--r-- 1 root root   546 mar  6  2021 128_ppc64_powerpc_biarch.patch
-rw-r--r-- 1 root root 10091 mar  6  2021 129_multiarch_libpath.patch
-rw-r--r-- 1 root root   579 mar  6  2021 130_gold_disable_testsuite_build.patch
-rw-r--r-- 1 root root  1404 mar  6  2021 131_ld_bootstrap_testsuite.patch
-rw-r--r-- 1 root root  2016 mar  6  2021 135_bfd_soversion.patch
-rw-r--r-- 1 root root   878 mar  6  2021 136_bfd_pic.patch
-rw-r--r-- 1 root root   391 mar  6  2021 157_ar_scripts_with_tilde.patch
-rw-r--r-- 1 root root  1141 mar  6  2021 158_ld_system_root.patch
-rw-r--r-- 1 root root   894 mar  6  2021 161_gold_dummy_zoption.diff
-rw-r--r-- 1 root root   599 mar  6  2021 164_ld_doc_remove_xref.diff
-rw-r--r-- 1 root root   673 mar  6  2021 aarch64-libpath.diff
-rw-r--r-- 1 root root   316 mar  6  2021 branch-no-development.diff
-rw-r--r-- 1 root root   139 mar  6  2021 branch-updates.diff
-rw-r--r-- 1 root root 18330 mar  6  2021 branch-version.diff
-rw-r--r-- 1 root root   816 mar  6  2021 gold-mips.diff
-rw-r--r-- 1 root root   422 mar  6  2021 gold-no-keep-files-mapped.diff
-rw-r--r-- 1 root root   375 mar  6  2021 gprof-build.diff
-rw-r--r-- 1 root root  4509 mar  6  2021 infinity-notes.diff
-rw-r--r-- 1 root root 17284 mar  6  2021 libctf-soname.diff
-rw-r--r-- 1 root root  2870 mar  6  2021 mips64-default-n64.diff
-rw-r--r-- 1 root root 17289 mar  6  2021 pgo+lto-1.diff
-rw-r--r-- 1 root root 38880 mar  6  2021 pgo+lto-2.diff
-rw-r--r-- 1 root root 17117 mar  6  2021 pgo+lto-3.diff
-rw-r--r-- 1 root root  1730 mar  6  2021 pgo+lto-check-ignore.diff
-rw-r--r-- 1 root root  5475 mar  6  2021 pr-ld-16428.diff
-rw-r--r-- 1 root root   842 mar  6  2021 series
taglio@HAM-01-RASB:~ $ uname -r ; uname -m
5.10.92-v8+
aarch64
taglio@HAM-01-RASB:~ $  ld --version | head -n 1; gcc --version | grep gcc; ldd --version | head -n 1
GNU ld (GNU Binutils for Debian) 2.35.2
gcc (Debian 10.2.1-6) 10.2.1 20210110
ldd (Debian GLIBC 2.31-13+rpt2+rpi1+deb11u2) 2.31
taglio@HAM-01-RASB:~ $ 

Next install on the ARM device the symlinksutility to convert absolute links (within the same filesystem) to relative links:

taglio@HAM-01-RASB:~ $ sudo apt install symlinks
...
taglio@HAM-01-RASB:~ $ sudo symlinks -rc /.
...
taglio@HAM-01-RASB:~ $

In the workstation set a global variable with the ARM binutils version:

$ echo export RASBU="2.35.2" >> "${HOME}"/.bashrc
$ source "${HOME}"/.bashrc

create some directory and download the patch:

$ sudo chown -R taglio:taglio "${RASTA}"
$ mkdir "${RASTA}"/src ; mkdir -p "${RASTA}"/patches/binutils/"${RASBU}"
$ cd "${RASTA}"/patches/binutils/"${RASBU}" ; scp ham-01-rasb.red.ama:/usr/src/binutils/patches/129_multiarch_libpath.patch ./
129_multiarch_libpath.patch                                                                                                                                                                                                                             100%   10KB   3.2MB/s   00:00    
taglio@trimurti:/media/taglio/BACK/raspi-staging/patches/binutils/2.35.2$ cd "${RASTA}"
taglio@trimurti:/media/taglio/BACK/raspi-staging$ 

Let initialize ct-ng:

$ ct-ng aarch64-rpi3-linux-gnu
  CONF  armv8-rpi3-linux-gnueabihf
#
# configuration written to .config
#

***********************************************************

Initially reported by: Stefan Hallas Mulvad <shm@hallas.nu>
URL: 

Comment:
crosstool-NG configuration for Raspberry Pi 3.

***********************************************************

Now configured for "armv8-rpi3-linux-gnueabihf"
$

Configure various options:

$ ct-ng menuconfig

Path and misc options:

Target options:

Toolchain options:

Operating system:

Binary utilities:

C-library:

C compiler:

Build the toolchain:

$ ct-ng build
...
[INFO ]  Finalizing the toolchain's directory: done in 5.83s (at 19:37)
[INFO ]  Build completed at 20220301.122948
[INFO ]  (elapsed: 19:37.30)
[INFO ]  Finishing installation (may take a few seconds)...
$

ALSA PCM capture to network

So what we want to obtain is the sound from a stash connected from the headphone jack to the line input jack, the blue one, transmitted to an IP network. We want to use X11 applications within an ssh remote session forwarding them and listen to them. To real scope of this document is build various radio ham remote stash, point of presence, and use the as we're directly interact with them.

Some application will work with audio servers and not directly with ALSA so we have to archive streaming over IP network for various scenario.

We decide to use ROC toolkit, because we've got different scenario and because we've found another radio operator that use it.

Install dependencies:

taglio@trimurti:~$  sudo apt install g++ scons ragel gengetopt

SCons is an interesting piece of software.

Clone the git repository of the project a set an environment variable:

taglio@trimurti:~/Sources/Git$ git clone https://github.com/roc-streaming/roc-toolkit.git
Cloning into 'roc-toolkit'...
remote: Enumerating objects: 16836, done.
remote: Counting objects: 100% (1189/1189), done.
remote: Compressing objects: 100% (797/797), done.
remote: Total 16836 (delta 501), reused 710 (delta 338), pack-reused 15647
Receiving objects: 100% (16836/16836), 5.71 MiB | 4.95 MiB/s, done.
Resolving deltas: 100% (11191/11191), done.
taglio@trimurti:~/Sources/Git$ export ROC_DIR="${HOME}/Sources/Git/roc-toolkit"

To cross compile ROC, the simplest way is use the toolchain virtualized in a docker container published as open source:

taglio@trimurti:~/Sources/Git$ sudo apt install docker.io 
taglio@trimurti:~/Sources/Git$ cd $ROC_DIR
taglio@trimurti:~/Sources/Git/roc-toolkit$ docker run -t --rm -u "${UID}" -v "${PWD}:${PWD}" -w "${PWD}" \
	rocproject/aarch64-linux-gnu\ 
	scons -Q --enable-pulseaudio-modules --host=aarch64-linux-gnu \
    --build-3rdparty=libuv,libunwind,openfec,alsa,pulseaudio:$(ssh ham-01-rasb.red.ama pulseaudio --version | cut -d ' ' -f2),sox,cpputest

Copy compiled binary to the raspberry host connected to the stash:

taglio@trimurti:~/Sources/Git/roc-toolkit/bin/aarch64-linux-gnu/$ ssh ham-01-rasb.red.ama mkdir -p Binaries/ROC
taglio@trimurti:~/Sources/Git/roc-toolkit/bin/aarch64-linux-gnu/$ scp * ham-01-rasb.red.ama:/home/taglio/Binaries/ROC/
libroc.so                            100%  484KB  10.5MB/s   00:00    
libroc.so.0                          100%  484KB  10.5MB/s   00:00    
libroc.so.0.1                        100%  484KB  10.6MB/s   00:00    
module-roc-sink-input.so             100%   20KB   5.5MB/s   00:00    
module-roc-sink.so                   100%   21KB   5.6MB/s   00:00    
roc-conv                             100%  802KB  10.8MB/s   00:00    
roc-example-receiver-sox             100%  249KB  10.3MB/s   00:00    
roc-example-sender-sinewave          100%   13KB   4.1MB/s   00:00    
roc-recv                             100% 1107KB  10.9MB/s   00:00    
roc-send                             100% 1079KB  10.9MB/s   00:00    
roc-test-address                     100%  658KB  10.9MB/s   00:00    
roc-test-audio                       100%  985KB  10.9MB/s   00:00    
roc-test-core                        100%  698KB  10.8MB/s   00:00    
roc-test-fec                         100% 1120KB  10.9MB/s   00:00    
roc-test-lib                         100%  682KB  10.9MB/s   00:00    
roc-test-netio                       100%  714KB  10.9MB/s   00:00    
roc-test-packet                      100%  803KB  10.8MB/s   00:00    
roc-test-pipeline                    100% 1162KB  11.0MB/s   00:00    
roc-test-rtp                         100%  847KB  10.9MB/s   00:00    
roc-test-sndio                       100%  896KB  10.9MB/s   00:00    
taglio@trimurti:~/Sources/Git/roc-toolkit/bin/arm-linux-gnueabihf$ 

Login into the HAM-01 remote stash device, that is my hostname, and copy binaries and launch ldconfig:

taglio@HAM-01-RASB:~/Binaries/ROC $ sudo cp roc-{recv,send,conv} /usr/bin/
taglio@HAM-01-RASB:~/Binaries/ROC $ sudo cp libroc.so* /usr/lib
taglio@HAM-01-RASB:~/Binaries/ROC $ sudo cp module-roc-{sink,sink-input}.so /usr/lib/pulse-14.2/modules/
taglio@HAM-01-RASB:~/Binaries/ROC $ sudo ldconfig

Now what we've first to configure is the receiving pulseaudio module in the workstation, so we've got to configure and install ROC into it:

taglio@trimurti:~/Sources/Git/roc-toolkit$ sudo apt install g++ pkg-config scons ragel gengetopt     libuv1-dev libunwind-dev libpulse-dev libsox-dev libcpputest-dev
...
taglio@trimurti:~/Sources/Git/roc-toolkit$ sudo apt install libtool intltool autoconf automake make cmake
...
taglio@trimurti:~/Sources/Git/roc-toolkit$

Next build it directly:

taglio@trimurti:~/Sources/Git/roc-toolkit$ scons -Q --build-3rdparty=openfec
...
taglio@trimurti:~/Sources/Git/roc-toolkit$ sudo scons -Q --build-3rdparty=openfec install
  INSTALL   /usr/include/roc
  INSTALL   /usr/lib/x86_64-linux-gnu/libroc.so.0.1
  INSTALL   /usr/lib/x86_64-linux-gnu/libroc.so.0
  INSTALL   /usr/lib/x86_64-linux-gnu/libroc.so
  INSTALL   /usr/bin/roc-conv
  INSTALL   /usr/bin/roc-recv
  INSTALL   /usr/bin/roc-send
taglio@trimurti:~/Sources/Git/roc-toolkit$ 

Remote radioham stash, QSL software.

A nice software list to use in remote X forwarding by ssh will be:

Despite others tutorials that use the ARM device to compile all those stuff, we will do it in our workstation for the same reasons than above. Next we will upload to the devices and running onto them.

Another time we speak about cross compiling. We speak about fast compile time and a single workstation to do it; in my toughs there is "remote stash as a service", many point of presences. Compile have to be centralized.

Let's do it with the crosstool-NG that we've got prepared.

Hackrf one

Bus 001 Device 003: ID 1d50:6089 OpenMoko, Inc. Great Scott Gadgets HackRF One SDR
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x1d50 OpenMoko, Inc.
  idProduct          0x6089 Great Scott Gadgets HackRF One SDR
  bcdDevice            1.02
  iManufacturer           1 Great Scott Gadgets
  iProduct                2 HackRF One
  iSerial                 4 0000000000000000088869dc35694c1b
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0020
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          3 Transceiver
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              500mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass    255 Vendor Specific Subclass
      bInterfaceProtocol    255 Vendor Specific Protocol
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
can't get debug descriptor: Resource temporarily unavailable
cannot read device status, Resource temporarily unavailable (11)

sudo apt install hackrf soapysdr-module-hackrf

Download from mossmann hackrf github the latest release.

pi@IOT-02-RASB:~/hackrf-2021.03.1 $ hackrf_info
hackrf_info version: unknown
libhackrf version: unknown (0.5)
Found HackRF
Index: 0
Serial number: 0000000000000000088869dc35694c1b
Board ID Number: 2 (HackRF One)
Firmware Version: 2018.01.1 (API:1.02)
Part ID Number: 0xa000cb3c 0x00614764
pi@IOT-02-RASB:~/hackrf-2021.03.1 $ 

Update the firmware:

root@IOT-02-RASB:/home/pi/hackrf-2021.03.1/firmware-bin# hackrf_spiflash -w hackrf_one_usb.bin
File size 35444 bytes.
Erasing SPI flash.
Writing 35444 bytes at 0x000000.
root@IOT-02-RASB:/home/pi/hackrf-2021.03.1/firmware-bin# 

Update the CPLD:

root@IOT-02-RASB:/home/pi/hackrf-2021.03.1# hackrf_cpldjtag -x firmware/cpld/sgpio_if/default.xsvf
File size 37629 bytes.
LED1/2/3 blinking means CPLD program success.
LED3/RED steady means error.
Wait message 'Write finished' or in case of LED3/RED steady, Power OFF/Disconnect the HackRF.
Write finished.
Please Power OFF/Disconnect the HackRF.
root@IOT-02-RASB:/home/pi/hackrf-2021.03.1#

Soapy remote

Use instructions that you can find into the github.

root@IOT-02-RASB:/home/pi/hackrf-2021.03.1# apt install soapyserver soapysdr-module-hackrf
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  python-colorzero
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
  soapyremote-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 57.4 kB of archives.
After this operation, 171 kB of additional disk space will be used.
Get:1 http://mirrors.ircam.fr/pub/raspbian/raspbian buster/main armhf soapyremote-server armhf 0.4.3-1 [57.4 kB]
Fetched 57.4 kB in 1s (49.0 kB/s)          
Selecting previously unselected package soapyremote-server.
(Reading database ... 40387 files and directories currently installed.)
Preparing to unpack .../soapyremote-server_0.4.3-1_armhf.deb ...
Unpacking soapyremote-server (0.4.3-1) ...
Setting up soapyremote-server (0.4.3-1) ...
Created symlink /etc/systemd/system/SoapySDRServer.service → /lib/systemd/system/soapyremote-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/soapyremote-server.service → /lib/systemd/system/soapyremote-server.service.
Processing triggers for man-db (2.8.5-2) ...
root@IOT-02-RASB:/home/pi/hackrf-2021.03.1#

Connect using CubicSDR or others that support the Soapy server protocol.

Skywave Linux

To got a good work environment with all the libraries necessary and all the tools installed, I prefer using a Linux distribution dedicated to radio ham. My choose is:

This distribution doesn't got the need to be installed and with qemu or virtualbox we can run it without any problem. It use the i3 tiling window manager, you've got to understand how does it work, but it rocks!

Similar projects

About

Guide to configure rasberry pi, hackrf one and soapy sdr to control the device remotely.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages