mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] zImage fix
@ 2012-04-13 10:10 Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 10:12 ` [PATCH 1/2 v3] arm: fix zImage support when a oftree is concatenated Jean-Christophe PLAGNIOL-VILLARD
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-04-13 10:10 UTC (permalink / raw)
  To: barebox

HI,

	fix zImage support when a oftree is concataned

	if the oftree is enabled used it
	otherwise just copy it

The following changes since commit d034757079c34d6ce258c1fd08f0bb1352e75622:

  arm: add Android boot image support (2012-04-13 18:13:53 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git zImage

for you to fetch changes up to cc80bdcb3991f995091697c035d156e1f03c6a35:

  arm: bootm: zImage allow to use the concataned oftree (2012-04-13 18:22:36 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
      arm: fix zImage support when a oftree is concatenated
      arm: bootm: zImage allow to use the concataned oftree

 arch/arm/lib/bootm.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)


Best Regards,
J.

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

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

* [PATCH 1/2 v3] arm: fix zImage support when a oftree is concatenated
  2012-04-13 10:10 [PATCH 0/2] zImage fix Jean-Christophe PLAGNIOL-VILLARD
@ 2012-04-13 10:12 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 10:12 ` [PATCH 2/2 v3] arm: bootm: zImage allow to use the concataned oftree Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 12:47 ` [PATCH 0/2] zImage fix Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-04-13 10:12 UTC (permalink / raw)
  To: barebox

When a oftree is concatenated,the zImage is bigger than the size specified in
the zImage header. Detect it and copy it too.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/lib/bootm.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index ac83ec7..813927a 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -124,6 +124,51 @@ struct zimage_header {
 
 #define ZIMAGE_MAGIC 0x016F2818
 
+static int do_bootz_linux_fdt(int fd, struct image_data *data)
+{
+	struct fdt_header __header, *header;
+	struct resource *r = data->os_res;
+	struct resource *of_res = data->os_res;
+	void *oftree;
+	int ret;
+
+	u32 end;
+
+	header = &__header;
+	ret = read(fd, header, sizeof(*header));
+	if (ret < sizeof(*header))
+		return ret;
+
+	if (file_detect_type(header) != filetype_oftree)
+		return -ENXIO;
+
+	end = be32_to_cpu(header->totalsize);
+
+	of_res = request_sdram_region("oftree", r->start + r->size, end);
+	if (!of_res) {
+		perror("zImage: oftree request_sdram_region");
+		return -ENOMEM;
+	}
+
+	oftree = (void*)of_res->start;
+
+	memcpy(oftree, header, sizeof(*header));
+
+	end -= sizeof(*header);
+
+	ret = read_full(fd, oftree + sizeof(*header), end);
+	if (ret < 0)
+		return ret;
+	if (ret < end) {
+		printf("premature end of image\n");
+		return -EIO;
+	}
+
+	pr_info("zImage: concatenated oftree detected\n");
+
+	return 0;
+}
+
 static int do_bootz_linux(struct image_data *data)
 {
 	int fd, ret, swap = 0;
@@ -197,6 +242,10 @@ static int do_bootz_linux(struct image_data *data)
 			*(u32 *)ptr = swab32(*(u32 *)ptr);
 	}
 
+	ret = do_bootz_linux_fdt(fd, data);
+	if (ret && ret != -ENXIO)
+		return ret;
+
 	return __do_bootm_linux(data, swap);
 
 err_out:
-- 
1.7.9.1


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

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

* [PATCH 2/2 v3] arm: bootm: zImage allow to use the concataned oftree
  2012-04-13 10:10 [PATCH 0/2] zImage fix Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 10:12 ` [PATCH 1/2 v3] arm: fix zImage support when a oftree is concatenated Jean-Christophe PLAGNIOL-VILLARD
@ 2012-04-13 10:12 ` Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 12:47 ` [PATCH 0/2] zImage fix Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-04-13 10:12 UTC (permalink / raw)
  To: barebox

This will allow to update it with fixup if the oftree support is builtin.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
v3:

	use the oftree only if oftree is enabled

Best Regards,
J.
 arch/arm/lib/bootm.c |   32 ++++++++++++++++++++++++++------
 1 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 813927a..26053dc 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -14,6 +14,7 @@
 #include <sizes.h>
 #include <libbb.h>
 #include <magicvar.h>
+#include <libfdt.h>
 
 #include <asm/byteorder.h>
 #include <asm/setup.h>
@@ -144,13 +145,22 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 
 	end = be32_to_cpu(header->totalsize);
 
-	of_res = request_sdram_region("oftree", r->start + r->size, end);
-	if (!of_res) {
-		perror("zImage: oftree request_sdram_region");
-		return -ENOMEM;
-	}
+	if (IS_BUILTIN(CONFIG_OFTREE)) {
+		oftree = malloc(end + 0x8000);
+		if (!oftree) {
+			perror("zImage: oftree malloc");
+			return -ENOMEM;
+		}
+	} else {
 
-	oftree = (void*)of_res->start;
+		of_res = request_sdram_region("oftree", r->start + r->size, end);
+		if (!of_res) {
+			perror("zImage: oftree request_sdram_region");
+			return -ENOMEM;
+		}
+
+		oftree = (void*)of_res->start;
+	}
 
 	memcpy(oftree, header, sizeof(*header));
 
@@ -164,6 +174,16 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
 		return -EIO;
 	}
 
+	if (IS_BUILTIN(CONFIG_OFTREE)) {
+		fdt_open_into(oftree, oftree, end + 0x8000);
+
+		ret = of_fix_tree(oftree);
+		if (ret)
+			return ret;
+
+		data->oftree = oftree;
+	}
+
 	pr_info("zImage: concatenated oftree detected\n");
 
 	return 0;
-- 
1.7.9.1


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

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

* Re: [PATCH 0/2] zImage fix
  2012-04-13 10:10 [PATCH 0/2] zImage fix Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 10:12 ` [PATCH 1/2 v3] arm: fix zImage support when a oftree is concatenated Jean-Christophe PLAGNIOL-VILLARD
  2012-04-13 10:12 ` [PATCH 2/2 v3] arm: bootm: zImage allow to use the concataned oftree Jean-Christophe PLAGNIOL-VILLARD
@ 2012-04-13 12:47 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-04-13 12:47 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Apr 13, 2012 at 12:10:46PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> HI,
> 
> 	fix zImage support when a oftree is concataned
> 
> 	if the oftree is enabled used it
> 	otherwise just copy it
> 
> The following changes since commit d034757079c34d6ce258c1fd08f0bb1352e75622:
> 
>   arm: add Android boot image support (2012-04-13 18:13:53 +0800)
> 
> are available in the git repository at:
> 
>   git://git.jcrosoft.org/barebox.git zImage
> 
> for you to fetch changes up to cc80bdcb3991f995091697c035d156e1f03c6a35:
> 
>   arm: bootm: zImage allow to use the concataned oftree (2012-04-13 18:22:36 +0800)

Applied, thanks.

Sascha

> 
> ----------------------------------------------------------------
> Jean-Christophe PLAGNIOL-VILLARD (2):
>       arm: fix zImage support when a oftree is concatenated
>       arm: bootm: zImage allow to use the concataned oftree
> 
>  arch/arm/lib/bootm.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 69 insertions(+), 0 deletions(-)
> 
> 
> Best Regards,
> J.
> 
> _______________________________________________
> 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	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-13 12:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 10:10 [PATCH 0/2] zImage fix Jean-Christophe PLAGNIOL-VILLARD
2012-04-13 10:12 ` [PATCH 1/2 v3] arm: fix zImage support when a oftree is concatenated Jean-Christophe PLAGNIOL-VILLARD
2012-04-13 10:12 ` [PATCH 2/2 v3] arm: bootm: zImage allow to use the concataned oftree Jean-Christophe PLAGNIOL-VILLARD
2012-04-13 12:47 ` [PATCH 0/2] zImage fix Sascha Hauer

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