/gom

Garage-O-Matic

Primary LanguageShell

##
## Instructions for building the Garage-O-Matic Kernel and Filesystem
##

###############################################################################
## Host dependencies
##

# Make ure the following packages are installed on the host computer:
#   make
#   flex
#   bc
#   bison
#   gcc
#   gettext
#   git
#   libncurses5-dev
#   svn
#   texinfo
#
# Comprehensive list of dependencies found here:
# http://buildroot.uclibc.org/downloads/manual/manual.html#requirement-mandatory
#

apt-get install make flex bc bison gcc gettext git libncurses5-dev svn texinfo

###############################################################################
## Environment
##

# Set the RPI_PATH environment variable to the gom/ directory
cd gom
export RPI_PATH=`pwd`

# Or source the env.sh file to setup the RPI_PATH and add the toolchain to the
# PATH:
. env.sh

###############################################################################
## Toolchain
##

# Clone the toolchain from the Raspberry PI's GitHub repository
git clone https://github.com/raspberrypi/tools.git

# Add the build tools to the path
export PATH=$PATH:$RPI_PATH/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin

###############################################################################
## Linux Kernel
##

# Clone the RPI fork of the kernel
git clone https://github.com/raspberrypi/linux.git

# Clean the project
make ARCH=arm mrproper

# Customize the kernel using menuconfig
cp config/linux-rpi-3.10.y.config linux/.config
make ARCH=arm menuconfig

# Build the kernel and copy the compress kernel image to the boot parition
make ARCH=arm
cp arch/arm/boot/zImage /media/bootfs/kernel.img

###############################################################################
## Buildroot
##

# Config Options:
#
# Target Architecture: ARM (little endian)
# Target Architecture Variant: generic_arm
# Toolchain  --->
#   Toolchain type: External toolchain
#   Toolchain: Custom toolchain
#   Toolchain origin: Pre-installed toolchain
#   Toolchain path: $RPI_PATH/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian
#   Toolchain prefix: arm-linux-gnueabihf
#   External toolchain C library: glibc/eglibc
#   Toolchain has C++ support: Yes
# System configuration  --->
#   System hostname: gom
#   System banner: Welcome to Garage-O-Matic
#   Passwords encoding: sha-256
#   /dev management: Dynamic using mdev
#   Root password: root
#   Port to run a getty (login prompt) on: ttyAMA0
# Package Selection for the target  --->
#   Interpreter languages and scripting  --->
#     php: Yes
#   Networking applications  --->
#     dropbear: Yes
#     lighttpd: Yes
#       openssl support: Yes
#       zlib support: Yes
#       pcre support: Yes
#     wireless tools: Yes
#     wpa_supplicant: Yes
#       Install wpa_cli binary: Yes
#       Install wpa_passphrase binary: Yes
# Filesystem images  --->
#   cpio the root filesystem: Yes
#     Compression method: gzip

# If starting from scratch, run the following:
make raspberrypi_defconfig

# Otherwise, copy the correct buildroot config from the config/ dir to buildroot-YYYY.MM/.config
cp config/buildroot-2014.02.config buildroot-2014.02/.config

# Customize buildroot using the menuconfig
make menuconfig

# Build
make

###############################################################################
## MicroSD Card
##

# Formating
sudo mkfs.vfat -n bootfs /dev/sdb1
sudo mkfs.ext4 -L rootfs /dev/sdb2

# Installing boot files
sudo mount /dev/sdb1 /media/bootfs
sudo cp $RPI_PATH/buildroot-2014.02/output/images/rpi-firmware/* /media/bootfs/
sudo cp $RPI_PATH/linux/arch/arm/boot/zImage /media/bootfs/kernel.img
sudo umount /dev/sdb1

# Installing root filesystem
sudo mount /dev/sdb2 /media/rootfs
sudo tar -xavf $RPI_PATH/buildroot-2014.02/output/images/rootfs.tar -C /media/rootfs/
sudo umount /dev/sdb2

###############################################################################
## Ram disk
##

# Mount the boot partition
sudo mount /dev/sdb1 /media/bootfs

# Copy the buildroot compressed cpio image to the boot partition
cp $RPI_PATH/buildroot-2014.02/output/images/rootfs.cpio.gz /media/bootfs/init.gz

#
# Modify the config.txt file to specify the init file to load.  Add the
# following line to load the init.gz file to address 0x00A00000:
#
#   initramfs init.gz 0x00A00000
#
# Or copy the existing config_initramfs.txt file to the boot partition
cp $RPI_PATH/bootfs/config_initramfs.txt /media/bootfs/config.txt

#
# Modify the cmdline.txt file to specify the kernel parameters to load the
# ramdisk as an initrd image.
#
#   initrd=0xA00000,<size> root=/dev/ram0
#
# Where <size> is the size of the init.gz file in bytes as a hex value.
#
# Or copy the existing cmdline_initramfs.txt file to the boot partition, and
# update the size to reflect the correct size of the init.gz file:
cp $RPI_PATH/bootfs/cmdline_initramfs.txt /media/bootfs/cmdline.txt

# Unmount the boot partition
sudo umount /dev/sdb1