All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] dfu: fix dfu tftp on sandbox
@ 2020-07-22 15:46 Heinrich Schuchardt
  0 siblings, 0 replies; only message in thread
From: Heinrich Schuchardt @ 2020-07-22 15:46 UTC (permalink / raw)
  To: u-boot

The environment variable loadaddr is in the virtual address space of the
sandbox. To get the actual memory address where the FIT image has been
loaded we have to convert this address according to the memory mapping of
the sandbox.

Equally the addresses in the *.its file have to be converted when used in
the dfu_ram driver.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 common/update.c       | 3 ++-
 drivers/dfu/dfu_ram.c | 7 ++++---
 include/dfu.h         | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/common/update.c b/common/update.c
index 8abc7bc02e..5811fac269 100644
--- a/common/update.c
+++ b/common/update.c
@@ -16,6 +16,7 @@
 #include <net.h>
 #include <net/tftp.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <dfu.h>
 #include <errno.h>

@@ -141,7 +142,7 @@ int update_tftp(ulong addr, char *interface, char *devstring)
 	}

 got_update_file:
-	fit = (void *)addr;
+	fit = map_sysmem(addr, 0);

 	if (!fit_check_format((void *)fit)) {
 		printf("Bad FIT format of the update file, aborting "
diff --git a/drivers/dfu/dfu_ram.c b/drivers/dfu/dfu_ram.c
index cc98668e7a..ab0ce9e6fa 100644
--- a/drivers/dfu/dfu_ram.c
+++ b/drivers/dfu/dfu_ram.c
@@ -10,6 +10,7 @@

 #include <common.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <errno.h>
 #include <dfu.h>

@@ -27,9 +28,9 @@ static int dfu_transfer_medium_ram(enum dfu_op op, struct dfu_entity *dfu,
 	}

 	if (op == DFU_OP_WRITE)
-		memcpy(dfu->data.ram.start + offset, buf, *len);
+		memcpy(map_sysmem(dfu->data.ram.start + offset, 0), buf, *len);
 	else
-		memcpy(buf, dfu->data.ram.start + offset, *len);
+		memcpy(buf, map_sysmem(dfu->data.ram.start + offset, 0), *len);

 	return 0;
 }
@@ -73,7 +74,7 @@ int dfu_fill_entity_ram(struct dfu_entity *dfu, char *devstr, char *s)
 	}

 	dfu->layout = DFU_RAM_ADDR;
-	dfu->data.ram.start = (void *)simple_strtoul(argv[1], NULL, 16);
+	dfu->data.ram.start = simple_strtoul(argv[1], NULL, 16);
 	dfu->data.ram.size = simple_strtoul(argv[2], NULL, 16);

 	dfu->write_medium = dfu_write_medium_ram;
diff --git a/include/dfu.h b/include/dfu.h
index 6fa4505936..84abdc79ac 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -79,7 +79,7 @@ struct nand_internal_data {
 };

 struct ram_internal_data {
-	void		*start;
+	unsigned long	start;
 	unsigned int	size;
 };

--
2.27.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-22 15:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 15:46 [PATCH 1/1] dfu: fix dfu tftp on sandbox Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.