Difference between revisions of "Raspberry Pi"

From ArchWiki
Jump to navigation Jump to search
(→‎I2C: added install and package links)
(Undo revision 472669 by Etskinner (talk) - RPi does not use i686/x86_64 packages)
Line 270: Line 270:
=== I2C ===
=== I2C ===
[[Install]] the {{pkg|i2c-tools}} and {{pkg|lm_sensors}} packages.
Install ''i2c-tools'' and ''lm_sensors'' packages.
Configure the bootloader to enable the i2c hardware by appending {{ic|/boot/config.txt}}:
Configure the bootloader to enable the i2c hardware by appending {{ic|/boot/config.txt}}:

Revision as of 16:39, 31 March 2017

Gnome-colors-add-files-to-archive.pngThis article is being considered for archiving.Gnome-colors-add-files-to-archive.png

Reason: Merged to [1].[2] Redirect to Category:ARM architecture. (Discuss in Talk:Raspberry Pi#)

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.

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, Zero W
  • 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 bus, they are likely caused by a slow micro SD card. See the Benchmarking#Flash media for measuring performance. The recommended solution is use so-called "Pro" class media classified as UHS-I U3 or better. As well, performance and system responsiveness can be tweaked by making adjustments to the system configuration. See Improving performance.

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.

Note: Although the RPi3 can run either ARMv7 (32-bit) or AArch64 (64-bit) architectures, there is currently no support for the vendor-provided libraries, extensions, or related software for AArch64 and some hardware on the board may not work, or may perform poorly. ARMv7 is recommended at this time.


The fresh install comes preconfigured to use the onboard NIC in dhcp mode via systemd-networkd. This should allow access to an official installation through Secure Shell. The default hostname is alarmpi. 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. See also Wireless network configuration.


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:

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:


Caveats for Analogue audio

Sometimes audio from the 3.5mm analogue output can be terribly distorted. Adding the following to /boot/config.txt may fix the problem.




Memory split between the CPU and GPU of the SoC can be set in boot/config.txt by adjusting the parameter gpu_mem which stands for the amount of RAM in MB that is available to the GPU (minimum 16, default 64) and the rest is available to the ARM CPU.

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


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

Or simply disable overscan if the TV/monitor has a "fit to screen" option.


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.[3]

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


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

$ /opt/vc/bin/vcgencmd measure_temp

Alternatively, simply read from the file system:

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

For human readable output:

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


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


BCM2708 has a hardware watchdog which can be utilized by enabling the bcm2708_wdog kernel module.

For proper operation the watchdog daemon also has to be installed, configured (by uncommenting the "watchdog-device" line in /etc/watchdog.conf) and enabled.

This should also apply for Raspberry Pi 2 by using the bcm2709_wdog module and Raspberry Pi 3 by using the bcm2835_wdt module.

Lightweight monitoring suite

monitorixAUR has specific support for the RPi since v3.2.0 through the raspberrypi = y setting in /etc/monitorix/monitorix.conf. Temperature, voltages, and frequencies are logged; screenshots available here.


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


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:
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)"

Serial console

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

Note: The Pi3 requires enable_uart=1 be added to /boot/config.txt in order to display boot messages.

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

console=ttyAMA0,38400 kgdboc=ttyAMA0,38400

Start and enable the getty@ttyAMA0 systemd service on the Pi.

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 package - which is installed by default.

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

Append to /boot/config.txt:




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:


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:

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.


The V4L2 driver by default only allows video recording up to 1280x720, else it glues together consecutive still screens resulting in videos of 4 fps or lower. Adding the following options removes this limitation.

options bcm2835-v4l2 max_video_width=3240 max_video_height=2464

Hardware random number generator

Arch Linux ARM for the Raspberry Pi had the bcm2708-rng module set to load at boot (see this); starting with kernel 4.4.7 the bcm2835_rng module replaces the former on Raspberry Pi 2 and Raspberry Pi 3 units.

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.

I/O pins


To be able to use the GPIO pins from Python, use the RPi.GPIO library. Install the python-raspberry-gpioAUR package.


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



Install i2c-tools and lm_sensors packages.

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


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


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

 i2cdetect -y 0
Note: When using the I2C1 port instead of I2C0, one 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:


Compiling on the RPi

Compiling can be very slow on a RPi. Distcc can greatly improve compilation times if other nodes are on the network. For users with x86_64 or i686 boxes, Distcc#Arch ARM describes the proper setup for distcc to use these resources.

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:

# chroot /mnt/arch /bin/bash

See also