Difference between revisions of "Panda How to MLO & u-boot"

From eLinux.org
Jump to: navigation, search
(Update to u-boot+spl)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
Newer kernels require that you use a recent MLO (x-loader) and u-boot.
+
Newer kernels require that you use a recent MLO (SPL) 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.  
 
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.  
Line 6: Line 6:
 
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.
 
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 ==
+
You can get u-boot from either linaro or mainline. The linaro tree usually has the latest patches.
First, let's get the x-loader source code and build it.
+
  
git clone git://gitorious.org/pandaboard/x-loader-mainline.git
+
== u-boot (linaro) ==
 +
First, let's get the u-boot source code and build it.
  
cd to the x-loader-mainline directory
+
git clone git://git.linaro.org/boot/u-boot-linaro-stable.git
  
Next, select the panda config:
+
cd to the u-boot-linaro-stable directory and checkout tag 2011.11.2
  
  make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi- omap4430panda_config
+
  cd u-boot-linaro-stable
 +
git checkout 2011.11.2
  
Now compile MLO:
+
Next, select the panda config. Make sure your cross compiler is in your $PATH:
  
  make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi- ift
+
  make CROSS_COMPILE=arm-none-linux-gnueabi- omap4_panda_config
  
This should produce the MLO file in the x-loader-mainline directory.
+
Change ttyS2 to ttyO2 in the u-boot kernel command line in: u-boot/include/configs/omap4_panda.h
  
== u-boot ==
+
Now compile U-boot:
Now for U-boot:
+
  
  git clone git://gitorious.org/pandaboard/u-boot-mainline.git
+
  make CROSS_COMPILE=arm-none-linux-gnueabi-
  
cd to the u-boot-mainline directory
+
This should produce the files MLO and u-boot.img in the u-boot directory. Copy both files to your sd card.
  
Next, select the panda config:
+
== u-boot (mainline) ==
  
make CROSS_COMPILE=Path_to_your/arm-2009q3/bin/arm-none-linux-gnueabi- omap4_panda_config
+
Same as above but clone from denx.de:
 
+
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-
+
  git clone git://git.denx.de/u-boot.git
  
This should produce u-boot.bin in the u-boot-mainline directory
+
And checkout tag v2011.09:
 +
 +
git checkout v2011.09
  
 +
Note: Tag v2011.09 from mainline might fail on some Pandaboard revisions, see http://lists.denx.de/pipermail/u-boot/2011-October/104842.html
 +
You can use Linaro instead.
  
 
=== boot.scr ===
 
=== boot.scr ===

Revision as of 20:21, 6 December 2011

Introduction

Newer kernels require that you use a recent MLO (SPL) 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.

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://git.linaro.org/boot/u-boot-linaro-stable.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 denx.de:

git clone git://git.denx.de/u-boot.git

And checkout tag v2011.09:

git checkout v2011.09

Note: Tag v2011.09 from mainline might fail on some Pandaboard revisions, see http://lists.denx.de/pipermail/u-boot/2011-October/104842.html You can use Linaro instead.

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.

#!/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).

More to come....