Raspberry Pi (简体中文)

From ArchWiki
Jump to: navigation, search
翻译状态: 本文是英文页面 Raspberry_Pi翻译,最后翻译时间:2014_05_09,点击这里可以查看翻译后英文页面的改动。

来自 Wikipedia:


树莓派最初的版本于2012年发布,基于博通的BCM2835芯片(ARM11 架构)。而最新的树莓派2于2015年发布,基于博通的BCM2836芯片(双核 ARM Cortex-A7 架构)。



Note: ArchLinux的ARM架构支持由 http://archlinuxarm.org 社区提供,而非Arch Linux社区官方支持。任何关于ARM架构下特有问题的讨论将会被关闭,详见Arch Linux distribution support ONLY 政策


树莓派是一个基于ARM的设备,因此它需要专门为此架构编译的二进制软件。这些二进制软件由Arch Linux ARM project提供,他们把Arch Linux移植到了ARM设备上。在他们的官方网站上也有一个松散的社区,而Arch Linux官方社区并不对ARM架构进行官方支持。


  • ARMv6 (BCM2835): 树莓派 Model A, A+, B, B+
  • ARMv7 (BCM2836): 树莓派 2 (基于 Model B+)


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.


参看 Arch Linux ARM Pi documentation 或者 Arch Linux ARM Pi2 documentation


Note: 所依赖的内核模块snd-bcm2835应当默认会被自动加载。

下载 alsa-utils, alsa-firmware, alsa-libalsa-plugins 包:

# pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins



$ amixer cset numid=3 x


  • 0 自动
  • 1 模拟输出
  • 3 HDMI





HDMI / 模拟 TV-输出



Use the -s parameter to check the status of your display, the -o parameter to turn your 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

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.

X.org driver

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

# pacman -S xf86-video-fbdev

Onboard Hardware Sensors


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

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

Lightweight Monitoring Suite

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


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


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 Overclocking article on elinux for additional options and examples.

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.

Users may query the current frequency of the CPU via this command:

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

Tips for maximizing SD card performance

See Improving performance for the general performance improvements.

Enable fsck on boot

To enable fsck on boot, the root filesystem should be mounted as readonly first, and then remounted as read-writable.

First, make root as read-only on boot. edit /boot/cmdline.txt to add "ro" after the option indicating root partition.

ipv6.disable=1 selinux=0 plymouth.enable=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p5 ro rootfstype=ext4 elevator=noop rootwait

Next, add next line in /etc/fstab to remount the partition during boot.

/dev/mmcblk0p5  /       ext4    remount,rw        0       0

Serial Console

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


Change speed from 115200 to 38400:

console=ttyAMA0,38400 kgdboc=ttyAMA0,38400

Start getty service

# 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

Then connect :)

# screen /dev/ttyUSB0 38400

Raspberry Pi Camera module

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:




if you get the following 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

try setting these values in /boot/config.txt:


Hardware Random Number Generator

ArchLinux ARM for the Raspberry Pi is distributed with the rng-tools package installed and the bcm2708-rng module set to load at boot (see this), but we must also 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 restarting the rngd daemon:

systemctl restart rngd

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 be able to use the GPIO pins from Python, you can use the RPi.GPIO library. Install either python-raspberry-gpioAUR or python2-raspberry-gpioAUR[broken link: archived in aur-mirror] from the AUR.

See also