mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] Auto-append ip= option for NFS boot with appendrot
From: Enrico Jorns @ 2016-09-19 16:03 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich, Gavin Schenk, Enrico Jorns, u.kleine-koenig

This patches allow booting from nfs without the need to additionally provide an
extra ip= option, such as ip=dhcp to the kernel commandline.

This is solved by adding a bootargs property to the network device of the
connection used for the NFS boot and appending this to the nfs bootarg string.

Note that these patches are based on the 'vsprintf: Add support for printing
ipv4 addresses with %pI4' series posted by Sascha.

Enrico Jorns (2):
  net: add linux.bootarg parameter from ifup call
  fs: nfs: pick up network interface bootargs parameter

 fs/nfs.c      |  8 ++++++++
 include/net.h |  1 +
 net/eth.c     |  1 +
 net/ifup.c    | 10 ++++++++++
 4 files changed, 20 insertions(+)

-- 
2.8.1


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

^ permalink raw reply

* Re: [PATCH] mtd: make sure address-cells/size-cells are set when adding partition nodes
From: Uwe Kleine-König @ 2016-09-19 10:55 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox
In-Reply-To: <1473919406-19038-1-git-send-email-m.olbrich@pengutronix.de>

On Thu, Sep 15, 2016 at 08:03:26AM +0200, Michael Olbrich wrote:
> address-cells/size-cells can either be set to 1 or 2 for 32 or 63 bit
s/63/64/ ?

Uwe
> addresses respectively. Barebox currently writes 32 bit addresses.

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

* Re: [PATCH] strings: new command
From: Sam Ravnborg @ 2016-09-19  8:38 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <20160917170731.GA30325@ravnborg.org>

> I was in a situation where I missed "strings".
> So here it is....
> I started out with cat.c - but ended up re-writing everything.
> 
> It has seen light testing on my x86 box.
> Ran it through checkpatch for good measure - fixed a few things.
> 
> The location in Makefile seems random, so I just put it next to cat.
> 
> Before applying please consider if strings is really
> general useful in barebox.

In the end I had no use for strings in barebox, so another reason
to consider if it is really needed.

	Sam

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

^ permalink raw reply

* [PATCH] strings: new command
From: Sam Ravnborg @ 2016-09-17 17:07 UTC (permalink / raw)
  To: Barebox List

From 724382cf9aa173b6ced9fd213bbb369d9a5e3739 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 17 Sep 2016 19:01:15 +0200
Subject: [PATCH 1/1] strings: new command

Implement a simple version of strings that will print
printable strings from one or more files.
Strings shall be at least 4 chars before thay are printed

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---

I was in a situation where I missed "strings".
So here it is....
I started out with cat.c - but ended up re-writing everything.

It has seen light testing on my x86 box.
Ran it through checkpatch for good measure - fixed a few things.

The location in Makefile seems random, so I just put it next to cat.

Before applying please consider if strings is really
general useful in barebox.


	Sam


 commands/Kconfig   |  10 +++++
 commands/Makefile  |   1 +
 commands/strings.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
 create mode 100644 commands/strings.c

diff --git a/commands/Kconfig b/commands/Kconfig
index 30bf429..2f9b5d8 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -993,6 +993,16 @@ config CMD_SHA512SUM
 
 	  Calculate a SHA512 digest over a FILE or a memory area.
 
+config CMD_STRINGS
+	tristate
+	default y
+	prompt "strings"
+	help
+	  Display printable strings in file(s) to stdout
+
+	  Usage: strings FILE...
+
+
 config CMD_UNCOMPRESS
 	bool
 	select UNCOMPRESS
diff --git a/commands/Makefile b/commands/Makefile
index 601f15f..7b11d73 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_CMD_RMDIR)		+= rmdir.o
 obj-$(CONFIG_CMD_CP)		+= cp.o
 obj-$(CONFIG_CMD_RM)		+= rm.o
 obj-$(CONFIG_CMD_CAT)		+= cat.o
+obj-$(CONFIG_CMD_STRINGS)	+= strings.o
 obj-$(CONFIG_CMD_MOUNT)		+= mount.o
 obj-$(CONFIG_CMD_UMOUNT)	+= umount.o
 obj-$(CONFIG_CMD_REGINFO)	+= reginfo.o
diff --git a/commands/strings.c b/commands/strings.c
new file mode 100644
index 0000000..e1e7287
--- /dev/null
+++ b/commands/strings.c
@@ -0,0 +1,121 @@
+/*
+ * strings.c - find strings in a file
+ *
+ * Copyright (c) 2016 Sam Ravnborg <sam@ravnborg.org>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <command.h>
+#include <fs.h>
+
+#include <linux/ctype.h>
+
+#define BUFSIZE    (1024)
+#define STRINGBUF  (1024 - 3)
+#define MIN_STRING 4
+
+/**
+ * @param[in] argc Argument count from command line
+ * @param[in] argv List of input arguments
+ */
+static int do_strings(int argc, char *argv[])
+{
+	char *string;
+	char *buf;
+	int args;
+	int err;
+	int ret;
+	int fd;
+	int i;
+	int s;
+
+	if (argc < 2) {
+		printf("strings: no file specified\n");
+		return 1;
+	}
+
+	buf = xmalloc(BUFSIZE);
+	/* Reserve room for newline + null */
+	string = xmalloc(STRINGBUF + 3);
+
+	args = 1;
+	err = 0;
+	s = 0;
+
+	while (args < argc) {
+		fd = open(argv[args], O_RDONLY);
+		if (fd < 0) {
+			err = 1;
+			printf("could not open %s: %s\n",
+				argv[args], errno_str());
+			goto out;
+		}
+
+		while ((ret = read(fd, buf, BUFSIZE)) > 0) {
+			for (i = 0; i < ret; i++) {
+				int nonprint = 0;
+
+				if (isascii(buf[i]) && isprint(buf[i]))
+					string[s++] = buf[i];
+				else
+					nonprint = 1;
+
+				if (nonprint) {
+					if (s >= MIN_STRING || s >= STRINGBUF) {
+						string[s++] = '\n';
+						string[s++] = '\0';
+						puts(string);
+					}
+
+					s = 0;
+				}
+			}
+
+			if (s >= MIN_STRING) {
+				string[s++] = '\n';
+				string[s++] = '\0';
+				puts(string);
+			}
+			s = 0;
+
+			if (ctrlc()) {
+				err = 1;
+				close(fd);
+				goto out;
+			}
+		}
+
+		close(fd);
+		args++;
+	}
+
+out:
+	free(string);
+	free(buf);
+
+	return err;
+}
+
+BAREBOX_CMD_HELP_START(strings)
+BAREBOX_CMD_HELP_TEXT("Display strings from a file")
+BAREBOX_CMD_HELP_END
+
+BAREBOX_CMD_START(strings)
+	.cmd = do_strings,
+	BAREBOX_CMD_DESC("display strings")
+	BAREBOX_CMD_OPTS("FILE...")
+	BAREBOX_CMD_GROUP(CMD_GRP_FILE)
+	BAREBOX_CMD_HELP(cmd_strings_help)
+BAREBOX_CMD_END
-- 
1.8.3.1


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

^ permalink raw reply related

* Re: [PATCH v2 1/3] state: copy backend of_path string
From: Antony Pavlov @ 2016-09-16  8:12 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox
In-Reply-To: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de>

On Fri, 16 Sep 2016 08:43:38 +0200
Michael Olbrich <m.olbrich@pengutronix.de> wrote:

> Caching pointers to device tree nodes or names is not save. The barebox
                                                        ^^^^ safe?
> internal device tree may be changed by loading a new device tree or through
> fixup handlers. As a result, the string may be deleted.
> Use local copies of the full path instead.
> 
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>

-- 
Best regards,
  Antony Pavlov

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

^ permalink raw reply

* Re: [PATCH] mtd: make sure address-cells/size-cells are set when adding partition nodes
From: Sascha Hauer @ 2016-09-16  8:03 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox
In-Reply-To: <1473919406-19038-1-git-send-email-m.olbrich@pengutronix.de>

On Thu, Sep 15, 2016 at 08:03:26AM +0200, Michael Olbrich wrote:
> address-cells/size-cells can either be set to 1 or 2 for 32 or 63 bit
> addresses respectively. Barebox currently writes 32 bit addresses.
> This makes sure that address-cells/size-cells are both set and have the
> correct value.
> 
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
> 
> Hi,
> 
> this is just a minor fix. What is really needed it support for 64 bit
> addressing.

Looking at the code this is already implemented. It already creates the
reg property using of_write_number() and honouring of_n_addr_cells() /
of_n_size_cells(). This of course only works when the target device tree
already has the #address-cells and #size-cells properties with the
correct values. So instead of just setting them to hardcoded '1' you
should set them to the desired value, the loop below should do the rest
correctly.

> Also, the bindings documentation says that all partitions
> should be in a 'partitions' sub node. The main question here is probably
> which kernel version introduced these features and what should be supported
> by barebox.

The partitions subnode was introduced with 4.4, so we better do not rely
on the kernel being able to handle it.

What we can and probably should do is to look into the target device tree
if it already has a partitions subnode with compatible = "fixed-partitions"
and if does, use it.

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

* Re: [PATCH v2 1/3] state: copy backend of_path string
From: Sascha Hauer @ 2016-09-16  7:47 UTC (permalink / raw)
  To: Michael Olbrich; +Cc: barebox
In-Reply-To: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de>

On Fri, Sep 16, 2016 at 08:43:38AM +0200, Michael Olbrich wrote:
> Caching pointers to device tree nodes or names is not save. The barebox
> internal device tree may be changed by loading a new device tree or through
> fixup handlers. As a result, the string may be deleted.
> Use local copies of the full path instead.
> 
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
> Changes since v1:
> - First patch split into two patches

Applied, thanks

Sascha

> 
>  common/state/backend.c | 3 ++-
>  common/state/state.h   | 2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/common/state/backend.c b/common/state/backend.c
> index 2f2e6dfd32d1..5235bb0283dd 100644
> --- a/common/state/backend.c
> +++ b/common/state/backend.c
> @@ -164,7 +164,7 @@ int state_backend_init(struct state_backend *backend, struct device_d *dev,
>  	if (ret)
>  		goto out_free_format;
>  
> -	backend->of_path = of_path;
> +	backend->of_path = xstrdup(of_path);
>  
>  	return 0;
>  
> @@ -185,4 +185,5 @@ void state_backend_free(struct state_backend *backend)
>  	state_storage_free(&backend->storage);
>  	if (backend->format)
>  		state_format_free(backend->format);
> +	free(backend->of_path);
>  }
> diff --git a/common/state/state.h b/common/state/state.h
> index 32146ca1bbc7..f930d06195b2 100644
> --- a/common/state/state.h
> +++ b/common/state/state.h
> @@ -87,7 +87,7 @@ struct state_backend_storage {
>  struct state_backend {
>  	struct state_backend_format *format;
>  	struct state_backend_storage storage;
> -	const char *of_path;
> +	char *of_path;
>  };
>  
>  struct state {
> -- 
> 2.8.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

* Re: [PATCH 1/3] ARM: imx6: split out IPU QoS setup
From: Sascha Hauer @ 2016-09-16  7:47 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <1473937823-30706-1-git-send-email-l.stach@pengutronix.de>

On Thu, Sep 15, 2016 at 01:10:21PM +0200, Lucas Stach wrote:
> Split into separate function and only call it after the chip type
> and revision is known.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  arch/arm/mach-imx/imx6.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
> index ba8fb8964ac8..07d3f57d8dcc 100644
> --- a/arch/arm/mach-imx/imx6.c
> +++ b/arch/arm/mach-imx/imx6.c
> @@ -31,10 +31,8 @@ void imx6_init_lowlevel(void)
>  {
>  	void __iomem *aips1 = (void *)MX6_AIPS1_ON_BASE_ADDR;
>  	void __iomem *aips2 = (void *)MX6_AIPS2_ON_BASE_ADDR;
> -	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
>  	bool is_imx6q = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6Q;
>  	bool is_imx6d = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6D;
> -	uint32_t val;
>  
>  	/*
>  	 * Set all MPROTx to be non-bufferable, trusted for R/W,
> @@ -94,6 +92,13 @@ void imx6_init_lowlevel(void)
>  		       MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_CLR);
>  	}
>  
> +}
> +
> +void imx6_setup_ipu_qos(void)
> +{
> +	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
> +	uint32_t val;
> +
>  	val = readl(iomux + IOMUXC_GPR4);
>  	val |= IMX6Q_GPR4_VPU_WR_CACHE_SEL | IMX6Q_GPR4_VPU_RD_CACHE_SEL |
>  		IMX6Q_GPR4_VPU_P_WR_CACHE_VAL | IMX6Q_GPR4_VPU_P_RD_CACHE_VAL_MASK |
> @@ -186,6 +191,8 @@ int imx6_init(void)
>  
>  	imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
>  
> +	imx6_setup_ipu_qos();
> +
>  	return 0;
>  }
>  
> -- 
> 2.8.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

* Re: [PATCH] commands: exit on invalid option
From: Sascha Hauer @ 2016-09-16  7:37 UTC (permalink / raw)
  To: Enrico Jorns; +Cc: barebox
In-Reply-To: <1473675656-23309-1-git-send-email-ejo@pengutronix.de>

On Mon, Sep 12, 2016 at 12:20:56PM +0200, Enrico Jorns wrote:
> Barebox commands should not perform any action and return 0 if an
> invalid parameter was given. This might cause undetected unintended
> behvaior when calling commands with wrong options, either manually or
> from a script.
> 
> Signed-off-by: Enrico Jorns <ejo@pengutronix.de>

Applied, thanks

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

* Re: [PATCH 0/4] Some updates for arm/mvebu
From: Sascha Hauer @ 2016-09-16  7:35 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Thomas Petazzoni, barebox, Ezequiel Garcia
In-Reply-To: <1473935897-9252-1-git-send-email-u.kleine-koenig@pengutronix.de>

On Thu, Sep 15, 2016 at 12:38:13PM +0200, Uwe Kleine-König wrote:
> Hello,
> 
> these are the first few patches I did while creating a port for a Netgear
> RN2120.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (4):
>   ARM: mvebu_defconfig: oldconfig
>   ARM: mvebu_defconfig: enable all machines, AEABI, nand and net driver
>   ARM: mvebu: select HAVE_DEFAULT_ENVIRONMENT_NEW
>   net: mvneta: clean txdesc before usage
> 
>  arch/arm/Kconfig                 |  1 +
>  arch/arm/configs/mvebu_defconfig | 18 ++++++++++++------
>  drivers/net/mvneta.c             |  1 +
>  3 files changed, 14 insertions(+), 6 deletions(-)

Applied, thanks

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

* [PATCH v2 2/3] state: don't keep pointers to device tree nodes
From: Michael Olbrich @ 2016-09-16  6:43 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich
In-Reply-To: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de>

Caching pointers to device tree nodes or is not save. The barebox internal
device tree may be changed by loading a new device tree or through fixup
handlers. As a result, the node may be deleted and replaced with a new one.
Keep a copy of the full path instead and resolve the node as needed.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
Changes since v1:
- First patch split into two patches

 common/state/state.c | 19 ++++++++++++-------
 common/state/state.h |  2 +-
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/common/state/state.c b/common/state/state.c
index 9b1d4edef132..0c329cd67548 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -202,15 +202,19 @@ struct device_node *state_to_node(struct state *state,
 				  enum state_convert conv)
 {
 	struct device_node *child;
-	struct device_node *root;
+	struct device_node *root, *state_root;
 	int ret;
 
-	root = of_new_node(parent, state->root->name);
+	state_root = of_find_node_by_path(state->of_path);
+	if (!state_root)
+		return ERR_PTR(-ENODEV);
+
+	root = of_new_node(parent, state_root->name);
 	ret = of_property_write_u32(root, "magic", state->magic);
 	if (ret)
 		goto out;
 
-	for_each_child_of_node(state->root, child) {
+	for_each_child_of_node(state_root, child) {
 		ret = state_convert_node_variable(state, child, root, "", conv);
 		if (ret)
 			goto out;
@@ -234,7 +238,7 @@ int state_from_node(struct state *state, struct device_node *node, bool create)
 
 	if (create) {
 		conv = STATE_CONVERT_FROM_NODE_CREATE;
-		state->root = node;
+		state->of_path = xstrdup(node->full_name);
 		state->magic = magic;
 	} else {
 		conv = STATE_CONVERT_FROM_NODE;
@@ -291,7 +295,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 	int ret;
 	phandle phandle;
 
-	node = of_find_node_by_path_from(root, state->root->full_name);
+	node = of_find_node_by_path_from(root, state->of_path);
 	if (node) {
 		/* replace existing node - it will be deleted later */
 		parent = node->parent;
@@ -299,7 +303,7 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 		char *of_path, *c;
 
 		/* look for parent, remove last '/' from path */
-		of_path = xstrdup(state->root->full_name);
+		of_path = xstrdup(state->of_path);
 		c = strrchr(of_path, '/');
 		if (!c)
 			return -ENODEV;
@@ -406,6 +410,7 @@ void state_release(struct state *state)
 	list_del(&state->list);
 	unregister_device(&state->dev);
 	state_backend_free(&state->backend);
+	free(state->of_path);
 	free(state);
 }
 
@@ -545,7 +550,7 @@ struct state *state_by_node(const struct device_node *node)
 	struct state *state;
 
 	list_for_each_entry(state, &state_list, list) {
-		if (state->root == node)
+		if (!strcmp(state->of_path, node->full_name))
 			return state;
 	}
 
diff --git a/common/state/state.h b/common/state/state.h
index f930d06195b2..7b3e49512e37 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -94,7 +94,7 @@ struct state {
 	struct list_head list; /* Entry to enqueue on list of states */
 
 	struct device_d dev;
-	struct device_node *root;
+	char *of_path;
 	const char *name;
 	uint32_t magic;
 
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH v2 3/3] state: fix finding the correct parent node
From: Michael Olbrich @ 2016-09-16  6:43 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich
In-Reply-To: <1474008220-7601-1-git-send-email-m.olbrich@pengutronix.de>

Looking for the parent node during fixup is broken. The path of the parent
node is not correctly terminated ('0' vs '\0'). Also, the new state node
should be added to the supplied device tree not the barebox device tree
used by of_find_node_by_path().

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 common/state/state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/state/state.c b/common/state/state.c
index 0c329cd67548..075618e5bb8f 100644
--- a/common/state/state.c
+++ b/common/state/state.c
@@ -307,8 +307,8 @@ static int of_state_fixup(struct device_node *root, void *ctx)
 		c = strrchr(of_path, '/');
 		if (!c)
 			return -ENODEV;
-		*c = '0';
-		parent = of_find_node_by_path(of_path);
+		*c = '\0';
+		parent = of_find_node_by_path_from(root, of_path);
 		if (!parent)
 			parent = root;
 
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH v2 1/3] state: copy backend of_path string
From: Michael Olbrich @ 2016-09-16  6:43 UTC (permalink / raw)
  To: barebox; +Cc: Michael Olbrich

Caching pointers to device tree nodes or names is not save. The barebox
internal device tree may be changed by loading a new device tree or through
fixup handlers. As a result, the string may be deleted.
Use local copies of the full path instead.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
Changes since v1:
- First patch split into two patches

 common/state/backend.c | 3 ++-
 common/state/state.h   | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/state/backend.c b/common/state/backend.c
index 2f2e6dfd32d1..5235bb0283dd 100644
--- a/common/state/backend.c
+++ b/common/state/backend.c
@@ -164,7 +164,7 @@ int state_backend_init(struct state_backend *backend, struct device_d *dev,
 	if (ret)
 		goto out_free_format;
 
-	backend->of_path = of_path;
+	backend->of_path = xstrdup(of_path);
 
 	return 0;
 
@@ -185,4 +185,5 @@ void state_backend_free(struct state_backend *backend)
 	state_storage_free(&backend->storage);
 	if (backend->format)
 		state_format_free(backend->format);
+	free(backend->of_path);
 }
diff --git a/common/state/state.h b/common/state/state.h
index 32146ca1bbc7..f930d06195b2 100644
--- a/common/state/state.h
+++ b/common/state/state.h
@@ -87,7 +87,7 @@ struct state_backend_storage {
 struct state_backend {
 	struct state_backend_format *format;
 	struct state_backend_storage storage;
-	const char *of_path;
+	char *of_path;
 };
 
 struct state {
-- 
2.8.1


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

^ permalink raw reply related

* Aw: Re: Re: errors copying UBI volumes
From: iw3gtf @ 2016-09-15 11:57 UTC (permalink / raw)
  To: s.hauer; +Cc: barebox
In-Reply-To: <20160915114401.z5tdaxcb6eesv3qn@pengutronix.de>

Hi,

> On Thu, Sep 15, 2016 at 01:13:14PM +0200, iw3gtf@arcor.de wrote:
> > Hi Sascha,
> > 
> > thanks for the answer,
> > 
> > > Hi Giorgio,
> > > 
> > > On Wed, Sep 14, 2016 at 05:52:32PM +0200, iw3gtf@arcor.de wrote:
> > > > Hi,
> > > > 
> > > > I'm working on an embedded board with an iMX25 arm CPU and a nand
> flash.
> > > > 
> > > > The board runs a linux kernel/userland.
> > > > 
> > > > When the user updates the firmware, the running userland/kernel
> creates
> > > some
> > > > new ubi volumes on the nand, let's say 'kernel_next' and
> 'userland_next'.
> > > > On the next system reboot barebox looks if it finds, lets say, the
> > > 'kernel_next' volume
> > > > and, in this case, it removes the old one ('kernel'), creates a new,
> empty
> > > one ('kernel'),
> > > > copies 'kernel_next' to the just created 'kernel' and finally removes
> the
> > > 'kernel_next'
> > > > to complete the update.
> > > 
> > > While this should work, why so complicated? Since this commit:
> > > 
> > > | commit 892abde56c1c5a62d49d8b70c73e5d388e74345d
> > > | Author: Richard Weinberger <richard@nod.at>
> > > | Date:   Mon Nov 24 22:30:10 2014 +0100
> > > |
> > > |    UBI: rename_volumes: Use UBI_METAONLY
> > > |    
> > > |    By using UBI_METAONLY in rename_volumes() it is now possible to
> rename
> > > |    an UBI volume atomically while it is open for writing.
> > > |    This is useful for firmware upgrades.
> > > 
> > > It should be possible to just remove 'kernel' and rename 'kernel_next'
> to
> > > 'kernel'
> > > without bootloader intervention.
> > 
> > This is a very good news for me, I already wanted to ask for a UBI rename
> feature.
> > Could you please elaborate a bit on this point: I looked for a shell
> command like the
> > 'ubirename', present in the 'mtd-utils' package, but could not find it.
> Maybe we just
> > need a new command implemented in '<barebox_root>/commands/ubi.c'.
> 
> You can add a ubirename command, patches welcome. Anyway, I suggested to
> rename it under Linux since you write your new Kernel/rootfs under Linux
> aswell.
> 

OK, I think I'll try to write a new command in commands/ubi.c and if it
results in something usable I'll send a patch to be reviewed.

giorgio


Giorgio, iw3gtf@arcor.de

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

^ permalink raw reply

* Re: Re: errors copying UBI volumes
From: Sascha Hauer @ 2016-09-15 11:44 UTC (permalink / raw)
  To: iw3gtf; +Cc: barebox
In-Reply-To: <247915608.359799.1473937994666.JavaMail.ngmail@webmail18.arcor-online.net>

On Thu, Sep 15, 2016 at 01:13:14PM +0200, iw3gtf@arcor.de wrote:
> Hi Sascha,
> 
> thanks for the answer,
> 
> > Hi Giorgio,
> > 
> > On Wed, Sep 14, 2016 at 05:52:32PM +0200, iw3gtf@arcor.de wrote:
> > > Hi,
> > > 
> > > I'm working on an embedded board with an iMX25 arm CPU and a nand flash.
> > > 
> > > The board runs a linux kernel/userland.
> > > 
> > > When the user updates the firmware, the running userland/kernel creates
> > some
> > > new ubi volumes on the nand, let's say 'kernel_next' and 'userland_next'.
> > > On the next system reboot barebox looks if it finds, lets say, the
> > 'kernel_next' volume
> > > and, in this case, it removes the old one ('kernel'), creates a new, empty
> > one ('kernel'),
> > > copies 'kernel_next' to the just created 'kernel' and finally removes the
> > 'kernel_next'
> > > to complete the update.
> > 
> > While this should work, why so complicated? Since this commit:
> > 
> > | commit 892abde56c1c5a62d49d8b70c73e5d388e74345d
> > | Author: Richard Weinberger <richard@nod.at>
> > | Date:   Mon Nov 24 22:30:10 2014 +0100
> > |
> > |    UBI: rename_volumes: Use UBI_METAONLY
> > |    
> > |    By using UBI_METAONLY in rename_volumes() it is now possible to rename
> > |    an UBI volume atomically while it is open for writing.
> > |    This is useful for firmware upgrades.
> > 
> > It should be possible to just remove 'kernel' and rename 'kernel_next' to
> > 'kernel'
> > without bootloader intervention.
> 
> This is a very good news for me, I already wanted to ask for a UBI rename feature.
> Could you please elaborate a bit on this point: I looked for a shell command like the
> 'ubirename', present in the 'mtd-utils' package, but could not find it. Maybe we just
> need a new command implemented in '<barebox_root>/commands/ubi.c'.

You can add a ubirename command, patches welcome. Anyway, I suggested to
rename it under Linux since you write your new Kernel/rootfs under Linux
aswell.

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

* Aw: Re: errors copying UBI volumes
From: iw3gtf @ 2016-09-15 11:13 UTC (permalink / raw)
  To: s.hauer, iw3gtf; +Cc: barebox

Hi Sascha,

thanks for the answer,

> Hi Giorgio,
> 
> On Wed, Sep 14, 2016 at 05:52:32PM +0200, iw3gtf@arcor.de wrote:
> > Hi,
> > 
> > I'm working on an embedded board with an iMX25 arm CPU and a nand flash.
> > 
> > The board runs a linux kernel/userland.
> > 
> > When the user updates the firmware, the running userland/kernel creates
> some
> > new ubi volumes on the nand, let's say 'kernel_next' and 'userland_next'.
> > On the next system reboot barebox looks if it finds, lets say, the
> 'kernel_next' volume
> > and, in this case, it removes the old one ('kernel'), creates a new, empty
> one ('kernel'),
> > copies 'kernel_next' to the just created 'kernel' and finally removes the
> 'kernel_next'
> > to complete the update.
> 
> While this should work, why so complicated? Since this commit:
> 
> | commit 892abde56c1c5a62d49d8b70c73e5d388e74345d
> | Author: Richard Weinberger <richard@nod.at>
> | Date:   Mon Nov 24 22:30:10 2014 +0100
> |
> |    UBI: rename_volumes: Use UBI_METAONLY
> |    
> |    By using UBI_METAONLY in rename_volumes() it is now possible to rename
> |    an UBI volume atomically while it is open for writing.
> |    This is useful for firmware upgrades.
> 
> It should be possible to just remove 'kernel' and rename 'kernel_next' to
> 'kernel'
> without bootloader intervention.

This is a very good news for me, I already wanted to ask for a UBI rename feature.
Could you please elaborate a bit on this point: I looked for a shell command like the
'ubirename', present in the 'mtd-utils' package, but could not find it. Maybe we just
need a new command implemented in '<barebox_root>/commands/ubi.c'.

> 
> BTW you should consider using Bootloader Spec entries
> (http://www.barebox.org/doc/latest/user/booting-linux.html#bootloader-spec).
> 
> This makes the kernel volume unnecessary and the kernel will only be a file
> in UBIFS and thus updating is a matter of 'cp newkernel /boot/kernel'.
> Also booting in barebox becomes as simple as 'boot nand0.ubi.rootfs', no
> further configuration or scripting required.
> 

thank you for the suggestion, I'll have a look at the method.

> > 
> > Here the relevant part of the init script:
> > 
> > ...
> > 	if [ -e $kernel_next ]; then
> > 		echo "Update the kernel... "
> > 		ubirmvol $ubi_root kernel
> > 		ubimkvol $ubi_root kernel 8M
> > 		cp $kernel_next $kernel
> > 		if [ $? != 0 ]; then
> > 			echo "***Errors copying $kernel_next to $kernel"
> > 			sleep 2
> > 		else
> > 			echo "Update OK."
> > 			ubirmvol $ubi_root kernel_next
> > 		fi
> > 	fi
> > ...
> > 
> > Now, after updating the barebox version to the current one, v2016.09.0,
> the 'cp' command
> > produces an almost endless sequence of failed assertions and stask
> backtraces:
> > 
> > ...
> > UBI assert failed in ubi_eba_read_leb at 359
> > Function entered at [<87053010>] from [<87018ce0>]
> > Function entered at [<87018ce0>] from [<87017fb4>]
> > Function entered at [<87017fb4>] from [<8703f100>]
> > Function entered at [<8703f100>] from [<8703f2cc>]
> > Function entered at [<8703f2cc>] from [<8703faf8>]
> > Function entered at [<8703faf8>] from [<87039e78>]
> > Function entered at [<87039e78>] from [<87029178>]
> > Function entered at [<87029178>] from [<87003614>]
> > Function entered at [<87003614>] from [<87008e0c>]
> > Function entered at [<87008e0c>] from [<870083a0>]
> > Function entered at [<870083a0>] from [<8700908c>]
> > Function entered at [<8700908c>] from [<870011cc>]
> > Function entered at [<870011cc>] from [<870515d4>]
> > Function entered at [<870515d4>] from [<80052648>]
> > UBI assert failed in ubi_eba_read_leb at 359
> > Function entered at [<87053010>] from [<87018ce0>]
> > Function entered at [<87018ce0>] from [<87017fb4>]
> > Function entered at [<87017fb4>] from [<8703f100>]
> > Function entered at [<8703f100>] from [<8703f2cc>]
> > Function entered at [<8703f2cc>] from [<8703faf8>]
> > Function entered at [<8703faf8>] from [<87039e78>]
> > ...
> 
> Please enable KALLSYMS to make this readable.
> 
> > 
> > After trying different things I realized that 'cp' has problems
> > only with UBI volumes that were created by the kernel/userland
> > during the firmware update process; if I create a volume within
> > barebox it just work as expected.
> > 
> > Here is the source code snippet with the failing assertion:
> > (file <barebox_root>/drivers/mtd/ubi/eba.c)
> > 
> > int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int
> lnum,
> > 		     void *buf, int offset, int len, int check)
> > {
> > ...
> > 	pnum = vol->eba_tbl[lnum];
> > 	if (pnum < 0) {
> > 		/*
> > 		 * The logical eraseblock is not mapped, fill the whole buffer
> > 		 * with 0xFF bytes. The exception is static volumes for which
> > 		 * it is an error to read unmapped logical eraseblocks.
> > 		 */
> > 		dbg_eba("read %d bytes from offset %d of LEB %d:%d (unmapped)",
> > 			len, offset, vol_id, lnum);
> > 		leb_read_unlock(ubi, vol_id, lnum);
> > 		ubi_assert(vol->vol_type != UBI_STATIC_VOLUME);
> > 		memset(buf, 0xFF, len);
> > 		return 0;
> > 	}
> 
> Have you created 'kernel_next' and/or 'userland_next' as static volume
> (-t=static)? The comment above states that in static volumes you cannot
> read unmapped logical eraseblocks. When wou do not completely fill
> 'kernel_next' with data then you can only read up to the point to which
> it is filled, the remaining LEBs are unmapped and thus unreadable.
> Note that when you hit the unmapped LEBs then you have already read all
> data; the errors only occur on the free space. This is the reason you
> can still boot the new system.
> 

yes, this is the right explanation for what happens on my system.
My userland creates static '*_next' volumes and their size is rounded up
to the next Mb so at the end it will almost always remain some empty/unmapped
LEBs.

The current barebox version just bark a bit louder about it and the 'cp' command
returns with an error making my whole update process fail.

If I had an 'ubirename' command all my problems would be solved.

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

giorgio


Giorgio, iw3gtf@arcor.de

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

^ permalink raw reply

* [PATCH 3/3] ARM: imx6qp: set NoC regulator to bypass
From: Lucas Stach @ 2016-09-15 11:10 UTC (permalink / raw)
  To: barebox
In-Reply-To: <1473937823-30706-1-git-send-email-l.stach@pengutronix.de>

The NoC regulator only passes the QoS signals through if it is
in bypass mode. This is a safe setting to give the IPU priority
over other requests. The kernel may change it to some other setting
once it knows the bandwidth requirements of the use-case.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c                   | 11 +++++++++++
 arch/arm/mach-imx/include/mach/imx6-regs.h |  3 +++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index 567559033770..f90eec8bd2c8 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -97,6 +97,7 @@ void imx6_init_lowlevel(void)
 void imx6_setup_ipu_qos(void)
 {
 	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
+	void __iomem *fast2 = (void *)MX6_FAST2_BASE_ADDR;
 	uint32_t val;
 
 	if (!cpu_mx6_is_mx6q() && !cpu_mx6_is_mx6d() &&
@@ -119,6 +120,16 @@ void imx6_setup_ipu_qos(void)
 	val &= ~(IMX6Q_GPR7_IPU2_ID00_RD_QOS_MASK | IMX6Q_GPR7_IPU2_ID01_RD_QOS_MASK);
 	val |= (0xf << 16) | (0x7 << 20);
 	writel(val, iomux + IOMUXC_GPR7);
+
+	/*
+	 * On i.MX6 QP/DP the NoC regulator for the IPU ports needs to be in
+	 * bypass mode for the above settings to take effect.
+	 */
+	if ((cpu_mx6_is_mx6q() || cpu_mx6_is_mx6d()) &&
+	    imx_silicon_revision() >= IMX_CHIP_REV_2_0) {
+		writel(0x2, fast2 + 0xb048c);
+		writel(0x2, fast2 + 0xb050c);
+	}
 }
 
 int imx6_init(void)
diff --git a/arch/arm/mach-imx/include/mach/imx6-regs.h b/arch/arm/mach-imx/include/mach/imx6-regs.h
index 68be43c9ab5b..e661c4ed120b 100644
--- a/arch/arm/mach-imx/include/mach/imx6-regs.h
+++ b/arch/arm/mach-imx/include/mach/imx6-regs.h
@@ -3,6 +3,9 @@
 
 #define MX6_GPMI_BASE_ADDR		0x00112000
 
+#define MX6_FAST1_BASE_ADDR		0x00c00000
+#define MX6_FAST2_BASE_ADDR		0x00b00000
+
 #define MX6_AIPS1_ARB_BASE_ADDR		0x02000000
 #define MX6_AIPS2_ARB_BASE_ADDR		0x02100000
 
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 2/3] ARM: imx6: don't execute IPU QoS setup on MX6 SX/SL
From: Lucas Stach @ 2016-09-15 11:10 UTC (permalink / raw)
  To: barebox
In-Reply-To: <1473937823-30706-1-git-send-email-l.stach@pengutronix.de>

SX and SL variants only include the PXP and have no IPU, so
skip any IPU related QoS setup.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index 07d3f57d8dcc..567559033770 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -99,6 +99,10 @@ void imx6_setup_ipu_qos(void)
 	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
 	uint32_t val;
 
+	if (!cpu_mx6_is_mx6q() && !cpu_mx6_is_mx6d() &&
+	    !cpu_mx6_is_mx6dl() && cpu_mx6_is_mx6s())
+		return;
+
 	val = readl(iomux + IOMUXC_GPR4);
 	val |= IMX6Q_GPR4_VPU_WR_CACHE_SEL | IMX6Q_GPR4_VPU_RD_CACHE_SEL |
 		IMX6Q_GPR4_VPU_P_WR_CACHE_VAL | IMX6Q_GPR4_VPU_P_RD_CACHE_VAL_MASK |
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 1/3] ARM: imx6: split out IPU QoS setup
From: Lucas Stach @ 2016-09-15 11:10 UTC (permalink / raw)
  To: barebox

Split into separate function and only call it after the chip type
and revision is known.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index ba8fb8964ac8..07d3f57d8dcc 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -31,10 +31,8 @@ void imx6_init_lowlevel(void)
 {
 	void __iomem *aips1 = (void *)MX6_AIPS1_ON_BASE_ADDR;
 	void __iomem *aips2 = (void *)MX6_AIPS2_ON_BASE_ADDR;
-	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
 	bool is_imx6q = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6Q;
 	bool is_imx6d = __imx6_cpu_type() == IMX6_CPUTYPE_IMX6D;
-	uint32_t val;
 
 	/*
 	 * Set all MPROTx to be non-bufferable, trusted for R/W,
@@ -94,6 +92,13 @@ void imx6_init_lowlevel(void)
 		       MX6_ANATOP_BASE_ADDR + HW_ANADIG_PFD_528_CLR);
 	}
 
+}
+
+void imx6_setup_ipu_qos(void)
+{
+	void __iomem *iomux = (void *)MX6_IOMUXC_BASE_ADDR;
+	uint32_t val;
+
 	val = readl(iomux + IOMUXC_GPR4);
 	val |= IMX6Q_GPR4_VPU_WR_CACHE_SEL | IMX6Q_GPR4_VPU_RD_CACHE_SEL |
 		IMX6Q_GPR4_VPU_P_WR_CACHE_VAL | IMX6Q_GPR4_VPU_P_RD_CACHE_VAL_MASK |
@@ -186,6 +191,8 @@ int imx6_init(void)
 
 	imx_set_silicon_revision(cputypestr, mx6_silicon_revision);
 
+	imx6_setup_ipu_qos();
+
 	return 0;
 }
 
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 2/2] convert users to %pI4
From: Sascha Hauer @ 2016-09-15 10:52 UTC (permalink / raw)
  To: Barebox List
In-Reply-To: <1473936737-4919-1-git-send-email-s.hauer@pengutronix.de>

Convert users of ip_to_string() and print_IPaddr() to %pI4 and
remove the now unused functions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-omap/xload.c |  9 ++++++---
 commands/tftp.c            |  4 +++-
 common/blspec.c            |  2 +-
 fs/nfs.c                   |  4 +---
 include/net.h              |  6 ------
 lib/parameter.c            |  2 +-
 net/dhcp.c                 |  6 +++---
 net/dns.c                  |  6 ++----
 net/lib.c                  | 19 -------------------
 net/net.c                  |  4 ++--
 net/netconsole.c           |  2 +-
 11 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
index 14a631e..822389c 100644
--- a/arch/arm/mach-omap/xload.c
+++ b/arch/arm/mach-omap/xload.c
@@ -231,8 +231,10 @@ static void *am33xx_net_boot(void)
 	int err;
 	int len;
 	struct dhcp_req_param dhcp_param;
-	const char *bootfile, *ip;
+	const char *bootfile;
+	IPaddr_t ip;
 	char *file;
+	char ip4_str[sizeof("255.255.255.255")];
 
 	am33xx_register_ethaddr(0, 0);
 
@@ -258,8 +260,9 @@ static void *am33xx_net_boot(void)
 	if (err)
 		return NULL;
 
-	ip = ip_to_string(net_get_serverip());
-	err = mount(ip, "tftp", TFTP_MOUNT, NULL);
+	ip = net_get_serverip();
+	sprintf(ip4_str, "%pI4", &ip);
+	err = mount(ip4_str, "tftp", TFTP_MOUNT, NULL);
 	if (err < 0) {
 		printf("Unable to mount.\n");
 		return NULL;
diff --git a/commands/tftp.c b/commands/tftp.c
index 6a3121a..08366b4 100644
--- a/commands/tftp.c
+++ b/commands/tftp.c
@@ -36,6 +36,7 @@ static int do_tftpb(int argc, char *argv[])
 	int tftp_push = 0;
 	int ret;
 	IPaddr_t ip;
+	char ip4_str[sizeof("255.255.255.255")];
 
 	while ((opt = getopt(argc, argv, "p")) > 0) {
 		switch(opt) {
@@ -73,7 +74,8 @@ static int do_tftpb(int argc, char *argv[])
 		goto err_free;
 
 	ip = net_get_serverip();
-	ret = mount(ip_to_string(ip), "tftp", TFTP_MOUNT_PATH, NULL);
+	sprintf(ip4_str, "%pI4", &ip);
+	ret = mount(ip4_str, "tftp", TFTP_MOUNT_PATH, NULL);
 	if (ret)
 		goto err_rmdir;
 
diff --git a/common/blspec.c b/common/blspec.c
index f02f5e9..b45bd29 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -306,7 +306,7 @@ static char *parse_nfs_url(const char *url)
 	if (ip == 0)
 		goto out;
 
-	hostpath = basprintf("%s:%s", ip_to_string(ip), path);
+	hostpath = basprintf("%pI4:%s", &ip, path);
 
 	prevpath = nfs_find_mountpath(hostpath);
 
diff --git a/fs/nfs.c b/fs/nfs.c
index 1e874d5..a0a9dfc 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -1314,10 +1314,8 @@ static char *rootnfsopts;
 static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
 {
 	char *str, *tmp;
-	const char *ip;
 
-	ip = ip_to_string(npriv->server);
-	str = basprintf("root=/dev/nfs nfsroot=%s:%s%s%s", ip, npriv->path,
+	str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path,
 			  rootnfsopts[0] ? "," : "", rootnfsopts);
 
 	/* forward specific mount options on demand */
diff --git a/include/net.h b/include/net.h
index 8f857c8..fd1c412 100644
--- a/include/net.h
+++ b/include/net.h
@@ -257,9 +257,6 @@ static inline int net_eth_to_udplen(char *pkt)
 int net_checksum_ok(unsigned char *, int);	/* Return true if cksum OK	*/
 uint16_t net_checksum(unsigned char *, int);	/* Calculate the checksum	*/
 
-/* Print an IP address on the console */
-void print_IPaddr (IPaddr_t);
-
 /*
  * The following functions are a bit ugly, but necessary to deal with
  * alignment restrictions on ARM.
@@ -308,9 +305,6 @@ static inline void net_copy_uint32(uint32_t *to, uint32_t *from)
 	memcpy(to, from, sizeof(uint32_t));
 }
 
-/* Convert an IP address to a string */
-char *ip_to_string (IPaddr_t x);
-
 /* Convert a string to ip address */
 int string_to_ip(const char *s, IPaddr_t *ip);
 
diff --git a/lib/parameter.c b/lib/parameter.c
index 656a603..a754fb8 100644
--- a/lib/parameter.c
+++ b/lib/parameter.c
@@ -642,7 +642,7 @@ static const char *param_ip_get(struct device_d *dev, struct param_d *p)
 	}
 
 	free(p->value);
-	p->value = xstrdup(ip_to_string(*pi->ip));
+	p->value = xasprintf("%pI4", pi->ip);
 
 	return p->value;
 }
diff --git a/net/dhcp.c b/net/dhcp.c
index 792ece4..c5386fe 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -613,13 +613,13 @@ static void dhcp_handler(void *ctx, char *packet, unsigned int len)
 		debug ("%s: State REQUESTING\n", __func__);
 
 		if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK ) {
+			IPaddr_t ip;
 			if (net_read_uint32((uint32_t *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
 				dhcp_options_process((u8 *)&bp->bp_vend[4], bp);
 			bootp_copy_net_params(bp); /* Store net params from reply */
 			dhcp_state = BOUND;
-			puts ("DHCP client bound to address ");
-			print_IPaddr(net_get_ip());
-			putchar('\n');
+			ip = net_get_ip();
+			printf("DHCP client bound to address %pI4\n", &ip);
 			return;
 		}
 		break;
diff --git a/net/dns.c b/net/dns.c
index 2acdb93..700c6b0 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -221,7 +221,7 @@ IPaddr_t resolv(const char *host)
 	if (string_to_ip(ns, &ip))
 		return 0;
 
-	debug("resolving host %s via nameserver %s\n", host, ip_to_string(ip));
+	debug("resolving host %s via nameserver %pI4\n", host, &ip);
 
 	dns_con = net_udp_new(ip, DNS_PORT, dns_handler, NULL);
 	if (IS_ERR(dns_con))
@@ -258,9 +258,7 @@ static int do_host(int argc, char *argv[])
 	if (!ip)
 		printf("unknown host %s\n", argv[1]);
 	else {
-		printf("%s is at ", argv[1]);
-		print_IPaddr(ip);
-		printf("\n");
+		printf("%s is at %pI4\n", argv[1], &ip);
 	}
 
 	return 0;
diff --git a/net/lib.c b/net/lib.c
index f1c60c9..d4343bc 100644
--- a/net/lib.c
+++ b/net/lib.c
@@ -57,25 +57,6 @@ void ethaddr_to_string(const u8 enetaddr[6], char *str)
 		 enetaddr[4], enetaddr[5]);
 }
 
-void print_IPaddr(IPaddr_t x)
-{
-	puts(ip_to_string(x));
-}
-
-char *ip_to_string(IPaddr_t x)
-{
-	static char s[sizeof("xxx.xxx.xxx.xxx")];
-
-	x = ntohl(x);
-	sprintf(s, "%d.%d.%d.%d",
-		 (int) ((x >> 24) & 0xff),
-		 (int) ((x >> 16) & 0xff),
-		 (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
-	);
-
-	return s;
-}
-
 int string_to_ip(const char *s, IPaddr_t *ip)
 {
 	IPaddr_t addr = 0;
diff --git a/net/net.c b/net/net.c
index df1d677..3c0e715 100644
--- a/net/net.c
+++ b/net/net.c
@@ -78,9 +78,9 @@ IPaddr_t getenv_ip(const char *name)
 
 int setenv_ip(const char *name, IPaddr_t ip)
 {
-	const char *str;
+	char str[sizeof("255.255.255.255")];
 
-	str = ip_to_string(ip);
+	sprintf(str, "%pI4", &ip);
 
 	setenv(name, str);
 
diff --git a/net/netconsole.c b/net/netconsole.c
index 0ee6a76..ce3c418 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -137,7 +137,7 @@ static int nc_set_active(struct console_device *cdev, unsigned flags)
 
 	net_udp_bind(priv->con, priv->port);
 
-	pr_info("netconsole initialized with %s:%d\n", ip_to_string(priv->ip), priv->port);
+	pr_info("netconsole initialized with %pI4:%d\n", &priv->ip, priv->port);
 
 	return 0;
 }
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 1/2] vsprintf: Add support for printing ipv4 addresses with %pI4
From: Sascha Hauer @ 2016-09-15 10:52 UTC (permalink / raw)
  To: Barebox List

Can be used conveniently in places that currently use ip_to_string().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 lib/vsprintf.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index f3885a8..fa9fb75 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -191,6 +191,27 @@ static char *symbol_string(char *buf, char *end, void *ptr, int field_width, int
 }
 
 static noinline_for_stack
+char *ip4_addr_string(char *buf, char *end, const u8 *addr, int field_width,
+		      int precision, int flags, const char *fmt)
+{
+	char ip4_addr[sizeof("255.255.255.255")];
+	char *pos;
+	int i;
+
+	pos = ip4_addr;
+
+	for (i = 0; i < 4; i++) {
+		pos = number(pos, pos + 3, addr[i], 10, 0, 0, LEFT);
+		if (i < 3)
+			*pos++ = '.';
+	}
+
+	*pos = 0;
+
+	return string(buf, end, ip4_addr, field_width, precision, flags);
+}
+
+static noinline_for_stack
 char *uuid_string(char *buf, char *end, const u8 *addr, int field_width,
 		int precision, int flags, const char *fmt)
 {
@@ -267,6 +288,8 @@ char *address_val(char *buf, char *end, const void *addr,
  *
  * Right now we handle:
  *
+ * - 'I' [4] for IPv4 addresses printed in the usual way
+ *       IPv4 uses dot-separated decimal without leading 0's (1.2.3.4)
  * - 'S' For symbolic direct pointers
  * - 'U' For a 16 byte UUID/GUID, it prints the UUID/GUID in the form
  *       "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
@@ -297,6 +320,12 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field
 		break;
 	case 'a':
 		return address_val(buf, end, ptr, field_width, precision, flags, fmt);
+	case 'I':
+		switch (fmt[1]) {
+		case '4':
+                        return ip4_addr_string(buf, end, ptr, field_width, precision, flags, fmt);
+		}
+		break;
 	}
 	flags |= SMALL;
 	if (field_width == -1) {
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 0/4] Some updates for arm/mvebu
From: Uwe Kleine-König @ 2016-09-15 10:38 UTC (permalink / raw)
  To: barebox; +Cc: Thomas Petazzoni, Ezequiel Garcia

Hello,

these are the first few patches I did while creating a port for a Netgear
RN2120.

Best regards
Uwe

Uwe Kleine-König (4):
  ARM: mvebu_defconfig: oldconfig
  ARM: mvebu_defconfig: enable all machines, AEABI, nand and net driver
  ARM: mvebu: select HAVE_DEFAULT_ENVIRONMENT_NEW
  net: mvneta: clean txdesc before usage

 arch/arm/Kconfig                 |  1 +
 arch/arm/configs/mvebu_defconfig | 18 ++++++++++++------
 drivers/net/mvneta.c             |  1 +
 3 files changed, 14 insertions(+), 6 deletions(-)

-- 
2.8.1


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

^ permalink raw reply

* [PATCH 4/4] net: mvneta: clean txdesc before usage
From: Uwe Kleine-König @ 2016-09-15 10:38 UTC (permalink / raw)
  To: barebox; +Cc: Thomas Petazzoni, Ezequiel Garcia
In-Reply-To: <1473935897-9252-1-git-send-email-u.kleine-koenig@pengutronix.de>

This fixes tx error detection which triggered way too often because the
hardware doesn't seem to clear the error bits on success

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/net/mvneta.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index 1690f3b576c7..5c163cebc7f4 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -395,6 +395,7 @@ static int mvneta_send(struct eth_device *edev, void *data, int len)
 	/* Flush transmit data */
 	dma_sync_single_for_device((unsigned long)data, len, DMA_TO_DEVICE);
 
+	memset(txdesc, 0, sizeof(*txdesc));
 	/* Fill the Tx descriptor */
 	txdesc->cmd_sts = MVNETA_TX_L4_CSUM_NOT | MVNETA_TXD_FLZ_DESC;
 	txdesc->buf_ptr = (u32)data;
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 2/4] ARM: mvebu_defconfig: enable all machines, AEABI, nand and net driver
From: Uwe Kleine-König @ 2016-09-15 10:38 UTC (permalink / raw)
  To: barebox; +Cc: Thomas Petazzoni, Ezequiel Garcia
In-Reply-To: <1473935897-9252-1-git-send-email-u.kleine-koenig@pengutronix.de>

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/configs/mvebu_defconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
index faaeb1de8476..9998ce42d6b0 100644
--- a/arch/arm/configs/mvebu_defconfig
+++ b/arch/arm/configs/mvebu_defconfig
@@ -6,7 +6,9 @@ CONFIG_MACH_MARVELL_ARMADA_XP_GP=y
 CONFIG_MACH_PLATHOME_OPENBLOCKS_AX3=y
 CONFIG_MACH_SOLIDRUN_CUBOX=y
 CONFIG_MACH_GLOBALSCALE_GURUPLUG=y
+CONFIG_MACH_PLATHOME_OPENBLOCKS_A6=y
 CONFIG_MACH_USI_TOPKICK=y
+CONFIG_AEABI=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_TEXT_BASE=0x0
 CONFIG_MALLOC_SIZE=0x0
@@ -90,6 +92,7 @@ CONFIG_NET=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_SERIAL_NS16550=y
+CONFIG_DRIVER_NET_MVNETA=y
 CONFIG_DRIVER_NET_ORION=y
 CONFIG_MARVELL_PHY=y
 CONFIG_DRIVER_SPI_GPIO=y
@@ -100,6 +103,7 @@ CONFIG_MTD=y
 CONFIG_MTD_M25P80=y
 CONFIG_NAND=y
 CONFIG_NAND_ORION=y
+CONFIG_NAND_MRVL_NFC=y
 CONFIG_DISK_AHCI=y
 CONFIG_USB_HOST=y
 CONFIG_USB_EHCI=y
-- 
2.8.1


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

^ permalink raw reply related

* [PATCH 1/4] ARM: mvebu_defconfig: oldconfig
From: Uwe Kleine-König @ 2016-09-15 10:38 UTC (permalink / raw)
  To: barebox; +Cc: Thomas Petazzoni, Ezequiel Garcia
In-Reply-To: <1473935897-9252-1-git-send-email-u.kleine-koenig@pengutronix.de>

This is the result of
	make mvebu_defconfig
	make savedefconfig
	mv defconfig arch/arm/configs/mvebu_defconfig
.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/configs/mvebu_defconfig | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
index bd978a9acbe2..faaeb1de8476 100644
--- a/arch/arm/configs/mvebu_defconfig
+++ b/arch/arm/configs/mvebu_defconfig
@@ -17,7 +17,13 @@ CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
 CONFIG_MENU=y
+CONFIG_BOOTM_SHOW_TYPE=y
+CONFIG_BOOTM_VERBOSE=y
+CONFIG_BOOTM_INITRD=y
+CONFIG_BOOTM_OFTREE=y
+CONFIG_BOOTM_OFTREE_UIMAGE=y
 CONFIG_BLSPEC=y
+CONFIG_FLEXIBLE_BOOTARGS=y
 CONFIG_IMD_TARGET=y
 CONFIG_CONSOLE_ACTIVATE_NONE=y
 CONFIG_PARTITION_DISK_EFI=y
@@ -26,13 +32,7 @@ CONFIG_CMD_IOMEM=y
 CONFIG_CMD_IMD=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_ARM_MMUINFO=y
-CONFIG_FLEXIBLE_BOOTARGS=y
 CONFIG_CMD_BOOT=y
-CONFIG_BOOTM_SHOW_TYPE=y
-CONFIG_BOOTM_VERBOSE=y
-CONFIG_BOOTM_INITRD=y
-CONFIG_BOOTM_OFTREE=y
-CONFIG_BOOTM_OFTREE_UIMAGE=y
 CONFIG_CMD_GO=y
 CONFIG_CMD_LOADS=y
 CONFIG_CMD_LOADY=y
-- 
2.8.1


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

^ permalink raw reply related


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