User Tools

Site Tools



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:

dnf -y install bcc

# 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

Raspbian cheatsheet

### Installation, with sdcard in /dev/mmcblk0
dd bs=4M if=2020-05-27-raspios-buster-lite-armhf.img of=/dev/mmcblk0 conv=fsync
mount /dev/mmcblk0p1 /mnt/tmp
touch /mnt/tmp/SSH
umount /mnt/tmp

# Put the card into the raspi, boot it
nmap -sP # find out IP
# ssh <ip> / user pi / password raspberry

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

# I like gkrellm
apt install  gkrellmd
echo 'allow-host' >>/etc/gkrellmd.conf 
systemctl enable gkrellmd
systemctl restart gkrellmd

### check cpu temperature
$ vcgencmd measure_temp

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

$ vcgencmd measure_clock arm
$ vcgencmd measure_volts

### 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 install rpi-eeprom 

# If you want to try kernel 5.4
BRANCH=master rpi-update
# BRANCH=next rpi-update

Overheating issues

Table below:

  • Raspbian, updates and firmware as of 2020-05-02
  • cpu temp: 'vcgencmd measure_temp' output
  • cpu temp with load: 4x 'md5sum /dev/urandom'
cooling method ambient air temp cpu temp idle cpu temp with load
passive heat spreader 28°C 52°C 78°C
passive heat spreader 24°C 47°C 73°C
none 26°C 47°C 78°C
Geekworm Raspberry pi 426°C 39°C 45°C
  • My first use of the pi4 was in 32°C environment temperature, without passive or active cooling. After some minutes, the pi4 was no longer reachable via SSH. Firmware updates improved the situation.
  • Underclocking could be an option:
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
Handler:Goto Sleep mode
chris@raspberrypi:~/rpi/RaspberryPi/bcm2835 $ 

Tried out:

git clone
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
  • HC-SR501 PIR Sensor -Infrarot Bewegungsmelder link
  • Feuchtigkeitssensor mit digitalem und analogem Ausgang link
  • Lichtsensor mit digitalem Ausgang link
  • 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

vi /boot/config.txt
# add: dtoverlay=dwc2
vi /boot/cmdline.txt
# add: modules-load=dwc2,g_ether
ifconfig -a # should show interface usb0
ip addr add dev usb0
ip link set up dev usb0

# on the opposite system
ip addr add 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: 2020/06/01 13:29 by chris