Minimalistic GUI on RPI4
For a project I needed a very very minimalistic system to run on an RPI 400.
I needed a GUI, a small set of apps and some control on the Hardware.
The Gui was written in C++ and Qt5, and needed to control the USB, the HostAP and some other system stuff.
Building the app is not important, but I’ll focus on the system installation. The app was packetized using
dpkg-buildpkg
and the deb system. I started with this minimal system before finally building it, so the
debian recipe included all the dependencies, both at build time and a run time.
After having flashed an image from Raspberry OS LITE 64 bit
into my sdcard, I ran apt update
and
apt upgrade
to have an up to date version of the system.
Then I installed only lxde and lxterminal:
$ sudo apt install xinit lxde_core lxterminal lxappearance
Then I ran raspi-config
and selected 1 System Options
and S5 Boot/auto login
, finally B4 Desktop Autologin
The default pi
user was created by the flashing tool, RaspberryPI Imager
that can be downloaded from the raspberry site. Before flashing I also enabled SSH.
After reboot, the system already displayed the desktop.
My application, for instance, created the icons and managed the configuration customization either during installation (in the preinst
file) or at first run.
The latter is needed when you need to modify some configuration file of other packages that cannot be dropped durin install. For example, dhcpd.conf
cannot be managed by your package, because it is owned by dhcpd
. In this case the best option is to check if the custom configuration has been already dropped, putting a signature on top of the file.
See my dhcpd.conf file:
# %Generated-by-Provisioning-tool
#
# Do not remove the line above. Otherwise the file will be overwritten.
# you may want to modify it, but do not remove or modify the signature in
# the first line.
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
authoritative;
subnet 192.168.200.0 netmask 255.255.255.0 {
range 192.168.200.2 192.168.200.99;
option broadcast-address 192.168.200.255;
default-lease-time 300;
max-lease-time 300;
}
When running, my tools check for this configuration file, checks if the signature (%Generated-by-Provisioning-tool
) is present at the first line, if not, it removes the file and drops its own version. User can eventually modify it, but must not remove the signature.
To manage the network configuration, I used nmcli
. It uses nmcli up
and nmcli down
to raise or shutdown the interface when needed, as well nmcli con add
or nmcli con delete
to specify any configuration. It used the static configuration (/etc/network/interface
) method but it is now not very reliable and it doesn’t integrate well with NetworkManager
. Instead with nmcli
you have perfect control over many if not all aspects, including the wifi supplicant parameters, tcp/ip, etc. I hated it before, but it is indeed very useful and very practical to use even programmatically.
nmcli
can also be used to specify a configuration to use when the USB network is enabled from an embedded device. On this arm board we were developing, uboot is configuring a network over USB using rndis, and nmcli con add type "ethernet" ifname "usb0" con-name "uboot USB" autoconnect "yes" ip4 "10.101.80.2/8"
configured the interface at installation phase (in postinst
file) and made the configuraton very easy. In this post I explained how to implement this without nmcli, but it is fairly complex and unreliable today.
With all this, after apt install ./mypackage_0.98.0.deb
my working station was ready without issues.
Happy Hacking.