Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

BuildYourOwn PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Build Your Own Linux System For Raspberry Pi

Build Your Own Linux System For


Raspberry Pi
Build Your Own Linux System For Raspberry Pi

Tools
Buildroot
Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux
systems through cross-compilation. We will use Buildroot to build Linux kernel
and root filesystem for Raspberry Pi.

SD Formatter 4.0 for SD/SDHC/SDXC


This software formats all SD memory cards, SDHC memory cards and SDXC
memory cards. SD Formatter provides quick and easy access to the full capabilities
of your SD, SDHC and SDXC memory cards. We will use this tool to format SD
card.

Win32 Disk Imager


This program is designed to write a raw disk image to a removable device or
backup a removable device to a raw image file. We will use this tool to write
xxx.img (which is built from Buildroot) into sdcard.
Build Your Own Linux System For Raspberry Pi

Buildroot Commands
make menuconfig
run the configuration assistant for Buildroot
make linux-menuconfig
run the configuration assistant for kernel
make clean
to delete all build products (including build directories, host, staging and target
trees, the images and the toolchain)
make distclean
to delete all build products as well as the configuration
make help
display help
make configuration file
to generate .config from common configuration.
e.g. make raspberrypi_defconfig. configuration file raspberrypi_defconfig in
configs/ will be used
Build Your Own Linux System For Raspberry Pi

Buildroot Directory Structure


configs/
where some common configuration files are stored
dl/
where download files are stored. You can change it by using make menuconfig.
By default, it will be automatically created in Buildroot tree
board/
board and platform specific files are stored

Buildroot output is stored in output/. This directory contains several subdirectories


output/images/
where all the images (kernel image, bootloader and root filesystem images) are
stored
output/build/
where all the components are built (this includes tools needed to run Buildroot on
the host and packages compiled for the target). The build/ directory contains one
subdirectory for each of these components.
Build Your Own Linux System For Raspberry Pi

Buildroot Directory Structure


output/staging/
which contains a hierarchy similar to a root filesystem hierarchy. This directory
contains the installation of the cross-compilation toolchain and all the userspace
packages selected for the target. However, this directory is not intended to be the
root filesystem for the target. it contains a lot of development files, unstripped
binaries and libraries that make it far too big for an embedded system
output/host/
contains the installation of tools compiled for the host that are needed for the
proper execution of Buildroot, including the cross-compilation toolchain
ouput/target
which contains almost the complete root filesystem for the target. Compared to
staging/, target/ contains only the files and libraries needed to run the selected
target applications. However, this directory should not be used on your target.
Instead, you should use one of the images built in the images/ directory. If you
need an extracted image of the root filesystem for booting over NFS, then use the
tarball image generated in images/ and extract it as root
Build Your Own Linux System For Raspberry Pi

Prepare Linux Kernel and Root Filesystem


1. Download Buildroot from https://buildroot.org/download.html. We need 2016.02-rc3
or above. You can also use git to download the latest version.
git clone git://git.buildroot.net/buildroot
2. tar zxvf buildroot-2016.02-rc3.tar.gz
3. cd buildroot-2016.02-rc3
4. make raspberrypi2_defconfig // if you are using Pi 1, run make raspberrypi_defconfig
5. make
6. After building, you should obtain following tree in output/images
Build Your Own Linux System For Raspberry Pi

Make .img File for Installation


If using Buildroot 2016.02-rc3 or above, sdcard.img will be generated automatically.
Following shows you how to manually make .img file

Download and install genimage


Download link http://www.pengutronix.de/software/genimage/download/ or use
git to download git clone http://git.pengutronix.de/git/genimage.git
cd genimage
./autogen.sh
./configure
make
sudo make install
Build Your Own Linux System For Raspberry Pi

Make .img File for Installation


Prepare .cfg file for genimage
genimage-raspberrypi2.cfg
image boot.vfat {
vfat {
files = { Files for boot partition
"bcm2709-rpi-2-b.dtb",
"rpi-firmware/bootcode.bin",
"rpi-firmware/cmdline.txt",
"rpi-firmware/config.txt",
"rpi-firmware/fixup.dat",
"rpi-firmware/start.elf",
"kernel-marked/zImage"
}
}
size = 32M
}

image sdcard.img {
hdimage {
} We will create two partitions
partition boot { One fat32 for boot
partition-type = 0xC
bootable = "true" Another ext4 for root fileystem
image = "boot.vfat"
}

partition rootfs {
partition-type = 0x83
image = "rootfs.ext4"
}
}
Build Your Own Linux System For Raspberry Pi

Make .img File for Installation


Script for generate .img file,

make-image.sh

#!/bin/sh

GENIMAGE_CFG="genimage-raspberrypi2.cfg"
GENIMAGE_TMP="genimage.tmp"

# Mark the kernel as DT-enabled


mkdir -p "kernel-marked"
mkknlimg "zImage" "kernel-marked/zImage"

rm -rf "${GENIMAGE_TMP}"

genimage \
--rootpath "path_to_buildroot/output/target" \
--tmppath "${GENIMAGE_TMP}" \
--inputpath "./" \
--outputpath "./" \
--config "${GENIMAGE_CFG}"
mkknlimg can be found in output/host/usr/bin, or you can download it from
https://github.com/raspberrypi/tools/blob/master/mkimage/mkknlimg
exit $?
Build Your Own Linux System For Raspberry Pi

Prepare SD Card
1. Download and install SDFormatter https://www.sdcard.org/downloads/formatter_4/
2. Run SDFormatter, Click Option and choose FORMAT SIZE ADJUSTMENT on
3. Click Format
Build Your Own Linux System For Raspberry Pi

Install Raspberry into SD Card


1. Download and install Win32 Disk Imager https://sourceforge.net/projects/win32diskimager/
2. Run Win32 Disk Imager and choose sdcard.img
3. Click Write
Build Your Own Linux System For Raspberry Pi

Third Party Operating System Images


You can find many third party operating system in https://www.raspberrypi.org/downloads/
Raspbian: https://www.raspberrypi.org/downloads/raspbian/
Ubuntu Mate: https://ubuntu-mate.org/raspberry-pi/
Retropie (turn the Raspberry Pi into a dedicated retro-gaming console):
http://blog.petrockblock.com/retropie/
Riscos: http://downloads.raspberrypi.org/riscos/
Openelec: http://downloads.raspberrypi.org/openelec/
Ubuntu: http://downloads.raspberrypi.org/ubuntu/
Raspbmc: http://downloads.raspberrypi.org/raspbmc/
Pidora: http://downloads.raspberrypi.org/pidora/
Arch: http://downloads.raspberrypi.org/arch/

Try to download these Images and install them into your SD Card. Have Fun!

You might also like