9
0
Fork 0

add alternate mechanism & flash scripts - part2

sorry, forgot to add these files :(
This commit is contained in:
Wolfram Sang 2008-02-15 11:47:18 +01:00
parent 788312ae29
commit 11d26a7de4
8 changed files with 104 additions and 49 deletions

View File

@ -4,6 +4,8 @@
#include <malloc.h>
#include <fs.h>
#define MAGIC 0x19691228
static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[])
{
void *buf;
@ -12,7 +14,7 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[])
if (argc != 2) {
u_boot_cmd_usage(cmdtp);
return 1;
return 0;
}
buf = read_file(argv[1], &size);
@ -20,6 +22,12 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[])
return 1;
ptr = buf;
if ((*ptr) != MAGIC) {
printf("Wrong magic! Expected 0x%08x, got 0x%08x.\n", MAGIC, *ptr);
return 1;
}
ptr++;
while ((ulong)ptr <= (ulong)buf + size && !(val = *ptr++))
bitcount += 32;
@ -32,14 +40,14 @@ static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[])
} while (val >>= 1);
}
printf("bitcount : %d\n", bitcount);
printf("Bitcount : %d\n", bitcount);
free(buf);
return (bitcount & 1) ? 2 : 3;
return (bitcount & 1) ? 3 : 2;
}
static __maybe_unused char cmd_alternate_help[] =
"Usage: alternate <file>\n"
"Usage: alternate <file>"
"\n";
U_BOOT_CMD_START(alternate)

View File

@ -1,4 +1,8 @@
echo "updating $image to $part"
#!/bin/sh
if [ $# = 1 ]; then
image=$1
fi
if [ -z "$part" -o -z "$image" ]; then
echo "define \$part and \$image"
@ -6,18 +10,28 @@ if [ -z "$part" -o -z "$image" ]; then
fi
if [ \! -e "$part" ]; then
echo "Partition $part does not exist"
exit 1
fi
if [ $# = 1 ]; then
image=$1
echo "Partition $part does not exist"
exit 1
fi
if [ x$ip = xdhcp ]; then
dhcp
dhcp
fi
ping $eth0.serverip
if [ $? -ne 0 ] ; then
echo "update aborted"
exit 1
fi
unprotect $part
echo
echo "Erasing partition $part"
erase $part
echo
echo "Flashing $image to $part"
tftp $image $part
protect $part

View File

@ -1,5 +1,19 @@
#!/bin/sh
. /env/config
. /env/bin/_alternate
if [ $? = 2 ]; then
act_kernel=/dev/nor0.kernel0
act_rootfs=/dev/mtdblock5
else
act_kernel=/dev/nor0.kernel1
act_rootfs=/dev/mtdblock6
fi
echo "-> Active kernel: $act_kernel"
echo "-> Active system: $act_rootfs"
echo
if [ x$1 = xflash ]; then
root=flash
kernel=flash
@ -10,14 +24,15 @@ if [ x$1 = xnet ]; then
kernel=net
fi
if [ $root = flash ]; then
bootargs="$bootargs root=/dev/mtdblock4 rootfstype=jffs2"
if [ x$ip = xdhcp ]; then
bootargs="$bootargs ip=dhcp"
else
bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
fi
if [ x$root = xflash ]; then
bootargs="$bootargs root=$act_rootfs rootfstype=jffs2"
else
if [ x$ip = xdhcp ]; then
bootargs="$bootargs ip=dhcp"
else
bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
fi
bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
fi
@ -30,5 +45,5 @@ if [ $kernel = net ]; then
tftp $uimage uImage
bootm uImage
else
bootm /dev/nor0.kernel
bootm $act_kernel
fi

View File

@ -1,14 +1,24 @@
#!/bin/sh
PATH=/env/bin
export PATH
. /env/config
addpart /dev/nor0 $mtdparts
echo
echo -n "Hit any key to stop autoboot: "
timeout -a 1
timeout -a $autoboot_timeout
if [ $? != 0 ]; then
echo "type update_kernel <imagename> to update kernel into flash"
echo "type udate_root <imagename> to update rootfs into flash"
exit
echo
echo "Type update_kernel [<imagename>] to update kernel into flash."
echo "Type update_system [<imagename>] to update rootfs into flash."
echo "Type update_application [<imagename>] to update applications into flash."
echo "Type update_persistent [<imagename>] to update persistent into flash."
echo "Type update_ubootenv [<imagename>] to update ubootenv into flash (use with care!)."
echo "Type reset_ageing to initialize the ageing partittion (use with care!)."
echo
exit
fi
boot

View File

@ -1,6 +1,14 @@
#!/bin/sh
. /env/config
image=$uimage
part=/dev/nor0.kernel
. /env/bin/_alternate
if [ $? = 2 ]; then
part=/dev/nor0.kernel0
else
part=/dev/nor0.kernel1
fi
. /env/bin/_update $1

View File

@ -1,6 +0,0 @@
. /env/config
image=$jffs2
part=/dev/nor0.root
. /env/bin/_update $1

View File

@ -4,7 +4,7 @@
image=$jffs2
alternate $ageing
. /env/bin/_alternate
if [ $? = 2 ]; then
part=/dev/nor0.system0
else

View File

@ -1,22 +1,28 @@
echo /env/config
ip=dhcp
eth0.ipaddr=192.168.23.164
eth0.ethaddr=80:87:78:74:73:63
eth0.serverip=192.168.23.1
eth0.netmask=255.255.255.0
eth0.gateway=192.168.23.1
uimage=uImage-bfin
jffs2=root-bfin.jffs2
nfsroot="/home/kleineb/pengutronix/pii-bf/OSELAS.BSP-Pipetronix-ipe337-trunk/root"
bootargs="console=ttyBF0,115200"
#!/bin/sh
# can be either 'net' or 'flash'
kernel=net
root=net
mtdparts="128k(uboot)ro,128k(ubootenv),128k(alternate),1536k(kernel),-(root)"
addpart /dev/nor0 $mtdparts
# use 'dhcp' todo dhcp in uboot and in kernel
#ip=dhcp
eth0.ipaddr=192.168.23.164
eth0.netmask=255.255.255.0
eth0.gateway=192.168.23.2
eth0.serverip=192.168.23.2
eth0.ethaddr=00:50:c2:72:a7:4a
uimage=uImage-bfin
jffs2=root-bfin.jffs2
appimage=apps-bfin
perimage=pers-bfin
envimage=uEnv-bfin
autoboot_timeout=1
nfsroot="/ptx/work/octopus/wsa/svn/OSELAS.BSP-Pipetronix-ipe337-trunk/root"
bootargs="console=ttyBF0,115200"
mtdparts="128k(uboot)ro,128k(ubootenv),128k(ageing),1280k(kernel0),1280k(kernel1),8704k(system0),8704k(system1),8320k(application),4096k(persistent)"
ageing=/dev/nor0.ageing