The Lab Book Pages

An online collection of electronics information

http://www.labbookpages.co.uk

Dr. Andrew Greensted
Last modified: 6th January 2011

Hide Menu


Valid XHTML Valid CSS
Valid RSS VIM Powered
RSS Feed Icon

This site uses Google Analytics to track visits. Privacy Statement

Page Icon

Custom System

This page provides instructions for creating a complete custom Linux system for the BeagleBoard-xM, this includes creating a toolchain, boot loader, kernel and root filing system. The result is a minimal system that boots quickly to a login prompt.

Note: The path /files/beagle is used as a general working space, this can easily be changed to wherever is convenient.


Processor Information

The BeagleBoard-xM uses a Texas Instruments DaVinci Digital Media Processor, the DM3730-1000. The main processing core is an ARM Cortex-A8 processor which is based on the ARMv7 architecture.

Note: These instructions set the processor to run at 800MHz, there is a kernel patch that allows 1GHz operation, but it involves adjusting the processor voltages. Although it's probably safe, it's not been included, take a look at this thread for further information.


Software Requirements

A number of packages must be installed for this process to work. The list below is based on a new Ubuntu 10.10 installation.

  • automake
  • bison
  • curl
  • cvs
  • flex
  • g++
  • gawk
  • libncurses5-dev
  • libtool
  • texinfo

Toolchain using Crosstool-NG

Crosstool-NG provides a very simple way of creating a custom toolchain. Use the commands below to download, unpack, compile and install the Crosstool-NG tools.

> cd /files/beagle
> wget http://ymorin.is-a-geek.org/download/crosstool-ng/crosstool-ng-1.9.1.tar.bz2
> tar -jxf crosstool-ng-1.9.1.tar.bz2
> cd crosstool-ng-1.9.1
> ./configure --prefix=/opt/beagleBoard-xM
> make
> make install (as root)

The next stage is to use just installed ct-ng tool to configure and create the new build environment. Use the commands below to start up the build configuration process.

> export PATH="/opt/beagleBoard-xM/bin:$PATH"
> cd /files/beagle
> mkdir ct-build src
> cd ct-build

A number of options must be set to ensure the cross-compiler tools are built correctly. The link below contains a configuration file that should be downloaded to the ct-build directory and renamed to .config.

Crosstool-NG Configuration

The final step is to actually build the toolchain, this will take a while, probably over an hour. When the build has finished, there should be a set of executable files in /files/beagle/x-tools/bin.

> ct-ng build

SD Card Setup

The BeagleBoard-xM uses an SD Card to store all files. Use the steps below to setup the card. Two partitions are created. The first is used to store the boot loader, kernel and root filing system. The second partition can be used for general file storage. Note: These steps will erase everything that is already on the card.

First you need to find what device file refers to the SD card, after plugging in the card, use the dmesg command to display the kernel messages, this should give an indication of the device file.

Use the command below (as root) to clear a section at the start of the card, this removes the partition table. In this case, /dev/sdb refers to the SD Card.

> dd if=/dev/zero of=/dev/sdb bs=1024 count=1024

Now create the first partition, this will use the FAT32 filing system. The partition will be 64M in size, which should provide plenty of room.

> fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1020, default 1):  (Press Enter)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1020, default 1020): +64M
Command (m for help): t
Hex code (type L to list codes): c
Command (m for help): a
Partition number (1-4): 1

Next, create the second partition. This will be formatted with EXT2 and fills the rest of the SD Card.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (18-1020, default 18):  (Press Enter)
Using default value 18
Last cylinder, +cylinders or +size{K,M,G} (18-1020, default 1020):  (Press Enter)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 83

Check that the partitions have been created correctly, then write the changes to the disk.

Command (m for help):  p

Disk /dev/sdb: 3951 MB, 3951034368 bytes
122 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 7564 * 512 = 3872768 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6c04288f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          18       67051+   c  W95 FAT32 (LBA)
/dev/sdb2              18        1020     3789564+  83  Linux

Command (m for help): w

The next step is to create the filing systems in the partitions.

> mkfs.vfat -F 32 -n "boot" /dev/sdb1
> mke2fs -L "files" /dev/sdb2

U-Boot Boot Loader

The U-Boot boot loader will be used to copy both the kernel and root filing system into memory, and then boot the system. Use the commands below to download and unpack U-Boot, then to setup the environment.

> cd /files/beagle
> wget ftp://ftp.denx.de/pub/u-boot/u-boot-2010.12-rc3.tar.bz2
> tar -jxf u-boot-2010.12-rc3.tar.bz2
> cd u-boot-2010.12-rc3
> export CROSS_COMPILE=arm-unknown-linux-gnueabi-
> export PATH="/files/beagle/x-tools/bin:$PATH"

Now, configure and make U-Boot

> make distclean
> make omap3_beagle_config
> make

Two files can now be copied to the SD Card. The first is a small file called MLO that will load the U-Boot binary. This must be copied to the card first, to ensure it is at the start of the card, after copying, unmount and them remount the card.

Next, copy the U-Boot binary to the card.

> cd /files/beagle
> mount /dev/sdb1 /mnt/beagle
> wget http://www.angstrom-distribution.org/demo/beagleboard/MLO
> cp MLO /mnt/beagle
> umount /mnt/beagle
> mount /dev/sdb1 /mnt/beagle
> cp u-boot-2010.12-rc3/u-boot.bin /mnt/beagle

Boot Script

U-Boot will search for a script file that can be used to set up the boot environment. The script must be compiled using the mkimage command which was compiled at the same time as the U-Boot binary.

Use the first command below (probably as root) to copy the mkimage binary over to live with the other BeagleBoard files. Then if not already set, adjust the path.

> cp /files/beagle/u-boot-2010.12-rc3/tools/mkimage /opt/beagleBoard-xM/bin/
> export PATH="/opt/beagleBoard-xM/bin:$PATH"

Create the boot script listed below.

File Excerpt: /files/beagle/bootScript
mmc init
setenv console tty0 console=ttyS2,115200n8
setenv ramroot /dev/ram0 rw ramdisk_size=131072 initrd=0x88000000,128M
setenv optargs mem=80M@0x80000000 mem=384M@0x88000000
setenv bootargs console=${console} ${optargs} mpurate=800 root=${ramroot} rootfstype=ext2
fatload mmc 0 0x82000000 uImage
fatload mmc 0 0x88000000 rootfs.ext2
bootm 0x82000000

U-Boot script: bootScript

Use the command below to create the compiled boot script. The output is a file called boot.scr which can be copied to the SD Card.

> mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'Boot script' -d bootScript boot.scr
> cp /files/beagle/boot.scr /mnt/beagle

Linux Kernel

The standard Linux kernel can be used with the BeagleBoard-xM. However, it does require a couple of patches. Download the two files linked to below and place in /files/beagle/patches. Please note I'm not the author of these patches, but if you are, please let me know so I can credit your work here.

kernel-2.6.36-bb-xm-mmc-fix.patch

kernel-2.6.36-bb-xm-usb-pwr.patch

Next download, unpack and patch the kernel.

> cd /files/beagle
> wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.36.2.tar.bz2
> tar -jxf linux-2.6.36.2.tar.bz2
> cd linux-2.6.36.2
> patch -p1 < ../patches/kernel-2.6.36-bb-xm-usb-pwr.patch
> patch -p1 < ../patches/kernel-2.6.36-bb-xm-mmc-fix.patch

Rather than detail how the kernel is configured, it is easier to provide a configuration file. Download the file linked to below, place in the linux-2.6.36.2 directory and rename to .config.

Kernel configuration

To review the kernel configuration, the command below can be used.

> make ARCH=arm menuconfig

Now compile the kernel. If not already done so, set the CROSS_COMPILE environment variable and adjust the path to include the cross compiler tools. The make command includes a -j3 switch that tells make to attempt 3 simultaneous jobs. To speed up the compilation, set this to the number of host cores +1.

> export CROSS_COMPILE=arm-unknown-linux-gnueabi-
> export PATH="/files/beagle/x-tools/bin:$PATH"
> make -j3 ARCH=arm uImage

The kernel image can now be copied to the SD Card.

> cp arch/arm/boot/uImage /mnt/beagle

Root Filing System using Buildroot

Buildroot is used to create the root filing system and to add in various applications. Use the commands below to download and unpack Buildroot. The umask command will make sure that the files are created with the correct permissions. Also note the -p flag used with tar. If the permissions are incorrect, there can be issues when using non-root users on the BeagleBoard system.

> umask 022
> cd /files/beagle
> wget http://www.buildroot.org/downloads/buildroot-2010.11.tar.gz
> tar -zpxf buildroot-2010.11.tar.gz
> cd buildroot-2010.11

As with the kernel, it is easiest to provide a configuration file. Download the link below and copy into the buildroot-2010.11 directory and rename to .config. Once the filing system image has been built, copy it to the SD Card.

Buildroot configuration

> make menuconfig
> make
> cp output/images/rootfs.ext2 /mnt/beagle

Booting

The SD Card should now hold a number of files, these are listed in the table below.

File Description
MLO Loader
u-boot.bin U-Boot Boot loader
boot.scr U-Boot script
uImage Linux Kernel
rootfs.ext2 Root Filing System

A tar archive of all these files can be downloaded using the link below. Make sure that the MLO file is copied over first, see the SD Card and U-Boot sections.

BeagleBoard System files

To boot the system, simply plug in the SD Card and switch on the power. Whilst the system boots, the U-Boot and kernel messages are output to the serial port, this also provides access to a login prompt. picocom is a very simple tool that can be used to communicate with the BeagleBoard. Use the command below to start picocom. Note: To exit picocom press control-a then control-x.

> picocom -b 115200 /dev/ttyS0

Book Logo