mameau%CWD%:> █
OFFLINE
$ cat article_0x08.txt
Testing a RPI as daily driver desktop (2020-12)       version 0x08 -- @sairukau

       Replacing a dead i7 2600K / Radeon RX580 / 16GB DDR3 temporarily

===============================================================================
Changelog
===============================================================================
v0x08  Attempted an updated to 5.10.2 see rpi-update section
       Displays boot in the alternate ports OK now
       Compiled OBS for a laugh
       Compiled syncterm to get back to L.O.R.D again
v0x07  Devilutionx 1.1.0 has an arm7l build, happy days
       Compiled ezquake, not yet happy days
       Mini-HDMI to VGA adapters arrived see hardware section
       Added some clarifying notes to Expected use cases
       Have ordered a powered usb hub to run the keyboard/mouse and webcam to
       free up onboard ports
       Tried out some openarena, grabbed some basic fps numbers
v0x06  Upgraded to kernel 5.10 then rolled back to 5.4, see rpi-update section
       Compiled retroarch for testing
v0x05  Tested out chiaki (PS4 remote play)
       Gave up on thunderbird and went back to mutt
v0x04  Fleshed out social media approach, primarily use bitlbee w/irssi already
       Compiled ckb-next and disabled keyboard rgb
       Figured out support for Mute/Volup/VolDown media keys
       Looking into IDEs normally use vim but was investigating vscodium when 
       the i7 bit it and vscodium has an arm deb available, wow
       Tested minetest and doco'd some FPS notes
v0x03  Remove firefox-esr and use chromium-browser
       browserpass extension for chromium-browser
       profile manager wrapper for chromium
       chromium-browser settings info listed
       Logitech C910 webcam tested
       found media keys aren't working on keyboard
v0x02  Connected up Bose QC35s through BT
       Applied fix for 3.5mm jack output with 2 HDMI displays
       Added speaker and sd card info
       Confirmed lightdm display config carries through to xfce session
       Fixed typo for pinentry (probably more)
v0x01  Initial Publication

===============================================================================
Expected Use cases
===============================================================================
- System administration
  - ssh (terminal)
  - remote desktop (remmina)
  - vnc (remmina)
- Developement work
  - python
  - bash
  - compiling (probably do this on vm now)
- Web browsing using Firefox (yes i was a FF user)
  - depends web browser
- Chat
  - IRC (irssi)
  - Gajim 
  - Skype
  - Hangouts
- Social Media
  - depends web browser and/or bitlbee
  - discord, no arm app (so see line above)
- Watching Streaming service: youtube, twitch
  - depends web browser
- NFS mount remote fs through automount
- Local s/hdd media from dock
  - performs OK, nothing much to report here
- Gaming
  - not sure how far we'll push this, considr it light-gaming
  - might consider steamlink to a remote machine (doesn't exist yet)
- Wine applications
  - might have to offload to a remote (pre-existing) windows VM

Note: while I have other systems I could have imaged another OS from, that
wasn't really the point of this exercise. Just decided to see how we went with
the shipped product

===============================================================================
Hardware (was Setup)
===============================================================================
RPI4 
 - 4G Model

xDual Head on HDMI (Shipped adapters)x
 - text is unreadable on displays
 - ignored edid in config.txt to get second screen up at 1920x1080
 - NOTE: no longer HDMI see Dual Head on VGA

Dual Head on VGA
 - replaced Dual Head on HDMI
 - Using UGREEN active micro hdmi to vga adapters

Corsair Keyboard/Mouse (RGB :/)
 - USB Keyboard
 - USB Mouse

Shintaro (powered) USB HDD Dock

4x USBs consumed
 - 2x USB 2.0 k/m
 - 2x USB 3.0 hdd/webcam

Ethernet

Bose Quiet Comfort 35 over Bluetooth

2x 32" FullHD (cheap) TVs
 - 1x Sanyo (Native: 1920x1080_60)
 - 1x Dick Smith (Native: 1360x768)

External Logitec speaker set 1sub+2t 3.5mm jack

32GB SD Card (shipped with RPi)
 - don't know what class when I remove the sd card next I'll make a note

Noobs (shipped with RPi)
 - Raspbian OS (Full)

===============================================================================
Changes
===============================================================================
OS Changes
- Install python3 and set as default
- Install ansible

The rest is deployed through ansible (locally)

Window Manager
- XFCE
- menulibre

Software
 $HOME/devel/ansible/raspbian/packages.yaml

===============================================================================
Migration
===============================================================================
I am looking to migrate from a dead i7 2600K setup temporarily so i'm only 
going to bring across some previous settings from my old environment

- Ansible playbooks
  - no issue
- XFCE
  - no issues
- Firefox
  - see Usage section
- Thunderbird
  - see Usage section
- SSH
  - no issues
- GNUPG
  - see Configuration section
- pass password store
  - see gnupg
- gajim
  - no issues
- social media and chat
  - a lot of networks are integrated with irssi using bitlbee
    - twitter, skype, steam, hangouts, discord, mastadon
  - any others can be used in chromium-browser (ff-esr lagged out)
- Automounts NFS
  - migrated configuration without issue
  - mounts to NAS are up

===============================================================================
Usage
===============================================================================
Keyboard/Mouse
 Intermittent issues on reboot enumerating the USB devices leaves then
 non-working in the OS works find in recovery mode though. Have to reinsert the
 devices a few times on occasion. Seems to only on a cold boot
 
 the ckb-next software isn't available in the raspbian repo so i'm stuck with
 idiotic rgb until i see if i can get that build for raspbian
 
 ckb-next: https://github.com/ckb-next/ckb-next/wiki/Linux-Installation

 ckb-next compiled without issue following the standard debian instructions
 Installed, migrated over settings and started ckb ... no issues

 media keys don't work

 - Created custom wrapper for patcl
 - Added custom keyboard shortcuts for 
   - XF86AudioLowerVolume
   - XF86AudioRaiseVolume
   - XF86AudioMute

 Noted the pulse plugin applet is laggy

Screens
 RPI will only boot with screens configured as
 - HDMI-1 Dick Smitch
 - HDMI-2 Sanyo

HDMI
 Text is horrible to read over HDMI on these screens, i knew this going in after
 experimenting on my HTPC years ago. Normally i run VGA on these screens and
 tweak the Modelines
 
 Have purchased some UGREEN Active MicroHDMI to VGA adapters to test

 Have been replaced HDMI with URGREEN Adapter

HDMI to VGA Adapters
 It has been a long existing problem that my TVs as monitors solution results
 in unreadable text, on the old system I was converting DP to VGA on this new
 system i had no choice but to use HDMI while I was waiting for some adapters
 to arrive.

 The adapter I have now are UGREEN branded micro hdmi to vga adapters

 They are externally powered through USB (optional) and do as they say. Both
 screens are up @1920x1080 60hz with the pre-existing configuration

 Some items of note
  - Enable hdmi_boost=4 in the config.txt
  - Blacks seem washed out without reconfiguring the displays, but in fairness
    this may have been a pre-existing problem.
  - Some potential lag introduced, still testing this
    - If it actually is it seems relatively stable so I should be able to
      adjust to it easily enough
    - I dont have tools to test this, so it'll be a subjective measure
  - Text is crystal clear (as expected), which was the goal

Default Performance
 Desktop
 - Laggy and almost unusable with 2 displays
 - Nothing is accelerated by default
 Web Browsing
 - Comes with chromium, i cannot migrate my setup to chromium from FF
 - Turns out firefox-esr wouldn't import profiles
 Audio
 - Doesn't work through 3.5mm jack (raspi-config), HDMI audio OK
 
 Firefox
 This is an absolutely horrible experience, firefox-esr is available this is 
 based on (currently) Firefox 78. Video playback is non-functional, audio cuts 
 out, sites do not function. 

 So for some key complaints
 - Sites display in the mobile version, can be fixed with a custom UA
 - Amazon.com does not function on this older browser, can be fixed with a custom UA
 - Audio works then cuts out and I haven't found a way to restore
 - Video playback never starts on youtube but did on twitch
 - Migrating profile across from the desktop release is impossible because the
   version is too old all profiles needed to be recreated

 ** ended up removing firefox-esr all together
 
 Chromium
 This is not a browser i'm used too and I can't import my profiles across easily
 atm but it seems to function OK in general compared with Firefox so its
 probably a preferable option in the long run

 Thunderbird
 - Seems to perform horribly but would not find my existing settings so I need
   to revisit this
 - Using imap anyway so i may return to Mutt as my daiy driver
 - Gave up on this, it wouldn't import the existing profiles and I have better
   things to do

 VLC
 - Can playback twitch/youtube streams
 - Consumes a ridiculous amount of CPU decoding (even hardware accellerated in
   theory)

 Storage performance
 This is over USB 3.0, I haven't completed any specific tests but it seems
 reasonable enough for general use.

 Network Performance
 Works well enough need to do some specific tests, speedtest results are
 comparable to my desktop results

  $ speedtest-cli --simple
  Ping: 16.382 ms
  Download: 273.90 Mbit/s
  Upload: 41.90 Mbit/s

Development
 Normally use vim for developerment in general but I had started to look into
 transitioning to codium the unbranded port. So to pickup where I left off ...

 vscodium is actually build for armhf which will run on the pi4, this was
 suprising to say the least. performance seems OK generally but I'm not doing
 too much with it yet

 get the latest armhf deb build from 
 https://github.com/VSCodium/vscodium/releases/latest

 # dpkg -i 

===============================================================================
Customisations
===============================================================================
HDMI
 This is really specific to my setup being the screens are both different but I
 am ignoring the EDID of the displays to get them both up on 1920x1080.

 # vi /boot/config.txt

 add this line, nfi what the 0xa5000080 represents for this setting atm

 hdmi_ignore_edid=0xa5000080

 Both displays come up at 1920x1080 after this without additional modelines

 The displays based on the boot issue are mapped incorrectly so I run the
 following to correct it.

 $ xrandr --output HDMI-2 --primary --left-of HDMI-1

 NB: .xprofile does not run atm so putting it there makes no difference
 NB: this is no longer an issue with hdmi_boost on

 You can work around this issue but configuring script that lightdm runs at
 startup once the screens are configured it carries through the xfce

 # vi /etc/lightdm/lightdm.conf
 display-setup-script=

Window Manager
 I wanted to use XFCE not LXDE so had to configure lightdm to run the session.
 I know you can configure lightdm to allow user selection but that isn't
 necessary in this case

 # vi /etc/lightdm/lightdm.conf

 set the following

 session-wrapper=xfce4-session

 Use display-setup-script to setup your screens through xrandr see
 Customisations -> HDMI.

Python 3
 Replaced python2 with python3 ... time to catch up

 # apt-get install python3
 # update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
 # update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
 # update-alternatives --config python

Audio
 3.5mm jack output fixed by applying a custom udev ruleset from
 - https://ubuntu-mate.community/t/3-5mm-audio-output-not-working-on-rpi4-with-20-04/22456/7 

 # vi /etc/udev/rules.d/79-rpi-pulseadio-fixes.rules

 Rule content
  SUBSYSTEM!="sound*", GOTO="end"
  ACTION!="change", GOTO="end"
  KERNEL!="card*", GOTO="end"
  
  # remove the 'internal' sound form factor, so more descriptive
  # names are used in pulseaudio for bcm... entries
  ENV{SOUND_FORM_FACTOR}=="internal", ENV{SOUND_FORM_FACTOR}=""
  
  # uncomment to ignore audio sink on HDMI1, even if present, so that
  # headphones + HDMI0 audio will work in pulseaudio - temporary workaround
  ATTRS{id}=="b2", ENV{PULSE_IGNORE}="1"
  
  LABEL="end"

 Then enter the mixer and turn on Analog Mono Output for bcm2835 Headphones

 Not sure why its mono, perhaps its a limitation of the jack.

Removed the default pi user

===============================================================================
Accelation
===============================================================================
Configuring Accelartion
 There is only the fake kms driver available and i'm not particularly across
 the vulkan support etc that is supposed to be coming, the rpi foundation 
 really doesn't seem to give a crap about real desktop performance on this 
 device because all the effort seems to be one man shows and not a roadmapped
 effort.

 This setup isn't terrible and make a distinct different to performance once
 completed.

 These references aren't exactly what i had to do but lets run with it and I'll
 doco my stuff thereafter, e.g. dont enable 4k support.

 References:
 - https://www.dedoimedo.com/computers/rpi4-ubuntu-mate-hw-video-acceleration.html 

 Setup acceleration
 # vi /boot/config.txt

 Add the following

 ## 4k support
 #hdmi_enable_4kp60=1

 ## fake kms
 dtoverlay=vc4-fkms-v3d 
 #dtoverlay=vc4-fkms-v3d-pi4
 ## real kms need to test
 #dtoverlay=vc4-kms-v3d
 #dtoverlay=vc4-kms-v3d-pi4

 # nfi need to look into it
 max_framebuffers=2

 # memory for GPU, 512 was crap
 gpu_mem=128
  
 Reboot and test

 # cat /proc/device-tree/soc/firmwarekms@7e600000/status
 # cat /proc/device-tree/v3dbus/v3d@7ec04000/status

 both should return "okay"


Configure acceleration in Applications
 Firefox
  about:config
  layers.acceleration.force-enabled -> true
 Chromium
  chrome://flags
  Override software rending list -> Enabled
 VLC
  Tools -> Preferences -> Video -> OpenGL video output
  NB: i'm not convinced the fkms driver actually offloads this I was seeing 400%
  CPU usage on twitch streams in top which is 100% usage on every core


===============================================================================
Post Acceleration Performance - fkms (fake kms)
===============================================================================
Firefox
 Video playback starts on youtube and twitch but hdmi audio cuts out pretty
 quickly

Chromium
 Video playback is near perfect on both platforms
 Amazon works

VLC
 As per the accelation config section, i'm not convinced the fkms achieves
 anything of note here

Gaming
 See dedicated section 

===============================================================================
Configuration
===============================================================================
gpg-agent (for pass)
 the configured pinentry program wasn't available on the rpi this presented as
 a "no secret key available" error which is shiteful but a list-secret-keys
 showed the key for decryption was available and could be confirmed by checking
 the ~/.password-store/.gpg-id entry

 Was gnome3, now gtk2
 
 $ vi ~/.gnupg/gpg-agent.conf
 pinentry-program /usr/bin/pinentry-gtk-2
 $ gpg-agent kill-agent bye

 or

 update-alternatives --config pinentry


bluetooth
 no applet available, not the end of the world but annoying from a desktop
 perspective

 # apt-get install blueman pulseaudio-module-bluetooth
 $ pactl load-module module-bluetooth-discover
 $ mkdir ~/.config/autostart
 $ ln -s /usr/bin/blueman-applet ~/.config/autostart/
 # service restart bluetooth

remmina
 Migrated settings without issue
 Performance seems on par with what I remember on the desktop OS (rdp)

===============================================================================
Replace firefox(-esr) with chromium-browser
===============================================================================
As a longtime firefox user this is a fair undertaking, need 
 - multiple profiles
 - pass intergration
 - proxy support
 - DOH support

chromium-browser
 integration with pass needs
 - browserpass ext
 - browserpass native messager (not available for arm 32b)

pass integration (browserpass extension)
 - install golang
   
 # apt-get install golang

 - add arm compilation support: https://github.com/sairuk/browserpass-native

 $ git clone https://github.com/sairuk/browserpass-native.git
 $ make browserpass-arm
 $ make BIN=browserpass-arm configure
 $ sudo make BIN=browserpass-arm install

 - add the extension in chromium

Multiple Profiles
 mimic firefox's profile screen
 will be handled at launch with custom profile browser written in tk

 will leverage --user-data-dir=DIR optiona

 profiles are now handled by a custom wrapper chromium-profile (bash/zenity)

Proxy support
 must be handled on launch by the command line
 see external multiple profiles solution

 e.g. --proxy-server=socks5://127.0.0.1:9050

DOH Support
  Needs to be configured via "Secure DNS Lookups"
  chrome://flags/#dns-over-https

  Doesn't work like firefox, still uses OS DNS anyway upgrades if recognized

General settings

 Some notes for myself where settings are when as opposed to FF

 chrome://settings

 Start-up
 - Browser to a specific page -> per Profile

 Sync and Google service
 Other Google services
 - Allow Chromium sign-in  -> Off

 Search Engine
 - Search engine used in the address bar -> DuckDuckGo

 Passwords 
 - Offer to save passwords -> Off
 - Auto Sign-in            -> Off

 Security
 - Safe browsing           -> Standard Protection

 Cookes and other site data
 - Block third-part cookies                           -> On
 - Send a 'Do Not Track' request                      -> On
 - Clear cookes and site data when you quite Chromium -> per Profile

===============================================================================
Gaming
===============================================================================
Not expecting anything much in regards to this, most games will not run on arm
and Steam is not available for arm but Steamlink is so that may be a possiblity

Box86
 I've played with this before its an interesting product may investigate whats
 available here

Steamlink
 Its available for pi and I have a laptop lying around that runs Steam
 currently

 ** have run out of usb ports for the SL adapter

Emulation
 Have a bit of an interest in emulation performance

 Retroarch compiled from source using a couple of guides
 - https://gist.github.com/ematysek/fc01a47c7d34f0ca4dad41226c53ff6e
 - https://gist.github.com/AlexMax/32e5d038a66ce57253e740ea75736805

 $ git clone https://github.com/libretro/RetroArch.git
 $ cd RetroArch
 $ git checkout v1.9.0

 followed guides are this, set CFLAGS/configure
 $ make -j4
 $ sudo make install

 run retroarch to create config files
 $ retroarch -f
 
 edit ~/.config/retroarch/retroarch.cfg and edit/update this line
 
 core_updater_buildbot_cores_url = "http://buildbot.libretro.com/nightly/linux/armhf/latest/"

 picodrive core segfaulted, genesis_plus_gx was OK
 sound was acceptable no noticable input lag

Minetest
 Use as an fps benchmark maybe?
 - 800x600   windowed   ~25fps  (default)
 - 1280x720  windowed   ~23fps
 - 1920x1080 Fullscreen ~17fps

Chiaki (PS4 Remote play)
 Well this is something i never would have expected to be possible but with
 some massaging chiaki compiles for the rpi albeit without sound. The
 recommended fork is from zerojay.

 https://github.com/zerojay/chiaki

 After a successful compilation the binary will end up in 

 /build/gui/

 Sound requires an upgrade to QT, upgrade to 5.12 and patch chiaki and
 recompile (ta RedMarsBlueMoon)

 Install Qt5.12 from https://github.com/koendv/qt5-opengl-raspberrypi

 # wget https://github.com/koendv/qt5-opengl-raspberrypi/releases/download/v5.12.5-1/qt5-opengl-dev_5.12.5_armhf.deb
 # apt install ./qt5-opengl-dev_5.12.5_armhf.deb

 Add QT_SELECT to your bashrc
 $ vi ~/.bashrc 
 export QT_SELECT=qt5-opengl

 Recomile (noting that cmake will complain about directory conflicts)

 Map the qt5 libraries into the chiaki dir so they use the 5.12 version

 $ ldd ./chiaki | grep -i qt

	libQt5Multimedia.so.5 => /usr/lib/qt5.12/lib/libQt5Multimedia.so.5 (0xb6e51000)
	libQt5OpenGL.so.5 => /usr/lib/qt5.12/lib/libQt5OpenGL.so.5 (0xb6e0b000)
	libQt5Svg.so.5 => /usr/lib/qt5.12/lib/libQt5Svg.so.5 (0xb6dc4000)
	libQt5Network.so.5 => /usr/lib/qt5.12/lib/libQt5Network.so.5 (0xb546a000)
	libQt5Widgets.so.5 => /usr/lib/qt5.12/lib/libQt5Widgets.so.5 (0xb4f4e000)
	libQt5Gui.so.5 => /usr/lib/qt5.12/lib/libQt5Gui.so.5 (0xb4a55000)
	libQt5Core.so.5 => /usr/lib/qt5.12/lib/libQt5Core.so.5 (0xb4560000)

 $ sudo make install

 Runs fine, set it to 720p/30fps

ezQuake
 I am a big fan of Quakeworld, its one of my base requirements for gaming on a
 pc and nQuake is my go to which leverages ezQuake. There is no arm package for
 nQuake available so I attempted to compile my own

 The application compiled without error _but_ running it on the fkms driver
 results in a general error for the id engine based games

  $ ./ezquake-linux-arm 
  Received signal 11, exiting...

 Looking through the source it doesn't seem like opengles is attached to any
 linux builds restricted to android/ios so I'll have to chase this up later

deviloutionX
 The diablo opensourced engine, works and it is glorious, there is alread and
 arm build released for this, so just install it with apt to pickup the
 dependancies

Openarena
 Enable fps reporting with /set cg_drawfps 1

  - 720x400 windowed, low geo, vertex lighting ~60fps
  - 1920x1080 fullscreen, defauls               10fps


Test candidates
- OpenMW
- ScummVM
- DOOM (GZ/Chocolate)
- Aliens vs Predator
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=100152&sid=5e343e2029147759f04eefbe08dff29d
- Parsec https://parsec.app/
 
===============================================================================
Wine Applications
===============================================================================
I need to run Clrmame Pro or an equivilent but that may need to be offloaded to
an external host

Starcraft & Diablo II
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=215056

===============================================================================
Extra Credit
===============================================================================
Just some additional items to potentially test

Docker FBNeo Dat infrastructure
 Might be interesting to see what the performance of my FBNeo dat pipeline is
 like on this hardware, it would need to be converted to compile the arm
 versions of fbneo to generate the dats

Filer
 A python/mysql based file database that supports external media, this will 
 function but the performance should be an interesting test

Webcam 
 Logitech C910 Webcam performance
 Works perfectly fine in discord test area, no noticable lag

OBS
 Dependancies through ansible
 $ git clone – recursive https://github.com/obsproject/obs-studio.git
 $ cd obs-studio
 $ mkdir build && cd build

 Testing this
 $ cmake -DCMAKE_C_FLAGS='-mfpu=neon -mtune=cortex-a72 -march=armv8-a' -DUNIX_STRUCTURE=1 -DCMAKE_INSTALL_PREFIX=/usr ..

 $ make -j4
 $ sudo make install

 Had major UI scaling descrepencies in this application so compiling against
 qt5.12 as a test. UI Scale is still stuff between monitors

 Capped minetest through OBS, as expected it completed brutalized the host
 resources wise, minetest was playable at ~2FPS.

syncterm
 https://blog.paradroyd.com/post/138091989521/compiling-syncterm-on-raspbian
 $ wget http://syncterm.bbsdev.net/syncterm-src.tgz
 *install ncurses dev (ansible)
 $ make -j4 SRC_ROOT=$HOME/devel/syncterm/src
 $ sudo make install


===============================================================================
rpi-update
===============================================================================
Wanted to test out the kms driver so upgraded the firmware. Throws a partition
size warning prior to starting update.

Starting on kernel 5.4.79

 # rpi-update

 Get a warning about parition size 255m v 256m recommended, confirm twice

Ended up on kernel 5.10.0

 Tried the kms driver which actually displayed a desktop on kernel 5.10 but had
 a corrupt mouse cursor. Rolled back to fkms with the intent to debug.

 Started experiencing hard locks during video playback while on 5.10.0

 Rolled back to kernel 5.4.79 (commit 8a4d444d6a621ff56fa8941480c40fe4587c7a98)

 # rpi-update 8a4d444d6a621ff56fa8941480c40fe4587c7a98

Back to kernel 5.4.79

Upgraded to 5.10.2
 - No graphical artifacts with kms driver
 - reconfigured to use fkms driver
 - Video still hard locks but it appears its actually related to the audio
   stream perhaps just through the 3.5mm jackso need to investigate that 
   further, video did not hard lock when audio was configured (no ouput)
   through one of the hdmi devices.
   - https://github.com/Hexxeh/rpi-firmware/issues/250
 - rolled back to 5.4.79


Upgraded to 5.4.81 (c91312ae1df5011bd77826e49d2b914b6d0e9b08)
 - Booting was not stable on this firmware
 - Rolled back 5.4.79