Jump to content

Rasberry Pi

From Smithnet Wiki

Device

cat /proc/device-tree/model

Hardware info:

  • AV Connector:
    • 1 (tip): L Audio
    • 2: R Audio
    • 3: Ground
    • Sleeve: Composite Video.
  • Boards
  • GPIO Header

Rasbery Pi OS

See /boot/firmware/config.txt.

Command line configuration program:

raspi-config

Upgrade:

apt update && sudo apt upgrade -y

Apache Web Server

apt install apache2 -y
  • Configuration: /etc/apache2
  • Serve from: /var/www/html

Composite Video

In /boot/firmware/config.txt:

enable_tvout=1
dtoverlay=vc4-kms-v3d,composite

Ensure hdmi_force_hotplug=1 is commented out or set to 0.

In /boot/firmware/cmdline.txt, either:

vc4.tv_norm=PAL
vc4.tv_norm=NTSC

To control overscan, see settings:

margin_left
margin_right

Go Development

Because of limited RAM, best to cross compile on a more powerful system:

CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build myprog.go

Or install ARMv6 release:

wget https://go.dev/dl/go1.26.3.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.26.3.linux-armv6l.tar.gz

Set environment variables:

PATH=$PATH:/usr/local/go/bin
GOPATH=$HOME/go

GPIO Development

Raspberry Pi OS use the newer gpiod subsystem (which interacts with /dev/gpiochip0).

In C++:

apt install libgpiod-dev gpiod
g++ -O3 prog.cpp -o prog -lgpiodcxx

See documentation

In Python, use:

apt install python3-gpiozero -y

In Go, use: periph.io

Mail

MUA:

apt install bsd-mailx
apt install mutt

Mount mail directory from server:

mailhost:/var/spool/mail    /var/mail    nfs    rw,nofail,noatime,_netdev,soft,intr    0    0

Or use automounter (see other section). Note: UID/GID must match.

Exim is the default MTA:

dpkg-reconfigure exim4-config
update-exim4.conf
systemctl restart exim4

Monitor logs:

tail -f /var/log/exim4/mainlog

NFS Automounter

apt install autofs nfs-common -y

To allow remove mounts to be accessed under /net/<server>/<export>, edit /etc/auto.master and enable the host map:

/net    -hosts --timeout=60
systemctl enable autofs
systemctl restart autofs

To mount remote mail directory:

Create the new /etc/auto.master.d/mail.autofs file:

/-    /etc/auto.direct    --timeout=60

Create the /etc/auto.direct file:

/var/mail    -fstype=nfs,rw,soft,intr,tcp,rsize=8192,wsize=8192    mailhost:/var/spool/mail
systemctl restart autofs

NTP Client

apt install systemd-timesyncd -y

Edit /etc/systemd/timesyncd.conf and set NTP parameter

systemctl restart systemd-timesyncd
timedatectl status
timedatectl timesync-status

Swap

free -m
swapon --show

Add filesystem swap:

swapoff -a
dd if=/dev/zero of=/swapfile bs=1M count=1024
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

Add to /etc/fstab:

/swapfile none swap sw 0 0

To see current zram configuration:

zramctl 
zramctl --output-all /dev/zram0

To resize:

swapoff /dev/zram0
zramctl --reset /dev/zram0
zramctl --find --size 512M
mkswap /dev/zram0
swapon /dev/zram0

Temperature

echo "scale=2; $(cat /sys/class/thermal/thermal_zone0/temp) / 1000" | bc

CPU Core throttling above 80 C.