* defaultv env update v2
@ 2010-10-11 13:53 Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it Jean-Christophe PLAGNIOL-VILLARD
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 13:53 UTC (permalink / raw)
To: barebox
Hi,
the following patch series update the update default env support by
using getopts and allow us to specify via Kconfig the dependecy of the
defaultenv
a secondi step could be to use the preprocessir to generate some part
of it
Best Regards,
J.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 2/6] commands/crc32: add compare 2 files crc Jean-Christophe PLAGNIOL-VILLARD
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
this will we usefull to enable functionnality if used
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/configs/neso_defconfig | 3 ++-
arch/arm/configs/pca100_defconfig | 3 ++-
arch/arm/configs/pcm037_defconfig | 3 ++-
arch/arm/configs/pcm038_defconfig | 3 ++-
arch/arm/configs/pcm043_defconfig | 3 ++-
common/Kconfig | 13 +++++++++++++
common/Makefile | 10 ++++++++--
7 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/arch/arm/configs/neso_defconfig b/arch/arm/configs/neso_defconfig
index 9f6e3f4..24125f9 100644
--- a/arch/arm/configs/neso_defconfig
+++ b/arch/arm/configs/neso_defconfig
@@ -12,7 +12,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/guf-neso/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/guf-neso/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
diff --git a/arch/arm/configs/pca100_defconfig b/arch/arm/configs/pca100_defconfig
index d1708a6..8c72bdf 100644
--- a/arch/arm/configs/pca100_defconfig
+++ b/arch/arm/configs/pca100_defconfig
@@ -12,7 +12,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/phycard-i.MX27/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/phycard-i.MX27/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
diff --git a/arch/arm/configs/pcm037_defconfig b/arch/arm/configs/pcm037_defconfig
index 8e60b0a..e12f690 100644
--- a/arch/arm/configs/pcm037_defconfig
+++ b/arch/arm/configs/pcm037_defconfig
@@ -10,7 +10,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/pcm037/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/pcm037/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
diff --git a/arch/arm/configs/pcm038_defconfig b/arch/arm/configs/pcm038_defconfig
index eacbbc6..2038f14 100644
--- a/arch/arm/configs/pcm038_defconfig
+++ b/arch/arm/configs/pcm038_defconfig
@@ -13,7 +13,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/pcm038/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/pcm038/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
diff --git a/arch/arm/configs/pcm043_defconfig b/arch/arm/configs/pcm043_defconfig
index 51ca833..2dd711b 100644
--- a/arch/arm/configs/pcm043_defconfig
+++ b/arch/arm/configs/pcm043_defconfig
@@ -13,7 +13,8 @@ CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/pcm043/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/pcm043/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
diff --git a/common/Kconfig b/common/Kconfig
index 123d070..fb47397 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -389,6 +389,19 @@ config DEFAULT_ENVIRONMENT
Enabling this option will give you a default environment when
the environment found in the environment sector is invalid
+config DEFAULT_ENVIRONMENT_GENERIC
+ bool
+ depends on DEFAULT_ENVIRONMENT
+ select SHELL_HUSH
+ prompt "Default environment generic"
+ help
+ With this option barebox will use the generic default
+ environment found under defaultenv/ in the src tree.
+ The Directory given with DEFAULT_ENVIRONMENT_PATH
+ will be added to the default environment. This should
+ at least contain a /env/config file.
+ This will be able to overwrite the files from defaultenv.
+
config DEFAULT_ENVIRONMENT_PATH
string
depends on DEFAULT_ENVIRONMENT
diff --git a/common/Makefile b/common/Makefile
index e56dbc2..753455b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -26,12 +26,18 @@ ifdef CONFIG_DEFAULT_ENVIRONMENT
$(obj)/startup.o: include/generated/barebox_default_env.h
$(obj)/env.o: include/generated/barebox_default_env.h
-ENV_FILES := $(shell cd $(srctree); for i in $(CONFIG_DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f {} \;; done)
+ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_GENERIC),y)
+DEFAULT_ENVIRONMENT_PATH = "defaultenv"
+endif
+
+DEFAULT_ENVIRONMENT_PATH += $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
+
+ENV_FILES := $(shell cd $(srctree); for i in $(DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f {} \;; done)
endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
barebox_default_env: $(ENV_FILES)
- $(Q)$(srctree)/scripts/genenv $(srctree) $(objtree) $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
+ $(Q)$(srctree)/scripts/genenv $(srctree) $(objtree) $(DEFAULT_ENVIRONMENT_PATH)
include/generated/barebox_default_env.h: barebox_default_env
$(Q)cat $< | $(objtree)/scripts/bin2c default_environment > $@
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/6] commands/crc32: add compare 2 files crc
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 3/6] defaultenv/update: merge update_rootfs and update_kernel Jean-Christophe PLAGNIOL-VILLARD
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
add -F options to compare to file crc
it's usefull to compare what you flash in a partition
it's selectable by CONFIG_CMD_CRC_CMP
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
commands/Kconfig | 5 ++
commands/crc.c | 111 ++++++++++++++++++++++++++++++++++++------------------
2 files changed, 79 insertions(+), 37 deletions(-)
diff --git a/commands/Kconfig b/commands/Kconfig
index 0fc80aa..5416073 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -202,6 +202,11 @@ config CMD_CRC
select CRC32
prompt "crc"
+config CMD_CRC_CMP
+ tristate
+ depends on CMD_CRC
+ prompt "compare 2 files crc"
+
config CMD_MTEST
tristate
prompt "mtest"
diff --git a/commands/crc.c b/commands/crc.c
index 4842cdc..d3e0865 100644
--- a/commands/crc.c
+++ b/commands/crc.c
@@ -30,20 +30,80 @@
#include <malloc.h>
#include <linux/ctype.h>
+static int file_crc(char* filename, ulong start, ulong size, ulong *crc,
+ ulong *total)
+{
+ int fd, now;
+ int ret = 0;
+ char *buf;
+
+ *total = 0;
+ *crc = 0;
+
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ printf("open %s: %s\n", filename, errno_str());
+ return fd;
+ }
+
+ if (start > 0) {
+ ret = lseek(fd, start, SEEK_SET);
+ if (ret == -1) {
+ perror("lseek");
+ goto out;
+ }
+ }
+
+ buf = xmalloc(4096);
+
+ while (size) {
+ now = min((ulong)4096, size);
+ now = read(fd, buf, now);
+ if (now < 0) {
+ ret = now;
+ perror("read");
+ goto out_free;
+ }
+ if (!now)
+ break;
+ *crc = crc32(*crc, buf, now);
+ size -= now;
+ *total += now;
+ }
+
+ printf ("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx",
+ filename, start, start + *total - 1, *crc);
+
+out_free:
+ free(buf);
+out:
+ close(fd);
+
+ return ret;
+}
+
static int do_crc(struct command *cmdtp, int argc, char *argv[])
{
ulong start = 0, size = ~0, total = 0;
ulong crc = 0, vcrc = 0;
char *filename = "/dev/mem";
- char *buf;
- int fd, opt, err = 0, filegiven = 0, verify = 0, now;
+#ifdef CONFIG_CMD_CRC_CMP
+ char *vfilename = NULL;
+#endif
+ int opt, err = 0, filegiven = 0, verify = 0;
- while((opt = getopt(argc, argv, "f:v:")) > 0) {
+ while((opt = getopt(argc, argv, "f:F:v:")) > 0) {
switch(opt) {
case 'f':
filename = optarg;
filegiven = 1;
break;
+#ifdef CONFIG_CMD_CRC_CMP
+ case 'F':
+ verify = 1;
+ vfilename = optarg;
+ break;
+#endif
case 'v':
verify = 1;
vcrc = simple_strtoul(optarg, NULL, 0);
@@ -61,38 +121,17 @@ static int do_crc(struct command *cmdtp, int argc, char *argv[])
}
}
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
- printf("open %s: %s\n", filename, errno_str());
+ if (file_crc(filename, start, size, &crc, &total) < 0)
return 1;
- }
- if (start > 0) {
- if (lseek(fd, start, SEEK_SET) == -1) {
- perror("lseek");
- err = 1;
- goto out;
- }
- }
-
- buf = xmalloc(4096);
-
- while (size) {
- now = min((ulong)4096, size);
- now = read(fd, buf, now);
- if (now < 0) {
- perror("read");
- goto out_free;
- }
- if (!now)
- break;
- crc = crc32(crc, buf, now);
- size -= now;
- total += now;
+#ifdef CONFIG_CMD_CRC_CMP
+ if (vfilename) {
+ size = total;
+ puts("\n");
+ if (file_crc(vfilename, start, size, &vcrc, &total) < 0)
+ return 1;
}
-
- printf ("CRC32 for %s 0x%08lx ... 0x%08lx ==> 0x%08lx",
- filename, start, start + total - 1, crc);
+#endif
if (verify && crc != vcrc) {
printf(" != 0x%08x ** ERROR **", vcrc);
@@ -101,11 +140,6 @@ static int do_crc(struct command *cmdtp, int argc, char *argv[])
printf("\n");
-out_free:
- free(buf);
-out:
- close(fd);
-
return err;
}
@@ -114,6 +148,9 @@ static const __maybe_unused char cmd_crc_help[] =
"Calculate a crc32 checksum of a memory area\n"
"Options:\n"
" -f <file> Use file instead of memory\n"
+#ifdef CONFIG_CMD_CRC_CMP
+" -F <file> Use file to compare\n"
+#endif
" -v <crc> Verfify\n";
BAREBOX_CMD_START(crc32)
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/6] defaultenv/update: merge update_rootfs and update_kernel
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 2/6] commands/crc32: add compare 2 files crc Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 4/6] defaultenv/update: add check crc32 options Jean-Christophe PLAGNIOL-VILLARD
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
use getopt to simplify it and prepare for xmodem support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
common/Kconfig | 1 +
defaultenv/bin/_update | 4 ---
defaultenv/bin/_update_help | 8 +++++++
defaultenv/bin/init | 3 +-
defaultenv/bin/update | 45 ++++++++++++++++++++++++++++++++++++++++++
defaultenv/bin/update_kernel | 15 --------------
defaultenv/bin/update_rootfs | 16 --------------
7 files changed, 55 insertions(+), 37 deletions(-)
create mode 100644 defaultenv/bin/_update_help
create mode 100644 defaultenv/bin/update
delete mode 100644 defaultenv/bin/update_kernel
delete mode 100644 defaultenv/bin/update_rootfs
diff --git a/common/Kconfig b/common/Kconfig
index fb47397..e8d467e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -393,6 +393,7 @@ config DEFAULT_ENVIRONMENT_GENERIC
bool
depends on DEFAULT_ENVIRONMENT
select SHELL_HUSH
+ select HUSH_GETOPT
prompt "Default environment generic"
help
With this option barebox will use the generic default
diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update
index ddd6b84..6f2ebd3 100644
--- a/defaultenv/bin/_update
+++ b/defaultenv/bin/_update
@@ -10,10 +10,6 @@ if [ ! -e "$part" ]; then
exit 1
fi
-if [ $# = 1 ]; then
- image=$1
-fi
-
if [ x$ip = xdhcp ]; then
dhcp
fi
diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
new file mode 100644
index 0000000..e6ea64c
--- /dev/null
+++ b/defaultenv/bin/_update_help
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-f imagename]"
+echo "update tools."
+echo""
+echo "type update -t kernel -d <nor|nand> [-f imagename] to update kernel into flash"
+echo "type update -t rootfs -d <nor|nand> [-f imagename] to update rootfs into flash"
+
diff --git a/defaultenv/bin/init b/defaultenv/bin/init
index a55e8e6..a39e5bd 100644
--- a/defaultenv/bin/init
+++ b/defaultenv/bin/init
@@ -25,8 +25,7 @@ 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"
+ update -h
echo
exit
fi
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
new file mode 100644
index 0000000..bdac11f
--- /dev/null
+++ b/defaultenv/bin/update
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+. /env/config
+
+type=""
+device_type=""
+
+while getopt "ht:d:f:" Option
+do
+if [ ${Option} = t ]; then
+ type=${OPTARG}
+elif [ ${Option} = d ]; then
+ device_type=${OPTARG}
+elif [ ${Option} = f ]; then
+ imagename=${OPTARG}
+else
+ . /env/bin/_update_help
+ exit 0
+fi
+done
+
+if [ x${type} = xkernel ]; then
+ image=$kernelimage
+elif [ x${type} = xrootfs ]; then
+ image=$rootfsimage
+ type=root
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+if [ x${imagename} != x ]; then
+ image=${imagename}
+fi
+
+if [ x${device_type} = xnand ]; then
+ part=/dev/nand0.${type}.bb
+elif [ x${device_type} = xnor ]; then
+ part=/dev/nor0.${type}
+else
+ . /env/bin/_update_help
+ exit 1
+fi
+
+. /env/bin/_update
diff --git a/defaultenv/bin/update_kernel b/defaultenv/bin/update_kernel
deleted file mode 100644
index 1d35ed9..0000000
--- a/defaultenv/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/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
diff --git a/defaultenv/bin/update_rootfs b/defaultenv/bin/update_rootfs
deleted file mode 100644
index 6366315..0000000
--- a/defaultenv/bin/update_rootfs
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/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
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/6] defaultenv/update: add check crc32 options
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
` (2 preceding siblings ...)
2010-10-11 14:34 ` [PATCH 3/6] defaultenv/update: merge update_rootfs and update_kernel Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 5/6] defaultenv: add xmodem support for update Jean-Christophe PLAGNIOL-VILLARD
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
common/Kconfig | 2 ++
defaultenv/bin/_update_help | 8 +++++---
defaultenv/bin/update | 8 +++++++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig
index e8d467e..617f640 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -394,6 +394,8 @@ config DEFAULT_ENVIRONMENT_GENERIC
depends on DEFAULT_ENVIRONMENT
select SHELL_HUSH
select HUSH_GETOPT
+ select CMD_CRC
+ select CMD_CRC_CMP
prompt "Default environment generic"
help
With this option barebox will use the generic default
diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
index e6ea64c..a23f00f 100644
--- a/defaultenv/bin/_update_help
+++ b/defaultenv/bin/_update_help
@@ -1,8 +1,10 @@
#!/bin/sh
-echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-f imagename]"
+echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-f imagename] -c"
echo "update tools."
-echo""
+echo ""
+echo "options"
+echo " -c to check the crc32 for the image and flashed one"
+echo ""
echo "type update -t kernel -d <nor|nand> [-f imagename] to update kernel into flash"
echo "type update -t rootfs -d <nor|nand> [-f imagename] to update rootfs into flash"
-
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
index bdac11f..504bff6 100644
--- a/defaultenv/bin/update
+++ b/defaultenv/bin/update
@@ -4,8 +4,9 @@
type=""
device_type=""
+check=n
-while getopt "ht:d:f:" Option
+while getopt "ht:d:f:c" Option
do
if [ ${Option} = t ]; then
type=${OPTARG}
@@ -13,6 +14,8 @@ elif [ ${Option} = d ]; then
device_type=${OPTARG}
elif [ ${Option} = f ]; then
imagename=${OPTARG}
+elif [ ${Option} = c ]; then
+ check=y
else
. /env/bin/_update_help
exit 0
@@ -43,3 +46,6 @@ else
fi
. /env/bin/_update
+if [ x${check} = xy ]; then
+ crc32 -f $image -F $part
+fi
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/6] defaultenv: add xmodem support for update
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
` (3 preceding siblings ...)
2010-10-11 14:34 ` [PATCH 4/6] defaultenv/update: add check crc32 options Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 6/6] defaultenv: add update_barebox to update barebox easly via tftp or xmodem Jean-Christophe PLAGNIOL-VILLARD
2010-10-12 8:13 ` [PATCH] nhk8815: use defaultenv Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
the default mode is tftp to do not change the default behavior
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
defaultenv/bin/_update | 26 +++++++++++++++++---------
defaultenv/bin/_update_help | 21 +++++++++++----------
defaultenv/bin/update | 11 ++++++++++-
3 files changed, 38 insertions(+), 20 deletions(-)
rewrite defaultenv/bin/_update_help (65%)
diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update
index 6f2ebd3..87e6922 100644
--- a/defaultenv/bin/_update
+++ b/defaultenv/bin/_update
@@ -10,14 +10,16 @@ if [ ! -e "$part" ]; then
exit 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
+if [ x$mode = xtftp ]; then
+ if [ x$ip = xdhcp ]; then
+ dhcp
+ fi
+
+ ping $eth0.serverip
+ if [ $? -ne 0 ] ; then
+ echo "Server did not reply! Update aborted."
+ exit 1
+ fi
fi
unprotect $part
@@ -30,6 +32,12 @@ erase $part
echo
echo "flashing $image to $part"
echo
-tftp $image $part
+
+if [ x$mode = xtftp ]; then
+ tftp $image $part
+else
+ loadb -f $image -c
+ cp $image $part
+fi
protect $part
diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
dissimilarity index 65%
index a23f00f..1d9b28e 100644
--- a/defaultenv/bin/_update_help
+++ b/defaultenv/bin/_update_help
@@ -1,10 +1,11 @@
-#!/bin/sh
-
-echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-f imagename] -c"
-echo "update tools."
-echo ""
-echo "options"
-echo " -c to check the crc32 for the image and flashed one"
-echo ""
-echo "type update -t kernel -d <nor|nand> [-f imagename] to update kernel into flash"
-echo "type update -t rootfs -d <nor|nand> [-f imagename] to update rootfs into flash"
+#!/bin/sh
+
+echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-m tftp|xmodem] [-f imagename] -c"
+echo "update tools."
+echo ""
+echo "options"
+echo " -c to check the crc32 for the image and flashed one"
+echo ""
+echo "default mode is tftp"
+echo "type update -t kernel -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update kernel into flash"
+echo "type update -t rootfs -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update rootfs into flash"
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
index 504bff6..032f340 100644
--- a/defaultenv/bin/update
+++ b/defaultenv/bin/update
@@ -5,8 +5,9 @@
type=""
device_type=""
check=n
+mode=tftp
-while getopt "ht:d:f:c" Option
+while getopt "ht:d:f:m:c" Option
do
if [ ${Option} = t ]; then
type=${OPTARG}
@@ -16,6 +17,8 @@ elif [ ${Option} = f ]; then
imagename=${OPTARG}
elif [ ${Option} = c ]; then
check=y
+elif [ ${Option} = m ]; then
+ mode=${OPTARG}
else
. /env/bin/_update_help
exit 0
@@ -45,6 +48,12 @@ else
exit 1
fi
+if [ x${mode} != xtftp ] && [ x${mode} != xxmodem ] ; then
+ echo "unsupported mode ${mode}."
+ . /env/bin/_update_help
+ exit 1
+fi
+
. /env/bin/_update
if [ x${check} = xy ]; then
crc32 -f $image -F $part
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/6] defaultenv: add update_barebox to update barebox easly via tftp or xmodem
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
` (4 preceding siblings ...)
2010-10-11 14:34 ` [PATCH 5/6] defaultenv: add xmodem support for update Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-11 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
2010-10-12 8:13 ` [PATCH] nhk8815: use defaultenv Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-11 14:34 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
defaultenv/bin/_update_help | 3 ++-
defaultenv/bin/update | 5 +++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/defaultenv/bin/_update_help b/defaultenv/bin/_update_help
index 1d9b28e..22d940e 100644
--- a/defaultenv/bin/_update_help
+++ b/defaultenv/bin/_update_help
@@ -1,6 +1,6 @@
#!/bin/sh
-echo "usage: $0 -t <kernel|rootfs> -d <nor|nand> [-m tftp|xmodem] [-f imagename] -c"
+echo "usage: $0 -t <kernel|rootfs|barebox> -d <nor|nand> [-m tftp|xmodem] [-f imagename] -c"
echo "update tools."
echo ""
echo "options"
@@ -9,3 +9,4 @@ echo ""
echo "default mode is tftp"
echo "type update -t kernel -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update kernel into flash"
echo "type update -t rootfs -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update rootfs into flash"
+echo "type update -t barebox -d <nor|nand> [-m tftp|xmodem] [-f imagename] to update barebox into flash"
diff --git a/defaultenv/bin/update b/defaultenv/bin/update
index 032f340..3601177 100644
--- a/defaultenv/bin/update
+++ b/defaultenv/bin/update
@@ -30,6 +30,11 @@ if [ x${type} = xkernel ]; then
elif [ x${type} = xrootfs ]; then
image=$rootfsimage
type=root
+elif [ x${type} = xbarebox ]; then
+ image=$bareboximage
+ if [ x${image} = x ]; then
+ imamge=barebox.bin
+ fi
else
. /env/bin/_update_help
exit 1
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] nhk8815: use defaultenv
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
` (5 preceding siblings ...)
2010-10-11 14:34 ` [PATCH 6/6] defaultenv: add update_barebox to update barebox easly via tftp or xmodem Jean-Christophe PLAGNIOL-VILLARD
@ 2010-10-12 8:13 ` Jean-Christophe PLAGNIOL-VILLARD
6 siblings, 0 replies; 8+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2010-10-12 8:13 UTC (permalink / raw)
To: barebox
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
arch/arm/boards/nhk8815/env/bin/_update | 36 ----------------
arch/arm/boards/nhk8815/env/bin/boot | 38 -----------------
arch/arm/boards/nhk8815/env/bin/init | 28 ------------
.../boards/nhk8815/env/bin/update_barebox_xmodem | 19 --------
arch/arm/boards/nhk8815/env/bin/update_kernel | 8 ----
arch/arm/boards/nhk8815/env/bin/update_root | 8 ----
arch/arm/boards/nhk8815/env/config | 44 +++++++++++++------
arch/arm/configs/nhk8815_defconfig | 5 +-
8 files changed, 33 insertions(+), 153 deletions(-)
delete mode 100644 arch/arm/boards/nhk8815/env/bin/_update
delete mode 100644 arch/arm/boards/nhk8815/env/bin/boot
delete mode 100644 arch/arm/boards/nhk8815/env/bin/init
delete mode 100644 arch/arm/boards/nhk8815/env/bin/update_barebox_xmodem
delete mode 100644 arch/arm/boards/nhk8815/env/bin/update_kernel
delete mode 100644 arch/arm/boards/nhk8815/env/bin/update_root
diff --git a/arch/arm/boards/nhk8815/env/bin/_update b/arch/arm/boards/nhk8815/env/bin/_update
deleted file mode 100644
index fb7cbe8..0000000
--- a/arch/arm/boards/nhk8815/env/bin/_update
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/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 "update aborted"
- exit 1
-fi
-
-unprotect $part
-
-echo
-echo "erasing partition $part"
-erase $part
-
-echo
-echo "flashing $image to $part"
-echo
-tftp $image $part
diff --git a/arch/arm/boards/nhk8815/env/bin/boot b/arch/arm/boards/nhk8815/env/bin/boot
deleted file mode 100644
index fd8d957..0000000
--- a/arch/arm/boards/nhk8815/env/bin/boot
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xflash ]; then
- root=flash
- kernel=flash
-fi
-
-if [ x$1 = xnet ]; then
- root=net
- kernel=net
-fi
-
-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=$rootpart rootfstype=jffs2"
-else
- bootargs="$bootargs root=/dev/nfs nfsroot=192.168.23.111:$nfsroot"
-fi
-
-bootargs="$bootargs"
-
-if [ $kernel = net ]; then
- if [ x$ip = xdhcp ]; then
- dhcp
- fi
- tftp $uimage uImage
- bootm uImage
-else
- bootm /dev/nor0.kernel
-fi
-
diff --git a/arch/arm/boards/nhk8815/env/bin/init b/arch/arm/boards/nhk8815/env/bin/init
deleted file mode 100644
index 5b45a70..0000000
--- a/arch/arm/boards/nhk8815/env/bin/init
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-PATH=/env/bin
-export PATH
-
-. /env/config
-
-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
-
-echo
-echo -n "Hit any key to stop autoboot: "
-timeout -a $autoboot_timeout
-if [ $? != 0 ]; then
- echo
- echo "type update_kernel [<imagename>] to update kernel into flash"
- echo "type udate_root [<imagename>] to update rootfs into flash"
- echo "type update_barebox_xmodem nor to update barebox into flash"
- echo
- exit
-fi
-
-boot
diff --git a/arch/arm/boards/nhk8815/env/bin/update_barebox_xmodem b/arch/arm/boards/nhk8815/env/bin/update_barebox_xmodem
deleted file mode 100644
index 40f4ad3..0000000
--- a/arch/arm/boards/nhk8815/env/bin/update_barebox_xmodem
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-part=/dev/nand0.barebox
-
-loadb -f barebox.bin -c
-
-unprotect $part
-echo
-echo "erasing partition $part"
-erase $part
-
-echo
-echo "flashing barebox.bin to $part"
-echo
-cp barebox.bin $part
-crc32 -f barebox.bin
-crc32 -f $part
diff --git a/arch/arm/boards/nhk8815/env/bin/update_kernel b/arch/arm/boards/nhk8815/env/bin/update_kernel
deleted file mode 100644
index db0f4c2..0000000
--- a/arch/arm/boards/nhk8815/env/bin/update_kernel
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-part=/dev/nand0.kernel
-
-. /env/bin/_update $1
diff --git a/arch/arm/boards/nhk8815/env/bin/update_root b/arch/arm/boards/nhk8815/env/bin/update_root
deleted file mode 100644
index 9530e84..0000000
--- a/arch/arm/boards/nhk8815/env/bin/update_root
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$jffs2
-part=/dev/nand0.rootfs
-
-. /env/bin/_update $1
diff --git a/arch/arm/boards/nhk8815/env/config b/arch/arm/boards/nhk8815/env/config
index 7e7fc45..e657a76 100644
--- a/arch/arm/boards/nhk8815/env/config
+++ b/arch/arm/boards/nhk8815/env/config
@@ -1,16 +1,33 @@
#!/bin/sh
-# can be either 'net' or 'flash'
-kernel=net
-root=net
-
-# use 'dhcp' todo dhcp in uboot and in kernel
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
ip=dhcp
-#
-# setup default ethernet address
-#
-#eth0.serverip=192.168.23.108
+# or set your networking parameters here
+#eth0.ipaddr=a.b.c.d
+#eth0.netmask=a.b.c.d
+#eth0.gateway=a.b.c.d
+#eth0.serverip=a.b.c.d
+
+# can be either 'net' or 'nand'
+kernel_loc=net
+# can be either 'net', 'nand' or 'initrd'
+rootfs_loc=net
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root.$rootfs_type
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+#kernelimage_type=zimage
+#kernelimage=zImage
+kernelimage_type=uimage
+kernelimage=uImage
+#kernelimage_type=raw
+#kernelimage=Image
+#kernelimage_type=raw_lzo
+#kernelimage=Image.lzo
# Partition Size Start
# XloaderTOC + X-Loader 256KB 0x00000000
@@ -22,11 +39,10 @@ ip=dhcp
nand_parts="256k(xloader)ro,256k(meminit),2M(barebox),3M(kernel),22M(rootfs),100M(userfs),384k(free),128k(bareboxenv)"
-uimage=uImage-nhk15
-
-# use 'dhcp' to do dhcp in uboot and in kernel
-ip=dhcp
-
autoboot_timeout=3
bootargs="root=/dev/ram0 console=ttyAMA1,115200n8 init=linuxrc"
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
+
diff --git a/arch/arm/configs/nhk8815_defconfig b/arch/arm/configs/nhk8815_defconfig
index e3f4102..b81afe2 100644
--- a/arch/arm/configs/nhk8815_defconfig
+++ b/arch/arm/configs/nhk8815_defconfig
@@ -10,7 +10,8 @@ CONFIG_AUTO_COMPLETE=y
CONFIG_MENU=y
CONFIG_PASSWD_SUM_SHA1=y
CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/nhk8815/env"
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv arch/arm/boards/nhk8815/env"
CONFIG_CMD_EDIT=y
CONFIG_CMD_SLEEP=y
CONFIG_CMD_SAVEENV=y
@@ -22,8 +23,8 @@ CONFIG_CMD_MENU=y
CONFIG_CMD_MENU_MANAGEMENT=y
CONFIG_CMD_PASSWD=y
CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_LOADB=y
CONFIG_CMD_MEMINFO=y
-CONFIG_CMD_CRC=y
CONFIG_CMD_MTEST=y
CONFIG_CMD_FLASH=y
CONFIG_CMD_BOOTM_ZLIB=y
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-10-12 8:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-11 13:53 defaultv env update v2 Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 1/6] defaultenv: introduce CONFIG_DEFAULT_ENVIRONMENT_GENERIC to enable it Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 2/6] commands/crc32: add compare 2 files crc Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 3/6] defaultenv/update: merge update_rootfs and update_kernel Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 4/6] defaultenv/update: add check crc32 options Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 5/6] defaultenv: add xmodem support for update Jean-Christophe PLAGNIOL-VILLARD
2010-10-11 14:34 ` [PATCH 6/6] defaultenv: add update_barebox to update barebox easly via tftp or xmodem Jean-Christophe PLAGNIOL-VILLARD
2010-10-12 8:13 ` [PATCH] nhk8815: use defaultenv Jean-Christophe PLAGNIOL-VILLARD
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox