Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active April 26, 2021 05:55
Show Gist options
  • Save weshouman/18015281336a3b53e0ad96f7e358f5a6 to your computer and use it in GitHub Desktop.
Save weshouman/18015281336a3b53e0ad96f7e358f5a6 to your computer and use it in GitHub Desktop.
Advanced RPI tips

Automated spawning of RPI images

  • We could use Vagrant to spawn an arm VM using this guide
  • The flow is like Vagrant -> Libvirt -> KVM -> QEMU -> Modified RPI image.
  • I remember finding an ansible book that modifies the RPI image for us, but I can't find it now ...

Mix Sound of Multi RPIs

To use a single speaker for multiple rpis, it would be tricky to search for that as Google will always redirect to multiple speakers a single rpi option.
Instead search for DAW mixer, here's a good list.
My understanding is that, the cheapest thing would be to utilize a whole SoC to mix between differen rpis and capture the sound output of this SoC. A physical mixer is pretty hard on pocket

Data Corruption Upon Power Cut-Offs

Prevention

If the sdcard is being written to while the system got rebooted, it's probable the a filesystem corruption may occur.
Always favor shutting down the RPI before unplugging it, in case you have a PoE like me, try to get an access for this bootloader to be able to shutdown first.
Notes:

Fix

  1. Enforcing fsck on boot.
    In my case that was pretty pointless, however here are the steps
    • Add the 2 lines fsck.mode=force and fsck.repair=yes to the /boot/cmdline.txt based on this answer
    • In /etc/fstab: add 1 in the last column of the root \ partition, and the other partition add 2 in the last column answer
    • Finally set the maximum number of reboots before checks to 1 by running sudo tune2fs -c 1 /dev/sdXY where /dev/sdXY is the root disk, in my case was /dev/sdb2, following this guide, note I didn't continue with the grub and other things for this guide.
    • Note I installed the latest e2fsck and tune2fs from source as the current version was missing a feature when I tried e2fsck for repairing at the beginning following on this answer
    • Note: using sudo e2fsck -C0 -tt -v -p -c /dev/sdb2 was a total waste of time, too slow and ineffective with no progress
    • Doing an fsck from my dev machine was pretty fast using sudo fsck.ext4 -f /dev/sdXY whic is pointed at by this answer. However, it didn't have an effect.
  2. Fixing the core issue, in my case it was invalid mount points in /etc/fstab by removing those extra mount lines, booting went through very smoothly.
    Note: to avoid unnecessary power cut-offs when PoE is used, follow this issue

Temperature

This article states the operation temperature of RPI for different CPU frequencies and hints to other articles speaking about undervoltage operation mode 600Mhz instead of 1200Mhz and later instead of 1500Mhz.
This article is an advanced deep look into the debugging of RPI's thermal characteristics.
To set a specific freq speed set Follow this answer. For more details follow this guide. Note: there are many types of *_freq. Note: the desired configurations are not found here Some interesting commands

# This one depends on apt install linux-tools-common
#   and will display the operation stats for different frequencies
#   Sample output: https://github.com/raspberrypi/linux/issues/1320#issuecomment-191754676
cpupower frequency-info

# This one will show the current operation clock speed, for RPi4 it's either 600169920 or 1500345728
vcgencmd measure_clock arm
# This one too
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Boot from SSD

follow this tutorial

Power Button

How to add a power button to your RPI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment