mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* new default environment
@ 2012-05-16  7:04 Sascha Hauer
  2012-05-16  7:04 ` [PATCH 1/3] bootm: Add default images variables Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-05-16  7:04 UTC (permalink / raw)
  To: barebox

Hi all,

The new environment patches have been around for some
time and I have continued working on them. They are now in a state
which makes me sufficiently happy to give them a try in mainline.

Changes to the last version I posted is some refactoring and as
a main feature improvement menu support. While being optional I think
it's really worth giving it a try. It offers easily selectable boot
entries and also provides an easy way to configure barebox during
runtime.

The new default env still has some rough edges, like for example
the Kconfig dependencies are not accurate. I think we can sort
this out in tree though.

BTW I have no plans (yet) to remove the old environment template
as it still contains some features which the new one does not
have (update, dfu on some boards). In the long run I hope we can
migrate all boards over, but in the mean time the old environment
can still be worked on.

Sascha


The following changes since commit 3f66e8dc57d0dd05e22d321786da39810ba6b7ff:

  Merge branch 'pu/magicvar' into next (2012-05-15 20:34:34 +0200)

are available in the git repository at:


  git://git.pengutronix.de/git/barebox.git work/defenv-2

for you to fetch changes up to 2078535ff07702beea71420d47b3cd391831026f:

  ARM pcm038: Switch to new environment (2012-05-16 08:48:37 +0200)

----------------------------------------------------------------
Sascha Hauer (3):
      bootm: Add default images variables
      Add next generation default environment template
      ARM pcm038: Switch to new environment

 arch/arm/boards/pcm038/env/config               |   52 ------------------
 arch/arm/boards/pcm038/env/init/bootargs-base   |    8 +++
 arch/arm/boards/pcm038/env/init/hostname        |    8 +++
 arch/arm/boards/pcm038/env/init/mtdparts-nand   |   11 ++++
 arch/arm/boards/pcm038/env/init/mtdparts-nor    |   11 ++++
 arch/arm/configs/pcm038_defconfig               |   14 ++---
 arch/arm/mach-imx/Kconfig                       |    1 +
 commands/Kconfig                                |    1 +
 commands/bootm.c                                |   66 ++++++++++++++++++-----
 common/Kconfig                                  |   20 ++++++-
 common/Makefile                                 |    7 +++
 defaultenv-2/base/bin/boot                      |   18 +++++++
 defaultenv-2/base/bin/bootargs-ip               |   11 ++++
 defaultenv-2/base/bin/bootargs-ip-barebox       |    7 +++
 defaultenv-2/base/bin/bootargs-ip-dhcp          |    5 ++
 defaultenv-2/base/bin/bootargs-ip-none          |    5 ++
 defaultenv-2/base/bin/bootargs-root-initrd      |   11 ++++
 defaultenv-2/base/bin/bootargs-root-jffs2       |    9 ++++
 defaultenv-2/base/bin/bootargs-root-nfs         |   15 ++++++
 defaultenv-2/base/bin/bootargs-root-ubi         |   13 +++++
 defaultenv-2/base/bin/ifup                      |   59 ++++++++++++++++++++
 defaultenv-2/base/bin/init                      |   46 ++++++++++++++++
 defaultenv-2/base/bin/mtdparts-add              |   49 +++++++++++++++++
 defaultenv-2/base/boot/nand-ubi                 |   10 ++++
 defaultenv-2/base/boot/net                      |   12 +++++
 defaultenv-2/base/data/ansi-colors              |   26 +++++++++
 defaultenv-2/base/data/boot-template            |   16 ++++++
 defaultenv-2/base/init/automount                |   27 ++++++++++
 defaultenv-2/base/init/bootargs-base            |    8 +++
 defaultenv-2/base/init/general                  |   18 +++++++
 defaultenv-2/base/init/hostname                 |    8 +++
 defaultenv-2/base/init/prompt                   |    7 +++
 defaultenv-2/base/network/eth0                  |   15 ++++++
 defaultenv-2/menu/menu/boot-entries-collect     |   13 +++++
 defaultenv-2/menu/menu/boot-entries-edit        |   20 +++++++
 defaultenv-2/menu/menu/boot-entries-remove      |   18 +++++++
 defaultenv-2/menu/menu/boot-menu-add-entry      |    5 ++
 defaultenv-2/menu/menu/boot-menu-new-boot-entry |   21 ++++++++
 defaultenv-2/menu/menu/init-entries-collect     |    9 ++++
 defaultenv-2/menu/menu/init-entries-edit        |   20 +++++++
 defaultenv-2/menu/menu/init-menu-add-entry      |    3 ++
 defaultenv-2/menu/menu/mainmenu                 |   28 ++++++++++
 42 files changed, 656 insertions(+), 75 deletions(-)
 delete mode 100644 arch/arm/boards/pcm038/env/config
 create mode 100644 arch/arm/boards/pcm038/env/init/bootargs-base
 create mode 100644 arch/arm/boards/pcm038/env/init/hostname
 create mode 100644 arch/arm/boards/pcm038/env/init/mtdparts-nand
 create mode 100644 arch/arm/boards/pcm038/env/init/mtdparts-nor
 create mode 100644 defaultenv-2/base/bin/boot
 create mode 100644 defaultenv-2/base/bin/bootargs-ip
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-barebox
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-dhcp
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-none
 create mode 100644 defaultenv-2/base/bin/bootargs-root-initrd
 create mode 100644 defaultenv-2/base/bin/bootargs-root-jffs2
 create mode 100644 defaultenv-2/base/bin/bootargs-root-nfs
 create mode 100644 defaultenv-2/base/bin/bootargs-root-ubi
 create mode 100644 defaultenv-2/base/bin/ifup
 create mode 100644 defaultenv-2/base/bin/init
 create mode 100644 defaultenv-2/base/bin/mtdparts-add
 create mode 100644 defaultenv-2/base/boot/nand-ubi
 create mode 100644 defaultenv-2/base/boot/net
 create mode 100644 defaultenv-2/base/data/ansi-colors
 create mode 100644 defaultenv-2/base/data/boot-template
 create mode 100644 defaultenv-2/base/init/automount
 create mode 100644 defaultenv-2/base/init/bootargs-base
 create mode 100644 defaultenv-2/base/init/general
 create mode 100644 defaultenv-2/base/init/hostname
 create mode 100644 defaultenv-2/base/init/prompt
 create mode 100644 defaultenv-2/base/network/eth0
 create mode 100644 defaultenv-2/menu/menu/boot-entries-collect
 create mode 100644 defaultenv-2/menu/menu/boot-entries-edit
 create mode 100644 defaultenv-2/menu/menu/boot-entries-remove
 create mode 100644 defaultenv-2/menu/menu/boot-menu-add-entry
 create mode 100644 defaultenv-2/menu/menu/boot-menu-new-boot-entry
 create mode 100644 defaultenv-2/menu/menu/init-entries-collect
 create mode 100644 defaultenv-2/menu/menu/init-entries-edit
 create mode 100644 defaultenv-2/menu/menu/init-menu-add-entry
 create mode 100644 defaultenv-2/menu/menu/mainmenu

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

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

* [PATCH 1/3] bootm: Add default images variables
  2012-05-16  7:04 new default environment Sascha Hauer
@ 2012-05-16  7:04 ` Sascha Hauer
  2012-05-16  7:04 ` [PATCH 2/3] Add next generation default environment template Sascha Hauer
  2012-05-16  7:04 ` [PATCH 3/3] ARM pcm038: Switch to new environment Sascha Hauer
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-05-16  7:04 UTC (permalink / raw)
  To: barebox

It turns out useful to be able to configure bootm before its usage.
This allows us to overwrite bootm settings on an individual base.
This patch adds global variables to configure the kernel image, the
initrd image and the devicetree image. These values will be used
unless overwritten explicitely with command line switches.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/Kconfig |    1 +
 commands/bootm.c |   66 ++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 53 insertions(+), 14 deletions(-)

diff --git a/commands/Kconfig b/commands/Kconfig
index 1839538..52e1f17 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -329,6 +329,7 @@ config CMD_BOOTM
 	select CRC32
 	select UNCOMPRESS
 	select FILETYPE
+	select GLOBALVAR
 	prompt "bootm"
 
 config CMD_BOOTM_SHOW_TYPE
diff --git a/commands/bootm.c b/commands/bootm.c
index 0c0e56a..2989d39 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -47,6 +47,8 @@
 #include <memory.h>
 #include <filetype.h>
 #include <binfmt.h>
+#include <globalvar.h>
+#include <magicvar.h>
 #include <asm-generic/memory_layout.h>
 
 static LIST_HEAD(handler_list);
@@ -136,7 +138,7 @@ static int bootm_open_initrd_uimage(struct image_data *data)
 }
 
 #ifdef CONFIG_OFTREE
-static int bootm_open_oftree(struct image_data *data, char *oftree, int num)
+static int bootm_open_oftree(struct image_data *data, const char *oftree, int num)
 {
 	enum filetype ft;
 	struct fdt_header *fdt, *fixfdt;
@@ -231,19 +233,25 @@ static struct image_handler *bootm_find_handler(enum filetype filetype,
 	return NULL;
 }
 
-static void bootm_image_name_and_no(char *name, int *no)
+static char *bootm_image_name_and_no(const char *name, int *no)
 {
-	char *at;
+	char *at, *ret;
+
+	if (!name || !*name)
+		return NULL;
 
 	*no = 0;
 
-	at = strchr(name, '@');
+	ret = xstrdup(name);
+	at = strchr(ret, '@');
 	if (!at)
-		return;
+		return ret;
 
 	*at++ = 0;
 
 	*no = simple_strtoul(at, NULL, 10);
+
+	return ret;
 }
 
 #define BOOTM_OPTS_COMMON "ca:e:vo:f"
@@ -261,7 +269,7 @@ static int do_bootm(int argc, char *argv[])
 	struct image_data data;
 	int ret = 1;
 	enum filetype os_type, initrd_type = filetype_unknown;
-	char *oftree = NULL;
+	const char *oftree = NULL, *initrd_file = NULL, *os_file = NULL;
 	int fallback = 0;
 
 	memset(&data, 0, sizeof(struct image_data));
@@ -271,6 +279,11 @@ static int do_bootm(int argc, char *argv[])
 	data.verify = 0;
 	data.verbose = 0;
 
+	oftree = getenv("global.bootm.oftree");
+	os_file = getenv("global.bootm.image");
+	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
+		initrd_file = getenv("global.bootm.initrd");
+
 	while ((opt = getopt(argc, argv, BOOTM_OPTS)) > 0) {
 		switch(opt) {
 		case 'c':
@@ -281,7 +294,7 @@ static int do_bootm(int argc, char *argv[])
 			data.initrd_address = simple_strtoul(optarg, NULL, 0);
 			break;
 		case 'r':
-			data.initrd_file = optarg;
+			initrd_file = optarg;
 			break;
 #endif
 		case 'a':
@@ -304,12 +317,21 @@ static int do_bootm(int argc, char *argv[])
 		}
 	}
 
-	if (optind == argc)
-		return COMMAND_ERROR_USAGE;
+	if (optind != argc)
+		os_file = argv[optind];
+
+	if (!os_file || !*os_file) {
+		printf("no boot image given\n");
+		goto err_out;
+	}
+
+	if (initrd_file && !*initrd_file)
+		initrd_file = NULL;
 
-	data.os_file = argv[optind];
+	if (oftree && !*oftree)
+		oftree = NULL;
 
-	bootm_image_name_and_no(data.os_file, &data.os_num);
+	data.os_file = bootm_image_name_and_no(os_file, &data.os_num);
 
 	os_type = file_name_detect_type(data.os_file);
 	if ((int)os_type < 0) {
@@ -332,8 +354,8 @@ static int do_bootm(int argc, char *argv[])
 		}
 	}
 
-	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && data.initrd_file) {
-		bootm_image_name_and_no(data.initrd_file, &data.initrd_num);
+	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD) && initrd_file) {
+		data.initrd_file = bootm_image_name_and_no(initrd_file, &data.initrd_num);
 
 		initrd_type = file_name_detect_type(data.initrd_file);
 		if ((int)initrd_type < 0) {
@@ -388,7 +410,7 @@ static int do_bootm(int argc, char *argv[])
 	if (oftree) {
 		int oftree_num;
 
-		bootm_image_name_and_no(oftree, &oftree_num);
+		oftree = bootm_image_name_and_no(oftree, &oftree_num);
 
 		ret = bootm_open_oftree(&data, oftree, oftree_num);
 		if (ret)
@@ -417,6 +439,8 @@ static int do_bootm(int argc, char *argv[])
 	printf("handler failed with %s\n", strerror(-ret));
 
 err_out:
+	free(data.initrd_file);
+	free(data.os_file);
 	if (data.os_res)
 		release_sdram_region(data.os_res);
 	if (data.initrd_res)
@@ -428,6 +452,18 @@ err_out:
 	return 1;
 }
 
+static int bootm_init(void)
+{
+
+	globalvar_add_simple("bootm.image");
+	globalvar_add_simple("bootm.oftree");
+	if (IS_ENABLED(CONFIG_CMD_BOOTM_INITRD))
+		globalvar_add_simple("bootm.initrd");
+
+	return 0;
+}
+late_initcall(bootm_init);
+
 BAREBOX_CMD_HELP_START(bootm)
 BAREBOX_CMD_HELP_USAGE("bootm [OPTIONS] image\n")
 BAREBOX_CMD_HELP_SHORT("Boot an application image.\n")
@@ -453,6 +489,8 @@ BAREBOX_CMD_START(bootm)
 BAREBOX_CMD_END
 
 BAREBOX_MAGICVAR(bootargs, "Linux Kernel parameters");
+BAREBOX_MAGICVAR_NAMED(global_bootm_image, global.bootm.image, "bootm default boot image");
+BAREBOX_MAGICVAR_NAMED(global_bootm_initrd, global.bootm.initrd, "bootm default initrd");
 
 static struct binfmt_hook binfmt_uimage_hook = {
 	.type = filetype_uimage,
-- 
1.7.10


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

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

* [PATCH 2/3] Add next generation default environment template
  2012-05-16  7:04 new default environment Sascha Hauer
  2012-05-16  7:04 ` [PATCH 1/3] bootm: Add default images variables Sascha Hauer
@ 2012-05-16  7:04 ` Sascha Hauer
  2012-06-04  8:47   ` Juergen Beisert
  2012-05-16  7:04 ` [PATCH 3/3] ARM pcm038: Switch to new environment Sascha Hauer
  2 siblings, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2012-05-16  7:04 UTC (permalink / raw)
  To: barebox

This adds a new environment template which aims to be more flexible
and configurable. Instead of having mainly two scripts (a config script
and a boot script) this template uses initscripts which control the
startup behaviour and configuration. Also we have boot scripts in
/env/boot which configure a single boot configuration. Additional
boot entries can be added by board specific entries or during runtime
by copying and editing a template entry.

Some more helpers handle for example network interfaces which can now
be brought up with 'ifup'. We use the automount feature to configure
mountpoints together with the commands to bring up the devices behind
these mountpoints.

Optionally menu support is available which hides many details behind
a nice looking interface.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/Kconfig                                  |   20 +++++++-
 common/Makefile                                 |    7 +++
 defaultenv-2/base/bin/boot                      |   18 +++++++
 defaultenv-2/base/bin/bootargs-ip               |   11 +++++
 defaultenv-2/base/bin/bootargs-ip-barebox       |    7 +++
 defaultenv-2/base/bin/bootargs-ip-dhcp          |    5 ++
 defaultenv-2/base/bin/bootargs-ip-none          |    5 ++
 defaultenv-2/base/bin/bootargs-root-initrd      |   11 +++++
 defaultenv-2/base/bin/bootargs-root-jffs2       |    9 ++++
 defaultenv-2/base/bin/bootargs-root-nfs         |   15 ++++++
 defaultenv-2/base/bin/bootargs-root-ubi         |   13 +++++
 defaultenv-2/base/bin/ifup                      |   59 +++++++++++++++++++++++
 defaultenv-2/base/bin/init                      |   46 ++++++++++++++++++
 defaultenv-2/base/bin/mtdparts-add              |   49 +++++++++++++++++++
 defaultenv-2/base/boot/nand-ubi                 |   10 ++++
 defaultenv-2/base/boot/net                      |   12 +++++
 defaultenv-2/base/data/ansi-colors              |   26 ++++++++++
 defaultenv-2/base/data/boot-template            |   16 ++++++
 defaultenv-2/base/init/automount                |   27 +++++++++++
 defaultenv-2/base/init/bootargs-base            |    8 +++
 defaultenv-2/base/init/general                  |   18 +++++++
 defaultenv-2/base/init/hostname                 |    8 +++
 defaultenv-2/base/init/prompt                   |    7 +++
 defaultenv-2/base/network/eth0                  |   15 ++++++
 defaultenv-2/menu/menu/boot-entries-collect     |   13 +++++
 defaultenv-2/menu/menu/boot-entries-edit        |   20 ++++++++
 defaultenv-2/menu/menu/boot-entries-remove      |   18 +++++++
 defaultenv-2/menu/menu/boot-menu-add-entry      |    5 ++
 defaultenv-2/menu/menu/boot-menu-new-boot-entry |   21 ++++++++
 defaultenv-2/menu/menu/init-entries-collect     |    9 ++++
 defaultenv-2/menu/menu/init-entries-edit        |   20 ++++++++
 defaultenv-2/menu/menu/init-menu-add-entry      |    3 ++
 defaultenv-2/menu/menu/mainmenu                 |   28 +++++++++++
 33 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 defaultenv-2/base/bin/boot
 create mode 100644 defaultenv-2/base/bin/bootargs-ip
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-barebox
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-dhcp
 create mode 100644 defaultenv-2/base/bin/bootargs-ip-none
 create mode 100644 defaultenv-2/base/bin/bootargs-root-initrd
 create mode 100644 defaultenv-2/base/bin/bootargs-root-jffs2
 create mode 100644 defaultenv-2/base/bin/bootargs-root-nfs
 create mode 100644 defaultenv-2/base/bin/bootargs-root-ubi
 create mode 100644 defaultenv-2/base/bin/ifup
 create mode 100644 defaultenv-2/base/bin/init
 create mode 100644 defaultenv-2/base/bin/mtdparts-add
 create mode 100644 defaultenv-2/base/boot/nand-ubi
 create mode 100644 defaultenv-2/base/boot/net
 create mode 100644 defaultenv-2/base/data/ansi-colors
 create mode 100644 defaultenv-2/base/data/boot-template
 create mode 100644 defaultenv-2/base/init/automount
 create mode 100644 defaultenv-2/base/init/bootargs-base
 create mode 100644 defaultenv-2/base/init/general
 create mode 100644 defaultenv-2/base/init/hostname
 create mode 100644 defaultenv-2/base/init/prompt
 create mode 100644 defaultenv-2/base/network/eth0
 create mode 100644 defaultenv-2/menu/menu/boot-entries-collect
 create mode 100644 defaultenv-2/menu/menu/boot-entries-edit
 create mode 100644 defaultenv-2/menu/menu/boot-entries-remove
 create mode 100644 defaultenv-2/menu/menu/boot-menu-add-entry
 create mode 100644 defaultenv-2/menu/menu/boot-menu-new-boot-entry
 create mode 100644 defaultenv-2/menu/menu/init-entries-collect
 create mode 100644 defaultenv-2/menu/menu/init-entries-edit
 create mode 100644 defaultenv-2/menu/menu/init-menu-add-entry
 create mode 100644 defaultenv-2/menu/menu/mainmenu

diff --git a/common/Kconfig b/common/Kconfig
index 9f0e0f8..ded34c0 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -495,6 +495,23 @@ endchoice
 
 endif
 
+config HAVE_DEFAULT_ENVIRONMENT_NEW
+	bool
+
+config DEFAULT_ENVIRONMENT_GENERIC_NEW
+	bool
+	depends on DEFAULT_ENVIRONMENT
+	depends on SHELL_HUSH
+	select HUSH_GETOPT
+	select GLOB
+	select GLOB_SORT
+	select CMD_GLOBAL
+	select CMD_AUTOMOUNT
+	select FLEXIBLE_BOOTARGS
+	prompt "Generic environment template"
+
+if !HAVE_DEFAULT_ENVIRONMENT_NEW
+
 config DEFAULT_ENVIRONMENT_GENERIC
 	bool
 	depends on DEFAULT_ENVIRONMENT
@@ -512,8 +529,7 @@ config DEFAULT_ENVIRONMENT_GENERIC
 	  at least contain a /env/config file.
 	  This will be able to overwrite the files from defaultenv.
 
-config HAVE_DEFAULT_ENVIRONMENT_NEW
-	bool
+endif
 
 config DEFAULT_ENVIRONMENT_PATH
 	string
diff --git a/common/Makefile b/common/Makefile
index b49e6e0..a1926d3 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -42,6 +42,13 @@ ifdef CONFIG_DEFAULT_ENVIRONMENT
 $(obj)/startup.o: include/generated/barebox_default_env.h
 $(obj)/env.o: include/generated/barebox_default_env.h
 
+ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW),y)
+DEFAULT_ENVIRONMENT_PATH = "defaultenv-2/base"
+ifeq ($(CONFIG_CMD_MENU_MANAGEMENT),y)
+DEFAULT_ENVIRONMENT_PATH += "defaultenv-2/menu"
+endif
+endif
+
 ifeq ($(CONFIG_DEFAULT_ENVIRONMENT_GENERIC),y)
 DEFAULT_ENVIRONMENT_PATH = "defaultenv"
 endif
diff --git a/defaultenv-2/base/bin/boot b/defaultenv-2/base/bin/boot
new file mode 100644
index 0000000..c5ad73d
--- /dev/null
+++ b/defaultenv-2/base/bin/boot
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ $# = 0 ]; then
+	scr="$global.boot.default"
+else
+	scr="$1"
+fi
+
+if [ -n "$scr" ]; then
+	if [ ! -f /env/boot/$scr ]; then
+		echo -e "/env/boot/$scr does not exist.\nValid choices:"
+		ls /env/boot
+		exit
+	fi
+	/env/boot/$scr
+fi
+
+bootm
diff --git a/defaultenv-2/base/bin/bootargs-ip b/defaultenv-2/base/bin/bootargs-ip
new file mode 100644
index 0000000..15041c6
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-ip
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# pass either static ip or dhcp to kernel based on barebox settings
+
+. /env/network/eth0
+
+if [ $ip = dhcp ]; then
+	global.linux.bootargs.ip="ip=dhcp"
+else
+	global.linux.bootargs.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
+fi
diff --git a/defaultenv-2/base/bin/bootargs-ip-barebox b/defaultenv-2/base/bin/bootargs-ip-barebox
new file mode 100644
index 0000000..986c142
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-ip-barebox
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# pass barebox ip settings for eth0 to Linux
+
+ifup eth0
+
+global.linux.bootargs.ip="ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask::eth0:"
diff --git a/defaultenv-2/base/bin/bootargs-ip-dhcp b/defaultenv-2/base/bin/bootargs-ip-dhcp
new file mode 100644
index 0000000..c542b24
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-ip-dhcp
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Do dhcp in Linux
+
+global.linux.bootargs.ip="ip=dhcp"
diff --git a/defaultenv-2/base/bin/bootargs-ip-none b/defaultenv-2/base/bin/bootargs-ip-none
new file mode 100644
index 0000000..c010154
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-ip-none
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# disable ip setup in Linux
+
+global.linux.bootargs.ip="ip=none"
diff --git a/defaultenv-2/base/bin/bootargs-root-initrd b/defaultenv-2/base/bin/bootargs-root-initrd
new file mode 100644
index 0000000..4c59625
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-root-initrd
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+rdinit="/sbin/init"
+
+while getopt "i:" opt; do
+	if [ ${opt} = i ]; then
+		rdinit=${OPTARG}
+	fi
+done
+
+global.linux.bootargs.root="root=/dev/ram0 rdinit=${rdinit}"
diff --git a/defaultenv-2/base/bin/bootargs-root-jffs2 b/defaultenv-2/base/bin/bootargs-root-jffs2
new file mode 100644
index 0000000..db036da
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-root-jffs2
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+while getopt "m:" opt; do
+	if [ ${opt} = m ]; then
+		mtd=${OPTARG}
+	fi
+done
+
+global.linux.bootargs.root="root=$mtd rootfstype=jffs2"
diff --git a/defaultenv-2/base/bin/bootargs-root-nfs b/defaultenv-2/base/bin/bootargs-root-nfs
new file mode 100644
index 0000000..bf97555
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-root-nfs
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+while getopt "n:s:" opt; do
+	if [ ${opt} = n ]; then
+		nfsroot=${OPTARG}
+	elif [ ${opt} = s ]; then
+		serverip=${OPTARG}
+	fi
+done
+
+if [ -n ${serverip} ]; then
+	nfsroot="$serverip:$nfsroot"
+fi
+
+global.linux.bootargs.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv-2/base/bin/bootargs-root-ubi b/defaultenv-2/base/bin/bootargs-root-ubi
new file mode 100644
index 0000000..ef89104
--- /dev/null
+++ b/defaultenv-2/base/bin/bootargs-root-ubi
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+ubiroot=root
+
+while getopt "m:r:" opt; do
+	if [ ${opt} = r ]; then
+		ubiroot=${OPTARG}
+	elif [ ${opt} = m ]; then
+		mtd=${OPTARG}
+	fi
+done
+
+global.linux.bootargs.root="root=ubi0:$ubiroot ubi.mtd=$mtd rootfstype=ubifs"
diff --git a/defaultenv-2/base/bin/ifup b/defaultenv-2/base/bin/ifup
new file mode 100644
index 0000000..9f6fd6b
--- /dev/null
+++ b/defaultenv-2/base/bin/ifup
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+mkdir -p /tmp/network
+
+if [ $# != 1 ]; then
+	echo "usage: ifup <interface>"
+	exit 1
+fi
+
+interface="$1"
+
+if [ -f /tmp/network/$interface ]; then
+	exit 0
+fi
+
+cmd=/env/network/$interface
+
+if [ ! -e $cmd ]; then
+	echo "$f: no such file"
+	exit 1
+fi
+
+ip=
+ipaddr=
+netmask=
+gateway=
+serverip=
+ethaddr=
+
+. $cmd
+
+if [ $? != 0 ]; then
+	echo "failed to bring up $interface"
+	exit 1
+fi
+
+if [ -f /env/network/${interface}-discover ]; then
+	/env/network/${interface}-discover
+	if [ $? != 0 ]; then
+		echo "failed to discover eth0"
+		exit 1
+	fi
+fi
+
+if [ -n "$ethaddr" ]; then
+	${interface}.ethaddr=$ethaddr
+fi
+
+if [ "$ip" = static ]; then
+	${interface}.ipaddr=$ipaddr
+	${interface}.netmask=$netmask
+	${interface}.serverip=$serverip
+	${interface}.gateway=$gateway
+elif [ "$ip" = dhcp ]; then
+	dhcp
+	exit $?
+fi
+
+echo -o /tmp/network/$interface up
diff --git a/defaultenv-2/base/bin/init b/defaultenv-2/base/bin/init
new file mode 100644
index 0000000..e293c62
--- /dev/null
+++ b/defaultenv-2/base/bin/init
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+global hostname=generic
+global user=none
+global tftp.server
+global tftp.path=/mnt/tftp-dhcp
+global autoboot_timeout=3
+global boot.default=net
+global allow_color=true
+global linux.bootargs.base
+global linux.bootargs.ip
+global linux.bootargs.root
+global editcmd=sedit
+
+/env/init/general
+
+if [ -e /env/menu ]; then
+	echo -e -n "\nHit m for menu or any other key to stop autoboot: "
+else
+	echo -e -n "\nHit any key to stop autoboot: "
+fi
+
+timeout -a $global.autoboot_timeout -v key
+autoboot="$?"
+
+if [ "${key}" = "q" ]; then
+	exit
+fi
+
+for i in /env/init/*; do
+	. $i
+done
+
+if [ "$autoboot" = 0 ]; then
+	boot
+fi
+
+if [ -e /env/menu ]; then
+	if [ "${key}" != "m" ]; then
+		echo -e "\ntype exit to get to the menu"
+		sh
+	fi
+	/env/menu/mainmenu
+fi
diff --git a/defaultenv-2/base/bin/mtdparts-add b/defaultenv-2/base/bin/mtdparts-add
new file mode 100644
index 0000000..58c9fa7
--- /dev/null
+++ b/defaultenv-2/base/bin/mtdparts-add
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+mkdir -p /tmp/mtdparts
+
+parts=
+device=
+kernelname=
+bbdev=
+
+while getopt "p:d:k:b" opt; do
+        if [ ${opt} = p ]; then
+                parts=${OPTARG}
+        elif [ ${opt} = d ]; then
+                device=${OPTARG}
+        elif [ ${opt} = k ]; then
+                kernelname=${OPTARG}
+	elif [ ${opt} = b ]; then
+		bbdev=true
+        fi
+done
+
+if [ -z "${device}" ]; then
+	echo "$0: no device given"
+	exit
+fi
+
+if [ -z "${parts}" ]; then
+	echo "$0: no partitions given"
+	exit
+fi
+
+if [ -e /tmp/mtdparts/${device} ]; then
+	if [ -n "/dev/${device}.*.bb" ]; then
+		nand -d /dev/${device}.*.bb
+	fi
+	delpart /dev/${device}.*
+fi
+
+addpart -n /dev/${device} "$parts" || exit
+mkdir -p /tmp/mtdparts/${device}
+
+if [ -n "${bbdev}" ]; then
+	nand -a /dev/${device}.*
+fi
+
+if [ -n ${kernelname} ]; then
+	global linux.mtdparts.${device}
+	global.linux.mtdparts.${device}="${kernelname}:${parts}"
+fi
diff --git a/defaultenv-2/base/boot/nand-ubi b/defaultenv-2/base/boot/nand-ubi
new file mode 100644
index 0000000..a3f748e
--- /dev/null
+++ b/defaultenv-2/base/boot/nand-ubi
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "nand (UBI)"
+	exit
+fi
+
+global.bootm.image="/dev/nand0.kernel.bb"
+#global.bootm.oftree="/env/oftree"
+bootargs-root-ubi -r root -m nand0.root
diff --git a/defaultenv-2/base/boot/net b/defaultenv-2/base/boot/net
new file mode 100644
index 0000000..2684c20
--- /dev/null
+++ b/defaultenv-2/base/boot/net
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "network (tftp, nfs)"
+	exit
+fi
+
+global.bootm.image="${global.tftp.path}/${global.user}-linux-${global.hostname}"
+#global.bootm.oftree="${global.tftp.path}/${global.user}-oftree-${global.hostname}"
+nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+bootargs-ip
+bootargs-root-nfs -n "$nfsroot"
diff --git a/defaultenv-2/base/data/ansi-colors b/defaultenv-2/base/data/ansi-colors
new file mode 100644
index 0000000..c71b6b7
--- /dev/null
+++ b/defaultenv-2/base/data/ansi-colors
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Colors
+export RED='\e[1;31m'
+export BLUE='\e[1;34m'
+export GREEN='\e[1;32m'
+export CYAN='\e[1;36m'
+export YELLOW='\e[1;33m'
+export PINK='\e[1;35m'
+export WHITE='\e[1;37m'
+
+export DARK_RED='\e[2;31m'
+export DARK_BLUE='\e[2;34m'
+export DARK_GREEN='\e[2;32m'
+export DARK_CYAN='\e[2;36m'
+export DARK_YELLOW='\e[2;33m'
+export DARK_PINK='\e[2;35m'
+export DARK_WHITE='\e[2;37m'
+
+export RED_INV='\e[1;41m'
+export BLUE_INV='\e[1;44m'
+export GREEN_INV='\e[1;42m'
+export CYAN_INV='\e[1;46m'
+export ORANGE_INV='\e[1;43m'
+export PINK_INV='\e[1;45m'
+export NC='\e[0m' # No Color
diff --git a/defaultenv-2/base/data/boot-template b/defaultenv-2/base/data/boot-template
new file mode 100644
index 0000000..1cacf18
--- /dev/null
+++ b/defaultenv-2/base/data/boot-template
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	boot-menu-add-entry "$0" "<menu text here>"
+	exit
+fi
+
+global.bootm.image=<path to image>
+#global.bootm.oftree=<path to oftree>
+#global.bootm.initrd=<path to initrd>
+
+#bootargs-ip
+
+#bootargs-root-nfs -n "<path on server>" -s <serverip>
+#bootargs-root-jffs2 -m <mtdname>
+#bootargs-root-ubi -r <volume> -m <mtdname>
diff --git a/defaultenv-2/base/init/automount b/defaultenv-2/base/init/automount
new file mode 100644
index 0000000..e029222
--- /dev/null
+++ b/defaultenv-2/base/init/automount
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Automountpoints"
+	exit
+fi
+
+# automount server returned from dhcp server
+
+mkdir -p /mnt/tftp-dhcp
+automount /mnt/tftp-dhcp 'ifup eth0; mount $eth0.serverip tftp /mnt/tftp-dhcp'
+
+# automount nfs server example
+
+#nfshost=somehost
+#mkdir -p /mnt/${nfshost}
+#automount /mnt/$nfshost "ifup eth0; mount ${nfshost}:/tftpboot nfs /mnt/${nfshost}"
+
+# static tftp server example
+
+#mkdir -p /mnt/tftp
+#automount -d /mnt/tftp 'ifup eth0; mount $serverip tftp /mnt/tftp'
+
+# FAT on usb disk example
+
+#mkdir -p /mnt/fat
+#automount -d /mnt/fat 'usb; mount /dev/usbdisk0.0 fat $automount_path'
diff --git a/defaultenv-2/base/init/bootargs-base b/defaultenv-2/base/init/bootargs-base
new file mode 100644
index 0000000..8e588ad
--- /dev/null
+++ b/defaultenv-2/base/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttyS0,115200"
diff --git a/defaultenv-2/base/init/general b/defaultenv-2/base/init/general
new file mode 100644
index 0000000..ad6c860
--- /dev/null
+++ b/defaultenv-2/base/init/general
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "general config settings"
+	exit
+fi
+
+# user (used for network filenames)
+global.user=sha
+
+# timeout in seconds before the default boot entry is started
+global.autoboot_timeout=3
+
+# default boot entry (one of /env/boot/*)
+global.boot.default=net
+
+# default tftp path
+global.tftp.path=/mnt/tftp-dhcp
diff --git a/defaultenv-2/base/init/hostname b/defaultenv-2/base/init/hostname
new file mode 100644
index 0000000..57a2c94
--- /dev/null
+++ b/defaultenv-2/base/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=generic
diff --git a/defaultenv-2/base/init/prompt b/defaultenv-2/base/init/prompt
new file mode 100644
index 0000000..11dce9f
--- /dev/null
+++ b/defaultenv-2/base/init/prompt
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ ${global.allow_color} = "true" ]; then
+	export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m "
+else
+	export PS1="barebox@\h:\w "
+fi
diff --git a/defaultenv-2/base/network/eth0 b/defaultenv-2/base/network/eth0
new file mode 100644
index 0000000..048a288
--- /dev/null
+++ b/defaultenv-2/base/network/eth0
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# ip setting (static/dhcp)
+ip=dhcp
+
+# static setup used if ip=static
+ipaddr=
+netmask=
+gateway=
+serverip=
+
+# MAC address if needed
+#ethaddr=xx:xx:xx:xx:xx:xx
+
+# put code to discover eth0 (i.e. 'usb') to /env/network/eth0-discover
diff --git a/defaultenv-2/menu/menu/boot-entries-collect b/defaultenv-2/menu/menu/boot-entries-collect
new file mode 100644
index 0000000..c066c93
--- /dev/null
+++ b/defaultenv-2/menu/menu/boot-entries-collect
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+cd /env/boot
+
+./$global.boot.default menu
+
+for i in *; do
+	if [ "$i" != "$global.boot.default" ]; then
+		./$i menu
+	fi
+done
+
+cd /
diff --git a/defaultenv-2/menu/menu/boot-entries-edit b/defaultenv-2/menu/menu/boot-entries-edit
new file mode 100644
index 0000000..c4e1c3d
--- /dev/null
+++ b/defaultenv-2/menu/menu/boot-entries-edit
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+	menu -a -m boot_entries_edit -d "\e[1;36mEdit boot entries\e[0m"
+
+	boot-entries-collect
+
+	menu -e -a -m boot_entries_edit -c "boot-menu-new-boot-entry" -d "Add a new entry"
+	menu -e -a -m boot_entries_edit -c "boot-entries-remove" -d "Remove an entry"
+	menu -e -a -m boot_entries_edit -c "menu_exit=true" -d "back"
+
+	menu -s -m boot_entries_edit
+	menu -r -m boot_entries_edit
+
+	if [ $menu_exit = true ]; then
+		exit
+	fi
+done
diff --git a/defaultenv-2/menu/menu/boot-entries-remove b/defaultenv-2/menu/menu/boot-entries-remove
new file mode 100644
index 0000000..566be9d
--- /dev/null
+++ b/defaultenv-2/menu/menu/boot-entries-remove
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+	menu -a -m boot_entries_remove -d "\e[1;36mRemove Boot entry\e[0m"
+
+	boot-entries-collect
+
+	menu -e -a -m boot_entries_remove -c "menu_exit=true" -d "back"
+
+	menu -s -m boot_entries_remove
+	menu -r -m boot_entries_remove
+
+	if [ $menu_exit = true ]; then
+		exit
+	fi
+done
diff --git a/defaultenv-2/menu/menu/boot-menu-add-entry b/defaultenv-2/menu/menu/boot-menu-add-entry
new file mode 100644
index 0000000..7e1d9c6
--- /dev/null
+++ b/defaultenv-2/menu/menu/boot-menu-add-entry
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+menu -e -a -m boot -c "boot $1" -d "Boot: ${GREEN}$2${NC}"
+menu -e -a -m boot_entries_edit -c "$global.editcmd /env/boot/$1" -d "${GREEN}$2${NC}"
+menu -e -a -m boot_entries_remove -c "rm /env/boot/$1" -d "${GREEN}$2${NC}"
diff --git a/defaultenv-2/menu/menu/boot-menu-new-boot-entry b/defaultenv-2/menu/menu/boot-menu-new-boot-entry
new file mode 100644
index 0000000..c5e982c
--- /dev/null
+++ b/defaultenv-2/menu/menu/boot-menu-new-boot-entry
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+name=
+
+readline "Name of the new entry: " name
+
+if [ -z "$name" ]; then
+	exit 1
+fi
+
+if [ -e "/env/boot/$name" ]; then
+	echo "entry $name already exists"
+	readline "<enter>" unused
+	exit 1
+fi
+
+cp /env/data/boot-template /env/boot/$name
+
+edit /env/boot/$name
+
+boot-menu-show rebuild
diff --git a/defaultenv-2/menu/menu/init-entries-collect b/defaultenv-2/menu/menu/init-entries-collect
new file mode 100644
index 0000000..dbb7757
--- /dev/null
+++ b/defaultenv-2/menu/menu/init-entries-collect
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+cd /env/init
+
+for i in *; do
+	./$i menu
+done
+
+cd /
diff --git a/defaultenv-2/menu/menu/init-entries-edit b/defaultenv-2/menu/menu/init-entries-edit
new file mode 100644
index 0000000..fc02b32
--- /dev/null
+++ b/defaultenv-2/menu/menu/init-entries-edit
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+	menu -a -m init_entries_edit -d "\e[1;36mEdit init entries\e[0m"
+
+	menu -e -a -m init_entries_edit -R -c "true" -d ">> Reset board to let changes here take effect <<"
+
+	init-entries-collect
+
+	menu -e -a -m init_entries_edit -c "menu_exit=true" -d "back"
+
+	menu -s -m init_entries_edit
+	menu -r -m init_entries_edit
+
+	if [ $menu_exit = true ]; then
+		exit
+	fi
+done
diff --git a/defaultenv-2/menu/menu/init-menu-add-entry b/defaultenv-2/menu/menu/init-menu-add-entry
new file mode 100644
index 0000000..7cb5686
--- /dev/null
+++ b/defaultenv-2/menu/menu/init-menu-add-entry
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+menu -e -a -m init_entries_edit -c "$global.editcmd /env/init/$1" -d "\e[1;32m$2\e[0m"
diff --git a/defaultenv-2/menu/menu/mainmenu b/defaultenv-2/menu/menu/mainmenu
new file mode 100644
index 0000000..d7b0033
--- /dev/null
+++ b/defaultenv-2/menu/menu/mainmenu
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+savepath=$PATH
+export menupath=$PATH:/env/menu
+
+if [ ${global.allow_color} = "true" ]; then
+	. /env/data/ansi-colors
+fi
+
+while true; do
+	export PATH=${menupath}
+
+	echo $PATH
+
+	menu -a -m boot -d "${CYAN}Welcome to Barebox${NC}"
+
+	boot-entries-collect
+
+	menu -e -a -R -m boot -c "$global.editcmd /env/network/eth0" -d "Network settings"
+	menu -e -a -m boot -c "boot-entries-edit" -d "Edit boot entries"
+	menu -e -a -m boot -c "init-entries-edit" -d "Edit init entries"
+	menu -e -a -R -m boot -c "saveenv || echo \"failed to save environment\" && sleep 2" -d "Save settings"
+	menu -e -a -m boot -c 'PATH=$savepath; echo "enter exit to return to menu"; sh' -d "${DARK_YELLOW}Shell${NC}"
+	menu -e -a -m boot -c reset -d "${RED}Reset${NC}"
+
+	menu -s -m boot
+	menu -r -m boot
+done
-- 
1.7.10


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

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

* [PATCH 3/3] ARM pcm038: Switch to new environment
  2012-05-16  7:04 new default environment Sascha Hauer
  2012-05-16  7:04 ` [PATCH 1/3] bootm: Add default images variables Sascha Hauer
  2012-05-16  7:04 ` [PATCH 2/3] Add next generation default environment template Sascha Hauer
@ 2012-05-16  7:04 ` Sascha Hauer
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-05-16  7:04 UTC (permalink / raw)
  To: barebox

This switches the pcm038 board to the new environment template and
does the necessary defaultconfig adjustments. Additionally it disables
UBI support as the pcm038 image is getting bigger and bigger and UBI
seems to be the most unused big (in size) feature.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/pcm038/env/config             |   52 -------------------------
 arch/arm/boards/pcm038/env/init/bootargs-base |    8 ++++
 arch/arm/boards/pcm038/env/init/hostname      |    8 ++++
 arch/arm/boards/pcm038/env/init/mtdparts-nand |   11 ++++++
 arch/arm/boards/pcm038/env/init/mtdparts-nor  |   11 ++++++
 arch/arm/configs/pcm038_defconfig             |   14 +++----
 arch/arm/mach-imx/Kconfig                     |    1 +
 7 files changed, 46 insertions(+), 59 deletions(-)
 delete mode 100644 arch/arm/boards/pcm038/env/config
 create mode 100644 arch/arm/boards/pcm038/env/init/bootargs-base
 create mode 100644 arch/arm/boards/pcm038/env/init/hostname
 create mode 100644 arch/arm/boards/pcm038/env/init/mtdparts-nand
 create mode 100644 arch/arm/boards/pcm038/env/init/mtdparts-nor

diff --git a/arch/arm/boards/pcm038/env/config b/arch/arm/boards/pcm038/env/config
deleted file mode 100644
index 32be5ec..0000000
--- a/arch/arm/boards/pcm038/env/config
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh
-
-hostname=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
-#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 'nfs', 'tftp', 'nor' or 'nand'
-kernel_loc=tftp
-# can be either 'net', 'nor', 'nand' or 'initrd'
-rootfs_loc=net
-
-# can be either 'jffs2' or 'ubifs'
-rootfs_type=ubifs
-rootfsimage=root-$hostname.$rootfs_type
-
-kernelimage=zImage-$hostname
-#kernelimage=uImage-$hostname
-#kernelimage=Image-$hostname
-#kernelimage=Image-$hostname.lzo
-
-if [ -n $user ]; then
-	kernelimage="$user"-"$kernelimage"
-	nfsroot="$eth0.serverip:/home/$user/nfsroot/$hostname"
-	rootfsimage="$user"-"$rootfsimage"
-else
-	nfsroot="$eth0.serverip:/path/to/nfs/root"
-fi
-
-autoboot_timeout=3
-
-bootargs="console=ttymxc0,115200"
-
-nor_parts="512k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
-rootfs_mtdblock_nor=3
-
-nand_parts="512k(barebox)ro,128k(bareboxenv),2M(kernel),-(root)"
-rootfs_mtdblock_nand=7
-nand_device="mxc_nand"
-
-# 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/boards/pcm038/env/init/bootargs-base b/arch/arm/boards/pcm038/env/init/bootargs-base
new file mode 100644
index 0000000..d869754
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/init/bootargs-base
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "Base bootargs"
+	exit
+fi
+
+global.linux.bootargs.base="console=ttymxc0,115200"
diff --git a/arch/arm/boards/pcm038/env/init/hostname b/arch/arm/boards/pcm038/env/init/hostname
new file mode 100644
index 0000000..09c2f08
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/init/hostname
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "hostname"
+	exit
+fi
+
+global.hostname=pcm038
diff --git a/arch/arm/boards/pcm038/env/init/mtdparts-nand b/arch/arm/boards/pcm038/env/init/mtdparts-nand
new file mode 100644
index 0000000..84220b7
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/init/mtdparts-nand
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NAND partitions"
+	exit
+fi
+
+mtdparts="512k(nand0.barebox)ro,128k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.root)"
+kernelname="mxc_nand"
+
+mtdparts-add -b -d nand0 -k ${kernelname} -p ${mtdparts}
diff --git a/arch/arm/boards/pcm038/env/init/mtdparts-nor b/arch/arm/boards/pcm038/env/init/mtdparts-nor
new file mode 100644
index 0000000..c2c4065
--- /dev/null
+++ b/arch/arm/boards/pcm038/env/init/mtdparts-nor
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+	init-menu-add-entry "$0" "NOR partitions"
+	exit
+fi
+
+mtdparts="512k(nor0.barebox)ro,128k(nor0.bareboxenv),4M(nor0.kernel),-(nor0.root)"
+kernelname="physmap-flash.0"
+
+mtdparts-add -d nor0 -k ${kernelname} -p ${mtdparts}
diff --git a/arch/arm/configs/pcm038_defconfig b/arch/arm/configs/pcm038_defconfig
index 4cb83e5..5ce4f7a 100644
--- a/arch/arm/configs/pcm038_defconfig
+++ b/arch/arm/configs/pcm038_defconfig
@@ -12,21 +12,22 @@ CONFIG_MALLOC_SIZE=0x1000000
 CONFIG_MALLOC_TLSF=y
 CONFIG_KALLSYMS=y
 CONFIG_LONGHELP=y
-CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
+CONFIG_MENU=y
 CONFIG_PARTITION=y
 CONFIG_PARTITION_DISK=y
-CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/pcm038/env"
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
 CONFIG_CMD_SAVEENV=y
-CONFIG_CMD_LOADENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_MEMINFO=y
@@ -54,9 +55,8 @@ CONFIG_CMD_UNCOMPRESS=y
 CONFIG_NET=y
 CONFIG_NET_DHCP=y
 CONFIG_NET_PING=y
-CONFIG_NET_TFTP=y
-CONFIG_NET_TFTP_PUSH=y
 CONFIG_NET_NETCONSOLE=y
+CONFIG_NET_RESOLV=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 CONFIG_NET_USB=y
 CONFIG_NET_USB_ASIX=y
@@ -67,13 +67,13 @@ CONFIG_NAND=y
 # CONFIG_NAND_ECC_SOFT is not set
 # CONFIG_NAND_ECC_HW_SYNDROME is not set
 CONFIG_NAND_IMX=y
-CONFIG_UBI=y
 CONFIG_USB=y
 CONFIG_USB_EHCI=y
 CONFIG_USB_ULPI=y
 CONFIG_VIDEO=y
 CONFIG_DRIVER_VIDEO_IMX=y
 CONFIG_IMXFB_DRIVER_VIDEO_IMX_OVERLAY=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
 CONFIG_ZLIB=y
 CONFIG_LZO_DECOMPRESS=y
-CONFIG_MFD_MC13XXX=y
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index b402677..7905027 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -290,6 +290,7 @@ config MACH_PCM038
 	select SPI
 	select DRIVER_SPI_IMX
 	select MFD_MC13XXX
+	select HAVE_DEFAULT_ENVIRONMENT_NEW
 	help
 	  Say Y here if you are using Phytec's phyCORE-i.MX27 (pcm038) equipped
 	  with a Freescale i.MX27 Processor
-- 
1.7.10


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

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

* Re: [PATCH 2/3] Add next generation default environment template
  2012-05-16  7:04 ` [PATCH 2/3] Add next generation default environment template Sascha Hauer
@ 2012-06-04  8:47   ` Juergen Beisert
  2012-06-24 12:23     ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Juergen Beisert @ 2012-06-04  8:47 UTC (permalink / raw)
  To: barebox

Sascha Hauer wrote:
> [...]
> diff --git a/defaultenv-2/base/init/bootargs-base
> b/defaultenv-2/base/init/bootargs-base new file mode 100644
> index 0000000..8e588ad
> --- /dev/null
> +++ b/defaultenv-2/base/init/bootargs-base
> @@ -0,0 +1,8 @@
> +#!/bin/sh
> +
> +if [ "$1" = menu ]; then
> +       init-menu-add-entry "$0" "Base bootargs"
> +       exit
> +fi
> +
> +global.linux.bootargs.base="console=ttyS0,115200"
> [...]

Seems if you want to change the console setting here, you always have to save 
the change and restart the system to take affect of the new value when 
the 'boot' command is running. Old behaviour was an immediate change without 
saving and restarting. This was a nice behaviour when one just wants to try a 
different parameter without destroying the old environment.

jbe

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

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

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

* Re: [PATCH 2/3] Add next generation default environment template
  2012-06-04  8:47   ` Juergen Beisert
@ 2012-06-24 12:23     ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2012-06-24 12:23 UTC (permalink / raw)
  To: Juergen Beisert; +Cc: barebox

On Mon, Jun 04, 2012 at 10:47:44AM +0200, Juergen Beisert wrote:
> Sascha Hauer wrote:
> > [...]
> > diff --git a/defaultenv-2/base/init/bootargs-base
> > b/defaultenv-2/base/init/bootargs-base new file mode 100644
> > index 0000000..8e588ad
> > --- /dev/null
> > +++ b/defaultenv-2/base/init/bootargs-base
> > @@ -0,0 +1,8 @@
> > +#!/bin/sh
> > +
> > +if [ "$1" = menu ]; then
> > +       init-menu-add-entry "$0" "Base bootargs"
> > +       exit
> > +fi
> > +
> > +global.linux.bootargs.base="console=ttyS0,115200"
> > [...]
> 
> Seems if you want to change the console setting here, you always have to save 
> the change and restart the system to take affect of the new value when 
> the 'boot' command is running. Old behaviour was an immediate change without 
> saving and restarting. This was a nice behaviour when one just wants to try a 
> different parameter without destroying the old environment.

Late response on this one:

You don't have to restart. Instead, you can just overwrite it on the
command line and boot afterwards:

barebox: global.linux.bootargs.base=console=ttymytempconsole0,115200
barebox: boot

Some more background:

The idea is that the bootentries in /env/boot/* can be executed and
setup the boot environment, afterwards you would only run 'bootm'
without additional arguments.

For example you could execute /env/boot/nand-ubi, then your setup would
be:

bootm.image = /dev/nand0.kernel.bb
bootm.oftree =
bootm.initrd =
linux.bootargs.base = console=ttymxc0,115200
linux.bootargs.ip = ip=dhcp
linux.bootargs.root = root=ubi0:root ubi.mtd=nand0.root rootfstype=ubifs
linux.mtdparts.nand0 = mxc_nand:512k(nand0.barebox)ro,128k(nand0.bareboxenv),4M(nand0.kernel),-(nand0.root)
linux.mtdparts.nor0 = physmap-flash.0:512k(nor0.barebox)ro,128k(nor0.bareboxenv),4M(nor0.kernel),-(nor0.root)

If then you want to boot once with a devicetree without permanently
changing you environment, you could do a

barebox: global.bootm.oftree=/whatever/oftree
barebox: bootm


The possibilities are there, maybe the question is how we can simplify
(and document) them so that people are actually aware of what can be
done.

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] 6+ messages in thread

end of thread, other threads:[~2012-06-24 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16  7:04 new default environment Sascha Hauer
2012-05-16  7:04 ` [PATCH 1/3] bootm: Add default images variables Sascha Hauer
2012-05-16  7:04 ` [PATCH 2/3] Add next generation default environment template Sascha Hauer
2012-06-04  8:47   ` Juergen Beisert
2012-06-24 12:23     ` Sascha Hauer
2012-05-16  7:04 ` [PATCH 3/3] ARM pcm038: Switch to new environment Sascha Hauer

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