Panda How to MLO & u-boot

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. MLO, u-boot and 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-mainline 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-mainline directory.

u-boot
Now for U-boot:

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

cd to the u-boot-mainline directory

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 (unless you are going to use boot.scr)

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-mainline directory

boot.scr
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 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
 * 1) !/bin/sh

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.

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;
 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include 
 * 5) include 
 * 6) include 

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