Monday, 23 March 2020

First encounter with physical programming

Just for fun I purchased a £12 electronics kit with a breadboard and built a pedestrian crossing light with it. It included a button to push for asking to turn red LED off and green LED on along with an active buzzer for hearing impaired. While this was great to get familiar with mu and gpiozero I am still looking for the first really meaningful project with electronics.

Sunday, 22 March 2020

First try on Ubuntu

I got excited about some edge compute tutorial of Ubuntu on Raspberry Pi but it turned out that my good old Raspoberry Pi 1 can not run that. Also live Ubuntu does not come with persistence so after a quick try I came back to Debian with RPD on my cute little SanDisk Cruzer Fit USB drive.

Reimaging Debian with RPD I went one step further on eye care and installed redshift and redshift-gtk from Preferences > Add / Remove Programs.

Sunday, 15 March 2020

Setting up brightness control

While most of the important functions of my keyboard like volume control worked out of the box even with animated Task Bar Panel Item there was one that after a while become painfully missing and this was brightness control. As brightness control works automatic under Windows it took me quite some time and even some tears to realize it does not work on Debian with Raspberry Pi Desktop (RPD from now on). As I found only resolution settings in Preferences > Screen Configuration that I already mentioned in the previous post I had to look for some other ways to make brightness control work. Searching on the topic the first hint was that brightness aka back light is not governed by ACPI on my laptop but it is Intel specific:

pi@raspberrypi:~ $ ls -la /sys/class/backlight/
total 0
drwxr-xr-x  2 root root 0 Mar 15 09:05 .
drwxr-xr-x 55 root root 0 Mar 15 09:05 ..
lrwxrwxrwx  1 root root 0 Mar 15 09:05 intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight
pi@raspberrypi:~ $ 

And indeed I could change brightness by simply writing a number between 0 and max_brightness:

pi@raspberrypi:~ $ sudo su
root@raspberrypi:/home/pi# echo 100 > /sys/class/backlight/intel_backlight/brightness
root@raspberrypi:/home/pi#

For some reason the configuration in /usr/share/X11/xorg.conf.d/20-intel.conf did not give me the usual keyboard controls back on brightness. There were some other hints on using acpi_osi= in grub command line and while it seems to make my brightness control keys working again but it gave me a lot of errors during boot and I could not figure out which of the numerous grub application I should use to update grub command line for persistence. I was not in favor risking to break boot of my laptop now as at the time of writing this blog we suffer from the most serious pandemic in my life the corona virus outbreak. Basically we are asked to self isolate so my laptop has become an even more important piece to be able to keep working.

But there are a few nice little applications that can be installed from Preferences > Add / Remove Software that make my brightness control keys working again. The first is xbacklight that can increase and decrease brightness in steps. In order to make it work on my laptop I had to add this configuration:

pi@raspberrypi:~ $ more /etc/X11/xorg.conf
Section "Device"
Identifier "Card0"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection
pi@raspberrypi:~ $

The other app is xbindkeys that can bind this brightness control back to my Fn F5 and Fn F6 keys by adding this to ~/.xbindkeysrc:

#BrightnessDown
"xbacklight -10"
    m:0x0 + c:232
    XF86MonBrightnessDown

#BrightnessUp
"xbacklight +10"
    m:0x0 + c:233
    XF86MonBrightnessUp


I have arrived to this config using xbindkeys-config with the Get Key pop up that might come useful to create other hot keys also.

After this starting xbindkeys has put my brightness control keys back in action even after reboot.


Sunday, 8 March 2020

Raspberry Pi Desktop

Last time I visited Hungary I took a few USB drives with me. In particular I took a very cute SanDisk Cruzer Fit that only minimally sticks out from my laptop. I have always been playing with the idea of using this cute little dongle for some Linux Live distribution. When I realized there is a Debian with Raspberry Pi Desktop I jumped on it!

While the installation guide is great as always on raspberry.org I could not follow it as my company IT makes all USB drives write protected by policy on my laptop. So I had to use my good old Raspberry Pi I have setup up again recently to burn the ISO on the dongle. I have used my laptop to download the ISO and scp it over to my little Pi where I could dd it onto /dev/sda.

dd status=progress if=2020-02-12-rpd-x86-buster.iso of=/dev/sda bs=2M

Just as a sidenote: I have also installed a graphical gparted application on my good old Pi and formatted the dongle to fat32. Furthermore also used fdisk on my dongle to create a DOS partition table, add a partition and make it bootable but I think this has all been overwritten when I have dd the ISO on /dev/sda... Not sure though hence I still mention it...

I have used the Send feedback webform on the installation guide at raspberry.org to encourage them to include this nice and simple option to create a bootable USB drive also under Raspbian with dd command. Furthermore I also used Send feedback to encourage them to include that this USB drive can simply run Debian live with Raspberry Pi Desktop with persistence in case someone wants to use it without installing it on the internal drive of the laptop.

I must confess I got confused first and used a second USB dongle after dd the ISO on it and followed the installation guide to install Debian with Raspberry Pi Desktop on my cute little SanDisk Cruzer Fit from this second dongle. I omitted the warnings of the installation guide about creating backup of the internal SSD drive as I was hoping I can avoid touching it. At the end of the installation process it seemingly tried to install GRUB boot loader on the first disk it found but the effect was dubious. What it actually did is it created a debian option in my laptop Boot Menu by probably writing into the MBR in the BIOS. But it never really installed GRUB on my cute little SanDisk Cruzer Fit hence it did not want to boot. I suspect it tried to install GRUB on my corporate internal drive but it probably failed as it is encrypted. When I plugged back the second dongle speculating how to fix GRUB install on my cute little SanDisk Cruzer Fit I accidentally realised running down the timeout when staying on the very first Run with persistence option of the Debian installer of the second dongle that this Run with persistence is exactly the option I wanted in the first place! It simply booted into Debian with Raspberry Pi Desktop and wrote all my configuration back to the Live USB drive! As this second dongle was sticking out very much I quickly went back and dd the ISO on my cute little SanDisk Cruzer Fit dongle and I am happily using it ever since.

Fortunately my laptop normal operation does not seem to be effected apart from this ineffective debian option in Boot Menu of its BIOS stuck there even with my cute little SanDisk Cruzer Fit removed but seemingly without doing anything harmful really. Otherwise without touching my laptop at boot up it still boots into corporate Windows from the internal SSD drive by default and I need to break the boot up at BIOS level to access the Boot Menu and boot into my nice little Live Debian with Raspberry Pi Desktop choosing the USB HDD option from the Boot Menu. Later installing efibootmgr gave me a tool to get rid of the debian entry from the Boot Menu.

Once I could run Debian with Raspberry Pi Desktop it picked up almost everything automatically on my Lenovo T480s - keyboard and touchpad was working fine to set default 'pi' user password and wifi password. Resolution was too high for my eyes so I set it back to 1280x720 in Preferences / Screen Configuration menu. To save resolution I used lxrandr from terminal that pops up a resolution setting window with a save function. To enable tapping and invert scrolling on the touchpad I have created:

pi@raspberrypi:~ $ more /etc/X11/xorg.conf.d/40-libinput.conf
Section "InputClass"
  Identifier "libinput touchpad catchall"
  MatchIsTouchpad "on"
  MatchDevicePath "/dev/input/event*"
  Driver "libinput"
  Option "Tapping" "on"
  Option "NaturalScrolling" "on"
EndSection

Enabled Battery Monitor on the top bar after my laptop repeatedly switched off and I realized it struggles with battery charging levels.

Finally I turned on sync with my Google account in Chromium and logged into my corporate Office 365 -  all sprinkled to life!

I could very easily add automatic open VPN to the test lab that I am currently working on by adding the configuration file under /etc/openvpn. Installing Real VNC Viewer also completed the experience both back to my good old Pi via cloud connection or the Ubuntu jumpserver via the open VPN tunnel.

The only thing I can not access now is the corporate VPN but for that I probably should boot into corporate Windows anyway.