Lab3 - Configuration and Compilation of U-Boot & X-Loader for BeagleBoard

Objective: Compile, configure and flash U-Boot and X-Loader on the Beagle board.
  • After this lab, you will be able to
    • Configure and compile and sign the X-loader
    • Configure and compile U-Boot
    • Use it on the Beagle board to flash X-loader and U-Boot to NAND.
  1. Ubuntu 10.04 (Lucid Linux) as a virtual machine in VMware Server/Workstation.
  2. SD Card (Min. 2 GB SD card required). 
  3. USB card reader (SD Card to USB interface)



(1) Linux BootDisk Format


This section describes about how to create a dual-partition card for Beagle Board to boot Linux from first partition and have root file system at second partition.


If you are using your Laptop then use USB card reader. You can’t access SD card in VMware on Windows as a host machine.


Fig. 1 USB Card Reader (link)


The purpose of creating a dual-partition card is to boot from a FAT partition that can be read by the OMAP3 ROM bootloader and Linux/Windows and then utilizing an ext3 partition for the Linux root file system.


Determine which device the SD Card Reader is on your system


Plug the SD Card into the SD Card Reader and then plug the SD Card Reader into your system. After doing that, do the following to determine which device it is on your system.


[dmesg | tail]


[ 6854.215650] sd 7:0:0:0: [sdc] Mode Sense: 0b 00 00 08
[ 6854.215653] sd 7:0:0:0: [sdc] Assuming drive cache: write through
[ 6854.215659]  sdc: sdc1
[ 6854.218079] sd 7:0:0:0: [sdc] Attached SCSI removable disk
[ 6854.218135] sd 7:0:0:0: Attached scsi generic sg2 type 0

In this case, it shows up as /dev/sdc (note sdc inside the square brackets above).


Check to see if the auto mounter has mounted the SD Card


Note there may be more than one partition (only one shown in the example below).

Note the "Mounted on" field in the above and use that name in the umount commands below.

If so, unmount it

[df -h]
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdc1             400M   94M  307M  24% /media/disk

[umount /media/disk]\

You can also unmout it by right click on SD card on your Ubuntu desktop.


Start fdisk


Be sure to choose the whole device (/dev/sdc), not a single partition (/dev/sdc1).


[sudo fdisk /dev/sdc]

 Print the partition record


So you know your starting point. Make sure to write down the number of bytes on the card (in this example, 2021654528).

Command (for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1         246     1974240+   c  W95 FAT32 (LBA)
Partition 1 has different physical/logical endings:
     phys=(244, 254, 63) logical=(245, 200, 19)

Delete any partitions that are there already

Command (for help): [d]
Selected partition 1


Set the Geometry of the SD Card


If the print out above does not show 255 heads, 63 sectors/track, then do the following expert mode steps to redo the SD Card:

·  Go into expert mode.

          Command (for help): [x]

·   Set the number of heads to 255.

 Expert Command (for help): [h]
 Number of heads (1-256, default xxx): [255]

·   Set the number of sectors to 63.

 Expert Command (for help): [s]
 Number of sectors (1-63, default xxx): [63]

·   Now calculate the number of Cylinders for your SD Card.

   #cylinders = FLOOR (the number of Bytes on the SD Card (from above) / 255 / 63 / 512)

   So for this example:  2021654528 / 255 / 63 / 512 = 245.79.  So we use 245 (i.e. truncate, don't round).

·   Set the number of cylinders to the number calculated.

  Expert Command (for help): [c]
  Number of cylinders (1-256, default xxx): [enter the number you calculated]

·  Return to Normal mode.

        Expert Command (for help): [r]

 Print the partition record to check your work

Command (for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Create the FAT32 partition for booting and transferring files from Windows


Command (for help): [n]
Command action
     primary partition (1-4)
Partition number (1-4): [1]
First cylinder (1-245, default 1): [(press Enter)]
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-245, default 245): [+50]

Command (for help): [t]
Selected partition 1
Hex code (type L to list codes): [c]
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Mark it as bootable


Command (for help): [a]
Partition number (1-4): [1]

Create the Linux partition for the root file system


Command (for help): [n]
Command action
     primary partition (1-4)
Partition number (1-4): [2]
First cylinder (52-245, default 52): [(press Enter)]
Using default value 52
Last cylinder or +size or +sizeM or +sizeK (52-245, default 245): [(press Enter)]

Using default value 245

Print to Check Your Work


Command (for help): [p]

Disk /dev/sdc: 2021 MB, 2021654528 bytes
255 heads, 63 sectors/track, 245 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          51      409626     W95 FAT32 (LBA)
/dev/sdc2              52         245     1558305   83  Linux

 Save the new partition records on the SD Card


This is an important step. All the work up to now has been temporary.


Command (for help): [w]
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information.
Syncing disks.


Format the partitions


The two partitions are given the volume names LABEL1 and LABEL2 by these commands. You can substitute your own volume labels.

[sudo mkfs.msdos -32 /dev/sdc1 -n LABEL1]
mkfs.msdos 2.11 (12 Mar 2005)

[sudo mkfs.ext3 -L LABEL2 /dev/sdc2]
mke2fs 1.40-WIP (14-Nov-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
195072 inodes, 389576 blocks
19478 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=402653184
12 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:


Following Snapshot shows result of created two new partitions. They are mounted as /media/LABEL1 and /media/LABEL2 respectively.



(2) Setup gitcore


Go to the [/home/<user>/felabs/sysdev/u-boot-omap/] directory.

$ cd /home/<user>/felabs/sysdev/u-boot-omap/




Install the git core package using command

$ apt-get install git-core




(3) X-Loader setup


Download X-loader for the original Git repository:


git clone git:// xloader


If your company's firewall blocks git requests, you can also get the same sources through http. This is equivalent, but slower:

git clone xloader


Go in to the directory xloader

$ cd xloader 

 We need two different X-loaders.


1. For MMC initial booting and

2. For NAND flash booting.


1. First for the MMC booting look for the “CFG_CMD_MMC” macro in the include/configs/omap3530beagle.h file and make sure it is enabled. In order to compile the X-Loader, you need to:


Set the CROSS_COMPILE environment variable:


export CROSS_COMPILE=arm-linux-


- Specify the PATH to the toolchain that you made:

export PATH=/usr/local/xtools/arm-unknown-linux-uclibcgnueabi/bin:$PATH


- Set the target board configuration


make omap3530beagle_config



Build Image


$ make


The resulting file is stored in the x-loader main directory as x-load.bin.


This file must be “signed” in order to be executed by the processor. Using the signGP tool in the tools/ subdirectory of the main directory of the lab, sign the x-load.bin file. This produces an xload.bin.ift file.


You can copy it to the MMC card, renaming it as MLO.



Copy x-load.bin.ift on Desktop and rename it to MLO.


2. Then, for NAND boot image, look for the “CFG_CMD_MMC” macro in the include/configs/omap3530beagle.h and comment it. Run make distclean and compile X-loader again. Sign the x load.bin file and copy it to the MMC card with its original name.


I copied header file omap3530beagle.h before edit that file.


Search for Macro “CFG_CMD_MMC”. You can find the following line. Comment that line as shown in next snapshot.


Save and quit from vi editor.


Run command make distclean from folder xloader and then again compile xloader as below.


$ make distclean

make omap3530beagle_config

$ make



Again sign the x load.bin file and copy it to the MMC card with its original name.


Copy x-load.bin.ift on Desktop for temporarary purpose.



 (4) U-Boot setup


Download U-Boot from the mainline Git repository:

git clone git:// u-boot-main


Get an understanding of its configuration and compilation step by reading the README file, and specifically the Building the software section.


Go into the directory u-boot-main and write following command.

cd u-boot-main/

git checkout --track -b omap3 origin/master


Now follow steps as below which create a required u-boot.bin file in current directory.


1.   Run make mrproper to clean up the sources

2.   Set the CROSS_COMPILE environment variable

make CROSS_COMPILE=arm-linux- mrproper

3.   Run make <NAME>_config, where <NAME> is the name of configuration file in include/configs/.

     For our platform, the configuration file is include/configs/omap3_beagle.h.


make CROSS_COMPILE=arm-linux- omap3_beagle_config


4.   Read this file to get an idea of how an U-Boot configuration file is written;

5.   Run make, which should build U-Boot.


make CROSS_COMPILE=arm-linux-


You can now copy the generated uboot.bin file to the MMC card.


Copy this u-boot.bin into first partition of SD card. SD card contents looks like a following Snapshot. Unmount the MMC card.


Start minicom and press RESET on Beagle Board. Now you can see the result as below.



[1] X-loader setup             

[2] Installation of git core package

[3] Beagle Board U-Boot and X-Loader installation information

[4] Getting U-Boot git from following link