UP  |  HOME
RSS | RSS Complete

ragna (Raspberry Pi 4 B)

Summary

TODO

Notes

TODO

Hardware

Make Raspberry Pi
Year 2019
Model 4 B
Chassis Okdo Case
Power Supply Raspberry Pi 5V USB C
Processor BCM2711
Memory 2GB
Ports 2x Micro HDMI
  RJ-45 LAN
  3.5mm Line Out
  2x USB 3.0
  2x USB 2.0
  USB C Power
Graphics VideoCore VI
Storage 32GB Micro SD
Dimensions  
Length/Depth 9.4 cm
Width 6.3 cm
Height/Thickness 3.2 cm
Weight kg (lbs oz)

Software

Operating System  
Unique applications  

Log

[2022-01-10 Mon] Installing Debian on Pi 4

According to https://wiki.debian.org/RaspberryPi4#Using_EFI_Firmware_and_the_regular_Debian_Installer follow the guide at https://forums.raspberrypi.com/viewtopic.php?t=282839&sid=32b6a47b8ded89b64bd1b4a967389655

  1. Pick the install media which will also be the OS drive (>16GB)
  2. Create a EFI System partition (ESP) and format it FAT32
  3. Copy the Debian netinstall iso files and RPi UEFI Firmware files (note there are hidden files to be included, .disk)
  4. Plug in media and boot the Pi
  5. Manually select device for install media. Choose none, then enter: -t vfat -o rw /dev/mmcblk1p1
  6. Customize partitioning (32GB total): 16GB /, 4GB /var, 2GB swap, 2.5GB /tmp, 6GB /home. Make sure to leave ESP partition. Debian partition should NOT create a second one. If so you failed to set the partition type or mark it as a system partition.

[2022-01-10 Mon] UEFI firmware won't boot headless

Set hdmi_force_hotplug to 1 in /boot/EFI/config.txt because the boot gets broken with no display attached. From https://github.com/pftf/RPi4/issues/162

[2022-01-10 Mon] Learning that GPIO support isn't mainline

Note: Before you try to do any of this on a mainline kernel there isn't actually any support for doing GPIO with these libraries. As far as I can see it's a dead end and you should run the raspberry pi kernel if you want to do GPIO things at the moment.

  • Device tree overlays

    I compile an overlay like:

    dtc -@ -I dts -O dtb -o gpio-shutdown.dtbo gpio-shutdown-overlay.dts
    mv gpio-shutdown.dtbo /boot/efi/overlays/
    

    Then modify /boot/efi/config.txt dtoverlay line to gpio-shutdown.

    I boot and nothing works. I tried loading gpio_keys module. gpioinfo doesn't say anything useful.

    Debian bullseye release libs (rpi.gpio and gpiozero) are too old to support pi 4. I fetched the dsc from bookworm release packages and built those. Something like this:

    dget ....dsc
    apt-get build-deps ...
    

    Manually install new build-deps.

    dget new deps
    debuild -i -us -uc
    dpkg -i ../*.deb
    

    Build and install things.

    This turned out to be an utter waste of time. rpi.gpio bombs because it tries to figure out what kind of pi it's on based on /proc/cpuinfo and mainline kernel seems to give a very sparse cpuinfo report.

    I hardcoded the test to succeed, and return a pi 4 and tried to run my script. This got further along, but gpiozero does it's own /proc probing, and I gave up on trying to modify it.

    I thought for a bit this might have to do with the wrong device tree so I manually specified it in /boot/efi/config.txt, but it made no difference.

    Tried upgrading to Debian testing (bookworm ~12) for kicks. This puts me on Linux 5.15.5. Nothing changes about the GPIO situation.

[2025-05-20 Tue] A dakboard

I made this into a dakboard using one of their free accounts.

I mostly followed https://thelinuxcode.com/guide-setup-dakboard-raspberry-pi-browser/, but some things have changed, and I ran into a few snags.

  • Pi OS is Wayland based now. I just reverted (raspi-config > Advanced > Wayland) to X11 to keep using unclutter for cursor hiding.
  • I wanted my GPIO shutdown button to work. I followed https://howchoo.com/pi/how-to-add-a-power-button-to-your-raspberry-pi/
  • I changed the hostname, but chromium's profile manager freaks out which breaks the autostart. Delete ~/.config/chromium/SingletonLock.

I considered running Dakboard's Pi OS since it claims to have touchscreen support and interactivity, but then I had another idea. I want to be able to access a second page for cameras.

The dakboard pi guide recommended using --app for the URL to launch. Chromium didn't seem to like multiple of these, and I don't know the ramifications of using it. I just removed it, and put both my URLs as arguments. I get 2 tabs still in kiosk mode, and things seem to be fine.

The Pi WiFi struggles a bit loading the cameras. Definitely a case where wired ethernet would be nice, but the planned location probably won't allow it.

I rigged up my single key CH552 keyboard. Short presses switch tabs, long presses refresh the page. I'll probably glue it to a back corner of the screen. It has some code like:

Listing 1: ch552_one_key.ino
#ifndef USER_USB_RAM
#error "This example needs to be compiled with a USER USB setting"
#endif

#include "USBHIDKeyboard.h"

#define BUTTON_PIN 14
const int SHORT_PRESS_TIME = 500; // 500 milliseconds

#define LED_WHITE 15
#define LED_BLUE 16
#define LED_GREEN 17

int lastState = LOW;  // the previous state from the input pin
int currentState;     // the current reading from the input pin
unsigned long pressedTime  = 0;
unsigned long releasedTime = 0;

void setup() {
  USBInit();
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_WHITE, OUTPUT);
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);

  // blink the LED once
  digitalWrite(LED_WHITE, HIGH);
  digitalWrite(LED_GREEN, LOW);
  digitalWrite(LED_BLUE, LOW);

  delay(1000); //off
  digitalWrite(LED_WHITE, LOW);
  digitalWrite(LED_GREEN, HIGH);
  digitalWrite(LED_BLUE, HIGH);

}

void loop() {
  // read the state of the switch/button:
  currentState = digitalRead(BUTTON_PIN);

  if(lastState == HIGH && currentState == LOW)        // button is pressed
    pressedTime = millis();
  else if(lastState == LOW && currentState == HIGH) { // button is released
    releasedTime = millis();

    long pressDuration = releasedTime - pressedTime;

    if( pressDuration < SHORT_PRESS_TIME ) {
      Keyboard_press(KEY_LEFT_CTRL);
      Keyboard_press(KEY_TAB);
      delay(100);
      Keyboard_releaseAll();
    } else {
      Keyboard_press(KEY_F5);
      delay(100);
      Keyboard_release(KEY_F5);
    }
  }

  lastState = currentState;
  delay(50);  //naive debouncing
}

I was considering a rotated display, and figured I'd just set it in the autostart file as well. Unfortunately those commands are run simultaneously which means you can't use xinput --map-to-output. I tried the commands below, but something is still wrong. Maybe the touch device doesn't exist yet?

@xrandr -o inverted
@xinput set-prop "Touch Device Name" "Coordinate Transformation Matrix" -1 0 1 0 -1 1 0 0 1

I ended up adding a .desktop file to ~/.config/autostart to run a script with the xinput command. This seems to happen late enough. Rather annoying.