diff --git a/board/ipe337/cmd_alternate.c b/board/ipe337/cmd_alternate.c index afe75d4..ce2e3e0 100644 --- a/board/ipe337/cmd_alternate.c +++ b/board/ipe337/cmd_alternate.c @@ -4,6 +4,8 @@ #include #include +#define MAGIC 0x19691228 + static int do_alternate (cmd_tbl_t *cmdtp, int argc, char *argv[]) { void *buf; @@ -12,7 +14,7 @@ if (argc != 2) { u_boot_cmd_usage(cmdtp); - return 1; + return 0; } buf = read_file(argv[1], &size); @@ -20,6 +22,12 @@ 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 @@ } 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 \n" +"Usage: alternate " "\n"; U_BOOT_CMD_START(alternate) diff --git a/board/ipe337/env/bin/_update b/board/ipe337/env/bin/_update index b21d173..124e285 100644 --- a/board/ipe337/env/bin/_update +++ b/board/ipe337/env/bin/_update @@ -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 @@ 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 diff --git a/board/ipe337/env/bin/boot b/board/ipe337/env/bin/boot index 20c59b9..8e44589 100644 --- a/board/ipe337/env/bin/boot +++ b/board/ipe337/env/bin/boot @@ -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 @@ kernel=net fi -if [ $root = flash ]; then - bootargs="$bootargs root=/dev/mtdblock4 rootfstype=jffs2" +if [ x$ip = xdhcp ]; then + bootargs="$bootargs ip=dhcp" 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 ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::" +fi + +if [ x$root = xflash ]; then + bootargs="$bootargs root=$act_rootfs rootfstype=jffs2" +else bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp" fi @@ -30,5 +45,5 @@ tftp $uimage uImage bootm uImage else - bootm /dev/nor0.kernel + bootm $act_kernel fi diff --git a/board/ipe337/env/bin/init b/board/ipe337/env/bin/init index 93eef1c..9ca41d6 100644 --- a/board/ipe337/env/bin/init +++ b/board/ipe337/env/bin/init @@ -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 to update kernel into flash" - echo "type udate_root to update rootfs into flash" - exit + echo + echo "Type update_kernel [] to update kernel into flash." + echo "Type update_system [] to update rootfs into flash." + echo "Type update_application [] to update applications into flash." + echo "Type update_persistent [] to update persistent into flash." + echo "Type update_ubootenv [] to update ubootenv into flash (use with care!)." + echo "Type reset_ageing to initialize the ageing partittion (use with care!)." + echo + exit fi boot diff --git a/board/ipe337/env/bin/update_kernel b/board/ipe337/env/bin/update_kernel index b62caea..fd3ad23 100644 --- a/board/ipe337/env/bin/update_kernel +++ b/board/ipe337/env/bin/update_kernel @@ -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 diff --git a/board/ipe337/env/bin/update_root b/board/ipe337/env/bin/update_root deleted file mode 100644 index 4d0c9b6..0000000 --- a/board/ipe337/env/bin/update_root +++ /dev/null @@ -1,6 +0,0 @@ -. /env/config - -image=$jffs2 -part=/dev/nor0.root - -. /env/bin/_update $1 diff --git a/board/ipe337/env/bin/update_system b/board/ipe337/env/bin/update_system index ac2e3e8..32d22e6 100644 --- a/board/ipe337/env/bin/update_system +++ b/board/ipe337/env/bin/update_system @@ -4,7 +4,7 @@ image=$jffs2 -alternate $ageing +. /env/bin/_alternate if [ $? = 2 ]; then part=/dev/nor0.system0 else diff --git a/board/ipe337/env/config b/board/ipe337/env/config index c15fba8..1fd7fbc 100644 --- a/board/ipe337/env/config +++ b/board/ipe337/env/config @@ -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