Difference between revisions of "Raspberry Pi"

From ArchWiki
Jump to: navigation, search
(Temperature: printing readable output)
(Video)
 
(190 intermediate revisions by 59 users not shown)
Line 1: Line 1:
[[Category:Getting and installing Arch]]
+
[[Category:ARM architecture]]
 
[[cs:Raspberry Pi]]
 
[[cs:Raspberry Pi]]
 +
[[ja:Raspberry Pi]]
 
[[ru:Raspberry Pi]]
 
[[ru:Raspberry Pi]]
{{Article summary start}}
+
[[uk:Raspberry Pi]]
{{Article summary text|Raspberry Pi (RPi) is a minimalist computer built for the [[Wikipedia:ARMv6|ARMv6 architecture]]. [http://www.raspberrypi.org/ More information about this project] and [http://uk.farnell.com/raspberry-pi technical specification].}}
+
[[zh-CN:Raspberry Pi]]
{{Article summary heading|Related}}
+
From [[Wikipedia:Raspberry_Pi|Wikipedia]]:
{{Article summary wiki|Beginners' Guide}}
+
  
[http://elinux.org/RPiconfig RPi Config] - Excellent source of info relating to under-the-hood tweaks.
+
:"''The Raspberry Pi is a series of credit card-sized single-board computers developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools.''"
  
[http://elinux.org/RPI_vcgencmd_usage RPi vcgencmd usage] - Overview of firmware command vcgencmd.
+
The original models, released in 2012, are based on the Broadcom SoC BCM2835 ([[Wikipedia:ARM11|ARM11 architecture]]). The Raspberry Pi 2, released in 2015, is shipped with a BCM2836 SoC (quad-core [[Wikipedia:ARM Cortex-A7|ARM Cortex-A7 architecture]]). In February 2016, the Pi 3 was launched which contains a BCM2837 SoC (quad-core [[Wikipedia:ARM Cortex-A53|ARM Cortex-A53 architecture]]) and built in WiFi and Bluetooth.
{{Article summary end}}
+
  
== Article Preface ==
+
== Article preface ==
This article is not meant to be an exhaustive setup guide and assumes that the reader has setup an Arch system before.  Arch newbies are encouraged to read the [[Beginners' Guide]] if unsure how to preform standard tasks such as creating users, managing the system, etc.
+
This article is not meant to be an exhaustive setup guide and assumes that the reader has setup an Arch system before.  Arch newbies are encouraged to read the [[Beginners' guide]] if unsure how to perform standard tasks such as creating users, managing the system, etc.
  
{{Note|Support for the ARM architecture is provided on http://archlinuxarm.org not through posts to the official Arch Linux Forum.  Any posts related to ARM specific issues will be promptly closed per the [https://wiki.archlinux.org/index.php/Forum_Etiquette#Arch_Linux_Distribution_Support_ONLY Arch Linux Distribution Support ONLY] policy.}}
+
{{Note|Support for the ARM architecture is provided on http://archlinuxarm.org not through posts to the official Arch Linux Forum.  Any posts related to ARM specific issues will be promptly closed per the [[Code of conduct#Arch Linux distribution support *only*]] policy.}}
 +
 
 +
== System architecture ==
 +
 
 +
The Raspberry Pi is an ARM-based device and therefore needs binaries compiled for this architecture. These binaries are provided by the [http://archlinuxarm.org/about Arch Linux ARM project] which ports Arch Linux to ARM-based devices. They also have a separate community and forum on their website, while original forum does ''not'' support ARM specific issues.
 +
With the introduction of the Raspberry Pi 2 the packages needed now depend on which architecture the devices has:
 +
* ARMv6 (BCM2835): Raspberry Pi Model A, A+, B, B+, Zero
 +
* ARMv7 (BCM2836): Raspberry Pi 2 (based on Model B+)
 +
* ARMv8 (BCM2837): Raspberry Pi 3
 +
 
 +
== SD card performance ==
 +
 
 +
System responsiveness, particularly during operations involving disk I/O such as updating the system, can be adversely affected by poor quality/slow SD media.  This is characterized by [http://archlinuxarm.org/forum/viewtopic.php?f=64&t=9467 frequent, often extended pauses] as pacman writes out files to the file system.  The pauses are not due to saturation of the RPi or RPi2 bus, but are likely the bottle-neck due to a slow SD (or micro SD) card. See the [[Benchmarking#Flash media]] for more.
 +
 
 +
Performance and system responsiveness can be generally improved by making adjustments to the system configuration. See especially [[Maximizing performance]] and [[SSD#Tips for minimizing disk reads/writes]].
 +
 
 +
=== Enable fsck on boot ===
 +
 
 +
Follow [[fsck#Boot time checking]]. Remember that kernel parameters are specified in {{ic|/boot/cmdline.txt}}.
  
 
== Installing Arch Linux ARM ==
 
== Installing Arch Linux ARM ==
  
See the [http://archlinuxarm.org/platforms/armv6/raspberry-pi#qt-platform_tabs-ui-tabs2 archlinuxarm documentation].
+
See the [http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM Pi documentation] or [http://archlinuxarm.org/platforms/armv7/broadcom/raspberry-pi-2 Arch Linux ARM Pi2 documentation] or [https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-3 Arch Linux ARM Pi3 documentation].
 +
 
 +
== Network ==
 +
 
 +
The fresh install comes preconfigured to use the onboard NIC in dhcp mode via [[systemd-networkd]] which should allow access to an official installation through [[Secure Shell]].  The root user's password is "root" and it is highly recommended to change the password and optionally set up [[SSH keys]].
 +
 
 +
=== Configure WLAN without ethernet ===
 +
 
 +
Users needing to establish a wireless internet connection will need to use a wireless daemon such as [[WPA supplicant]].  Consult the [[Beginners'_guide#Wireless|wireless section]] of the Beginner's Guide for additional instruction.
  
 
== Audio ==
 
== Audio ==
{{Note| The requisite module '''snd-bcm2835''' should be autoloaded by default.}}
+
{{Pkg|alsa-utils}} should supply the needed programs to use onboard sound. Default volume can be adjusted using {{ic|alsamixer}}.
 +
 
 +
A key change with Linux kernel version 4.4.x for ARM related to ALSA and to the needed sound module: in order to use tools such as {{ic|alsamixer}} with the current kernel, users ''must'' modify {{ic|/boot/config.txt}} to contain the following line:
  
Install the needed packages:
+
  dtparam=audio=on
  pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
+
  
Optionally adjust the default volume using `alsamixer` and ensure that the sole source "PCM" is not muted (denoted by double MM if muted).
+
{{Tip|Ensure that the sole source "PCM" is not muted (denoted by {{ic|MM}} if muted, press {{ic|M}} to unmute).}}
  
 
Select an audio source for output:
 
Select an audio source for output:
  amixer cset numid=3 x
+
  $ amixer cset numid=3 ''x''
  
Where 'x' corresponds to:
+
Where {{ic|''x''}} corresponds to:
 
*0 for Auto
 
*0 for Auto
 
*1 for Analog out
 
*1 for Analog out
*3 for HDMI
+
*2 for HDMI
  
=== Caveats for HDMI Audio ===
+
=== Caveats for HDMI audio ===
 
Some applications require a setting in {{ic|/boot/config.txt}} to force audio over HDMI:
 
Some applications require a setting in {{ic|/boot/config.txt}} to force audio over HDMI:
 
  hdmi_drive=2
 
  hdmi_drive=2
  
== Onboard Hardware Sensors ==
+
== Video ==
 +
 
 +
=== HDMI / analog TV-Out ===
 +
With the default configuration,  the Raspberry Pi uses HDMI video if a  [[wikipedia:HDMI|HDMI]] monitor is connected.  Otherwise, it uses analog TV-Out (also known as composite output or RCA)
 +
 
 +
To turn the HDMI or analog TV-Out on or off, have a look at
 +
 
 +
/opt/vc/bin/tvservice
 +
 
 +
Use the ''-s'' parameter to check the status; the ''-o'' parameter to turn the display off and ''-p'' parameter to power on HDMI with preferred settings.
 +
 
 +
Adjustments are likely required to correct proper overscan/underscan and are easily achieved in {{ic|boot/config.txt}} in which many tweaks are set.  To fix, simply uncomment the corresponding lines and setup per the commented instructions:
 +
 
 +
# uncomment the following to adjust overscan. Use positive numbers if console
 +
# goes off screen, and negative if there is too much border
 +
#overscan_left=16
 +
overscan_right=8
 +
overscan_top=-16
 +
overscan_bottom=-16
 +
 
 +
Or you can simply disable overscan if you have a "fit to screen" option in your monitor/TV:
 +
 
 +
disable_overscan=1
 +
 
 +
Users wishing to use the analog video out should consult [https://raw.github.com/Evilpaul/RPi-config/master/config.txt this] config file which contains options for non-NTSC outputs.
 +
 
 +
A reboot is needed for new settings to take effect.
 +
 
 +
=== Caveats for analog TV-Out ===
 +
 
 +
Since Raspberry Pi 1 Model B+ and Raspberry Pi 2 Model B, the composite video socket was removed, with the replacement of composite signal through the 3.5mm video/audio jack. Some RCA cables do not follow the same standard as Raspberry Pi, in which case connect the red or white audio plug for video.[http://www.raspberrypi-spy.co.uk/2014/07/raspberry-pi-model-b-3-5mm-audiovideo-jack/]
 +
 
 +
=== X.org driver ===
 +
 
 +
The X.org driver for Raspberry Pi can be [[installed]] with the ''xf86-video-fbdev'' or ''xf86-video-fbturbo-git'' package.
 +
 
 +
== Onboard hardware sensors ==
 
=== Temperature ===
 
=== Temperature ===
Temperatures sensors for the board itself are including as part of the '''raspberrypi-firmware-tools''' package.  The RPi offers a sensor on the BCM2835 SoC (CPU/GPU):
+
Temperatures sensors can be queried with utils in the ''raspberrypi-firmware-tools'' package.  The RPi offers a sensor on the BCM2835 SoC (CPU/GPU):
  
/opt/vc/bin/vcgencmd measure_temp
+
{{hc|$ /opt/vc/bin/vcgencmd measure_temp|2=
temp=49.8'C
+
temp=49.8'C
 +
}}
  
Alternatively, simply read from the filesystem:
+
Alternatively, simply read from the file system:
cat /sys/class/thermal/thermal_zone0/temp              
+
{{hc|$ cat /sys/class/thermal/thermal_zone0/temp|2=
49768
+
49768
 +
}}
  
 
For human readable output:
 
For human readable output:
awk '{printf "%3.1f°C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp  
+
{{hc|$ awk '{printf "%3.1f°C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp|2=
54.1°C
+
54.1°C
 +
}}
  
 
=== Voltage ===
 
=== Voltage ===
 
Four different voltages can be monitored via {{ic|/opt/vc/bin/vcgencmd}} as well:
 
Four different voltages can be monitored via {{ic|/opt/vc/bin/vcgencmd}} as well:
  
  % /opt/vc/bin/vcgencmd measure_volts <id>
+
  $ /opt/vc/bin/vcgencmd measure_volts ''<id>''
  
 +
Where {{ic|''<id>''}} is:
 
*core for core voltage
 
*core for core voltage
 
*sdram_c for sdram Core voltage
 
*sdram_c for sdram Core voltage
Line 66: Line 132:
 
*sdram_p for sdram PHY voltage
 
*sdram_p for sdram PHY voltage
  
=== Lightweight Monitoring Suite ===
+
=== Lightweight monitoring suite ===
{{AUR|Monitorix}} has specific support for the RPi since v3.2.0.  Screenshots available [[http://www.monitorix.org/screenshots.html here]].
+
{{AUR|monitorix}} has specific support for the RPi since v3.2.0.  Screenshots available [http://www.monitorix.org/screenshots.html here].
 +
 
 +
== Overclocking/underclocking ==
  
== Overclocking/Underclocking ==
 
 
The RPi can be overclocked by editing {{ic|/boot/config.txt}}, for example:
 
The RPi can be overclocked by editing {{ic|/boot/config.txt}}, for example:
 
   
 
   
Line 79: Line 146:
 
  over_voltage=0
 
  over_voltage=0
  
The optional xxx_min lines define the min usage of their respective settings. When the system is not under load, the values will drop down to those specified. Consult the [http://elinux.org/RPiconfig#Overclocking Overclocking] article on elinux for additional options and examples.
+
The optional {{ic|*_min}} lines define the minimum frequency to be used for the given component. When the system is not under load, the frequencies will drop down to the minimum value. Consult the [http://elinux.org/RPiconfig#Overclocking Overclocking] article on elinux for additional options and examples.
  
 
A reboot is needed for new settings to take effect.
 
A reboot is needed for new settings to take effect.
  
{{Note|The overclocked setting for CPU clock applies only when the governor throttles up the CPU, i.e. under load.}}
+
The overclocked setting for CPU clock applies only when the governor throttles up the CPU, i.e. under load. To query the current frequency of the CPU:
  
Users may query the current frequency of the CPU via this command:
+
  $ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
  cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
+
  
== Serial Console ==
+
See [[CPU frequency scaling]] for details on scaling governors.
Edit the default /boot/cmdline.txt
+
  
Change loglevel to 5 to see boot messages
+
{{Tip|The following script will show all frequencies set on the RPi:
 +
{{bc|<nowiki>
 +
#/bin/bash
 +
for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do
 +
    echo -e "$src:\t$(/opt/vc/bin/vcgencmd  measure_clock $src)"
 +
done
 +
</nowiki>}}
 +
}}
 +
 
 +
== Serial console ==
 +
Edit the default {{ic|/boot/cmdline.txt}}, change {{ic|loglevel}} to {{ic|5}} to see boot messages:
 
  loglevel=5
 
  loglevel=5
  
Change speed from 115200 to 38400
+
If the default speed of 115200 does not work properly, try changing it to 38400:
 
  console=ttyAMA0,38400 kgdboc=ttyAMA0,38400
 
  console=ttyAMA0,38400 kgdboc=ttyAMA0,38400
  
Start getty service
+
Start getty service on the Pi
  systemctl start getty@ttyAMA0
+
  # systemctl start getty@ttyAMA0
  
 
Enable on boot
 
Enable on boot
  systemctl enable getty@ttyAMA0.service
+
  # systemctl enable getty@ttyAMA0.service
  
 
Creating the proper service link:
 
Creating the proper service link:
  ln -s /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service
+
  # ln -s /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service
  
Then connect :)
+
From a PC, connect:
  screen /dev/ttyUSB0 38400
+
  # screen /dev/ttyUSB0 38400
  
== Video ==
+
== Raspberry Pi camera module ==
pacman -S xf86-video-fbdev
+
The commands for the camera module are included as part of the ''raspberrypi-firmware-tools'' package - which is installed by default.
 +
$ /opt/vc/bin/raspistill
 +
$ /opt/vc/bin/raspivid
  
Adjustments are likely required to correct proper overscan/underscan and are easily achieved in {{ic|boot/config.txt}} in which many tweaks are setTo fix, simply uncomment the corresponding lines and setup per the commented instructions:
+
Append to {{ic|/boot/config.txt}}:
 +
gpu_mem=128
 +
start_file=start_x.elf
 +
  fixup_file=fixup_x.dat
  
# uncomment the following to adjust overscan. Use positive numbers if console
+
Optionally
# goes off screen, and negative if there is too much border
+
  disable_camera_led=1
#overscan_left=16
+
overscan_right=8
+
overscan_top=-16
+
  overscan_bottom=-16
+
  
Users wishing to use the analog video out should consult [https://raw.github.com/Evilpaul/RPi-config/master/config.txt this] config file which contains options for non-NTSC outputs.
+
The following is a common error:
 +
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
 +
mmal: camera component couldn't be enabled
 +
mmal: main: Failed to create camera component
 +
mmal: Failed to run camera app. Please check for firmware updates
  
A reboot is needed for new settings to take effect.
+
which can be corrected by setting these values in {{ic|/boot/config.txt}}:
 +
cma_lwm=
 +
cma_hwm=
 +
cma_offline_start=
  
== Raspberry Pi Camera module ==
+
Another common error:
The commands for the camera module are including as part of the '''raspberrypi-firmware-tools''' package - which is installed by default. You can then use:
+
/opt/vc/bin/raspistill
+
/opt/vc/bin/raspivid
+
  
You need to append to /boot/config.txt:
+
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
 +
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
 +
mmal: Failed to create camera component
 +
mmal: main: Failed to create camera component
 +
mmal: Only 64M of gpu_mem is configured. Try running "sudo raspi-config" and ensure that "memory_split" has a value of 128 or greater
  
start_file=start_x.elf
+
can be corrected by adding the following line:
fixup_file=fixup_x.dat
+
{{hc|/etc/modprobe.d/blacklist.conf|blacklist i2c_bcm2708}}
  
Optionally
+
In order to use standard applications (those that look for {{ic|/dev/video0}}) the V4L2 driver must be loaded.  This can be done automatically at boot by creating an autoload file such as the following.
  disable_camera_led=1
+
{{hc|/etc/modules-load.d/rpi-camera.conf|bcm2835-v4l2}}
 +
 
 +
== Hardware random number generator ==
 +
Arch Linux ARM for the Raspberry Pi has the {{ic|bcm2708-rng}} module set to load at boot (see [http://archlinuxarm.org/forum/viewtopic.php?f=31&t=4993#p27708 this]), but install the ''rng-tools'' and tell the Hardware RNG Entropy Gatherer Daemon (''rngd'') where to find the hardware random number generator.
 +
 
 +
This can be done by editing {{ic|/etc/conf.d/rngd}}:
 +
 
 +
RNGD_OPTS="-o /dev/random -r /dev/hwrng"
 +
 
 +
and enabling and [[start]]ing the ''rngd'' service.
 +
 
 +
If [[haveged]] is running, it should be stopped and disabled, as it might compete with ''rngd'' and is only preferred when there is no hardware random number generator available.
 +
 
 +
Once completed, this change ensures that data from the hardware random number generator is fed into the kernel's entropy pool at {{ic|/dev/random}}. To check the available entropy, run:
 +
 
 +
# cat /proc/sys/kernel/random/entropy_avail
 +
 
 +
The number it reports should be around 3000, whereas before setting up ''rngd'' it would have been closer to 1000.
 +
 
 +
== GPIO ==
 +
=== SPI ===
 +
To enable the {{ic|/dev/spidev*}} devices, uncomment the following line:
 +
{{hc|head=/boot/config.txt|output=
 +
device_tree_param=spi=on
 +
}}
 +
 
 +
=== Python ===
 +
To be able to use the GPIO pins from Python, use the [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO] library. Install either {{AUR|python-raspberry-gpio}} or {{AUR|python2-raspberry-gpio}}{{Broken package link|{{aur-mirror|python2-raspberry-gpio}}}} from the [[AUR]].
 +
 
 +
== I2C ==
 +
 
 +
Install ''i2c-tools'' and ''lm_sensors'' packages.
 +
 
 +
Configure the bootloader to enable the i2c hardware by appending {{ic|/boot/config.txt}}:
 +
  dtparam=i2c_arm=on
 +
 
 +
Configure the {{ic|i2c-dev}} and {{ic|i2c-bcm2708}} (if you did not blacklist it for the camera) modules to be loaded at boot:
 +
 
 +
{{hc|/etc/modules-load.d/raspberrypi.conf|i2c-dev
 +
i2c-bcm2708}}
 +
 
 +
Reboot the Raspberry Pi and issue the following command to get the hardware address:
 +
  i2cdetect -y 0
 +
 
 +
{{Note|If you use the I2C1 port instead of I2C0, you will need to run {{ic|i2cdetect -y 1}} instead and replace {{ic|i2c-0}} with {{ic|i2c-1}} in the following steps.}}
 +
 
 +
Now we need to tell Linux to instantiate the device. Change the hardware address to the address found in the previous step with '0x' as prefix (e.g. 0x48) and choose a device name:
 +
  echo <devicename> <hardware address> >/sys/class/i2c-adapter/i2c-0/new_device
 +
 
 +
Check the dmesg command for a new entry:
 +
  i2c-0: new_device: Instantiated device ds1621 at 0x48
 +
Finally, read the sensor output:
 +
  sensors
 +
 
 +
== QEMU chroot ==
 +
 
 +
Sometimes it is easier to work directly on a disk image instead of the real Raspberry Pi. This can be achieved by mounting an SD card containing the RPi root partition and chrooting into it. From the chroot it should be possible to run ''pacman'' and install more packages, compile large libraries etc. Since the executables are for the ARM architecture, the translation to x86 needs to be performed by [[QEMU]].
 +
 
 +
{{Note|As of January 2016, {{pkg|make}} won't run in QEMU for ARM so it is not possible to build packages this way.  Follow the [https://archlinuxarm.org/wiki/Distcc_Cross-Compiling guide on the Arch Linux ARM website] to build a cross-compiler if building ARM packages is needed.}}
 +
 
 +
Install {{AUR|binfmt-support}} and {{AUR|qemu-user-static}} from the [[AUR]].
 +
 
 +
Make sure that the ARM to x86 translation is active:
 +
 
 +
# update-binfmts --importdir /var/lib/binfmts/ --import
 +
# update-binfmts --display qemu-arm
 +
 
 +
If ARM to x86 translation is not active, enable it using update-binfmts:
 +
 
 +
# update-binfmts --enable qemu-arm
 +
 
 +
Mount the SD card to {{ic|mnt/}} (the device name may be different).
 +
 
 +
# mkdir mnt
 +
# mount /dev/mmcblk0p2 mnt
 +
 
 +
Copy the QEMU executable, which will handle the translation from ARM, to the SD card root:
 +
 
 +
# cp /usr/bin/qemu-arm-static mnt/usr/bin
 +
 
 +
Finally chroot into the SD card root as described in [[Change root#Using chroot]], keeping in mind that {{ic|qemu-arm-static}} needs to be called in the {{ic|chroot}} command i.e.:
 +
 
 +
# chroot /mnt/arch /usr/bin/qemu-arm-static /bin/bash
 +
 
 +
== See also ==
 +
* [https://www.raspberrypi.org Raspberry Pi] - Official website
 +
* [http://elinux.org/RPiconfig RPi Config] - Excellent source of info relating to under-the-hood tweaks.
 +
* [http://elinux.org/RPI_vcgencmd_usage RPi vcgencmd usage] - Overview of firmware command vcgencmd.
 +
* [http://archpi.dabase.com/ Arch Linux ARM on Raspberry PI] - A FAQ style site with hints and tips for running Arch Linux on the RPi
 +
* [https://github.com/phortx/Raspberry-Pi-Setup-Guide] - A really opinionated guide how to setup a RPi with Arch Linux

Latest revision as of 00:22, 26 June 2016

From Wikipedia:

"The Raspberry Pi is a series of credit card-sized single-board computers developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools."

The original models, released in 2012, are based on the Broadcom SoC BCM2835 (ARM11 architecture). The Raspberry Pi 2, released in 2015, is shipped with a BCM2836 SoC (quad-core ARM Cortex-A7 architecture). In February 2016, the Pi 3 was launched which contains a BCM2837 SoC (quad-core ARM Cortex-A53 architecture) and built in WiFi and Bluetooth.

Article preface

This article is not meant to be an exhaustive setup guide and assumes that the reader has setup an Arch system before. Arch newbies are encouraged to read the Beginners' guide if unsure how to perform standard tasks such as creating users, managing the system, etc.

Note: Support for the ARM architecture is provided on http://archlinuxarm.org not through posts to the official Arch Linux Forum. Any posts related to ARM specific issues will be promptly closed per the Code of conduct#Arch Linux distribution support *only* policy.

System architecture

The Raspberry Pi is an ARM-based device and therefore needs binaries compiled for this architecture. These binaries are provided by the Arch Linux ARM project which ports Arch Linux to ARM-based devices. They also have a separate community and forum on their website, while original forum does not support ARM specific issues. With the introduction of the Raspberry Pi 2 the packages needed now depend on which architecture the devices has:

  • ARMv6 (BCM2835): Raspberry Pi Model A, A+, B, B+, Zero
  • ARMv7 (BCM2836): Raspberry Pi 2 (based on Model B+)
  • ARMv8 (BCM2837): Raspberry Pi 3

SD card performance

System responsiveness, particularly during operations involving disk I/O such as updating the system, can be adversely affected by poor quality/slow SD media. This is characterized by frequent, often extended pauses as pacman writes out files to the file system. The pauses are not due to saturation of the RPi or RPi2 bus, but are likely the bottle-neck due to a slow SD (or micro SD) card. See the Benchmarking#Flash media for more.

Performance and system responsiveness can be generally improved by making adjustments to the system configuration. See especially Maximizing performance and SSD#Tips for minimizing disk reads/writes.

Enable fsck on boot

Follow fsck#Boot time checking. Remember that kernel parameters are specified in /boot/cmdline.txt.

Installing Arch Linux ARM

See the Arch Linux ARM Pi documentation or Arch Linux ARM Pi2 documentation or Arch Linux ARM Pi3 documentation.

Network

The fresh install comes preconfigured to use the onboard NIC in dhcp mode via systemd-networkd which should allow access to an official installation through Secure Shell. The root user's password is "root" and it is highly recommended to change the password and optionally set up SSH keys.

Configure WLAN without ethernet

Users needing to establish a wireless internet connection will need to use a wireless daemon such as WPA supplicant. Consult the wireless section of the Beginner's Guide for additional instruction.

Audio

alsa-utils should supply the needed programs to use onboard sound. Default volume can be adjusted using alsamixer.

A key change with Linux kernel version 4.4.x for ARM related to ALSA and to the needed sound module: in order to use tools such as alsamixer with the current kernel, users must modify /boot/config.txt to contain the following line:

dtparam=audio=on
Tip: Ensure that the sole source "PCM" is not muted (denoted by MM if muted, press M to unmute).

Select an audio source for output:

$ amixer cset numid=3 x

Where x corresponds to:

  • 0 for Auto
  • 1 for Analog out
  • 2 for HDMI

Caveats for HDMI audio

Some applications require a setting in /boot/config.txt to force audio over HDMI:

hdmi_drive=2

Video

HDMI / analog TV-Out

With the default configuration, the Raspberry Pi uses HDMI video if a HDMI monitor is connected. Otherwise, it uses analog TV-Out (also known as composite output or RCA)

To turn the HDMI or analog TV-Out on or off, have a look at

/opt/vc/bin/tvservice

Use the -s parameter to check the status; the -o parameter to turn the display off and -p parameter to power on HDMI with preferred settings.

Adjustments are likely required to correct proper overscan/underscan and are easily achieved in boot/config.txt in which many tweaks are set. To fix, simply uncomment the corresponding lines and setup per the commented instructions:

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
overscan_right=8
overscan_top=-16
overscan_bottom=-16

Or you can simply disable overscan if you have a "fit to screen" option in your monitor/TV:

disable_overscan=1

Users wishing to use the analog video out should consult this config file which contains options for non-NTSC outputs.

A reboot is needed for new settings to take effect.

Caveats for analog TV-Out

Since Raspberry Pi 1 Model B+ and Raspberry Pi 2 Model B, the composite video socket was removed, with the replacement of composite signal through the 3.5mm video/audio jack. Some RCA cables do not follow the same standard as Raspberry Pi, in which case connect the red or white audio plug for video.[1]

X.org driver

The X.org driver for Raspberry Pi can be installed with the xf86-video-fbdev or xf86-video-fbturbo-git package.

Onboard hardware sensors

Temperature

Temperatures sensors can be queried with utils in the raspberrypi-firmware-tools package. The RPi offers a sensor on the BCM2835 SoC (CPU/GPU):

$ /opt/vc/bin/vcgencmd measure_temp
temp=49.8'C

Alternatively, simply read from the file system:

$ cat /sys/class/thermal/thermal_zone0/temp
49768

For human readable output:

$ awk '{printf "%3.1f°C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp
54.1°C

Voltage

Four different voltages can be monitored via /opt/vc/bin/vcgencmd as well:

$ /opt/vc/bin/vcgencmd measure_volts <id>

Where <id> is:

  • core for core voltage
  • sdram_c for sdram Core voltage
  • sdram_i for sdram I/O voltage
  • sdram_p for sdram PHY voltage

Lightweight monitoring suite

monitorixAUR has specific support for the RPi since v3.2.0. Screenshots available here.

Overclocking/underclocking

The RPi can be overclocked by editing /boot/config.txt, for example:

arm_freq=800
arm_freq_min=100
core_freq=300
core_freq_min=75
sdram_freq=400
over_voltage=0

The optional *_min lines define the minimum frequency to be used for the given component. When the system is not under load, the frequencies will drop down to the minimum value. Consult the Overclocking article on elinux for additional options and examples.

A reboot is needed for new settings to take effect.

The overclocked setting for CPU clock applies only when the governor throttles up the CPU, i.e. under load. To query the current frequency of the CPU:

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

See CPU frequency scaling for details on scaling governors.

Tip: The following script will show all frequencies set on the RPi:
#/bin/bash
for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do
    echo -e "$src:\t$(/opt/vc/bin/vcgencmd  measure_clock $src)"
done

Serial console

Edit the default /boot/cmdline.txt, change loglevel to 5 to see boot messages:

loglevel=5

If the default speed of 115200 does not work properly, try changing it to 38400:

console=ttyAMA0,38400 kgdboc=ttyAMA0,38400

Start getty service on the Pi

# systemctl start getty@ttyAMA0

Enable on boot

# systemctl enable getty@ttyAMA0.service

Creating the proper service link:

# ln -s /usr/lib/systemd/system/serial-getty@.service /etc/systemd/system/getty.target.wants/serial-getty@ttyAMA0.service

From a PC, connect:

# screen /dev/ttyUSB0 38400

Raspberry Pi camera module

The commands for the camera module are included as part of the raspberrypi-firmware-tools package - which is installed by default.

$ /opt/vc/bin/raspistill
$ /opt/vc/bin/raspivid

Append to /boot/config.txt:

gpu_mem=128
start_file=start_x.elf
fixup_file=fixup_x.dat

Optionally

disable_camera_led=1

The following is a common error:

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

which can be corrected by setting these values in /boot/config.txt:

cma_lwm=
cma_hwm=
cma_offline_start=

Another common error:

mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Only 64M of gpu_mem is configured. Try running "sudo raspi-config" and ensure that "memory_split" has a value of 128 or greater

can be corrected by adding the following line:

/etc/modprobe.d/blacklist.conf
blacklist i2c_bcm2708

In order to use standard applications (those that look for /dev/video0) the V4L2 driver must be loaded. This can be done automatically at boot by creating an autoload file such as the following.

/etc/modules-load.d/rpi-camera.conf
bcm2835-v4l2

Hardware random number generator

Arch Linux ARM for the Raspberry Pi has the bcm2708-rng module set to load at boot (see this), but install the rng-tools and tell the Hardware RNG Entropy Gatherer Daemon (rngd) where to find the hardware random number generator.

This can be done by editing /etc/conf.d/rngd:

RNGD_OPTS="-o /dev/random -r /dev/hwrng"

and enabling and starting the rngd service.

If haveged is running, it should be stopped and disabled, as it might compete with rngd and is only preferred when there is no hardware random number generator available.

Once completed, this change ensures that data from the hardware random number generator is fed into the kernel's entropy pool at /dev/random. To check the available entropy, run:

# cat /proc/sys/kernel/random/entropy_avail

The number it reports should be around 3000, whereas before setting up rngd it would have been closer to 1000.

GPIO

SPI

To enable the /dev/spidev* devices, uncomment the following line:

/boot/config.txt
device_tree_param=spi=on

Python

To be able to use the GPIO pins from Python, use the RPi.GPIO library. Install either python-raspberry-gpioAUR or python2-raspberry-gpioAUR[broken link: archived in aur-mirror] from the AUR.

I2C

Install i2c-tools and lm_sensors packages.

Configure the bootloader to enable the i2c hardware by appending /boot/config.txt:

 dtparam=i2c_arm=on

Configure the i2c-dev and i2c-bcm2708 (if you did not blacklist it for the camera) modules to be loaded at boot:

/etc/modules-load.d/raspberrypi.conf
i2c-dev
i2c-bcm2708

Reboot the Raspberry Pi and issue the following command to get the hardware address:

 i2cdetect -y 0
Note: If you use the I2C1 port instead of I2C0, you will need to run i2cdetect -y 1 instead and replace i2c-0 with i2c-1 in the following steps.

Now we need to tell Linux to instantiate the device. Change the hardware address to the address found in the previous step with '0x' as prefix (e.g. 0x48) and choose a device name:

 echo <devicename> <hardware address> >/sys/class/i2c-adapter/i2c-0/new_device

Check the dmesg command for a new entry:

 i2c-0: new_device: Instantiated device ds1621 at 0x48

Finally, read the sensor output:

 sensors

QEMU chroot

Sometimes it is easier to work directly on a disk image instead of the real Raspberry Pi. This can be achieved by mounting an SD card containing the RPi root partition and chrooting into it. From the chroot it should be possible to run pacman and install more packages, compile large libraries etc. Since the executables are for the ARM architecture, the translation to x86 needs to be performed by QEMU.

Note: As of January 2016, make won't run in QEMU for ARM so it is not possible to build packages this way. Follow the guide on the Arch Linux ARM website to build a cross-compiler if building ARM packages is needed.

Install binfmt-supportAUR and qemu-user-staticAUR from the AUR.

Make sure that the ARM to x86 translation is active:

# update-binfmts --importdir /var/lib/binfmts/ --import
# update-binfmts --display qemu-arm

If ARM to x86 translation is not active, enable it using update-binfmts:

# update-binfmts --enable qemu-arm

Mount the SD card to mnt/ (the device name may be different).

# mkdir mnt
# mount /dev/mmcblk0p2 mnt

Copy the QEMU executable, which will handle the translation from ARM, to the SD card root:

# cp /usr/bin/qemu-arm-static mnt/usr/bin

Finally chroot into the SD card root as described in Change root#Using chroot, keeping in mind that qemu-arm-static needs to be called in the chroot command i.e.:

# chroot /mnt/arch /usr/bin/qemu-arm-static /bin/bash

See also