With my homeboard booting up, it's time to make it show something. Some day I'll build a net-boot capable system, but until then I'd like to have it do something, even if it's by installing a few services by hand.
SD bootstrap
[Feb 25 edit: added this section]
An Rpi Zero won't do much without one, so, starting with a base Raspbian Bookworm for Rpi Zero (32 bit), with no GUI:
- Download an ISO compatible with the board
sudo dd of=/dev/sdX if=./XXXX.img bs=8M status=progress
- Mount sd card, then
- Enable ssh:
cd /media/$USER/bootfs && touch ssh && touch ssh.txt
- Create user (headless):
echo username:password > /media/$USER/bootfs/userconf.txt
These steps will give you an sd card that should boot and automatically connect to an eth connection (not wifi, of course), and let you ssh into the device to continue the setup. No need to hook up a keyboard.
First boot
Optional: UART is useful to debug the first boot, but if the SD bootstrap was successful everything should just work.
- Debug why the system doesn't boot, as with any new install
- UART into the system, then enable SSH (because the USB ports are hard to reach to connect a keyboard)
- Disconnect UART, reconnect sensors, login over SSH
- apt-get update, upgrade, etc...
Prepare Wayland
Raspbian Bookworm 32bit doesn't have support for Wayland out of the box. To enable:
- Add this magic to /boot/firmware/config.txt
dtoverlay=vc4-kms-v3d
gpu_mem=128
- /boot/firmware/cmdline.txt needs to have
wayland=on
sudo apt-get install mesa-utils-bin wayfire seatd
- seatd is required to manage sessions, otherwise wayfire will complain it can't open a terminal.sudo usermod -aG tty username
- I'm not sure if this is required. Try to skip it and see what happens. Let me know if you do.- reboot
- After booting up, it should be possible to run
wayfire
in a terminal; an empty Wayland screen (with a cursor) should show up
Wayfire as a service
With everything "working", we can make Wayfire a system service, so it will start at boot:
Add this to /etc/systemd/system/wayfire.service
(change the user name, and you may want to change the runtime dir too):
[Unit]
Description=wayfire
After=multi-user.target
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000
ExecStart=wayfire
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=10s
User=batman
[Install]
WantedBy=multi-user.target
Now enable the service
sudo systemctl daemon-reload
sudo systemctl enable wayfire
Use this on your next reboot to find out why things are broken: journalctl --follow --unit wayfire
Note: wayfire seems to crash a few times on startup. I guess there is a service dependency I haven't found yet, but as long as it's set to Restart=Always
it should eventually come up.
Screen rotation
Because of the way the flex cable is fed to the HDMI-to-eDP board, the screen may end up rotated 180 degrees. You may also want a portrait picture frame, instead of a landscape one. To rotate Wayland:
- Do
kmsprint
orkmsprint -m
- Look for the name of the screen, eg HDMI-A-1
- Look for the mode, eg 1920x1080@60.00
- Create this in ~/.config/wayfire.ini, replacing the values found above for your setup
[output:HDMI-A-1]
mode = 1920X1080@60.00
position = 0,0
transform = 90
~~No need to reboot Wayfire, it should pick up the changes and fix itself immediately. I think.~~ You'll need to sudo systemctl restart wayfire
to see the changes.
swayimg
With a GUI, it's time to show a picture. I hacked swayimg to load pictures from a local server, plus a few other useful features to make it more usable in a RpiW, like consuming less memory than default, and porting to 32 bits. To install dependencies:
sudo apt-get install libcurl git ninja-build meson
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libwayland-dev wayland-protocols
sudo apt-get install libjson-c-dev libxkbcommon-dev libfontconfig-dev libjpeg-dev
To build: [Yes, this is building swayimg in our target. This is horrible and will take a long time, so be prepared for a long coffee break. Some day I'll setup a crosscompiler].
git clone https://github.com/nicolasbrailo/swayimg.git
meson setup [build|--wipe build]
ninja -C build
To start:
- Launch Wayfire in a terminal
- In another terminal:
WAYLAND_DISPLAY="wayland-1" DISPLAY="" /home/batman/swayimg/build/swayimg
Check that nothing crashes too much.
P0 picture frame
Also this to /etc/systemd/system/ambience.service
(also change the user name. Or make a new user):
[Unit]
Description=ambience
After=multi-user.target
[Service]
Environment=XDG_RUNTIME_DIR=/run/user/1000 WAYLAND_DISPLAY="wayland-1" DISPLAY=""
ExecStart=/home/batman/swayimg/build/swayimg
StandardOutput=inherit
StandardError=inherit
Restart=always
RestartSec=3s
User=batman
[Install]
WantedBy=multi-user.target
Then:
sudo systemctl daemon-reload
- In a terminal:
journalctl --follow --unit wayfire --unit ambience
- In another terminal:
sudo systemctl enable ambience
sudo systemctl restart ambience
Next time you boot up, the Stonebaked Margherita P0 frame should behave like a picture frame.
Make sure the meson
step finds curl and libjpeg, otherwise it won't be a very useful LAN picture frame.