[PATCH 07/11] add a generic default environment

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Tue Jun 15 05:13:03 EDT 2010


Hello Sascha,

> diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
> new file mode 100644
> index 0000000..8c300a3
> --- /dev/null
> +++ b/defaultenv/bin/boot
> @@ -0,0 +1,110 @@
> +#!/bin/sh
> +
> +. /env/config
> +
> +if [ x$1 = xnand ]; then
> +	rootfs_loc=nand
> +	kernel_loc=nand
> +elif [ x$1 = xnor ]; then
> +	rootfs_loc=nor
> +	kernel_loc=nor
> +elif [ x$1 = xnet ]; then
> +	rootfs_loc=net
> +	kernel_loc=net
> +fi
case "$1" in
nand|nor|net)
	rootfs_loc=$1;
	kernel_loc=$1;
	;;
esac

> +
> +
> +if [ x$ip = xdhcp ]; then
> +	bootargs="$bootargs ip=dhcp"
> +elif [ x$ip = xnone ]; then
> +	bootargs="ip=none"
> +else
> +	bootargs="$bootargs ip=$eth0.ipaddr::$eth0.gateway:$eth0.netmask:::"
> +fi
> +
> +
> +if [ $rootfs_loc = net ]; then
"x$rootfs_loc" = "xnet"

> +	bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
> +elif [ $rootfs_loc = initrd ]; then
> +	bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
Wouldn't it be nice to load the initrd into /dev/ram0, too?

> +else
> +	if [ x$rootfs_loc = xnand ]; then
> +		rootfs_mtdblock=$rootfs_mtdblock_nand
> +	else
> +		rootfs_mtdblock=$rootfs_mtdblock_nor
> +	fi
> +
> +	if [ $rootfs_type = ubifs ]; then
> +		bootargs="$bootargs root=ubi0:root ubi.mtd=$rootfs_mtdblock"
> +	else
> +		bootargs="$bootargs root=/dev/mtdblock$rootfs_mtdblock"
> +	fi
> +
> +	bootargs="$bootargs rootfstype=$rootfs_type noinitrd"
> +fi
> +
> +if [ -n $nor_parts ]; then
> +	mtdparts="${mtdparts}physmap-flash.o:${nor_parts};"
> +fi
> +
> +if [ -n $nand_parts ]; then
> +	mtdparts="${mtdparts}$nand_device:${nor_parts};"
> +fi
> +
> +if [ -n $mtdparts ]; then
> +	bootargs="${bootargs} mtdparts=\"${mtdparts}\""
> +fi
> +
> +if [ ! -e /dev/ram0.kernelraw ]; then
> +	# arm raw kernel images are usually located at sdram start + 0x8000
> +	addpart dev/ram0 8M at 0x8000(kernelraw)
> +fi
> +
> +if [ ! -e /dev/ram0.kernel ]; then
> +	# Here we can safely put the kernel without risking of overwriting it
> +	# while extracting
> +	addpart dev/ram0 8M(kernel)
> +fi
> +
> +if [ $kernel_loc = net ]; then
> +	if [ x$ip = xdhcp ]; then
> +		dhcp
> +	fi
> +	if [ $kernelimage_type = uimage ]; then
> +		netload="/dev/ram0.kernel"
> +	elif [ $kernelimage_type = zimage ]; then
> +		netload="/dev/ram0.kernel"
> +	elif [ $kernelimage_type = raw ]; then
> +		netload="/dev/ram0.kernelraw"
> +	elif [ $kernelimage_type = raw_lzo ]; then
> +		netload="/dev/ram0.kernel"
> +	else
> +		echo "error: missing kernel_image_type"
> +		exit 1
> +	fi
> +	tftp $kernelimage $netload || exit 1
> +	kdev="$netload"
> +elif [ $kernel_loc = nor ]; then
> +	kdev="/dev/nor0.kernel"
> +elif [ $kernel_loc = nand ]; then
> +	kdev="/dev/nand0.kernel.bb"
> +else
> +	echo "error: missing kernel_loc"
> +	exit 1
> +fi
> +
> +if [ $kernelimage_type = uimage ]; then
> +	bootm $kdev
> +elif [ $kernelimage_type = zimage ]; then
> +	bootz $kdev
> +elif [ $kernelimage_type = raw ]; then
> +	if [ $kernel_loc != net ]; then
> +		ec
maybe better spell that out?

> +		cp $kdev /dev/ram0.kernelraw
> +	fi
> +	bootu /dev/ram0.kernelraw
> +elif [ $kernelimage_type = raw_lzo ]; then
> +	unlzo $kdev /dev/ram0.kernelraw
> +	bootu /dev/ram0.kernelraw
> +fi
> +
trailing new line

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the barebox mailing list