Difference between revisions of "Raspberry Pi"

From Christoph's Personal Wiki
Jump to: navigation, search
(Throttling)
(Tools)
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This article will be all about my '''Raspberry Pi''' projects.
 
This article will be all about my '''Raspberry Pi''' projects.
  
==Miscellaneous==
+
==Common commands==
  
 
* Find Raspberry Pi IP address on your local WiFi network:
 
* Find Raspberry Pi IP address on your local WiFi network:
Line 36: Line 36:
  
 
* Find out where your Raspberry Pi was made and other details about the hardware:
 
* Find out where your Raspberry Pi was made and other details about the hardware:
$ cat /proc/cpuinfo | grep -E '^Hardware|^Revision|^Serial'
+
<pre>
Hardware : BCM2835
+
$ cat /proc/cpuinfo | grep -E '^Hardware|^Revision|^Serial'
Revision : a22082
+
Hardware : BCM2835
Serial : 0000000038e10351
+
Revision : a22082
 +
Serial : 0000000038e10351
 +
 
 +
# ~OR~
 +
 
 +
$ cat /proc/cpuinfo | grep -E '^Hardware|^Revision|^Serial'
 +
Hardware : BCM2711
 +
Revision : d03114
 +
Serial : 10000000ecaf3b49
 +
</pre>
  
 
Then, go [https://elinux.org/RPi_HardwareHistory here] or [https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md here] and, using the above hardware/revision codes, find out where you RPi was made.
 
Then, go [https://elinux.org/RPi_HardwareHistory here] or [https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md here] and, using the above hardware/revision codes, find out where you RPi was made.
  
So, in my case, I have a '''Raspberry Pi 3 Model B''' manufactured by Embest in 2016 (Q1).
+
So, in my case, I have the following:
 +
* '''Raspberry Pi 3 Model B''' (1 GB) manufactured by Embest in 2016 (Q1).
 +
* '''Raspberry Pi 4 Model B''' (8 GB) manufactured by Sony in 2020 (Q2).
  
 
===32-bit or 64-bit===
 
===32-bit or 64-bit===
Line 51: Line 62:
 
  armv8  # <- 64-bit => ARMv8 Processor
 
  armv8  # <- 64-bit => ARMv8 Processor
  
$ tr '\0' '\n' </proc/device-tree/model;arch
+
<pre>
Raspberry Pi 3 Model B Rev 1.2
+
$ tr '\0' '\n' </proc/device-tree/model;arch
armv7l
+
Raspberry Pi 3 Model B Rev 1.2
 +
armv7l
 +
$ tr '\0' '\n' </proc/device-tree/model;arch
 +
Raspberry Pi 4 Model B Rev 1.4
 +
armv7l
 +
</pre>
  
 
  $ getconf LONG_BIT
 
  $ getconf LONG_BIT
Line 97: Line 113:
 
600000
 
600000
 
<unsupported>
 
<unsupported>
 +
</pre>
 +
 +
===Video===
 +
 +
* Capture a 10 seconds video with your camera module:
 +
<pre>
 +
$ raspivid -o video.h264 -t 10000
 
</pre>
 
</pre>
  
Line 125: Line 148:
 
* Display GPIO pinout (GUI-only):
 
* Display GPIO pinout (GUI-only):
 
  $ pinout
 
  $ pinout
 +
 +
==GPIO==
 +
 +
* Light up an LED:
 +
<pre>
 +
$ sudo -i
 +
# Use GPIO pin 27 by creating a virtual file:
 +
$ echo "27" > /sys/class/gpio/export
 +
# Set pin 27 to ''out'' mode (allows us to turn on/off):
 +
$ echo "out" > /sys/class/gpio/gpio27/direction
 +
# Turn pin on/off:
 +
$ echo "1" > /sys/class/gpio/gpio27/value
 +
$ echo "0" > /sys/class/gpio/gpio27/value
 +
$ exit
 +
</pre>
 +
 +
===I2C===
 +
 +
<pre>
 +
$ sudo apt-get install -y python-smbus i2c-tools
 +
</pre>
 +
 +
* If you know an I2C device is connected to your RPi, but you do not know its 7-bit I2C address, use the following command to find it:
 +
<pre>
 +
$ sudo i2cdetect -y 0
 +
</pre>
 +
 +
This will search <code>/dev/i2c-0</code> for all address, and if an MCP4725 DAC breakout is properly connected and it is set to its default address it should show up at <code>0x62</code>.
 +
 +
If you are using a 512MB Raspberry Pi version 2, you will need to use <code>/dev/i2c-1</code> by running:
 +
<pre>
 +
$ sudo i2cdetect -y 1  # as the i2c port number changed from #0 to #1
 +
</pre>
 +
 +
==Compute Modules==
 +
 +
<div style="float:left; margin:0px 20px 20px 0px;">
 +
{| align="center" style="border: 1px solid #999; background-color:#FFFFFF"
 +
|-
 +
! colspan="4" bgcolor="#EFEFEF" | '''Part number options'''
 +
|-align="center" bgcolor="#1188ee"
 +
!Model
 +
!Wireless
 +
!RAM LPDDR4
 +
!eMMC Storage
 +
|- align="left"
 +
|'''CM4''' || 0 = No || 01 = 1 GB || 000 = 0 GB (Lite)
 +
|-
 +
| || 1 = Yes || 02 = 2 GB || 008 = 8 GB
 +
|-
 +
| || || 04 = 4 GB || 016 = 16 GB
 +
|-
 +
| || || 08 = 8 GB || 032 = 32 GB
 +
|}
 +
 +
Example Part Number: '''CM4102032''': Raspberry Pi Compute Module 4, 2GB RAM, 32GB eMMC, Wireless, BCM2711, ARM Cortex-A72, RPL#SC0670B
 +
 +
==Miscellaneous==
 +
 +
* Commands to remove Microsoft's repo and GPG key from your Pi:
 +
<pre>
 +
$ sudo rm /etc/apt/sources.list.d/vscode.list
 +
$ sudo rm /etc/apt/trusted.gpg.d/microsoft.gpg
 +
$ sudo apt update
 +
</pre>
 +
 +
Use [https://vscodium.com/ VSCodium] instead.
 +
 +
* Get the current pull:
 +
<pre>
 +
$ cat /sys/devices/platform/rpi-poe-power-supply@0/power_supply/rpi-poe/current_now
 +
601000
 +
# Note:
 +
# 60100uA = 0.6A
 +
# 0.6A @ 5V (nominal) = 3W (P = IV)
 +
</pre>
 +
 +
* Turn a specified GPIO pin (e.g., pin 23) on/off:
 +
<pre>
 +
echo "23" > /sys/class/gpio/export
 +
echo "out" > /sys/class/gpio/gpio23/direction
 +
echo "1" > /sys/class/gpio/gpio23/value
 +
echo "0" > /sys/class/gpio/gpio23/value
 +
</pre>
 +
 +
* Setup HDMI HotSwap:
 +
<pre>
 +
$ vi /boot/config.txt
 +
hdmi_force_hotplug=1
 +
</pre>
 +
 +
* Real-time update for added HDD:
 +
<pre>
 +
$ echo 1 | sudo tee /sys/bus/pci/rescan
 +
</pre>
 +
 +
==Memory==
 +
 +
* 1GB: 4HBMGCJ
 +
* 2GB: D9WHZ
 +
* 4GB: D9WHV
 +
* 8GB: D9ZCL
 +
 +
==Turing Pi v2==
 +
 +
SEE: https://turingpi.com/turing-pi-v2-is-here/
 +
 +
; Specs:
 +
* Mini ITX standard
 +
* 4x Nodes
 +
* Managed Switch, VLAN
 +
* HDMI
 +
* 2x Mini PCIe Gen2
 +
* 2x SATA III  6 Gbps
 +
* 2x 1 Gbps Ethernet
 +
* 4x USB 3.0 (2x Front / 2x Back)
 +
* GPIO 40-pin (RPi compatible)
 +
* 24-pin ATX power
 +
; Removed:
 +
* 4x Node Fan connector
 +
* 3x GPIO 40-pin
 +
* Audio-out 3.5mm
 +
; Added:
 +
* Nvidia Jetson Support
 +
* Board Management Controller with remote access
 +
* System Fan connector
 +
 +
<pre>
 +
---
 +
slot_1:
 +
  - HDMI
 +
  - GPIO
 +
  - mPCIe
 +
slot_2:
 +
  - mPCIe
 +
slot_3:
 +
  - SATA
 +
slot_4:
 +
  - USB
 +
</pre>
  
 
==External links==
 
==External links==
 
* [https://www.raspberrypi.org/ Official website]
 
* [https://www.raspberrypi.org/ Official website]
 +
* [https://rpilocator.com/ rpilocator]
  
 
===GPIO===
 
===GPIO===
Line 133: Line 297:
 
* [http://rasp.io/portsplus/ Pinout PCB]
 
* [http://rasp.io/portsplus/ Pinout PCB]
 
* [https://github.com/splitbrain/rpibplusleaf Printable Pinout]
 
* [https://github.com/splitbrain/rpibplusleaf Printable Pinout]
 +
 +
===Tools===
 +
* [https://www.raspberrypi.com/documentation/accessories/camera.html libcamera]
 +
* [https://github.com/cz172638/v4l-utils video4linux] (<code>apt install v4l-utils</code>)
 +
* [https://github.com/billw2/rpi-clone A shell script to clone a booted disk]
 +
 +
===Alternative OSes===
 +
 +
* [https://sourceforge.net/projects/openmediavault/files/ openmediavault]
 +
* [https://ichigojam.github.io/RPi/ IchigoJam BASIC]
 +
* [https://volumio.org/ Volumio]
 +
* [https://blitterstudio.com/amiberry/ Amiberry]
 +
* [https://www.riscosopen.org/content/downloads/raspberry-pi RiscOS]
 +
* [https://github.com/FydeOS/chromium_os-raspberry_pi ChromiumOS]
 +
** [https://www.iottechtrends.com/install-chromium-os-on-raspberry-pi/ ChromiumOS Tutorial]
 +
* [https://github.com/sakaki-/gentoo-on-rpi-64bit Genpi64]
 +
* [https://retropie.org.uk/download/ RetroPie]
 +
 +
===PCIe devices===
 +
* [https://pipci.jeffgeerling.com/ Raspberry Pi PCIe Devices] &mdash; by Jeff Geerling
 +
 +
===Cases===
 +
* [https://www.jeffgeerling.com/blog/2021/argon-one-m2-raspberry-pi-ssd-case-review Argon One M.2 Raspberry Pi SSD Case Review] &mdash; by Jeff Geerling
 +
 +
===Miscelleaneous===
 +
* [https://www.raspberrypi.org/documentation/hardware/raspberrypi/power/README.md Power supply]
 +
* [https://chromium.github.io/octane/ Octane 2.0 JavaScript Benchmark]
  
 
[[Category:Electronics]]
 
[[Category:Electronics]]
 
[[Category:Technical and Specialized Skills]]
 
[[Category:Technical and Specialized Skills]]
 
[[Category:Hobbies]]
 
[[Category:Hobbies]]

Latest revision as of 22:57, 24 September 2022

This article will be all about my Raspberry Pi projects.

Common commands

  • Find Raspberry Pi IP address on your local WiFi network:
$ sudo nmap -sP 10.0.0.0/24 | awk '/^Nmap/{ip=$NF}/B8:27:EB/{print ip}'

#~OR~

IFACE=eth0
# trigger IPv6 neighbour discovery with link-local scope multicast:
ping6 -c2 -I $IFACE ff02::1 > /dev/null
# print the results, filtered by MAC address vendor prefix of Raspberry Pi Foundation:
ip -6 neigh | grep b8:27:eb

#~OR~

$ arp-scan --interface=eth0 --localnet | grep b8:27:eb
  • Store the following in your ~/.ssh/config file:
Host rpi
    HostName 10.x.x.x
    User pi
    ProxyCommand none
    TCPKeepAlive yes
    ServerAliveInterval 5
    PubkeyAuthentication no
    PreferredAuthentications keyboard-interactive,password

Then,

$ ssh rpi

Or, better yet, use SSH keys.

  • Find out where your Raspberry Pi was made and other details about the hardware:
$ cat /proc/cpuinfo | grep -E '^Hardware|^Revision|^Serial'
Hardware	: BCM2835
Revision	: a22082
Serial		: 0000000038e10351

# ~OR~

$ cat /proc/cpuinfo | grep -E '^Hardware|^Revision|^Serial'
Hardware	: BCM2711
Revision	: d03114
Serial		: 10000000ecaf3b49

Then, go here or here and, using the above hardware/revision codes, find out where you RPi was made.

So, in my case, I have the following:

  • Raspberry Pi 3 Model B (1 GB) manufactured by Embest in 2016 (Q1).
  • Raspberry Pi 4 Model B (8 GB) manufactured by Sony in 2020 (Q2).

32-bit or 64-bit

$ arch || uname -a
armv7l  # <- 32-bit => ARMv7 Processor rev 4 (v7l)
armv8   # <- 64-bit => ARMv8 Processor
$ tr '\0' '\n' </proc/device-tree/model;arch
Raspberry Pi 3 Model B Rev 1.2
armv7l
$ tr '\0' '\n' </proc/device-tree/model;arch
Raspberry Pi 4 Model B Rev 1.4
armv7l
$ getconf LONG_BIT
32  # <- 32-bit
64  # <- 64-bit
$ dpkg --print-architecture
armhf

Throttling

$ vcgencmd get_throttled
111100000000000001010
||||             ||||_ under-voltage
||||             |||_ currently throttled
||||             ||_ arm frequency capped
||||             |_ soft temperature reached
||||_ under-voltage has occurred since last reboot
|||_ throttling has occurred since last reboot
||_ arm frequency capped has occurred since last reboot
|_ soft temperature reached since last reboot

Over-clocking

$ sudo cat /sys/devices/system/cpu/cpufreq/policy0/*
0 1 2 3
600000
1200000
600000
355000
0 1 2 3
600000 1200000 
conservative ondemand userspace powersave performance schedutil 
600000
BCM2835 CPUFreq
ondemand
1200000
600000
<unsupported>

Video

  • Capture a 10 seconds video with your camera module:
$ raspivid -o video.h264 -t 10000

Useful commands

  • Check which network the wireless adaptor is using:
$ iwconfig
  • Print a list of the currently available wireless networks:
$ iwlist wlan0 scan
  • Show details about the device's memory:
$ cat /proc/meminfo
  • Show the size and number of partitions on the SD card or hard drive:
$ cat /proc/partitions
  • Show which version of the Raspberry Pi you are using:
$ cat /proc/version
  • Show all of the installed packages that are related to XXX:
$ dpkg --get-selections | grep XXX
  • Show all of the installed packages:
$ dpkg --get-selections
  • Show the IP address of the Raspberry Pi:
$ hostname -I
  • List USB hardware connected to the Raspberry Pi:
$ lsusb
  • Show the temperature of the CPU:
$ vcgencmd measure_temp
  • Show the memory split between the CPU and GPU:
$ vcgencmd get_mem arm && vcgencmd get_mem gpu
  • Display GPIO pinout (GUI-only):
$ pinout

GPIO

  • Light up an LED:
$ sudo -i
# Use GPIO pin 27 by creating a virtual file:
$ echo "27" > /sys/class/gpio/export
# Set pin 27 to ''out'' mode (allows us to turn on/off):
$ echo "out" > /sys/class/gpio/gpio27/direction
# Turn pin on/off:
$ echo "1" > /sys/class/gpio/gpio27/value
$ echo "0" > /sys/class/gpio/gpio27/value
$ exit

I2C

$ sudo apt-get install -y python-smbus i2c-tools
  • If you know an I2C device is connected to your RPi, but you do not know its 7-bit I2C address, use the following command to find it:
$ sudo i2cdetect -y 0

This will search /dev/i2c-0 for all address, and if an MCP4725 DAC breakout is properly connected and it is set to its default address it should show up at 0x62.

If you are using a 512MB Raspberry Pi version 2, you will need to use /dev/i2c-1 by running:

$ sudo i2cdetect -y 1  # as the i2c port number changed from #0 to #1

Compute Modules

Part number options
Model Wireless RAM LPDDR4 eMMC Storage
CM4 0 = No 01 = 1 GB 000 = 0 GB (Lite)
1 = Yes 02 = 2 GB 008 = 8 GB
04 = 4 GB 016 = 16 GB
08 = 8 GB 032 = 32 GB

Example Part Number: CM4102032: Raspberry Pi Compute Module 4, 2GB RAM, 32GB eMMC, Wireless, BCM2711, ARM Cortex-A72, RPL#SC0670B

Miscellaneous

  • Commands to remove Microsoft's repo and GPG key from your Pi:
$ sudo rm /etc/apt/sources.list.d/vscode.list
$ sudo rm /etc/apt/trusted.gpg.d/microsoft.gpg
$ sudo apt update

Use VSCodium instead.

  • Get the current pull:
$ cat /sys/devices/platform/rpi-poe-power-supply@0/power_supply/rpi-poe/current_now
601000
# Note:
# 60100uA = 0.6A
# 0.6A @ 5V (nominal) = 3W (P = IV)
  • Turn a specified GPIO pin (e.g., pin 23) on/off:
echo "23" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio23/direction
echo "1" > /sys/class/gpio/gpio23/value
echo "0" > /sys/class/gpio/gpio23/value
  • Setup HDMI HotSwap:
$ vi /boot/config.txt
hdmi_force_hotplug=1
  • Real-time update for added HDD:
$ echo 1 | sudo tee /sys/bus/pci/rescan

Memory

  • 1GB: 4HBMGCJ
  • 2GB: D9WHZ
  • 4GB: D9WHV
  • 8GB: D9ZCL

Turing Pi v2

SEE: https://turingpi.com/turing-pi-v2-is-here/

Specs
  • Mini ITX standard
  • 4x Nodes
  • Managed Switch, VLAN
  • HDMI
  • 2x Mini PCIe Gen2
  • 2x SATA III 6 Gbps
  • 2x 1 Gbps Ethernet
  • 4x USB 3.0 (2x Front / 2x Back)
  • GPIO 40-pin (RPi compatible)
  • 24-pin ATX power
Removed
  • 4x Node Fan connector
  • 3x GPIO 40-pin
  • Audio-out 3.5mm
Added
  • Nvidia Jetson Support
  • Board Management Controller with remote access
  • System Fan connector
---
slot_1:
  - HDMI
  - GPIO
  - mPCIe
slot_2:
  - mPCIe
slot_3:
  - SATA
slot_4:
  - USB

External links

GPIO

Tools

Alternative OSes

PCIe devices

Cases

Miscelleaneous