Site Tools


Sidebar

hardwarerelated:raspberry_pi_4

Which OS to run?

You can also put multiple OS's on one card, for example RaspiOS/Fedora32/Debian all together.

It feels slow!

How to distinguish which resource is under pressure? Measure. 'iostat' can show I/O load, vmstat/htop load on CPU.

  • CPU:
    • Buy good case/cooler
    • consider overclocking
    • 32bit or 64bit kernel? Depends on your application. Some results are better on the 32bit kernel.
  • Network:
    • Verify gbit mode is properly set, with ethtool
  • I/O: My first 'its slow' impression was from 'dnf -y update' updating 120 packages in ~40 minutes. CPUs not loaded, but storage was the issue: sdcards are optimized for big sequential load, not small random access. Here are details. Just using a different sdcard, this went to 15minutes. Approaches to fix:
    • Move the partition to USB3 connected devices (but USB flash can be as slow as sdcards. SSD are an option.)
    • Move the part where I/O is done to NFS via ethernet, for example if kernel compilation is causing the load these directories can be moved.
    • Buy sdcards doing well with random 4k access.

Measuring size of your I/O requests:

# https://github.com/iovisor/bcc
dnf -y install bcc
/usr/share/bcc/tools/bitesize'

# Then perform your I/O intensive operation, for example:
dnf -y update

# Evaluation of my I/O for 'dnf update', computed over all processes:
         0 -> 1          : 2487         (7%)
         2 -> 3          : 2327         (6%)
         4 -> 7          : 19501        (54%)
         8 -> 15         : 4443         (12%)
        16 -> 31         : 3687         (10%)
        32 -> 63         : 1979         (5%)
        64 -> 127        : 371          (1%)
       128 -> 255        : 223          (1%)
       256 -> 511        : 514          (1%)
       512 -> 1023       : 327          (1%)
      1024 -> 2047       : 497          (1%)
=> So when looking at benchmarks, 4k random access is most interesting

Raspberry Pi OS cheatsheet

### Installation, with sdcard in /dev/mmcblk0,
### or usb3 connected nvme-enclosure
# https://www.raspberrypi.com/software/operating-systems/
xzcat 2023-05-03-raspios-bullseye-arm64-lite.img.xz | \
  dd bs=4M of=/dev/mmcblk0 conv=fsync
mount /dev/mmcblk0p1 /mnt/tmp

# if the raspi should activate sshd
touch /mnt/tmp/SSH
vi /mnt/tmp/userconf.txt
# add here user + hashed password
# pattern: user:hashedpassword
# password hashing:
# echo 'mypassword' | openssl passwd -6 -stdin

# if resizing of the partition should be disabled
vi /mnt/tmp/cmdline.txt
# remove init=/usr/lib/raspi-config/init_resize.sh

umount /mnt/tmp

# Put the card into the raspi, boot it
nmap -sP 192.168.0.0/24 # find out IP
# ssh <ip> / user /password from userconf.txt

cat >>~/.bashrc<<EOT
# extend prompt to have temperature
export PS1='[\u@\h \$(cut -b 1,2 /sys/devices/virtual/thermal/thermal_zone0/temp)°C \W]\$ '
# colored iostat output
export S_COLORS=always
alias ll='ls -al'
export LC_ALL=en_GB.UTF-8
EOT

### check cpu temperature
$ vcgencmd measure_temp
temp=64.0'C

### current cpu details
$ lscpu|grep MHz
CPU max MHz:         1500.0000
CPU min MHz:         600.0000

$ vcgencmd measure_clock arm
frequency(48)=600117184
$ vcgencmd measure_volts
volt=0.8367V

### Are we throttled? Anything else than 0 means "yes"
$ vcgencmd get_throttled

### temperature in prompt
$ export PS1='\u@\h:'`vcgencmd measure_temp|cut -b 6,7`'°C:\w\$ '

### firmware update
apt update 
apt upgrade
apt full-upgrade # update to new major versions
apt install rpi-eeprom 
rpi-eeprom-update
rpi-eeprom-update -a

# If you want to try newer kernels for testing
BRANCH=master rpi-update
# BRANCH=next rpi-update

Overheating issues

vi /boot/config.txt

# in section [pi4] add
over_voltage=-1  # or "-2"
arm_freq=1250    # default is 1500Mhz
arm_freq_min=150 # also worth trying, default is 600Mhz

# then reboot

Using 2.9“ 296×128 ePaper Display Modue/SPI Interface

My initial issue: I did not get any output from the device. After recompiling the demo-app with DEBUG, I got this:

chris@raspberrypi:~/rpi/RaspberryPi/bcm2835 $ sudo ./epd 
2.9inch e-Paper demo
bcm2835 init success !!! 
Debug: e-Paper busy
^C
Handler:Goto Sleep mode
chris@raspberrypi:~/rpi/RaspberryPi/bcm2835 $ 

Tried out:

git clone https://github.com/waveshare/e-Paper
cd e-Paper/RaspberryPi&JetsonNano/c
vi examples/main.c
#   // EPD_2in9_test();
#   // EPD_2in9bc_test();
#   EPD_2in9d_test();

# and then run 'epd'
sudo ./epd
# this finally works for me

Sensors/addon list

List of the hardware/sensors I got.

  • Raspberry Pi USB-C power supply 5,1V / 3,0A, EU
  • Micro HDMI Adaptercable D-Stecker -A-Buchse 15cm schwarz
  • 4 teiliges Kühlkörper Set für Raspberry Pi 4, silber (amazon)
  • Raspberry Pi 4 B, 2GB RAM
  • RFID Lesegerät mit SPI Schnittstelle inkl. Karte & Dongle (link)
  • PCF8591 AD/ DA Konverter Modul link
  • 2.9“ 296×128 ePaper Display Modul mit SPI Interface, dreifarbig (rot, schwarz, weiß) link docs

Configuring network over usb-c

# https://www.raspberrypi.org/forums/viewtopic.php?t=245810
vi /boot/config.txt
# add: dtoverlay=dwc2
vi /boot/cmdline.txt
# add: modules-load=dwc2,g_ether
reboot
ifconfig -a # should show interface usb0
ip addr add 192.168.1.4/24 dev usb0
ip link set up dev usb0

# on the opposite system
ip addr add 192.168.1.4/24 dev enp0s20f0u1i1
ip link set up dev enp0s20f0u1i1
latency: ICMP RTTbandwidth
usb-c network 0.2-0.3ms down 140mbit/s / up 187mbit/s
pi4 gbit ethernet0.24-0.3ms down 764mbit/s / up 914mbit/s
  • latency, ICMP RTT: 0.2-0.3ms (gbit ethernet: 0.24-0.3ms)
  • bandwidth: 16mbyte/sec down / 22mbyte/sec up (gbit ethernet: 90mbyte/sec down / 50mbyte/sec up)
hardwarerelated/raspberry_pi_4.txt · Last modified: 2024/02/12 07:32 by chris