Created page with "Category:ARM architecture Category:ARM架构 (简体中文) {{translateme (简体中文)}} cs:Raspberry Pi ru:Raspberry Pi en:Raspberry Pi Raspberry Pi (..."
New page
[[Category:ARM architecture]]
[[Category:ARM架构 (简体中文)]]
{{translateme (简体中文)}}
[[cs:Raspberry Pi]]
[[ru:Raspberry Pi]]
[[en:Raspberry Pi]]
Raspberry Pi (树梅派) 是一个基于[[Wikipedia:ARMv6|ARMv6 架构]]的微型计算机. 查询更多信息可访问[http://www.raspberrypi.org/ 项目主页] 和 [http://uk.farnell.com/raspberry-pi 教程].
== 前言 ==
这篇文章并不是详尽的安装指南,我们假设读者已经成功在树梅派上部署了ArchLinux系统.初次使用ArchLinux的同学可以阅读[[Beginners' guide]].
{{Note|ArchLinux的ARM架构通过http://archlinuxarm.org社区进行非官方支持.任何ARM架构下特有的问题会在[https://wiki.archlinux.org/index.php/Forum_Etiquette#Arch_Linux_Distribution_Support_ONLY Arch Linux Distribution Support ONLY] 官方论坛上被关闭.}}
== 在树梅派上部署ArchLinux ==
参看[http://archlinuxarm.org/platforms/armv6/raspberry-pi ArchLinux ARM]网站文档.
=== 无线网络 ===
默认情况下,安装好的Arch会通过dhcpd连接有线网络.如果你想通过无线网络访问你的树梅派,可以像下面这样创建无线网络配置,并且启用它.
{{Note|首先,你需要一个可以被树梅派正确识别的无线网卡,使用net_tools包里面的iwconfig命令可以查看到当前可用的无线网卡,它可能被命名为wlanX或者raX.}}
# cd /etc/netctl
# cp /examples/wireless-wpa .
# vi wireless-wpa
编辑好配置文件后,使用netctl启动并将其设置为开机自动启动.
# netctl start wireless-wpa
# netctl enable wireless-wpa
然后,你还需要将sshd设置为开机自动启动.
# systemctl enable sshd
这样,你就可以在另一台电脑上使用ssh客户端访问你的树梅派了.
== Audio ==
{{Note|The requisite module {{ic|snd-bcm2835}} should be autoloaded by default.}}
Install the '''alsa-utils''', '''alsa-firmware''', '''alsa-lib''' and '''alsa-plugins''' packages:
# pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
Optionally adjust the default volume using {{ic|alsamixer}} and 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:
$ amixer cset numid=3 ''x''
Where {{ic|''x''}} corresponds to:
*0 for Auto
*1 for Analog out
*3 for HDMI
=== Caveats for HDMI Audio ===
Some applications require a setting in {{ic|/boot/config.txt}} to force audio over HDMI:
hdmi_drive=2
== Video ==
=== HDMI / Analog TV-Out ===
To turn the [[wikipedia:HDMI|HDMI]] or analog TV-Out on or off, have a look at
/opt/vc/bin/tvservice
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 {{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
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.
=== 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 ==
=== 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):
{{hc|$ /opt/vc/bin/vcgencmd measure_temp|2=
temp=49.8'C
}}
Alternatively, simply read from the file system:
{{hc|$ cat /sys/class/thermal/thermal_zone0/temp|2=
49768
}}
For human readable output:
{{hc|awk '{printf "%3.1f°C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp|2=
54.1°C
}}
=== Voltage ===
Four different voltages can be monitored via {{ic|/opt/vc/bin/vcgencmd}} as well:
$ /opt/vc/bin/vcgencmd measure_volts ''<id>''
Where {{ic|''<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 ===
{{AUR|monitorix}} has specific support for the RPi since v3.2.0. Screenshots available [http://www.monitorix.org/screenshots.html here].
== Overclocking/Underclocking ==
The RPi can be overclocked by editing {{ic|/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 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.
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 ==
{{Accuracy|1=Very questionable tips, see also [https://wiki.archlinux.org/index.php?title=ArchWiki:Reports&diff=next&oldid=286971].}}
=== Enable TRIM and noatime by Mount Flags ===
Using this flag in one's {{ic|/etc/fstab}} enables TRIM and noatime on the root ext4 partition. For example:
/dev/root / ext4 noatime,'''discard''' 0 0
{{Note|/dev/root entry maybe missing from your /etc/fstab; by default it is mounted as a VFS by the kernel during system boot.}}
=== Move /var/log to RAM ===
{{Warning|All system logs will be lost on every reboot.}}
Add this entry to your {{ic|/etc/fstab}} to create a RAM disk that is 16MiB in size:
tmpfs /var/log tmpfs nodev,nosuid,size=16M 0 0
Delete your existing log directory:
# rm -R /var/log
Reboot system for changes to take effect.
== Serial Console ==
Edit the default {{ic|/boot/cmdline.txt}}, change {{ic|loglevel}} to {{ic|5}} to see boot messages:
loglevel=5
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 {{ic|/boot/config.txt}}:
start_file=start_x.elf
fixup_file=fixup_x.dat
Optionally
disable_camera_led=1
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 {{ic|/boot/config.txt}}:
cma_lwm=
cma_hwm=
cma_offline_start=
== 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 [http://archlinuxarm.org/forum/viewtopic.php?f=31&t=4993#p27708 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 {{ic|/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 {{ic|/dev/random}}.
== GPIO ==
=== Python ===
To be able to use the GPIO pins from Python, you can use the [https://pypi.python.org/pypi/RPi.GPIO RPi.GPIO] library. Install either {{AUR|python-raspberry-gpio}} or {{AUR|python2-raspberry-gpio}} from the [[AUR]].
== See also ==
* [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/ Archlinux ARM on Raspberry PI] - A FAQ style site with hints and tips for running Archlinux on the rpi