hardwarerelated:raspberry_pi_4
Table of Contents
Which OS to run?
- Raspbian
- is easiest to setup, and most widely used
- https://dietpi.com/ – DietPi, streamlines Raspberry Pi OS, over/underclock options, logging to ram-fs by default and hourly sync
- Fedora36
- Centos images exist
- Debian
- Installing 64-bit Debian/Raspbian dualboot on a Raspberry Pi 4.
- Images can boot with kernel 5.5 and 5.6
- https://wiki.debian.org/RaspberryPi4 – Debian status
- Android
You can also put multiple OS's on one card, for example RaspiOS/Fedora32/Debian all together.
Links
- Building a HDMI signal grabber with the raspi would be nice
- Toshiba TC358743 based addon boards for the raspi are available, there is Linux support.
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
Raspbian cheatsheet
### Installation, with sdcard in /dev/mmcblk0, ### or usb3 connected nvme-enclosure # https://www.raspberrypi.com/software/operating-systems/ dd bs=4M if=2022-09-22-raspios-bullseye-arm64-lite.img 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
- cpu temp: 'vcgencmd measure_temp' output
- cpu temp with load: 4x 'md5sum /dev/urandom'
- Geekworm Raspberry pi 4 is recommended
- 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 ^C Handler:Goto Sleep mode chris@raspberrypi:~/rpi/RaspberryPi/bcm2835 $
Tried out:
- Ensure that spi devices are activated in /boot/config.txt: “dtparam=spi=on”
- running rpi-update
- updating kernel and system with “apt-get update; apt-get dist-upgrade”
- doublechecking the connected pins
- running raspi-config, to activate SPI
- The code from the upstream git repo works for me:
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.
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 RTT | bandwidth | |
---|---|---|
usb-c network | 0.2-0.3ms | down 140mbit/s / up 187mbit/s |
pi4 gbit ethernet | 0.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: 2023/05/14 08:07 by chris