logo
Jiff Slater
🤔 About
✍️ Contact
📚Knowledge
28 Jul 2021
 

Quickly gathering pulseaudio diagnostics
2 July 2021

Recently while using KDE Neon I found pulseaudio constantly crashing and relaunching during Zoom calls.  Unfortunately, in most instances this meant the audio stream was lost and I had to refresh the tab, interrupting my meeting.

To resolve this I had to turn on better logging for pulseaudio.  This is pretty simple to do with systemd as it’s managing a user instance of pulseaudio.  First, check the ExecStart line of the existing service.

systemctl --user cat pulseaudio.service

ExecStart=/usr/bin/pulseaudio --daemonize=no --log-target=journal

Add the new ExecStart line in an override file.  The first ExecStart is to reset the variable.

systemctl --user edit pulseaudio.service

ExecStart=

ExecStart=/usr/bin/pulseaudio --daemonize=no --log-target=journal --log-level=info

Check the logs using journalctl next time the crash happens.

journalctl --user --reverse --unit=pulseaudio.service

I found the following line that I think was causing the problem

Jul 02 09:26:02 light pulseaudio[27653]: Source alsa_input.usb-AKM_AK5371-00.analog-stereo idle for too long, suspending ...

To resolve this I commented the suspend on idle plugin in /etc/pulse/default.pa

# load-module module-suspend-on-idle

This resolved the issue. I emptied out the override file to stop the extra logging from happening.

Update on this blog
29 June 2021

Over the next four weeks, I’m going to be merging all my blog posts together on this single site.  I’ll also be moving away from WordPress to a static site generated primarily from reStructedText files.  This’ll free up this additional server and let me safely store all my information in a single git repository.

For the most part, the only visible change will be the additional posts available for viewing on this site.

Stay tuned!

Mounting a local directory in a qemu/kvm virtual machine
28 January 2021

I usually try to run my virtual machines using my existing kernel and this means that any modules I use I have to mount them within the virtual machine. I usually use the 9p mount to achieve this but in some scenarios it’s easier to use the virtual vfat mount type in KVM/QEMU.

With the 9p mount, you can use.

qemu_system_x86_64 -fsdev local,path=/directory,security-model=mapped-xattr,id=9p,readonly -device virtio-9p-pci,mount_tag=9p

And mount it locally with

mount -t 9p -o trans=virtio 9p /guest/directory

You can also use the virtual FAT filesystem.

qemu_system_x86_64 -file=fat:ro:/directory,id=vfat,format=raw,if=none -device usb-storage,drive=vfat

Flashing Mobian to the eMMC from within the PinePhone
17 January 2021

Getting Mobian onto the PinePhone is manageable but the given instructions don’t seem to work on my device. I had to apply to the following patch to get the Python installer to flash succesfully.

Log into the PinePhone over SSH (or use the phone itself, you savage :P).

Download the installer from https://salsa.debian.org/Mobian-team/mobian-installer/-/blob/master/mobian_installer.py

Make the following changes before executing:

  • Remove the references to libparted and py and reference the system libraries instead with import parted and import py.
  • In L307, replace logfn = os.path.join(os.environ["USER_PWD"], "mobian_installer.log") with logfn = os.path.join("/home/mobian", "mobian_installer.log")
Searching and executing for only a set of specific file types by extension
16 January 2021

I recently needed to copy a bunch of videos over a slow performing network and hard disk and didn’t want to copy over extraenous files. I used a combination of rsync and find to make sure that only the files I needed were executed and played.

Sending files over
$ rsync -rv ./ --filter "+ */" --filter "+ *.mp4" --filter "+ *.mkv" --filter "- *" user@host:./

Executing (playing) the files
$ find . -type f -name "*.mkv" -print0 -or -name "*.mp4" -print0 | sort -Rz | xargs -0 -n1 omxplayer -r -o hdmi

Quick break down of the commands.

The -print0 && -0 uses GNU extensions to tell both find and xargs to ignore whitespace and only start a new iteration when there’s a null character (‘\0’). The sort command randomises the output and reads line by line using nul termination ('z'). xargs -n1 means to pass the arguments line by line to the following command.

Scheduling a shutdown with systemd

Occasionally, you’ll make a change in Linux that might be a bit precarious – you commit the change with a hesitation anticipation of a problem or uncertainty on the next reboot. In these cases, it may be desirable to schedule a shutdown if nothing is done within a certain time period.

I do this frequently when I’m testing changes to a Raspberry Pi that doesn’t have an off button. This reduces the likelihood that I need to turn off the device by removing power (a problematic shut-off method that can cause problems with the SD card).

If systemd is available, you can create a new timer that executes after a set amount of time.

We’ll create a systemd unit that executes after the multi-user target has completed.

Create a small script to trigger the auto-reboot.

/usr/local/bin/auto-poweroff.sh
#!/bin/bash
/usr/bin/sleep 60
/sbin/poweroff

/etc/systemd/system/auto-poweroff.service
[Unit]
Description="Automatically power off after a period of time."
Type=oneshot
IgnoreOnIsolate=yes
After=ssh.service

[Service]
ExecStart=/usr/local/bin/auto-poweroff.sh

[Install]
WantedBy=multi-user.target

Finally create the symlink into the multi-user.target directory.

cd /etc/systemd/system/multi-user.target.wants/
ln -s ../auto-poweroff.sh

Manually setting up host only networking with QEMU guest
15 January 2021

By default QEMU makes it very easy to connect a virtual machine to the Internet using the user mode network with -netdev user. However, I’m using a custom configuration that connects my virtual machines to a pfsense instance so I needed to add an extra bridge for host to guest communication.

You can create a local bridge and tap pair on the host by using the iproute2 set of tools.

# ip link add dev bridge00 type bridge
# ip tuntap add tap00 mode tap user $USER group kvm
# ip link set tap00 master bridge00
# ip link set dev bridge00 up
# ip link set dev tap00 up

Now for most use cases, there’s no need to set up some fancy DHCP server on the host to serve a single client so I configure a simple static configuration and add that associated configuration in the guest’s equivalent to rc.local.

(host) # ip addr add 192.168.123.1/24 broadcast 192.168.123.255 dev bridge00

Inside the guest you can give yourself a static IP and communicate to the host like so.

(guest) # ip addr add 192.168.123.2/24 dev ens1

Finally, UP the interface in the guest.

# ip link set dev ens1 up

Now you should be able to SSH or ping the guest on this private network with the virtual machine.

Dynasty by Wedgewood – glass piece in House of Cards
11 October 2020

A bit of an unusual post for me – I was rather fascinated by the sets in House of Cards and really wanted to find which wine glass the Underwood’s used at their dining table.  After a lot of searching it seems it’s the Dynasty pattern by Wedgewood.  An antique piece that seems to be available on Replacements.com.

 

General knowledge and concepts for high-level discussions
22 August 2020

I’ve moved further additions to this page to my /knowledge page.

When discussing complicated topics it can be helpful to have a unified pool of knowledge.  Below is a list of things I try to keep in my conceptual model of the world so I can have fruitful discussions with my peers.

Mathematics

  • Probability distributions and cumulative distribution functions

Sciences

  • Critical exponents near phase transitions: the universal behaviour of physical quantities near continuous phase transitions.
  • Prosaic AI when we reach AGI
    • The idea that we’ll build an AI that doesn’t reveal anything new about humankind or the world.  Similar to the idea of transformative AI.
  • Re-inforcement learning
  • Local hidden variable theory
  • Chaos and non-chaos
    • Dis-order free, localisation
Pinebook Pro Review
13 February 2020

Pinebook Pro Review

Short summary: if you’re on the fence about buying the Pinebook Pro as a supplementary laptop for short trips where extreme performance is not necessary, you’d be hard pressed to find a better option for $200.

I’ve been using the Pinebook Pro regularly as my daily driver for the past couple of weeks and wanted to note down some thoughts. But first, specs of the device:

  • [Compute] Rockchip RK3399 SOC with Mali T860 MP4 GPU.
    • Rockchip contains a dual-core Cortex-A72 and quad-core Cortex-A53 in big.LITTLE configuration.
    • Surprisingly this SOC supports hardware virtualisation.
    • It also supports AArch32/AArch64 with backwards compatibility with Armv7.
    • The RK3399 can handle H.264/H.265/VP9 up to 4Kx2K@60fps which is pretty incredible for such a low power chip.
    • Finally, the embedded GPU can support DX11.1 and OpenGL ES/3.1.
  • [Memory] 4GB Low Power DDR4 RAM.
  • [Display] 14.1” 1080p 60Hz IPS display panel
  • [Power] 10,000mAh LiPo battery with USB-C 15W power delivery support and additional power port (5V 3A).
  • [Storage] 64GB eMMC 5.0, bootable microSD card slot.
  • [Connectivity] WiFi 802.11ac and BT 5.0.
  • [Audio] Stereo speakers, headphone jack, and single microphone.
  • [Camera] Single 1080p/2MP front facing camera in display.
  • [Input] Trackpad and ANSI keyboard.
  • [Boot] 128MB SPI boot flash
  • [I/O] 1 USB type C host controller with DisplayPort 1.2 and Power Delivery; 1 USB Type-C port; 1 USB 3.0 port; 1 USB 2.0 port.

Keyboard

The keyboard is of average quality. I’m using the ANSI version. The keys feel mushy on the way down but have quite a bit of spring back allowing you to type reasonably fast. In a typing test between this device and my Macbook Pro 2018, I found myself to type about 5 to 10 WPM faster on average on the Pinebook Pro. The position of the trackpad means that sometimes you’ll inadvertently move your fingers and trigger mouse movement – which sometimes results in your words being scrambled. Turning off the trackpad when an external mouse is connected can help to resolve this issue. There’s no backlighting on the keys.

Unlike the Macbook Pro, I didn’t experience any issues with repeating keys unless I had the repeat delay set low and the repeat rate set high.

Trackpad

The trackpad is a bit small given the available space on the frame. Precision is poor unless you’re making long swipes across the trackpad. Small, minor adjustments are difficult to position so I’d recommend you set the sensitivity low. I expect there to be iterative updates here to the trackpad firmware that will improve the readings.

Build quality of the case

The PBP comes in a hard metal frame. It’s cool to the touch when the device is off and has a beautiful matte black colour. I have no concerns throwing this device in my backpack or upon a desk as the frame seems very capable of protecting the RockChip innards.

If I had a choice of this frame and a durable plastic one, I’d choose the plastic one for an even lighter laptop.

Performance

The big question about this laptop: the performance. I found that I could comfortably watch 720p videos on YouTube and 480p streams on Twitch with live chat visible. The machine seemed also capable of having two streams side-by-side with occassional, but manageable stuttering on each.

By default the performance settings on Firefox is set to use 8 threads which I think is set a bit high considering that there’s only two BIG CPUs. Switching between 2 and 8 doesn’t seem to change the performance. I use a mixture of uBlock Origin and uBlock Matrix to reduce the amount of scripts running in each tab – again, this only seems to affect the initial page load speed – after the webapp is running I didn’t notice a performance difference.

I haven’t tried running any games on this device and don’t plan to – that’s what my Nintendo Switch is for!

Finally, I noticed some high pitched whining when the device was under load. Usually opening a web browser causes this whine. It’s pretty annoying and something that I hope can be fixed in due time.

Audio

The audio quality is passable and has little distortion across the volume range. I would say it’s good enough to understand a movie but not enough to enjoy a movie. Stick to headphones!

Overall

I’d recommend the Pinebook Pro as a great travel laptop if you primarily work in DevOps or live in the command line. It doesn’t grind to a halt under load – it simply slows down and I think you’ll get used to the reduced speed rather quickly.

I think this laptop’s ideal purpose is to serve as a realistic representation of what 99% of your users experience when they use your webapp. Keep it on your desk as a second laptop for testing performance improvements you’re making.

As a representation of the state of Linux on ARM, you can’t go wrong with this laptop.  It’s battery life is an solid 10 to 12 hours.  Suspend isn’t as power performant as on the Macbook so you’ll be shutting down this machine when you’re not using it.

For the hackers and tinkerers inside all of us, you’d be surprised at how easily you can get up and running.  Just download an image, flash to a USB stick or SD card, insert it into the machine, and boot up.  Run through a 5 minute installation and you’ll have a fresh installation very quickly.  However, be warned that if you have a more esteroic setup (and I mean that from a Linux on ARM perspective), such as LUKS on LVM or custom peripherals you need to get working — you’ll be spending a few days wrapping your head around compiling a custom kernel, getting the initial ramdisk built with all the required modules, and dealing with the quirks (i.e. the separate bootloader partition before the EFI partition).

The PBP wiki has a very thorough guide on the internals of the machine and I think with enough time you can enable any scenario on this device.  The forums are teeming with information and you’ll be entering the space with quite a bit of SME that can give you tips on using the machine.

Buy this machine.

Built with Wordpress and Vim
© 2008 to 2021 Jiff Slater