Revision as of 14:25, 31 March 2017

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.

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.

Installing Arch Linux ARM

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.

Network

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

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

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.

audio_pwm_mode=2

Video

CPU/GPU RAM split

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

/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 simply disable overscan if the TV/monitor has a "fit to screen" option.

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

Temperature

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

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

Watchdog

BCM2708 has a hardware watchdog which can be utilized by enabling the bcm2708_wdogkernel 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.

Overclocking/underclocking

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:

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

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.

/etc/modprobe.d/rpi-camera.conf

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.

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.