add a generic default environment
We have several nearly identical default environments in the tree. Lets merge them to a single environment and use it on many boards. This defaultenv is arm centric at the moment due to the use of arm specific boot commands. This can be improved over time. changes since last version: - fix potentially empty variable tests - be a bit more verbose in boot script - run a board specific init script (/env/bin/init_board) if it exists Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
e7048e1862
commit
c56830349b
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "$part" -o -z "$image" ]; then
|
||||
echo "define \$part and \$image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$part" ]; then
|
||||
echo "Partition $part does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# = 1 ]; then
|
||||
image=$1
|
||||
fi
|
||||
|
||||
if [ x$ip = xdhcp ]; then
|
||||
dhcp
|
||||
fi
|
||||
|
||||
ping $eth0.serverip
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Server did not reply! Update aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unprotect $part
|
||||
|
||||
echo
|
||||
echo "erasing partition $part"
|
||||
echo
|
||||
erase $part
|
||||
|
||||
echo
|
||||
echo "flashing $image to $part"
|
||||
echo
|
||||
tftp $image $part
|
||||
|
||||
protect $part
|
|
@ -0,0 +1,109 @@
|
|||
#!/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
|
||||
|
||||
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 [ x$rootfs_loc = xnet ]; then
|
||||
bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
|
||||
elif [ x$rootfs_loc = xinitrd ]; then
|
||||
bootargs="$bootargs root=/dev/ram0 rdinit=/sbin/init"
|
||||
else
|
||||
if [ x$rootfs_loc = xnand ]; then
|
||||
rootfs_mtdblock=$rootfs_mtdblock_nand
|
||||
else
|
||||
rootfs_mtdblock=$rootfs_mtdblock_nor
|
||||
fi
|
||||
|
||||
if [ x$rootfs_type = xubifs ]; 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@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 [ x$kernel_loc = xnet ]; 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: set kernelimage_type to one of 'uimage', 'zimage', 'raw' or 'raw_lzo'"
|
||||
exit 1
|
||||
fi
|
||||
tftp $kernelimage $netload || exit 1
|
||||
kdev="$netload"
|
||||
elif [ x$kernel_loc = xnor ]; then
|
||||
kdev="/dev/nor0.kernel"
|
||||
elif [ x$kernel_loc = xnand ]; then
|
||||
kdev="/dev/nand0.kernel.bb"
|
||||
else
|
||||
echo "error: set kernel_loc to one of 'net', 'nand' or 'nor'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "booting kernel of type $kernelimage_type from $kdev"
|
||||
|
||||
if [ x$kernelimage_type = xuimage ]; then
|
||||
bootm $kdev
|
||||
elif [ x$kernelimage_type = xzimage ]; then
|
||||
bootz $kdev
|
||||
elif [ x$kernelimage_type = xraw ]; then
|
||||
if [ $kernel_loc != net ]; then
|
||||
cp $kdev /dev/ram0.kernelraw
|
||||
fi
|
||||
bootu /dev/ram0.kernelraw
|
||||
elif [ x$kernelimage_type = xraw_lzo ]; then
|
||||
unlzo $kdev /dev/ram0.kernelraw
|
||||
bootu /dev/ram0.kernelraw
|
||||
fi
|
|
@ -0,0 +1 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
PATH=/env/bin
|
||||
export PATH
|
||||
|
||||
. /env/config
|
||||
if [ -e /dev/nor0 ]; then
|
||||
addpart /dev/nor0 $nor_parts
|
||||
fi
|
||||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -f /env/bin/init_board ]; then
|
||||
/env/bin/init_board
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -n "Hit any key to stop autoboot: "
|
||||
timeout -a $autoboot_timeout
|
||||
if [ $? != 0 ]; then
|
||||
echo
|
||||
echo "type update_kernel nand|nor [<imagename>] to update kernel into flash"
|
||||
echo "type update_rootfs nand|nor [<imagename>] to update rootfs into flash"
|
||||
echo
|
||||
exit
|
||||
fi
|
||||
|
||||
boot
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /env/config
|
||||
image=$kernelimage
|
||||
|
||||
if [ x$1 = xnand ]; then
|
||||
part=/dev/nand0.kernel.bb
|
||||
elif [ x$1 = xnor ]; then
|
||||
part=/dev/nor0.kernel
|
||||
else
|
||||
echo "usage: $0 nor|nand [imagename]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /env/bin/_update $2
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
. /env/config
|
||||
|
||||
image=$rootfsimage
|
||||
|
||||
if [ x$1 = xnand ]; then
|
||||
part=/dev/nand0.root.bb
|
||||
elif [ x$1 = xnor ]; then
|
||||
part=/dev/nor0.root
|
||||
else
|
||||
echo "usage: $0 nor|nand [imagename]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. /env/bin/_update $2
|
Loading…
Reference in New Issue