[PATCH] of: fix how an initrd is passed to Linux

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Thu Apr 25 08:49:47 EDT 2013


Linux expects linux,initrd-end to contain the first unused address. As
this doesn't match the end semantic used by barebox (i.e. end contains
the last used address) adding one is necessary.

Without this change Linux fails for me to correctly extract a gzipped
cpio archive provided as initrd.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
---
 drivers/of/base.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d22031f..6cb5521 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1078,6 +1078,10 @@ int of_device_is_stdout_path(struct device_d *dev)
  *
  * Add initrd properties to the devicetree, or, if end is 0,
  * delete them.
+ *
+ * Note that Linux interprets end differently than Barebox. For Linux end points
+ * to the first address after the memory occupied by the image while barebox
+ * lets end pointing the the last occupied byte.
  */
 int of_add_initrd(struct device_node *root, resource_size_t start,
 		resource_size_t end)
@@ -1092,7 +1096,7 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
 	if (end) {
 		of_write_number(buf, start, 2);
 		of_set_property(chosen, "linux,initrd-start", buf, 8, 1);
-		of_write_number(buf, end, 2);
+		of_write_number(buf, end + 1, 2);
 		of_set_property(chosen, "linux,initrd-end", buf, 8, 1);
 	} else {
 		struct property *pp;
-- 
1.8.2.rc2




More information about the barebox mailing list