Difference between revisions of "Raspberry Pi/Quick Install Guide"
m (10.0 -> 13.0 profile update) |
(→Enable software clock: added back the commands to install ntp-client, started discussion on subject.) |
||
Line 140: | Line 140: | ||
| rc-update del hwclock boot}} | | rc-update del hwclock boot}} | ||
To set the [[system time]] correctly use [[NTP]] to setup the system clock on boot. | To set the [[system time]] correctly use [[NTP]] to setup the system clock on boot. | ||
+ | {{Emerge|ntp}} | ||
+ | {{RootCmd| rc-update add ntp-client default }} | ||
=== Enable SSH Daemon === | === Enable SSH Daemon === |
Revision as of 16:16, 18 February 2013
Installing Gentoo onto a Raspberry Pi is relatively straight forward and in some ways easier because a kernel image is provided by the Raspberry Pi Foundation. This means you can get Gentoo installed quickly onto you Raspberry Pi.
Preparing the SD Card
The Raspberry Pi boots off a FAT32 /boot partition, you will also require a root and swap partition.
Create the Partitions
Use the fdisk command to create the partitions.
root #
fdisk /dev/mmcblk0
'"`UNIQ--pre-00000000-QINU`"'
Create the File Systems
root #
mkfs.vfat -F 16 /dev/mmcblk0p1
root #
mkswap /dev/mmcblk0p2
root #
mkfs.ext4 /dev/mmcblk0p3
Installing onto the SD card
Mounting the partitions
root #
mkdir /mnt/gentoo
root #
mount /dev/mmcblk0p3 /mnt/gentoo
root #
mkdir /mnt/gentoo/boot/
root #
mount /dev/mmcblk0p1 /mnt/gentoo/boot
Extract Stage 3 Image
root #
cd /tmp/
root #
wget ftp://de-mirror.org/gentoo/releases/arm/autobuilds/current-stage3-armv6j_hardfp/stage3-armv6j_hardfp-*.tar.bz2
root #
tar xfpj stage3-armv6j_hardfp-*.tar.bz2 -C /mnt/gentoo/
Install Portage
root #
tar xjf portage-latest.tar.bz2 -C /mnt/gentoo/usr
Install kernel and modules
The Raspberry Pi Foundation maintain a branch of the Linux kernel that will run on the Raspberry Pi, including a compiled version which we use here.
root #
cd /tmp/
root #
git clone --depth 1 git://github.com/raspberrypi/firmware/
root #
cd firmware/boot
root #
cp * /mnt/gentoo/boot/
root #
cp -r ../modules /mnt/gentoo/lib/
Configure the system
Edit fstab
Edit the fstab to match your partition scheme.
root #
nano /mnt/gentoo/etc/fstab
Set boot options
You need to create a file cmdline.txt in /boot to pass options to the kernel.
root #
nano /mnt/gentoo/boot/cmdline.txt
Edit make.conf
The default make.conf includes basic CFLAGS. If you would like to change the settings to something more 'optimal' for the Pi look at the details on the relevant wiki page.
Configure time zone
Find your time zone using this command.
root #
ls /mnt/gentoo/usr/share/zoneinfo
(Suppose you want to use Europe/London)
root #
cp /mnt/gentoo/usr/share/zoneinfo/Europe/London /mnt/gentoo/etc/localtime
(Next set the timezone)
root #
echo "Europe/London" > /mnt/gentoo/etc/timezone
Clear root password
As we do not chroot before we boot, you will need to unset the root password. Allowing you to login with a blank password for the root user.
root #
nano /mnt/gentoo/etc/shadow
Edit the line for root so it looks like the example below. Template:File
Unmount SD and then boot your Raspberry Pi
Unmount the SD card.
root #
umount /mnt/gentoo/boot
root #
umount /mnt/gentoo
Plugin the SD card to your Raspberry Pi, make sure you have a keyboard and monitor also plugged in then connect the power. Hopefully Gentoo will boot giving you a login prompt, login as root and no password. During the first boot you will see a few warnings and errors which we will fix in the next section.
Post boot configuration
Set root password
Immediately set a root password.
root #
passwd
Enabling networking on boot
Assuming you are using DHCP on the eth0.
root #
cd /etc/init.d/
root #
ln -s net.lo net.eth0
root #
rc-config start net.eth0
root #
rc-update add net.eth0 boot
Select profile
List the available profiles.
root #
eselect profile list
Select the desired profile, for example [25] default/linux/arm/13.0/armv6j:
root #
eselect profile set 25
Configuring inittab and rc.conf
Uncomment the linux specific rc.conf rc_sys value, to stop warning in boot up.
root #
nano /etc/rc.conf
Comment out the s0 Serial console to stop "INIT: Id "s0" respawning too fast" messages on the console.
root #
nano /etc/inittab
Enable software clock
The Raspberry Pi does not have a hardware clock, so you need to disable the hwclock daemon and enable swclock.
root #
rc-update add swclock boot
root #
rc-update del hwclock boot
To set the system time correctly use NTP to setup the system clock on boot.
root #
emerge --ask ntp
root #
rc-update add ntp-client default
Enable SSH Daemon
root #
rc-update add sshd default
root #
/etc/init.d/sshd start
Overclocking
It is very easy to overclock a Raspberry Pi up to 1000MHz without affecting your warranty [1]
'"`UNIQ--pre-00000005-QINU`"'
Enabling Overclocking
To enable overclocking select one of the suggest modes from the list above, "Medium" is generally a good starting point. Edit the /boot/config.txt, add the appropriate values and reboot the Raspberry Pi for changes to take effect.
root #
mount /boot/
root #
nano /boot/config.txt
Optional cpufrequtils
To manage the CPU frequency scaling you can use the cpufrequtils.
root #
emerge --ask cpufrequtils
root #
rc-update add cpufrequtils default
The default scaling governor can be changed in the /etc/conf.d/cpufrequtils file Template:File
Confirm the current scaling and CPU using the cpufreq-info command
root #
cpufreq-info
Force Turbo Option
The force turbo option turns off the dynamic clocks and runs the Raspberry Pi constantly at the highest arm_freq. [2] Edit the /boot/config.txt, add force_turbo=1 then reboot the Raspberry Pi for changes to take effect.
root #
nano /boot/config.txt
Changing memory split
Not strictly speaking speaking overclocking, but the memory used by the GPU can be changed. To change the memory used by the GPU down to a minimum of 16MB add the gpu_mem value to /boot/config.txt, then reboot the Raspberry Pi for changes to take effect. Template:File
Cross building
This is not strictly required, but it is extremely practical given the source driven nature of Gentoo. Building almost anything on the Raspberry Pi takes a very, very long time - especially when there are a lot of dependencies involved.
Fortunately, you can offload much of the heavy lifting work to a more powerful system (such as your main gentoo desktop/server) using crossdev and distcc (though this will only work for packages must compile c/c++).
It is also suggested that the first package you build on the Raspberry Pi should be distcc, as it will dramatically speed up subsequent packages that require a lot of compilation.
distcc
On all distcc build servers and on the Raspberry Pi, you will need to install sys-devel/distcc:
root #
emerge --ask distcc
Edit the distcc config file to ensure it is on the right subnet for your network configuration, for example:
Then register and start the distcc daemon:
root #
rc-update add distccd default
root #
rc-config start distccd
On the Raspberry Pi
Tell portage to use distcc: Template:File
(Optional) Also add to FEATURE "buildpkg" to tell the Raspberry Pi to build package files for everything it builds (if you want to use the same setup on multiple Raspberry Pis without recompiling):
Edit the distcc host file to tell your Raspberry Pi to submit compile jobs to your server:
Now you will need to tell distcc the specific compiler name to use instead of just "gcc":
root #
cd /usr/lib/distcc/bin
root #
ls -l
total 0 lrwxrwxrwx 1 root root 15 Dec 23 20:13 c++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 cc -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 g++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 gcc -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 armv6j-hardfloat-linux-gnueabi-c++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 armv6j-hardfloat-linux-gnueabi-g++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 23 20:13 armv6j-hardfloat-linux-gnueabi-gcc -> /usr/bin/distcc
We need to replace those symlinks with the following script:
root #
rm c++ g++ gcc cc
root #
chmod a+x /usr/lib/distcc/bin/armv6j-hardfloat-linux-gnueabi-wrapper
root #
ln -s armv6j-hardfloat-linux-gnueabi-wrapper cc
root #
ln -s armv6j-hardfloat-linux-gnueabi-wrapper gcc
root #
ln -s armv6j-hardfloat-linux-gnueabi-wrapper g++
root #
ln -s armv6j-hardfloat-linux-gnueabi-wrapper c++
Double check that you did things right:
root #
ls -l
total 4 lrwxrwxrwx 1 root root 15 Dec 8 00:38 armv6j-hardfloat-linux-gnueabi-c++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 8 00:38 armv6j-hardfloat-linux-gnueabi-g++ -> /usr/bin/distcc lrwxrwxrwx 1 root root 15 Dec 8 00:38 armv6j-hardfloat-linux-gnueabi-gcc -> /usr/bin/distcc -rwxr-xr-x 1 root root 85 Dec 8 01:04 armv6j-hardfloat-linux-gnueabi-wrapper lrwxrwxrwx 1 root root 38 Dec 8 01:05 c++ -> armv6j-hardfloat-linux-gnueabi-wrapper lrwxrwxrwx 1 root root 38 Dec 8 01:04 cc -> armv6j-hardfloat-linux-gnueabi-wrapper lrwxrwxrwx 1 root root 38 Dec 8 01:04 g++ -> armv6j-hardfloat-linux-gnueabi-wrapper lrwxrwxrwx 1 root root 38 Dec 8 01:04 gcc -> armv6j-hardfloat-linux-gnueabi-wrapper
You can now check what is being dispatched to your build machines while doing an emerge operation with this script:
Or simpler with:
root #
watch -n1 DISTCC_DIR="/var/tmp/portage/.distcc/" distccmon-text
crossdev
This will setup crossdev on your beefy server(s) so that it can compile binaries compatible with the Raspberry Pi. Note that you can have multiple compilation nodes - just add them to the list of hosts on the Raspberry Pi. Distcc will decide when to distribute the compilation though, so chances are you will never be able to fully load even a single modern build server with jobs from the Raspberry Pi.
Install sys-devel/crossdev:
root #
emerge --ask crossdev
You will need to maintain separate portage profiles for the Raspberry Pi and your server's default, so you must convert your existing profile files to folders. Copy the following file to ~/convert-profile-to-files.sh, and then run it as root:
Create a cross toolchain for ARM: (drop -S if you plan to run an unstable system):
root #
crossdev -S -v -t armv6j-hardfloat-linux-gnueabi
If the cross toolchain for ARM fail to build try this:
root #
CFLAGS="-O2 -pipe" CXXFLAGS="${CFLAGS}" crossdev -S -v -t armv6j-hardfloat-linux-gnueabi
Install Video Core Userland tools and libraries
The ARM side libraries for interfacing to Raspberry Pi GPU are included in a package raspberrypi-userland. Which includes the Video Core tools, GLES2, EGL, openmax and openVG libs that support the Raspberry Pi GPU.
root #
emerge --ask raspberrypi-userland
See also
External resources
- Gentoo Embedded Handbook with more information about embedded hardware, cross compiling and other related topics.
- DistCC Cross-compiling Guide about cross-compiling with DistCC
- Raspberry Pi Hub at eLinux wiki, with more advanced tutorials to get the most out of your Raspberry Pi