Difference between revisions of "Raspberry Pi"

From ArchWiki
Jump to: navigation, search
(removing duplicate content - this page should only cover things specific to the hardware)
(Added configuration instructions for feeding random numbers from the hardware random number generator to /dev/random.)
(47 intermediate revisions by 22 users not shown)
Line 1: Line 1:
{{delete|Archlinuxarm is a seperate project.  The lead dev for alarm does not support this page.}}
 
 
[[Category:Getting and installing Arch]]
 
[[Category:Getting and installing Arch]]
{{Note|Support for the ARM architecture is provided on http://archlinuxarm.org/ }}
+
[[cs:Raspberry Pi]]
 +
[[ru:Raspberry Pi]]
 +
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].
  
How mature is Raspberry Pi (RPI). A brief overview.
+
== 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.
  
== What is Raspberry Pi ==
+
{{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.}}
 
+
It is a minimalist computer built for ARMv6 architecture. [http://www.raspberrypi.org/ More information about this project] and [http://uk.farnell.com/raspberry-pi technical specification].
+
  
 
== Installing Arch Linux ARM ==
 
== Installing Arch Linux ARM ==
  
In this manual will describe only essential moments for different RPI. Other procedures are the same instructions for ArchLinux. The only exception is the basic initialization and installation of equipment. It is further assumed that the configuration is performed on a machine running Archlinux.
+
See the [http://archlinuxarm.org/platforms/armv6/raspberry-pi#qt-platform_tabs-ui-tabs2 archlinuxarm documentation].
  
=== Backup Cards ===
+
== Audio ==
If you own an official card provided with your RPI ([http://uk.farnell.com/samsung/raspberry-pi-prog-4gb-sdcard/memory-sdcard-raspberry-pi-4gb/dp/2113756 for example]) recommend before installing Arch ARM Linux to backup using {{ic|dd}}. The path must be specified to the device {{ic|/dev/sdX}} not for another partition {{ic|/dev/sdc1}}
+
{{Note| The requisite module '''snd-bcm2835''' should be autoloaded by default.}}
  
  # dd if=/dev/sdX of=$HOME/backup_RPi.img
+
Install the needed packages:
 +
  pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins
  
{{Note | There is a bit copy of the card. The resulting file is the same size as your card.}}
+
Optionally adjust the default volume using `alsamixer` and ensure that the sole source "PCM" is not muted (denoted by double MM if muted).
{{Note | card may not be installed.}}
+
{{Warning | Bad parameters can damage your data.}}
+
  
=== Installation ===
+
Select an audio source for output:
 +
amixer cset numid=3 x
  
Installation is similar to backing card. Download the image file from [http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM]
+
Where 'x' corresponds to:
 +
*0 for Auto
 +
*1 for Analog out
 +
*3 for HDMI
  
# dd bs=1M if=/path/to/archlinux.img of=/dev/sdX
+
=== Caveats for HDMI Audio ===
 +
Some applications require a setting in {{ic|/boot/config.txt}} to force audio over HDMI:
 +
hdmi_drive=2
  
After inserting the card into the slot on the PPi should boot the base system Arch Linux ARM.
+
== Video ==
  
=== Home ===
+
=== HDMI / Analog TV-Out ===
 +
To turn the [[HDMI]] or analog TV-Out on or off, you can have a look at
  
The downloaded image file is approximately 2 gigabytes of which is /boot 94 megabytes and / 1.8 gigabytes. If you used a larger card to 2GB, so I recommend the rest of the card to connect as /home (or /usr). Clearance must be formatted using the example [[Gparted]]. At the first possible opportunity (after booting RPI or after mounting the card in the computer) need to be adjusted {{ic | /etc/fstab}}
+
/opt/vc/bin/tvservice
  
# sudo vim /etc/fstab
+
Among other, you can 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.
  
For example, add
+
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:
  
  /dev/mmcblk0p3 / home ext4 defaults 0 0
+
  # 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
  
== The first operation ==
+
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.
  
Summary of the [http://archlinuxarm.org/support/guides/system/first-steps official procedure]:
+
A reboot is needed for new settings to take effect.
  
=== Remote SSH access ===
+
=== X.org driver ===
  
If you do not use the HDMI output RPI and you will access the device using SSH, the following applies.
+
The X.org driver for Raspberry Pi can be installed with:
Root pasword is: {{ic | root}}. I recommend to perform key exchange [[SSH_Keys]].
+
  
  $ ssh root@192.168.1.123 (Use your Ip RPI)
+
  pacman -S xf86-video-fbdev
  
=== Localization ===
+
== Onboard Hardware Sensors ==
 +
=== 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):
  
  # vim /etc/locale.gen
+
  /opt/vc/bin/vcgencmd measure_temp
 +
temp=49.8'C
  
uncomment {{ic | en_US.UTF-8 UTF-8}} and {{ic | en_US ISO-8859-2}}
+
Alternatively, simply read from the filesystem:
 +
cat /sys/class/thermal/thermal_zone0/temp               
 +
49768
  
generate localization files
+
For human readable output:
 +
awk '{printf "%3.1f°C\n", $1/1000}' /sys/class/thermal/thermal_zone0/temp
 +
54.1°C
  
# locale-gen
+
=== Voltage ===
 +
Four different voltages can be monitored via {{ic|/opt/vc/bin/vcgencmd}} as well:
  
=== Setting the time and date using OpenNTP ===
+
% /opt/vc/bin/vcgencmd measure_volts <id>
  
dopnit
+
*core for core voltage
 +
*sdram_c for sdram Core voltage
 +
*sdram_i for sdram I/O voltage
 +
*sdram_p for sdram PHY voltage
  
=== Setting the time and date manually ===
+
=== Lightweight Monitoring Suite ===
 +
{{AUR|Monitorix}} has specific support for the RPi since v3.2.0.  Screenshots available [[http://www.monitorix.org/screenshots.html here]].
  
complete
+
== 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
  
=== Changing the root password ===
+
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.
After the first start RPI is native root password to root. It is therefore necessary to change it. Executed after power command {{ic | passwd}}
+
  
# passwd root
+
A reboot is needed for new settings to take effect.
  
=== Adding another user ===
+
{{Note|The overclocked setting for CPU clock applies only when the governor throttles up the CPU, i.e. under load.}}
Using {{ic|adduser}} to add the user.
+
  
  # adduser
+
Users may query the current frequency of the CPU via this command:
 +
  cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
  
=== Sudo ===
+
== Tips for Maximizing SD Card Performance ==
Start {{ic|visudo}}
+
  
# sudo visudo
+
=== Enable TRIM and noatime by Mount Flags ===
  
add the line "USER ALL = (ALL) ALL" below the line root ALL = (ALL) ALL
+
Using this flag in one's {{ic|/etc/fstab}} enables TRIM and noatime on the root ext4 partition.
  
== Video ==
+
/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 affect.
 +
 
 +
=== Link bash_history to /dev/null ===
 +
 
 +
{{Warning|Your bash history be lost at the end of each session.}}
 +
 
 +
ln -sf ~/.bash_history /dev/null
 +
 
 +
== Serial Console ==
 +
Edit the default /boot/cmdline.txt
 +
 
 +
Change loglevel to 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 /boot/config.txt:
 +
 
 +
start_file=start_x.elf
 +
fixup_file=fixup_x.dat
 +
 
 +
Optionally
 +
disable_camera_led=1
 +
 
 +
== 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}}.
  
The generic {{pkg|xf86-video-fbdev}} driver can be used.
+
== 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.

Revision as of 10:18, 5 January 2014

Raspberry Pi (RPi) is a minimalist computer built for the ARMv6 architecture. More information about this project and technical specification.

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.

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 Arch Linux Distribution Support ONLY policy.

Installing Arch Linux ARM

See the archlinuxarm documentation.

Audio

Note: The requisite module snd-bcm2835 should be autoloaded by default.

Install the needed packages:

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

Select an audio source for output:

amixer cset numid=3 x

Where 'x' corresponds to:

  • 0 for Auto
  • 1 for Analog out
  • 3 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

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

/opt/vc/bin/tvservice

Among other, you can 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
#overscan_left=16
overscan_right=8
overscan_top=-16
overscan_bottom=-16

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:

pacman -S xf86-video-fbdev

Onboard Hardware Sensors

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

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

Alternatively, simply read from the filesystem:

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>
  • 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 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

Enable TRIM and noatime by Mount Flags

Using this flag in one's /etc/fstab enables TRIM and noatime on the root ext4 partition.

/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 /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 affect.

Link bash_history to /dev/null

Warning: Your bash history be lost at the end of each session.
ln -sf ~/.bash_history /dev/null

Serial Console

Edit the default /boot/cmdline.txt

Change loglevel to 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 /boot/config.txt:

start_file=start_x.elf
fixup_file=fixup_x.dat

Optionally

disable_camera_led=1

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.

See also