Panda How to MLO & u-boot

From eLinux.org
Revision as of 09:34, 22 July 2011 by KenMcGuire (talk | contribs)
Jump to: navigation, search

This is a WIP don't be surprised if nothing below this line is correct.

Introduction

Newer kernels require that you use a recent MLO (x-loader) and u-boot.

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. Kernels have also been successfully built with arm-2010q1.

MLO

First, let's get the x-loader source code and build it.

git clone git://gitorious.org/pandaboard/x-loader-mainline.git

cd to the x-loader directory

Next, select the panda config:

make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi- omap4430panda_config

Now compile MLO:

make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi- ift

This should produce the MLO file in the x-loader directory.


u-boot

Now for U-boot:

git clone git://gitorious.org/pandaboard/u-boot-mainline.git


Next, select the panda config:

make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/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 USE_PRIVATE_LIBGG=yes CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi-

This should produce u-boot.bin in the u-boot directory

boot.scr

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.

#!/bin/sh
if [ ! "$1" = "/dev/sda" ] ; then
	DRIVE=$1
	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 CYLINDERS - $CYLINDERS
		{
		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
	fi 
fi


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).