Panda How to MLO & u-boot

Revision as of 14:18, 6 December 2011 by Defiant (talk | contribs) (Introduction: note x-loader -> spl)
Jump to: navigation, search


Newer kernels require that you use a recent MLO (SPL) and u-boot. Note: New u-boot with SPL replaces x-loader which you might find in other howtos.

You can build these from source, or try to find binaries. One issue with the binary route is that you might want to alter the kernel command line embedded inside u-boot. Such as for experimenting with different partition formats, or different filesystem types (ext3 vs ext2), etc. Of course you could stop the autoboot and type it in yourself, but we will build from source. An even better solution is to use a boot.scr file to send parameters to u-boot, it's easy to create, see below.

For this How-to, we will use the Code Sourcery G++ version arm-2009q3. It should already be installed on your system. MLO, u-boot and kernels have also been successfully built with arm-2010q1.

You can get u-boot from either linaro or mainline. The linaro tree usually has the latest patches.

u-boot (linaro)

First, let's get the u-boot source code and build it.

git clone git://

cd to the u-boot-linaro-stable directory and checkout tag 2011.11.2

cd u-boot-linaro-stable
git checkout 2011.11.2

Next, select the panda config. Make sure your cross compiler is in your $PATH:

make CROSS_COMPILE=arm-none-linux-gnueabi- omap4_panda_config

Change ttyS2 to ttyO2 in the u-boot kernel command line in: u-boot/include/configs/omap4_panda.h

Now compile U-boot:

make CROSS_COMPILE=arm-none-linux-gnueabi-

This should produce the files MLO and u-boot.img in the u-boot directory. Copy both files to your sd card.

u-boot (mainline)

Same as above but clone from

git clone git://

And checkout tag v2011.09:

git checkout v2011.09

Note: Tag v2011.09 from mainline might fail on some Pandaboard revisions, see You can use Linaro instead.


Copy the following code to boot_mmc.txt

setenv bootargs 'root=/dev/mmcblk0p2 rw rootwait rootfstype=ext3 console=ttyO2,115200n8  vram=16M'
fatload mmc 0 82000000 uImage
bootm 82000000

Then run the following command from in same directory that you created boot_mmc.txt:

mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Panda SD Boot" -d boot_mmc.txt boot.scr

This will produce a boot.scr file.

Edit the boot_mmc.txt file to suit your needs and re-run the mkimage command to generate a new boot.scr, put it into the vfat partition along with MLO and uboot.bin.

Creating a working SD card

Use this script to prepare an SD card with the small vfat partition and the larger ext2/3 partition (it has been posted many places, I take no credit for it btw, the card needs to be larger than 64Mbytes since this original script wants to make a 64Mbyte vfat partition) You may need to be root for some of the following operations. For the feint of heart, you can use sudo instead in the right places.

if [ ! "$1" = "/dev/sda" ] ; then
	if [ -b "$DRIVE" ] ; then
		dd if=/dev/zero of=$DRIVE bs=1024 count=1024
		SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
		echo DISK SIZE - $SIZE bytes
		CYLINDERS=`echo $SIZE/255/63/512 | bc`
		echo ,9,0x0C,*
		echo ,,,-
		} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE
		mkfs.vfat -F 32 -n "boot" ${DRIVE}1
		mke2fs -j -L "rootfs" ${DRIVE}2

If you have trouble with the pandaboards ROM CODE not liking your vfat partition check it out with this program.

Thanks go to mru and av500 who have gone a long way to dispell the cargo-cult fokelore surrounding the ROM CODE.

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main( int argc, char **argv )
	if ( argc < 2 ) {
		printf("check /dev/sdX you must be root too \n");
		return 1;
	int fd = open( argv[1], O_RDONLY );

	lseek( fd, 0 + 446 + 8, SEEK_SET );

	int start;
	int num_mbr;
	read( fd, &start, 4 );
	read( fd, &num_mbr, 4 );

	int num_bpb = 0;
	lseek( fd, start * 512 + 0x13, SEEK_SET );
	read( fd, &num_bpb, 2 );

	if( num_bpb == 0 ) {
		lseek( fd, start * 512 + 0x20, SEEK_SET );
		read( fd, &num_bpb, 4 );
	printf( "start: %d  mbr: %d  bpb: %d -> %s\n", 
		start, num_mbr, num_bpb, 
		num_mbr == num_bpb ? "PASS" : "FAIL!" );

	return num_mbr == num_bpb;

Save the above text as sdtest.c and compile it with:

gcc sdtest.c -o sdtest

I run it on the desktop that setup my sd card, if it reports failure then something went wrong with the setup script.

No clue as to how to fix it (yet).

More to come....