Skip to contentSkip to conversation

zImage fix

PATCH Applied Jean-Christophe PLAGNIOL-VILLARD 2 participants 4 messages Apr 13, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

cover zImage fix

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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#1 lore raw

PATCH v3 1/2 arm: fix zImage support when a oftree is concatenated

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

---
 arch/arm/lib/bootm.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
arch/arm/lib/bootm.c +49 -0
index ac83ec7..813927a 100644
@@ -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:
Signature · 7 lines
1.7.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v3 2/2 arm: bootm: zImage allow to use the concataned oftree

In reply to Jean-Christophe PLAGNIOL-VILLARD

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

---
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(-)
arch/arm/lib/bootm.c +26 -6
index 813927a..26053dc 100644
@@ -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;
Signature · 7 lines
1.7.9.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD

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)

Quoted 7 lines

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

Quoted 18 lines

----------------------------------------------------------------
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Signature · 9 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox