2. Contents
1. Setup Toolchain
2. Build procedure for Bootloader
3. Build procedure for Kernel
4. Setup SD card
5. Setup File System
6. Build a kernel Module
3. 1. Setup Toolchain
In order to compile the source for ARM we need a cross compile toolchain to set up in
our host machine. Some of sources of Toolchains are liste below.
1. http://www.angstrom-distribution.org/toolchains/
2. http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/
3. https://launchpad.net/linaro-toolchain-binaries/trunk
Download any one of the above toolchain and extract it or setup as per the instruction
below.
1. Angstrom
Extract the source
sudo tar -C / -xjf angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2
Export the PATH
export PATH=/usr/local/angstrom/arm/bin:$PATH
2. Sourcery CodeBench Lite Edition
Extract the source
tar xvf arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar
Export the PATH
export PATH=/opt/CodeSourcery/Sourcery_G++_Lite/bin:$PATH
If the installation is successful, You will see the toolchain symbolic links in terminal by typing
‘arm’ and tab.
4. 2. Build procedure for Bootloader
We need a bootloader to load the kernel. The U-Boot utility is a multi-platform, open-source,
universal boot-loader with comprehensive support for loading and managing boot images,
such as the Linux kernel.
1. Download the u-boot source
git clone git://git.denx.de/u-boot.git
cd u-boot/
git checkout v2013.07 -b tmp
2. Patch for zImage boot
wget -c https://raw.github.com/eewiki/u-boot-patches/master/v2013.07/
0001-omap3_beagle-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-omap3_beagle-uEnv.txt-bootz-n-fixes.patch
3. Make the u-boot
make CROSS_COMPILE=arm-none-linux-gnueabi- mrproper
make CROSS_COMPILE=arm-none-linux-gnueabi- omap3_beagle_config
make CROSS_COMPILE=arm-none-linux-gnueabi-
Alternate methods are available in
http://eewiki.net/display/linuxonarm/BeagleBoard#BeagleBoard-Bootloader:U-Boot
5. 3. Build procedure for Kernel
The kernel is a program that constitutes the central core of a computer operating system. It
has complete control over everything that occurs in the system. The kernel is the first part of
the operating system to load into memory during booting (i.e., system startup), and it remains
there for the entire duration of the computer session because its services are required
continuously. Thus it is important for it to be as small as possible while still providing all the
essential services needed by the other parts of the operating system and by the various
application programs.
1. Download kernel from custom beagleboard repo
git clone git://github.com/beagleboard/kernel.git && cd kernel
2. Checkout to latest branch
git checkout origin/beagleboard-3.0 -b beagleboard-3.0
3. Run the patch script.
./patch.sh
4. Copy the configuration to default configuration folder.
cp ../patches/beagleboard/defconfig .config
5. Make the changes using menuconfig.
make -j2 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
6. Make the kernel image.
make -j2 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage
7. Final uImage is created in arch/arm/boot.
6. 4. Setup SD card
For these instruction, we are assuming: DISK=/dev/sdb, "lsblk" is very useful for determining
the device id.
export DISK=/dev/sdb
Erase Micro SD
sudo dd if=/dev/zero of=${DISK} bs=1M count=16
Create Partition Layout:
sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,48,0xE,*
,,,-
__EOF__
Format Partitions:
sudo mkfs.vfat -F 16 ${DISK}1 -n boot
sudo mkfs.ext4 ${DISK}2 -L rootfs
Mount Partitions:
sudo mkdir -p /media/boot/
sudo mkdir -p /media/rootfs/
sudo mount ${DISK}1 /media/boot/
sudo mount ${DISK}2 /media/rootfs/
7. 5. Setup File System
A file system is a type of data store which can be used to store, retrieve and update a set of
files. The term refers to either the abstract data structures used to define files, or the actual
software or firmware components that implement the abstract ideas.
Download filesystem
http://rcn-ee.net/deb/minfs/wheezy/debian-7.0.0-minimal-armhf-2013-05-05.tar.xz
http://rcn-ee.net/deb/minfs/raring/ubuntu-13.04-minimal-armhf-2013-05-05.tar.xz
http://narcissus.angstrom-distribution.org/
In case your downloaded filesystem is ‘.tar.xz’ extract the tar first with the following
command
tar xJf ubuntu-13.04-minimal-armhf-2013-05-05.tar.xz
1. Setup RootFS
Then extract the ‘tar’ to rootfs partition of SD card.
sudo tar xfvp ./*-*-minimal-arm*-*/arm*-rootfs-*.tar -C /media/rootfs/
2. Setup Boot partition
Copy the MLO, u-boot.img, zImage and uEnv.txt to boot partition
sudo cp -v ./u-boot/MLO /media/boot/
sudo cp -v ./u-boot/u-boot.img /media/boot/
sudo cp -v ./uEnv.txt /media/boot/
sudo cp -v ./arch/arm/boot/zImage /media/boot/zImage