mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* More patches
@ 2010-06-14  9:48 Sascha Hauer
  2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Hi all,

Here are some more patches, most notably the the possibility to merge
the default environment together from different directories. We can then
introduce a generic default environment which can be used from multiple
boards. Each board can make specific additions to this default environment.

Also, maybe this is controversal, the network stack now generates a random
MAC address if now valid address is found.

Sascha

The following changes since commit 52f760cd61e3f6ca6deb8e5c47eef168b598a674:

  dhcp: do not call net_unregister if net_udp_new failed (2010-06-14 09:39:29 +0200)

are available in the git repository at:
  git://git.pengutronix.de/git/barebox.git pu

Sascha Hauer (11):
      pcm037: Add MMU support
      bootu: Allow passing in devices as parameter
      Allow to merge default environment from more than one directory
      include support for a simple pseudo number generator
      net: implement random_ether_addr
      net: use a random mac address if the current device does not have one
      add a generic default environment
      pcm038: use generic default env
      pcm043: use generic default env
      pcm037: use generic default env
      pca100: use generic default env

 Makefile                                           |   15 ---
 arch/arm/configs/pca100_defconfig                  |    2 +-
 arch/arm/configs/pcm037_defconfig                  |    2 +-
 arch/arm/configs/pcm038_defconfig                  |    2 +-
 arch/arm/configs/pcm043_defconfig                  |    2 +-
 arch/arm/lib/armlinux.c                            |   10 ++-
 arch/arm/mach-imx/Kconfig                          |    2 +
 board/pcm037/env/bin/boot                          |   47 ---------
 board/pcm037/env/bin/init                          |   37 -------
 board/pcm037/env/bin/update_root                   |   16 ---
 board/pcm037/env/config                            |   62 ++++++++---
 board/pcm037/pcm037.c                              |   31 ++++++
 board/pcm038/env/bin/_update                       |   36 -------
 board/pcm038/env/bin/boot                          |   47 ---------
 board/pcm038/env/bin/hush_hack                     |    1 -
 board/pcm038/env/bin/init                          |   37 -------
 board/pcm038/env/bin/update_kernel                 |   15 ---
 board/pcm038/env/bin/update_root                   |   16 ---
 board/pcm038/env/config                            |   62 ++++++++---
 board/pcm043/env/bin/_update                       |   36 -------
 board/pcm043/env/bin/boot                          |   47 ---------
 board/pcm043/env/bin/hush_hack                     |    1 -
 board/pcm043/env/bin/update_kernel                 |   15 ---
 board/pcm043/env/config                            |   65 +++++++++---
 board/phycard-i.MX27/env/bin/_update               |   36 -------
 board/phycard-i.MX27/env/bin/boot                  |   40 -------
 board/phycard-i.MX27/env/bin/hush_hack             |    1 -
 board/phycard-i.MX27/env/bin/init                  |   37 -------
 board/phycard-i.MX27/env/bin/update_kernel         |   15 ---
 board/phycard-i.MX27/env/bin/update_root           |   16 ---
 board/phycard-i.MX27/env/config                    |   57 ++++++++---
 common/Kconfig                                     |    4 +-
 common/Makefile                                    |    6 +-
 {board/pcm037/env => defaultenv}/bin/_update       |    5 +-
 defaultenv/bin/boot                                |  110 ++++++++++++++++++++
 {board/pcm037/env => defaultenv}/bin/hush_hack     |    0
 {board/pcm043/env => defaultenv}/bin/init          |   11 +--
 {board/pcm037/env => defaultenv}/bin/update_kernel |    2 +-
 .../update_root => defaultenv/bin/update_rootfs    |    4 +-
 include/net.h                                      |   17 +++
 include/random.h                                   |    7 ++
 lib/Makefile                                       |    1 +
 lib/random.c                                       |   22 ++++
 net/net.c                                          |   11 ++-
 scripts/genenv                                     |   17 +++
 45 files changed, 424 insertions(+), 601 deletions(-)
 delete mode 100644 board/pcm037/env/bin/boot
 delete mode 100644 board/pcm037/env/bin/init
 delete mode 100644 board/pcm037/env/bin/update_root
 delete mode 100644 board/pcm038/env/bin/_update
 delete mode 100644 board/pcm038/env/bin/boot
 delete mode 100644 board/pcm038/env/bin/hush_hack
 delete mode 100644 board/pcm038/env/bin/init
 delete mode 100644 board/pcm038/env/bin/update_kernel
 delete mode 100644 board/pcm038/env/bin/update_root
 delete mode 100644 board/pcm043/env/bin/_update
 delete mode 100644 board/pcm043/env/bin/boot
 delete mode 100644 board/pcm043/env/bin/hush_hack
 delete mode 100644 board/pcm043/env/bin/update_kernel
 delete mode 100644 board/phycard-i.MX27/env/bin/_update
 delete mode 100644 board/phycard-i.MX27/env/bin/boot
 delete mode 100644 board/phycard-i.MX27/env/bin/hush_hack
 delete mode 100644 board/phycard-i.MX27/env/bin/init
 delete mode 100644 board/phycard-i.MX27/env/bin/update_kernel
 delete mode 100644 board/phycard-i.MX27/env/bin/update_root
 rename {board/pcm037/env => defaultenv}/bin/_update (86%)
 create mode 100644 defaultenv/bin/boot
 rename {board/pcm037/env => defaultenv}/bin/hush_hack (100%)
 rename {board/pcm043/env => defaultenv}/bin/init (59%)
 rename {board/pcm037/env => defaultenv}/bin/update_kernel (91%)
 rename board/pcm043/env/bin/update_root => defaultenv/bin/update_rootfs (91%)
 create mode 100644 include/random.h
 create mode 100644 lib/random.c
 create mode 100755 scripts/genenv

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 01/11] pcm037: Add MMU support
  2010-06-14  9:48 More patches Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 02/11] bootu: Allow passing in devices as parameter Sascha Hauer
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/Kconfig |    2 ++
 board/pcm037/pcm037.c     |   31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 419daab..721264b 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -206,7 +206,9 @@ choice
 config MACH_PCM037
 	bool "phyCORE-i.MX31"
 	select MACH_HAS_LOWLEVEL_INIT
+	select HAVE_MMU
 	select USB_ISP1504 if USB
+	select ARCH_HAS_L2X0
 	help
 	  Say Y here if you are using Phytec's phyCORE-i.MX31 (pcm037) equipped
 	  with a Freescale i.MX31 Processor
diff --git a/board/pcm037/pcm037.c b/board/pcm037/pcm037.c
index aee40c6..2e6968b 100644
--- a/board/pcm037/pcm037.c
+++ b/board/pcm037/pcm037.c
@@ -33,6 +33,7 @@
 #include <asm/armlinux.h>
 #include <mach/gpio.h>
 #include <asm/io.h>
+#include <asm/mmu.h>
 #include <partition.h>
 #include <asm/mach-types.h>
 #include <mach/imx-nand.h>
@@ -117,6 +118,7 @@ static struct device_d sdram1_dev = {
 struct imx_nand_platform_data nand_info = {
 	.width = 1,
 	.hw_ecc = 1,
+	.flash_bbt = 1,
 };
 
 static struct device_d nand_dev = {
@@ -226,8 +228,37 @@ static void pcm037_usb_init(void)
 }
 #endif
 
+#ifdef CONFIG_MMU
+static void pcm037_mmu_init(void)
+{
+	mmu_init();
+
+	arm_create_section(0x80000000, 0x80000000, 128, PMD_SECT_DEF_CACHED);
+	arm_create_section(0x90000000, 0x80000000, 128, PMD_SECT_DEF_UNCACHED);
+
+	setup_dma_coherent(0x10000000);
+
+#if TEXT_BASE & (0x100000 - 1)
+#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
+#else
+	arm_create_section(0x0,        TEXT_BASE,   1, PMD_SECT_DEF_UNCACHED);
+#endif
+	mmu_enable();
+
+#ifdef CONFIG_CACHE_L2X0
+	l2x0_init((void __iomem *)0x30000000, 0x00030024, 0x00000000);
+#endif
+}
+#else
+static void pcm037_mmu_init(void)
+{
+}
+#endif
+
 static int imx31_devices_init(void)
 {
+	pcm037_mmu_init();
+
 	__REG(CSCR_U(0)) = 0x0000cf03; /* CS0: Nor Flash */
 	__REG(CSCR_L(0)) = 0x10000d03;
 	__REG(CSCR_A(0)) = 0x00720900;
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 02/11] bootu: Allow passing in devices as parameter
  2010-06-14  9:48 More patches Sascha Hauer
  2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 03/11] Allow to merge default environment from more than one directory Sascha Hauer
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/lib/armlinux.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/armlinux.c b/arch/arm/lib/armlinux.c
index 75c6519..a38c6bf 100644
--- a/arch/arm/lib/armlinux.c
+++ b/arch/arm/lib/armlinux.c
@@ -332,15 +332,21 @@ BAREBOX_CMD_END
 #ifdef CONFIG_CMD_BOOTU
 static int do_bootu(struct command *cmdtp, int argc, char *argv[])
 {
-	void (*theKernel)(int zero, int arch, void *params);
+	void (*theKernel)(int zero, int arch, void *params) = NULL;
 	const char *commandline = getenv("bootargs");
+	int fd;
 
 	if (argc != 2) {
 		barebox_cmd_usage(cmdtp);
 		return 1;
 	}
 
-	theKernel = (void *)simple_strtoul(argv[1], NULL, 0);
+	fd = open(argv[1], O_RDONLY);
+	if (fd > 0)
+		theKernel = (void *)memmap(fd, PROT_READ);
+
+	if (!theKernel)
+		theKernel = (void *)simple_strtoul(argv[1], NULL, 0);
 
 	setup_start_tag();
 	setup_memory_tags();
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 03/11] Allow to merge default environment from more than one directory
  2010-06-14  9:48 More patches Sascha Hauer
  2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
  2010-06-14  9:48 ` [PATCH 02/11] bootu: Allow passing in devices as parameter Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Makefile        |   15 ---------------
 common/Kconfig  |    4 ++--
 common/Makefile |    6 ++++--
 scripts/genenv  |   17 +++++++++++++++++
 4 files changed, 23 insertions(+), 19 deletions(-)
 create mode 100755 scripts/genenv

diff --git a/Makefile b/Makefile
index d17ca47..e24ae45 100644
--- a/Makefile
+++ b/Makefile
@@ -1299,18 +1299,3 @@ Makefile: ;
 # information in a variable se we can use it in if_changed and friends.
 .PHONY: $(PHONY)
 
-#
-# sanity checks for check default environemnt
-#
-ifdef CONFIG_DEFAULT_ENVIRONMENT
-
-ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_PATH),"")
-$(error default environment path empty))
-endif
-
-saved-env_path := $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
-CONFIG_DEFAULT_ENVIRONMENT_PATH := $(shell cd $(if $(filter /%,$(CONFIG_DEFAULT_ENVIRONMENT_PATH)),,$(srctree)/)$(CONFIG_DEFAULT_ENVIRONMENT_PATH) && /bin/pwd)
-$(if $(CONFIG_DEFAULT_ENVIRONMENT_PATH),, \
-	$(error default environment path $(saved-env_path) does not exist))
-
-endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
diff --git a/common/Kconfig b/common/Kconfig
index f514759..a58f242 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -339,8 +339,8 @@ config DEFAULT_ENVIRONMENT_PATH
 	depends on DEFAULT_ENVIRONMENT
 	prompt "Default environment path"
 	help
-	  The path the default environment will be taken from. Relative
-	  pathes will be relative to the barebox Toplevel dir, but absolute
+	  Space separated list of pathes the default environment will be taken from.
+	  Relative pathes will be relative to the barebox Toplevel dir, but absolute
 	  pathes are fine aswell.
 
 endmenu
diff --git a/common/Makefile b/common/Makefile
index 0c075a9..aebaa39 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -15,6 +15,7 @@ obj-y += env.o
 obj-y += startup.o
 obj-y += misc.o
 obj-y += memsize.o
+obj-y += sysdev.o
 obj-$(CONFIG_MODULES) += module.o
 extra-$(CONFIG_MODULES) += module.lds
 
@@ -22,9 +23,10 @@ ifdef CONFIG_DEFAULT_ENVIRONMENT
 $(obj)/startup.o: include/barebox_default_env.h
 $(obj)/env.o: include/barebox_default_env.h
 
-ENV_FILES := $(shell find $(srctree)/$(CONFIG_DEFAULT_ENVIRONMENT_PATH))
+ENV_FILES := $(shell cd $(srctree); for i in $(CONFIG_DEFAULT_ENVIRONMENT_PATH); do find $${i} -type f -exec readlink -f {} \;; done)
+
 endif # ifdef CONFIG_DEFAULT_ENVIRONMENT
 
 include/barebox_default_env.h: $(ENV_FILES)
-	$(Q)scripts/bareboxenv -s $(srctree)/$(CONFIG_DEFAULT_ENVIRONMENT_PATH) barebox_default_env
+	$(Q)scripts/genenv $(srctree) $(CONFIG_DEFAULT_ENVIRONMENT_PATH)
 	$(Q)cat barebox_default_env | scripts/bin2c default_environment > $@
diff --git a/scripts/genenv b/scripts/genenv
new file mode 100755
index 0000000..6a833b1
--- /dev/null
+++ b/scripts/genenv
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Generate the default environment file from a list of directories
+# usage: genenv <basedir> <dir>...
+# where <basedir> is the base directory for relative pathes in <dir>
+cd $1 || exit 1
+shift
+
+tempdir=$(mktemp -d)
+
+for i in $*; do
+	cp -r $i/* $tempdir
+done
+scripts/bareboxenv -s $tempdir barebox_default_env
+
+rm -r $tempdir
+
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (2 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 03/11] Allow to merge default environment from more than one directory Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-15  9:39   ` Peter Korsgaard
  2010-06-17 13:17   ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 05/11] net: implement random_ether_addr Sascha Hauer
                   ` (6 subsequent siblings)
  10 siblings, 2 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/random.h |    7 +++++++
 lib/Makefile     |    1 +
 lib/random.c     |   22 ++++++++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)
 create mode 100644 include/random.h
 create mode 100644 lib/random.c

diff --git a/include/random.h b/include/random.h
new file mode 100644
index 0000000..29911d8
--- /dev/null
+++ b/include/random.h
@@ -0,0 +1,7 @@
+#ifndef __RANDOM_H
+#define __RANDOM_H
+
+void get_random_bytes(char *buf, int len);
+void srand(unsigned int);
+
+#endif /* __RANDOM_H */
diff --git a/lib/Makefile b/lib/Makefile
index b072fb6..4a33aaa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
 obj-y			+= glob.o
 obj-y			+= notifier.o
 obj-y			+= copy_file.o
+obj-y			+= random.o
 obj-y			+= lzo/
 obj-$(CONFIG_LZO_DECOMPRESS)		+= decompress_unlzo.o
 obj-$(CONFIG_PROCESS_ESCAPE_SEQUENCE)	+= process_escape_sequence.o
diff --git a/lib/random.c b/lib/random.c
new file mode 100644
index 0000000..25315e7
--- /dev/null
+++ b/lib/random.c
@@ -0,0 +1,22 @@
+#include <common.h>
+#include <random.h>
+
+static int random_seed;
+
+static unsigned char rand(void)
+{
+	random_seed = random_seed * 1103515245 + 12345;
+	return (unsigned char)(random_seed / 65536) % 256;
+}
+
+void srand(unsigned int seed)
+{
+	random_seed = seed;
+}
+
+void get_random_bytes(char *buf, int len)
+{
+	while (len--)
+		*buf++ = rand();
+}
+
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 05/11] net: implement random_ether_addr
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (3 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 06/11] net: use a random mac address if the current device does not have one Sascha Hauer
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/net.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/net.h b/include/net.h
index 8db83d8..2e17e39 100644
--- a/include/net.h
+++ b/include/net.h
@@ -16,6 +16,8 @@
 #include <linux/types.h>
 #include <param.h>
 #include <malloc.h>
+#include <clock.h>
+#include <random.h>
 #include <asm/byteorder.h>	/* for nton* / ntoh* stuff */
 
 
@@ -331,6 +333,21 @@ static inline int is_broadcast_ether_addr(const u8 *addr)
 }
 
 /**
+ * random_ether_addr - Generate software assigned random Ethernet address
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Generate a random Ethernet address (MAC) that is not multicast
+ * and has the local assigned bit set.
+ */
+static inline void random_ether_addr(u8 *addr)
+{
+	srand(get_time_ns());
+	get_random_bytes(addr, 6);
+	addr [0] &= 0xfe;	/* clear multicast bit */
+	addr [0] |= 0x02;	/* set local assignment bit (IEEE802) */
+}
+
+/**
  * is_valid_ether_addr - Determine if the given Ethernet address is valid
  * @addr: Pointer to a six-byte array containing the Ethernet address
  *
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 06/11] net: use a random mac address if the current device does not have one
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (4 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 05/11] net: implement random_ether_addr Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 net/net.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/net/net.c b/net/net.c
index 4305c72..8d99595 100644
--- a/net/net.c
+++ b/net/net.c
@@ -345,12 +345,21 @@ static LIST_HEAD(connection_list);
 
 static struct net_connection *net_new(IPaddr_t dest, rx_handler_f *handler)
 {
+	struct eth_device *edev = eth_get_current();
 	struct net_connection *con;
 	int ret;
 
-	if (!is_valid_ether_addr(net_ether))
+	if (!edev)
 		return ERR_PTR(-ENETDOWN);
 
+	if (!is_valid_ether_addr(net_ether)) {
+		char str[sizeof("xx:xx:xx:xx:xx:xx")];
+		random_ether_addr(net_ether);
+		ethaddr_to_string(net_ether, str);
+		printf("warning: No MAC address set. Using random address %s\n", str);
+		dev_set_param(&edev->dev, "ethaddr", str);
+	}
+
 	/* If we don't have an ip only broadcast is allowed */
 	if (!net_ip && dest != 0xffffffff)
 		return ERR_PTR(-ENETDOWN);
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 07/11] add a generic default environment
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (5 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 06/11] net: use a random mac address if the current device does not have one Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-15  9:13   ` Uwe Kleine-König
  2010-06-17 13:20   ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 08/11] pcm038: use generic default env Sascha Hauer
                   ` (3 subsequent siblings)
  10 siblings, 2 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

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.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 defaultenv/bin/_update       |   39 +++++++++++++++
 defaultenv/bin/boot          |  110 ++++++++++++++++++++++++++++++++++++++++++
 defaultenv/bin/hush_hack     |    1 +
 defaultenv/bin/init          |   30 +++++++++++
 defaultenv/bin/update_kernel |   15 ++++++
 defaultenv/bin/update_rootfs |   16 ++++++
 6 files changed, 211 insertions(+), 0 deletions(-)
 create mode 100644 defaultenv/bin/_update
 create mode 100644 defaultenv/bin/boot
 create mode 100644 defaultenv/bin/hush_hack
 create mode 100644 defaultenv/bin/init
 create mode 100644 defaultenv/bin/update_kernel
 create mode 100644 defaultenv/bin/update_rootfs

diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update
new file mode 100644
index 0000000..ddd6b84
--- /dev/null
+++ b/defaultenv/bin/_update
@@ -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
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
+
+
+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
+	bootargs="$bootargs root=/dev/nfs nfsroot=$nfsroot,v3,tcp noinitrd"
+elif [ $rootfs_loc = initrd ]; 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 [ $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@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
+		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
+
diff --git a/defaultenv/bin/hush_hack b/defaultenv/bin/hush_hack
new file mode 100644
index 0000000..5fffa92
--- /dev/null
+++ b/defaultenv/bin/hush_hack
@@ -0,0 +1 @@
+nand -a /dev/nand0.*
diff --git a/defaultenv/bin/init b/defaultenv/bin/init
new file mode 100644
index 0000000..b17fcbc
--- /dev/null
+++ b/defaultenv/bin/init
@@ -0,0 +1,30 @@
+#!/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
+
+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
diff --git a/defaultenv/bin/update_kernel b/defaultenv/bin/update_kernel
new file mode 100644
index 0000000..1d35ed9
--- /dev/null
+++ b/defaultenv/bin/update_kernel
@@ -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
diff --git a/defaultenv/bin/update_rootfs b/defaultenv/bin/update_rootfs
new file mode 100644
index 0000000..6366315
--- /dev/null
+++ b/defaultenv/bin/update_rootfs
@@ -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
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 08/11] pcm038: use generic default env
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (6 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 09/11] pcm043: " Sascha Hauer
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/configs/pcm038_defconfig  |    2 +-
 board/pcm038/env/bin/_update       |   36 ---------------------
 board/pcm038/env/bin/boot          |   47 ---------------------------
 board/pcm038/env/bin/hush_hack     |    1 -
 board/pcm038/env/bin/init          |   37 ---------------------
 board/pcm038/env/bin/update_kernel |   15 ---------
 board/pcm038/env/bin/update_root   |   16 ---------
 board/pcm038/env/config            |   62 ++++++++++++++++++++++++++----------
 8 files changed, 46 insertions(+), 170 deletions(-)
 delete mode 100644 board/pcm038/env/bin/_update
 delete mode 100644 board/pcm038/env/bin/boot
 delete mode 100644 board/pcm038/env/bin/hush_hack
 delete mode 100644 board/pcm038/env/bin/init
 delete mode 100644 board/pcm038/env/bin/update_kernel
 delete mode 100644 board/pcm038/env/bin/update_root

diff --git a/arch/arm/configs/pcm038_defconfig b/arch/arm/configs/pcm038_defconfig
index 0c9ac5f..a80089c 100644
--- a/arch/arm/configs/pcm038_defconfig
+++ b/arch/arm/configs/pcm038_defconfig
@@ -110,7 +110,7 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
 # CONFIG_OF_FLAT_TREE is not set
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/pcm038/env"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv board/pcm038/env"
 
 #
 # Debugging
diff --git a/board/pcm038/env/bin/_update b/board/pcm038/env/bin/_update
deleted file mode 100644
index 014bce3..0000000
--- a/board/pcm038/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/board/pcm038/env/bin/boot b/board/pcm038/env/bin/boot
deleted file mode 100644
index dfb59aa..0000000
--- a/board/pcm038/env/bin/boot
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xnand ]; then
-	root=nand
-	kernel=nand
-fi
-
-if [ x$1 = xnet ]; then
-	root=net
-	kernel=net
-fi
-
-if [ x$1 = xnor ]; then
-	root=nor
-	kernel=nor
-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 = xnand ]; then
-	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
-elif [ x$root = xnor ]; then
-	bootargs="$bootargs root=$rootpart_nor rootfstype=jffs2"
-else
-	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
-fi
-
-bootargs="$bootargs mtdparts=physmap-flash.0:$nor_parts;imx_nand:$nand_parts"
-
-if [ $kernel = net ]; then
-	if [ x$ip = xdhcp ]; then
-		dhcp
-	fi
-	tftp $uimage uImage || exit 1
-	bootm uImage
-elif [ $kernel = nor ]; then
-	bootm /dev/nor0.kernel
-else
-	bootm /dev/nand0.kernel.bb
-fi
-
diff --git a/board/pcm038/env/bin/hush_hack b/board/pcm038/env/bin/hush_hack
deleted file mode 100644
index 5fffa92..0000000
--- a/board/pcm038/env/bin/hush_hack
+++ /dev/null
@@ -1 +0,0 @@
-nand -a /dev/nand0.*
diff --git a/board/pcm038/env/bin/init b/board/pcm038/env/bin/init
deleted file mode 100644
index 3bfd194..0000000
--- a/board/pcm038/env/bin/init
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 [ -z $eth0.ethaddr ]; then
-	while [ -z $eth0.ethaddr ]; do
-		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
-	done
-	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
-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_root nand|nor [<imagename>] to update rootfs into flash"
-	echo
-	exit
-fi
-
-boot
diff --git a/board/pcm038/env/bin/update_kernel b/board/pcm038/env/bin/update_kernel
deleted file mode 100644
index 05c822d..0000000
--- a/board/pcm038/env/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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/board/pcm038/env/bin/update_root b/board/pcm038/env/bin/update_root
deleted file mode 100644
index eaf36eb..0000000
--- a/board/pcm038/env/bin/update_root
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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
-
diff --git a/board/pcm038/env/config b/board/pcm038/env/config
index 9fcb3dc..a8be5c9 100644
--- a/board/pcm038/env/config
+++ b/board/pcm038/env/config
@@ -1,24 +1,11 @@
 #!/bin/sh
 
-# can be either 'net', 'nor' or 'nand''
-kernel=net
-root=net
-
-uimage=uImage-pcm038
-jffs2=root-pcm038.jffs2
-
-autoboot_timeout=3
-
-nfsroot="/ptx/work/octopus/rsc/svn/oselas/bsp/phytec/phyCORE-i.MX27/OSELAS.BSP-Phytec-phyCORE-i.MX27-trunk/root"
-bootargs="console=ttymxc0,115200"
-
-nor_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nor="/dev/mtdblock3"
-
-nand_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nand="/dev/mtdblock7"
+machine=pcm038
+eth0.serverip=
+user=
 
 # use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
 
 # or set your networking parameters here
@@ -26,3 +13,44 @@ ip=dhcp
 #eth0.netmask=a.b.c.d
 #eth0.gateway=a.b.c.d
 #eth0.serverip=a.b.c.d
+
+# can be either 'net', 'nor' or 'nand'
+kernel_loc=net
+# can be either 'net', 'nor', 'nand' or 'initrd'
+rootfs_loc=net
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root-$machine.$rootfs_type
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage_type=zimage
+kernelimage=zImage-$machine
+#kernelimage_type=uimage
+#kernelimage=uImage-$machine
+#kernelimage_type=raw
+#kernelimage=Image-$machine
+#kernelimage_type=raw_lzo
+#kernelimage=Image-$machine.lzo
+
+if [ -n $user ]; then
+	kernelimage="$user"-"$kernelimage"
+	nfsroot="$eth0.serverip:/home/$user/nfsroot/$machine"
+	rootfsimage="$user"-"$rootfsimage"
+else
+	nfsroot="$eth0.serverip:/path/to/nfs/root"
+fi
+
+autoboot_timeout=3
+
+bootargs="console=ttymxc0,115200"
+
+nor_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nor=3
+
+nand_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
+
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 09/11] pcm043: use generic default env
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (7 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 08/11] pcm038: use generic default env Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 10/11] pcm037: " Sascha Hauer
  2010-06-14  9:48 ` [PATCH 11/11] pca100: " Sascha Hauer
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/configs/pcm043_defconfig  |    2 +-
 board/pcm043/env/bin/_update       |   36 --------------------
 board/pcm043/env/bin/boot          |   47 --------------------------
 board/pcm043/env/bin/hush_hack     |    1 -
 board/pcm043/env/bin/init          |   37 --------------------
 board/pcm043/env/bin/update_kernel |   15 --------
 board/pcm043/env/bin/update_root   |   16 ---------
 board/pcm043/env/config            |   65 ++++++++++++++++++++++++++----------
 8 files changed, 48 insertions(+), 171 deletions(-)
 delete mode 100644 board/pcm043/env/bin/_update
 delete mode 100644 board/pcm043/env/bin/boot
 delete mode 100644 board/pcm043/env/bin/hush_hack
 delete mode 100644 board/pcm043/env/bin/init
 delete mode 100644 board/pcm043/env/bin/update_kernel
 delete mode 100644 board/pcm043/env/bin/update_root

diff --git a/arch/arm/configs/pcm043_defconfig b/arch/arm/configs/pcm043_defconfig
index 5563356..72a8a42 100644
--- a/arch/arm/configs/pcm043_defconfig
+++ b/arch/arm/configs/pcm043_defconfig
@@ -109,7 +109,7 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
 # CONFIG_OF_FLAT_TREE is not set
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/pcm043/env/"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv board/pcm043/env"
 
 #
 # Debugging
diff --git a/board/pcm043/env/bin/_update b/board/pcm043/env/bin/_update
deleted file mode 100644
index 014bce3..0000000
--- a/board/pcm043/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/board/pcm043/env/bin/boot b/board/pcm043/env/bin/boot
deleted file mode 100644
index 7bbff2d..0000000
--- a/board/pcm043/env/bin/boot
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xnand ]; then
-	root=nand
-	kernel=nand
-fi
-
-if [ x$1 = xnet ]; then
-	root=net
-	kernel=net
-fi
-
-if [ x$1 = xnor ]; then
-	root=nor
-	kernel=nor
-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 = xnand ]; then
-	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
-elif [ x$root = xnor ]; then
-	bootargs="$bootargs root=$rootpart_nor rootfstype=jffs2"
-else
-	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
-fi
-
-bootargs="$bootargs mtdparts=physmap-flash.0:$nor_parts;mxc_nand:$nand_parts"
-
-if [ $kernel = net ]; then
-	if [ x$ip = xdhcp ]; then
-		dhcp
-	fi
-	tftp $uimage uImage || exit 1
-	bootm uImage
-elif [ $kernel = nor ]; then
-	bootm /dev/nor0.kernel
-else
-	bootm /dev/nand0.kernel.bb
-fi
-
diff --git a/board/pcm043/env/bin/hush_hack b/board/pcm043/env/bin/hush_hack
deleted file mode 100644
index 5fffa92..0000000
--- a/board/pcm043/env/bin/hush_hack
+++ /dev/null
@@ -1 +0,0 @@
-nand -a /dev/nand0.*
diff --git a/board/pcm043/env/bin/init b/board/pcm043/env/bin/init
deleted file mode 100644
index 3bfd194..0000000
--- a/board/pcm043/env/bin/init
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 [ -z $eth0.ethaddr ]; then
-	while [ -z $eth0.ethaddr ]; do
-		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
-	done
-	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
-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_root nand|nor [<imagename>] to update rootfs into flash"
-	echo
-	exit
-fi
-
-boot
diff --git a/board/pcm043/env/bin/update_kernel b/board/pcm043/env/bin/update_kernel
deleted file mode 100644
index 05c822d..0000000
--- a/board/pcm043/env/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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/board/pcm043/env/bin/update_root b/board/pcm043/env/bin/update_root
deleted file mode 100644
index eaf36eb..0000000
--- a/board/pcm043/env/bin/update_root
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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
-
diff --git a/board/pcm043/env/config b/board/pcm043/env/config
index c1ab234..212b6a9 100644
--- a/board/pcm043/env/config
+++ b/board/pcm043/env/config
@@ -1,29 +1,58 @@
 #!/bin/sh
 
-# can be either 'net', 'nor' or 'nand''
-kernel=nor
-root=nor
+machine=pcm043
+eth0.serverip=
+user=
 
-uimage=uImage-pcm043
-jffs2=root-pcm043.jffs2
+# use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
+ip=dhcp
+
+# 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', 'nor' or 'nand'
+kernel_loc=net
+# can be either 'net', 'nor', 'nand' or 'initrd'
+rootfs_loc=net
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root-$machine.$rootfs_type
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage_type=zimage
+kernelimage=zImage-$machine
+#kernelimage_type=uimage
+#kernelimage=uImage-$machine
+#kernelimage_type=raw
+#kernelimage=Image-$machine
+#kernelimage_type=raw_lzo
+#kernelimage=Image-$machine.lzo
+
+if [ -n $user ]; then
+	kernelimage="$user"-"$kernelimage"
+	nfsroot="$eth0.serverip:/home/$user/nfsroot/$machine"
+	rootfsimage="$user"-"$rootfsimage"
+else
+	nfsroot="$eth0.serverip:/path/to/nfs/root"
+fi
 
 autoboot_timeout=3
 
-nfsroot="/path/to/nfs_root"
 bootargs="console=ttymxc0,115200"
 
-nor_parts="256k(barebox)ro,128k(bareboxenv),2048k(kernel),-(root)"
-rootpart_nor="/dev/mtdblock3"
-nand_parts="256k(barebox)ro,128k(bareboxenv),2048k(kernel),-(root)"
-rootpart_nand="/dev/mtdblock3"
+bootargs="$bootargs video=mx3fb:CTP-CLAA070LC0ACW"
 
-# use 'dhcp' to do dhcp in barebox and in kernel
-ip=dhcp
+nor_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nor=3
 
-# or set your networking parameters here
-eth0.ipaddr=192.168.3.11
-eth0.netmask=255.255.255.0
-#eth0.gateway=a.b.c.d
-#eth0.serverip=192.168.3.10
-#eth0.ethaddr=aa.bb.cc.dd.ee.ff
+nand_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
 
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 10/11] pcm037: use generic default env
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (8 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 09/11] pcm043: " Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  2010-06-14  9:48 ` [PATCH 11/11] pca100: " Sascha Hauer
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/configs/pcm037_defconfig  |    2 +-
 board/pcm037/env/bin/_update       |   36 ---------------------
 board/pcm037/env/bin/boot          |   47 ---------------------------
 board/pcm037/env/bin/hush_hack     |    1 -
 board/pcm037/env/bin/init          |   37 ---------------------
 board/pcm037/env/bin/update_kernel |   15 ---------
 board/pcm037/env/bin/update_root   |   16 ---------
 board/pcm037/env/config            |   62 ++++++++++++++++++++++++++----------
 8 files changed, 46 insertions(+), 170 deletions(-)
 delete mode 100644 board/pcm037/env/bin/_update
 delete mode 100644 board/pcm037/env/bin/boot
 delete mode 100644 board/pcm037/env/bin/hush_hack
 delete mode 100644 board/pcm037/env/bin/init
 delete mode 100644 board/pcm037/env/bin/update_kernel
 delete mode 100644 board/pcm037/env/bin/update_root

diff --git a/arch/arm/configs/pcm037_defconfig b/arch/arm/configs/pcm037_defconfig
index e82733f..9353d0e 100644
--- a/arch/arm/configs/pcm037_defconfig
+++ b/arch/arm/configs/pcm037_defconfig
@@ -106,7 +106,7 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
 # CONFIG_OF_FLAT_TREE is not set
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/pcm037/env"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv board/pcm037/env"
 
 #
 # Debugging
diff --git a/board/pcm037/env/bin/_update b/board/pcm037/env/bin/_update
deleted file mode 100644
index 014bce3..0000000
--- a/board/pcm037/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/board/pcm037/env/bin/boot b/board/pcm037/env/bin/boot
deleted file mode 100644
index dfb59aa..0000000
--- a/board/pcm037/env/bin/boot
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xnand ]; then
-	root=nand
-	kernel=nand
-fi
-
-if [ x$1 = xnet ]; then
-	root=net
-	kernel=net
-fi
-
-if [ x$1 = xnor ]; then
-	root=nor
-	kernel=nor
-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 = xnand ]; then
-	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
-elif [ x$root = xnor ]; then
-	bootargs="$bootargs root=$rootpart_nor rootfstype=jffs2"
-else
-	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
-fi
-
-bootargs="$bootargs mtdparts=physmap-flash.0:$nor_parts;imx_nand:$nand_parts"
-
-if [ $kernel = net ]; then
-	if [ x$ip = xdhcp ]; then
-		dhcp
-	fi
-	tftp $uimage uImage || exit 1
-	bootm uImage
-elif [ $kernel = nor ]; then
-	bootm /dev/nor0.kernel
-else
-	bootm /dev/nand0.kernel.bb
-fi
-
diff --git a/board/pcm037/env/bin/hush_hack b/board/pcm037/env/bin/hush_hack
deleted file mode 100644
index 5fffa92..0000000
--- a/board/pcm037/env/bin/hush_hack
+++ /dev/null
@@ -1 +0,0 @@
-nand -a /dev/nand0.*
diff --git a/board/pcm037/env/bin/init b/board/pcm037/env/bin/init
deleted file mode 100644
index 3bfd194..0000000
--- a/board/pcm037/env/bin/init
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 [ -z $eth0.ethaddr ]; then
-	while [ -z $eth0.ethaddr ]; do
-		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
-	done
-	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
-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_root nand|nor [<imagename>] to update rootfs into flash"
-	echo
-	exit
-fi
-
-boot
diff --git a/board/pcm037/env/bin/update_kernel b/board/pcm037/env/bin/update_kernel
deleted file mode 100644
index 05c822d..0000000
--- a/board/pcm037/env/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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/board/pcm037/env/bin/update_root b/board/pcm037/env/bin/update_root
deleted file mode 100644
index eaf36eb..0000000
--- a/board/pcm037/env/bin/update_root
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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
-
diff --git a/board/pcm037/env/config b/board/pcm037/env/config
index fb1f5af..bf15620 100644
--- a/board/pcm037/env/config
+++ b/board/pcm037/env/config
@@ -1,24 +1,11 @@
 #!/bin/sh
 
-# can be either 'net', 'nor' or 'nand''
-kernel=net
-root=net
-
-uimage=uImage-pcm037
-jffs2=root-pcm037.jffs2
-
-autoboot_timeout=3
-
-nfsroot="/ptx/work/octopus/rsc/svn/oselas/bsp/phytec/phyCORE-i.MX27/OSELAS.BSP-Phytec-phyCORE-i.MX27-trunk/root"
-bootargs="console=ttymxc0,115200"
-
-nor_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nor="/dev/mtdblock3"
-
-nand_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nand="/dev/mtdblock7"
+machine=pcm037
+eth0.serverip=
+user=
 
 # use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
 
 # or set your networking parameters here
@@ -26,3 +13,44 @@ ip=dhcp
 #eth0.netmask=a.b.c.d
 #eth0.gateway=a.b.c.d
 #eth0.serverip=a.b.c.d
+
+# can be either 'net', 'nor' or 'nand'
+kernel_loc=net
+# can be either 'net', 'nor', 'nand' or 'initrd'
+rootfs_loc=net
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root-$machine.$rootfs_type
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage_type=zimage
+kernelimage=zImage-$machine
+#kernelimage_type=uimage
+#kernelimage=uImage-$machine
+#kernelimage_type=raw
+#kernelimage=Image-$machine
+#kernelimage_type=raw_lzo
+#kernelimage=Image-$machine.lzo
+
+if [ -n $user ]; then
+	kernelimage="$user"-"$kernelimage"
+	nfsroot="$eth0.serverip:/home/$user/nfsroot/$machine"
+	rootfsimage="$user"-"$rootfsimage"
+else
+	nfsroot="$eth0.serverip:/path/to/nfs/root"
+fi
+
+autoboot_timeout=3
+
+bootargs="console=ttymxc0,115200"
+
+nor_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nor=3
+
+nand_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
+
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 11/11] pca100: use generic default env
  2010-06-14  9:48 More patches Sascha Hauer
                   ` (9 preceding siblings ...)
  2010-06-14  9:48 ` [PATCH 10/11] pcm037: " Sascha Hauer
@ 2010-06-14  9:48 ` Sascha Hauer
  10 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-14  9:48 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/configs/pca100_defconfig          |    2 +-
 board/phycard-i.MX27/env/bin/_update       |   36 -----------------
 board/phycard-i.MX27/env/bin/boot          |   40 -------------------
 board/phycard-i.MX27/env/bin/hush_hack     |    1 -
 board/phycard-i.MX27/env/bin/init          |   37 ------------------
 board/phycard-i.MX27/env/bin/update_kernel |   15 -------
 board/phycard-i.MX27/env/bin/update_root   |   16 --------
 board/phycard-i.MX27/env/config            |   57 +++++++++++++++++++++-------
 8 files changed, 44 insertions(+), 160 deletions(-)
 delete mode 100644 board/phycard-i.MX27/env/bin/_update
 delete mode 100644 board/phycard-i.MX27/env/bin/boot
 delete mode 100644 board/phycard-i.MX27/env/bin/hush_hack
 delete mode 100644 board/phycard-i.MX27/env/bin/init
 delete mode 100644 board/phycard-i.MX27/env/bin/update_kernel
 delete mode 100644 board/phycard-i.MX27/env/bin/update_root

diff --git a/arch/arm/configs/pca100_defconfig b/arch/arm/configs/pca100_defconfig
index f0a9512..52a5d93 100644
--- a/arch/arm/configs/pca100_defconfig
+++ b/arch/arm/configs/pca100_defconfig
@@ -110,7 +110,7 @@ CONFIG_CONSOLE_ACTIVATE_FIRST=y
 # CONFIG_OF_FLAT_TREE is not set
 CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="board/phycard-i.MX27/env/"
+CONFIG_DEFAULT_ENVIRONMENT_PATH="defaultenv board/phycard-i.MX27/env"
 
 #
 # Debugging
diff --git a/board/phycard-i.MX27/env/bin/_update b/board/phycard-i.MX27/env/bin/_update
deleted file mode 100644
index 014bce3..0000000
--- a/board/phycard-i.MX27/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/board/phycard-i.MX27/env/bin/boot b/board/phycard-i.MX27/env/bin/boot
deleted file mode 100644
index 56a0377..0000000
--- a/board/phycard-i.MX27/env/bin/boot
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xnand ]; then
-	root=nand
-	kernel=nand
-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 = xnand ]; then
-	bootargs="$bootargs root=$rootpart_nand rootfstype=jffs2"
-else
-	bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp"
-fi
-
-bootargs="$bootargs mtdparts=mxc_nand:$nand_parts"
-
-if [ $kernel = net ]; then
-	if [ x$ip = xdhcp ]; then
-		dhcp
-	fi
-	tftp $uimage uImage || exit 1
-	bootm uImage
-elif [ $kernel = nor ]; then
-	bootm /dev/nor0.kernel
-else
-	bootm /dev/nand0.kernel.bb
-fi
-
diff --git a/board/phycard-i.MX27/env/bin/hush_hack b/board/phycard-i.MX27/env/bin/hush_hack
deleted file mode 100644
index 5fffa92..0000000
--- a/board/phycard-i.MX27/env/bin/hush_hack
+++ /dev/null
@@ -1 +0,0 @@
-nand -a /dev/nand0.*
diff --git a/board/phycard-i.MX27/env/bin/init b/board/phycard-i.MX27/env/bin/init
deleted file mode 100644
index 3bfd194..0000000
--- a/board/phycard-i.MX27/env/bin/init
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/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 [ -z $eth0.ethaddr ]; then
-	while [ -z $eth0.ethaddr ]; do
-		readline "no MAC address set for eth0. please enter the one found on your board: " eth0.ethaddr
-	done
-	echo -a /env/config "eth0.ethaddr=$eth0.ethaddr"
-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_root nand|nor [<imagename>] to update rootfs into flash"
-	echo
-	exit
-fi
-
-boot
diff --git a/board/phycard-i.MX27/env/bin/update_kernel b/board/phycard-i.MX27/env/bin/update_kernel
deleted file mode 100644
index 05c822d..0000000
--- a/board/phycard-i.MX27/env/bin/update_kernel
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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/board/phycard-i.MX27/env/bin/update_root b/board/phycard-i.MX27/env/bin/update_root
deleted file mode 100644
index eaf36eb..0000000
--- a/board/phycard-i.MX27/env/bin/update_root
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-image=$uimage
-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
-
diff --git a/board/phycard-i.MX27/env/config b/board/phycard-i.MX27/env/config
index 6a93580..d0670de 100644
--- a/board/phycard-i.MX27/env/config
+++ b/board/phycard-i.MX27/env/config
@@ -1,21 +1,11 @@
 #!/bin/sh
 
-# can be either 'net', 'nor' or 'nand''
-kernel=net
-root=net
-
-uimage=uImage-pca100
-jffs2=root-pca100.jffs2
-
-autoboot_timeout=3
-
-nfsroot="/tmp/root"
-bootargs="console=ttymxc0,115200"
-
-nand_parts="256k(barebox)ro,128k(bareboxenv),1536k(kernel),-(root)"
-rootpart_nand="/dev/mtdblock3"
+machine=pca100
+eth0.serverip=
+user=
 
 # use 'dhcp' to do dhcp in barebox and in kernel
+# use 'none' if you want to skip kernel ip autoconfiguration
 ip=dhcp
 
 # or set your networking parameters here
@@ -23,3 +13,42 @@ ip=dhcp
 #eth0.netmask=a.b.c.d
 #eth0.gateway=a.b.c.d
 #eth0.serverip=a.b.c.d
+
+# can be either 'net', 'nor' or 'nand'
+kernel_loc=net
+# can be either 'net', 'nor', 'nand' or 'initrd'
+rootfs_loc=net
+
+# can be either 'jffs2' or 'ubifs'
+rootfs_type=ubifs
+rootfsimage=root-$machine.$rootfs_type
+
+# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo
+kernelimage_type=zimage
+kernelimage=zImage-$machine
+#kernelimage_type=uimage
+#kernelimage=uImage-$machine
+#kernelimage_type=raw
+#kernelimage=Image-$machine
+#kernelimage_type=raw_lzo
+#kernelimage=Image-$machine.lzo
+
+if [ -n $user ]; then
+	kernelimage="$user"-"$kernelimage"
+	nfsroot="$eth0.serverip:/home/$user/nfsroot/$machine"
+	rootfsimage="$user"-"$rootfsimage"
+else
+	nfsroot="$eth0.serverip:/path/to/nfs/root"
+fi
+
+autoboot_timeout=3
+
+bootargs="console=ttymxc0,115200"
+
+nand_parts="256k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
+rootfs_mtdblock_nand=7
+
+# set a fancy prompt (if support is compiled in)
+PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m "
+
+
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 07/11] add a generic default environment
  2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
@ 2010-06-15  9:13   ` Uwe Kleine-König
  2010-06-17 13:20   ` Sascha Hauer
  1 sibling, 0 replies; 21+ messages in thread
From: Uwe Kleine-König @ 2010-06-15  9:13 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

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@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/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
@ 2010-06-15  9:39   ` Peter Korsgaard
  2010-06-15 11:54     ` Sascha Hauer
  2010-06-17 13:17   ` Sascha Hauer
  1 sibling, 1 reply; 21+ messages in thread
From: Peter Korsgaard @ 2010-06-15  9:39 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

>>>>> "Sascha" == Sascha Hauer <s.hauer@pengutronix.de> writes:

 Sascha> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
 Sascha> ---
 Sascha>  include/random.h |    7 +++++++
 Sascha>  lib/Makefile     |    1 +
 Sascha>  lib/random.c     |   22 ++++++++++++++++++++++
 Sascha>  3 files changed, 30 insertions(+), 0 deletions(-)
 Sascha>  create mode 100644 include/random.h
 Sascha>  create mode 100644 lib/random.c

 Sascha> diff --git a/lib/random.c b/lib/random.c
 Sascha> new file mode 100644
 Sascha> index 0000000..25315e7
 Sascha> --- /dev/null
 Sascha> +++ b/lib/random.c
 Sascha> @@ -0,0 +1,22 @@
 Sascha> +#include <common.h>
 Sascha> +#include <random.h>
 Sascha> +
 Sascha> +static int random_seed;
 Sascha> +
 Sascha> +static unsigned char rand(void)
 Sascha> +{
 Sascha> +	random_seed = random_seed * 1103515245 + 12345;
 Sascha> +	return (unsigned char)(random_seed / 65536) % 256;
 Sascha> +}

Any reason to not make this public and return int instead similar to
rand(3)?

We could presumably simply do:

#define RAND_MAX 255

And to be completely correct, these prototypes should be in stdlib.h
instead.

-- 
Bye, Peter Korsgaard

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-15  9:39   ` Peter Korsgaard
@ 2010-06-15 11:54     ` Sascha Hauer
  0 siblings, 0 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-15 11:54 UTC (permalink / raw)
  To: Peter Korsgaard; +Cc: barebox

Hi Peter,

On Tue, Jun 15, 2010 at 11:39:39AM +0200, Peter Korsgaard wrote:
> >>>>> "Sascha" == Sascha Hauer <s.hauer@pengutronix.de> writes:
> 
>  Sascha> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
>  Sascha> ---
>  Sascha>  include/random.h |    7 +++++++
>  Sascha>  lib/Makefile     |    1 +
>  Sascha>  lib/random.c     |   22 ++++++++++++++++++++++
>  Sascha>  3 files changed, 30 insertions(+), 0 deletions(-)
>  Sascha>  create mode 100644 include/random.h
>  Sascha>  create mode 100644 lib/random.c
> 
>  Sascha> diff --git a/lib/random.c b/lib/random.c
>  Sascha> new file mode 100644
>  Sascha> index 0000000..25315e7
>  Sascha> --- /dev/null
>  Sascha> +++ b/lib/random.c
>  Sascha> @@ -0,0 +1,22 @@
>  Sascha> +#include <common.h>
>  Sascha> +#include <random.h>
>  Sascha> +
>  Sascha> +static int random_seed;
>  Sascha> +
>  Sascha> +static unsigned char rand(void)
>  Sascha> +{
>  Sascha> +	random_seed = random_seed * 1103515245 + 12345;
>  Sascha> +	return (unsigned char)(random_seed / 65536) % 256;
>  Sascha> +}
> 
> Any reason to not make this public and return int instead similar to
> rand(3)?

The reason was that I did not need rand but get_random_bytes and I
wasn't aware that rand() is that close to the corresponding libc
function.

> 
> We could presumably simply do:
> 
> #define RAND_MAX 255
> 
> And to be completely correct, these prototypes should be in stdlib.h
> instead.

Ok, will do.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
  2010-06-15  9:39   ` Peter Korsgaard
@ 2010-06-17 13:17   ` Sascha Hauer
  2010-06-17 13:26     ` Andy Pont
  2010-06-17 14:14     ` Peter Korsgaard
  1 sibling, 2 replies; 21+ messages in thread
From: Sascha Hauer @ 2010-06-17 13:17 UTC (permalink / raw)
  To: barebox


Here is an updated version. I have put get_random_bytes() into
stdlib.h aswell, though of course this is no stdlib function.

Sascha

[PATCH 04/24] include support for a simple pseudo number generator

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 include/net.h    |    1 +
 include/stdlib.h |   16 ++++++++++++++++
 lib/Makefile     |    1 +
 lib/random.c     |   22 ++++++++++++++++++++++
 4 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 include/stdlib.h
 create mode 100644 lib/random.c

diff --git a/include/net.h b/include/net.h
index 8db83d8..709e76c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <param.h>
 #include <malloc.h>
+#include <stdlib.h>
 #include <asm/byteorder.h>	/* for nton* / ntoh* stuff */
 
 
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..dc72013
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,16 @@
+#ifndef __STDLIB_H
+#define __STDLIB_H
+
+#define RAND_MAX 32767
+
+/* return a pseudo-random integer in the range [0, RAND_MAX] */
+unsigned int rand(void);
+
+/* set the seed for rand () */
+void srand(unsigned int seed);
+
+/* fill a buffer with pseudo-random data */
+void get_random_bytes(char *buf, int len);
+
+
+#endif /* __STDLIB_H */
diff --git a/lib/Makefile b/lib/Makefile
index b072fb6..4a33aaa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
 obj-y			+= glob.o
 obj-y			+= notifier.o
 obj-y			+= copy_file.o
+obj-y			+= random.o
 obj-y			+= lzo/
 obj-$(CONFIG_LZO_DECOMPRESS)		+= decompress_unlzo.o
 obj-$(CONFIG_PROCESS_ESCAPE_SEQUENCE)	+= process_escape_sequence.o
diff --git a/lib/random.c b/lib/random.c
new file mode 100644
index 0000000..48c923f
--- /dev/null
+++ b/lib/random.c
@@ -0,0 +1,22 @@
+#include <common.h>
+#include <stdlib.h>
+
+static unsigned int random_seed;
+
+unsigned int rand(void)
+{
+	random_seed = random_seed * 1103515245 + 12345;
+	return (random_seed / 65536) % 32768;
+}
+
+void srand(unsigned int seed)
+{
+	random_seed = seed;
+}
+
+void get_random_bytes(char *buf, int len)
+{
+	while (len--)
+		*buf++ = rand() % 256;
+}
+
-- 
1.7.1


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 07/11] add a generic default environment
  2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
  2010-06-15  9:13   ` Uwe Kleine-König
@ 2010-06-17 13:20   ` Sascha Hauer
  2010-06-19 20:14     ` Uwe Kleine-König
  1 sibling, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2010-06-17 13:20 UTC (permalink / raw)
  To: barebox

next try...

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>
---
 defaultenv/bin/_update       |   39 +++++++++++++++
 defaultenv/bin/boot          |  109 ++++++++++++++++++++++++++++++++++++++++++
 defaultenv/bin/hush_hack     |    1 +
 defaultenv/bin/init          |   34 +++++++++++++
 defaultenv/bin/update_kernel |   15 ++++++
 defaultenv/bin/update_rootfs |   16 ++++++
 6 files changed, 214 insertions(+), 0 deletions(-)
 create mode 100644 defaultenv/bin/_update
 create mode 100644 defaultenv/bin/boot
 create mode 100644 defaultenv/bin/hush_hack
 create mode 100644 defaultenv/bin/init
 create mode 100644 defaultenv/bin/update_kernel
 create mode 100644 defaultenv/bin/update_rootfs

diff --git a/defaultenv/bin/_update b/defaultenv/bin/_update
new file mode 100644
index 0000000..ddd6b84
--- /dev/null
+++ b/defaultenv/bin/_update
@@ -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
diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
new file mode 100644
index 0000000..6a508fb
--- /dev/null
+++ b/defaultenv/bin/boot
@@ -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
diff --git a/defaultenv/bin/hush_hack b/defaultenv/bin/hush_hack
new file mode 100644
index 0000000..5fffa92
--- /dev/null
+++ b/defaultenv/bin/hush_hack
@@ -0,0 +1 @@
+nand -a /dev/nand0.*
diff --git a/defaultenv/bin/init b/defaultenv/bin/init
new file mode 100644
index 0000000..a55e8e6
--- /dev/null
+++ b/defaultenv/bin/init
@@ -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
diff --git a/defaultenv/bin/update_kernel b/defaultenv/bin/update_kernel
new file mode 100644
index 0000000..1d35ed9
--- /dev/null
+++ b/defaultenv/bin/update_kernel
@@ -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
diff --git a/defaultenv/bin/update_rootfs b/defaultenv/bin/update_rootfs
new file mode 100644
index 0000000..6366315
--- /dev/null
+++ b/defaultenv/bin/update_rootfs
@@ -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
-- 
1.7.1

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-17 13:17   ` Sascha Hauer
@ 2010-06-17 13:26     ` Andy Pont
  2010-06-17 14:14     ` Peter Korsgaard
  1 sibling, 0 replies; 21+ messages in thread
From: Andy Pont @ 2010-06-17 13:26 UTC (permalink / raw)
  To: 'Sascha Hauer'; +Cc: barebox

Sascha Hauer wrote...

> +#define RAND_MAX 32767
> +
> +/* return a pseudo-random integer in the range [0, RAND_MAX] */
> +unsigned int rand(void);

*Snip*

> +unsigned int rand(void)
> +{
> +	random_seed = random_seed * 1103515245 + 12345;
> +	return (random_seed / 65536) % 32768;
> +}

The return value on this function seems wrong as it will always return a
value between 0 and 32767 irrespective of what RAND_MAX is set to which
doesn't agree with the comment on the function prototype.

Although it may just be me being dim as my hayfever is driving me mad today
:-)

A.



_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] include support for a simple pseudo number generator
  2010-06-17 13:17   ` Sascha Hauer
  2010-06-17 13:26     ` Andy Pont
@ 2010-06-17 14:14     ` Peter Korsgaard
  1 sibling, 0 replies; 21+ messages in thread
From: Peter Korsgaard @ 2010-06-17 14:14 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

>>>>> "Sascha" == Sascha Hauer <s.hauer@pengutronix.de> writes:

 Sascha> Here is an updated version. I have put get_random_bytes() into
 Sascha> stdlib.h aswell, though of course this is no stdlib function.

 Sascha> Sascha

Looks good to me, thanks

Acked-by: Peter Korsgaard <jacmet@sunsite.dk>

-- 
Bye, Peter Korsgaard

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 07/11] add a generic default environment
  2010-06-17 13:20   ` Sascha Hauer
@ 2010-06-19 20:14     ` Uwe Kleine-König
  0 siblings, 0 replies; 21+ messages in thread
From: Uwe Kleine-König @ 2010-06-19 20:14 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hello Sascha,

On Thu, Jun 17, 2010 at 03:20:59PM +0200, Sascha Hauer wrote:
> diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
> new file mode 100644
> index 0000000..6a508fb
> --- /dev/null
> +++ b/defaultenv/bin/boot
> @@ -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
I'm not sure if barebox supports the case statement.  Even if not you
can simplify that to

	if [ "x$1" = "xnand" ] || [ "x$1" = "xnor" ] || [ "x$1" = "xnet" ]; then
		rootfs_loc="$1";
		kernel_loc="$1";
	fi

Best regards
Uwe

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/11] include support for a simple pseudo number generator
@ 2010-06-18  6:28 'Sascha Hauer'
  0 siblings, 0 replies; 21+ messages in thread
From: 'Sascha Hauer' @ 2010-06-18  6:28 UTC (permalink / raw)
  To: Andy Pont; +Cc: barebox

On Thu, Jun 17, 2010 at 02:26:58PM +0100, Andy Pont wrote:
> Sascha Hauer wrote...
> 
> > +#define RAND_MAX 32767
> > +
> > +/* return a pseudo-random integer in the range [0, RAND_MAX] */
> > +unsigned int rand(void);
> 
> *Snip*
> 
> > +unsigned int rand(void)
> > +{
> > +	random_seed = random_seed * 1103515245 + 12345;
> > +	return (random_seed / 65536) % 32768;
> > +}
> 
> The return value on this function seems wrong as it will always return a
> value between 0 and 32767 irrespective of what RAND_MAX is set to which
> doesn't agree with the comment on the function prototype.

Well the way the rand function is implemented it is not suitable for
RAND_MAX > 32767. Ok, changed it for the attached patch.

I originally thought there would be discussion about the pros and cons
of random ethernet addresses, but about not this patch ;)

Sascha

commit dcd5248b7dceb918c5c5d9b045893421ddc6c112
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date:   Fri Jun 11 14:10:36 2010 +0200

    include support for a simple pseudo number generator
    
    Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

diff --git a/include/net.h b/include/net.h
index 8db83d8..709e76c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <param.h>
 #include <malloc.h>
+#include <stdlib.h>
 #include <asm/byteorder.h>	/* for nton* / ntoh* stuff */
 
 
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..dc72013
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,16 @@
+#ifndef __STDLIB_H
+#define __STDLIB_H
+
+#define RAND_MAX 32767
+
+/* return a pseudo-random integer in the range [0, RAND_MAX] */
+unsigned int rand(void);
+
+/* set the seed for rand () */
+void srand(unsigned int seed);
+
+/* fill a buffer with pseudo-random data */
+void get_random_bytes(char *buf, int len);
+
+
+#endif /* __STDLIB_H */
diff --git a/lib/Makefile b/lib/Makefile
index b072fb6..4a33aaa 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
 obj-y			+= glob.o
 obj-y			+= notifier.o
 obj-y			+= copy_file.o
+obj-y			+= random.o
 obj-y			+= lzo/
 obj-$(CONFIG_LZO_DECOMPRESS)		+= decompress_unlzo.o
 obj-$(CONFIG_PROCESS_ESCAPE_SEQUENCE)	+= process_escape_sequence.o
diff --git a/lib/random.c b/lib/random.c
new file mode 100644
index 0000000..352d6bf
--- /dev/null
+++ b/lib/random.c
@@ -0,0 +1,26 @@
+#include <common.h>
+#include <stdlib.h>
+
+static unsigned int random_seed;
+
+#if RAND_MAX > 32767
+#error this rand implementation is for RAND_MAX < 32678 only.
+#endif
+
+unsigned int rand(void)
+{
+	random_seed = random_seed * 1103515245 + 12345;
+	return (random_seed / 65536) % (RAND_MAX + 1);
+}
+
+void srand(unsigned int seed)
+{
+	random_seed = seed;
+}
+
+void get_random_bytes(char *buf, int len)
+{
+	while (len--)
+		*buf++ = rand() % 256;
+}
+
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2010-06-19 20:14 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-14  9:48 More patches Sascha Hauer
2010-06-14  9:48 ` [PATCH 01/11] pcm037: Add MMU support Sascha Hauer
2010-06-14  9:48 ` [PATCH 02/11] bootu: Allow passing in devices as parameter Sascha Hauer
2010-06-14  9:48 ` [PATCH 03/11] Allow to merge default environment from more than one directory Sascha Hauer
2010-06-14  9:48 ` [PATCH 04/11] include support for a simple pseudo number generator Sascha Hauer
2010-06-15  9:39   ` Peter Korsgaard
2010-06-15 11:54     ` Sascha Hauer
2010-06-17 13:17   ` Sascha Hauer
2010-06-17 13:26     ` Andy Pont
2010-06-17 14:14     ` Peter Korsgaard
2010-06-14  9:48 ` [PATCH 05/11] net: implement random_ether_addr Sascha Hauer
2010-06-14  9:48 ` [PATCH 06/11] net: use a random mac address if the current device does not have one Sascha Hauer
2010-06-14  9:48 ` [PATCH 07/11] add a generic default environment Sascha Hauer
2010-06-15  9:13   ` Uwe Kleine-König
2010-06-17 13:20   ` Sascha Hauer
2010-06-19 20:14     ` Uwe Kleine-König
2010-06-14  9:48 ` [PATCH 08/11] pcm038: use generic default env Sascha Hauer
2010-06-14  9:48 ` [PATCH 09/11] pcm043: " Sascha Hauer
2010-06-14  9:48 ` [PATCH 10/11] pcm037: " Sascha Hauer
2010-06-14  9:48 ` [PATCH 11/11] pca100: " Sascha Hauer
2010-06-18  6:28 [PATCH 04/11] include support for a simple pseudo number generator 'Sascha Hauer'

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox