dfu: fix dfu tftp on sandbox
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 22 Jul 2020 15:46:02 +0000 (17:46 +0200)
committerMarek Vasut <marex@denx.de>
Tue, 1 Sep 2020 12:47:43 +0000 (14:47 +0200)
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
drivers/dfu/dfu_ram.c
include/dfu.h

index d885479..36b6b75 100644 (file)
@@ -24,6 +24,7 @@
 #include <net.h>
 #include <net/tftp.h>
 #include <malloc.h>
+#include <mapmem.h>
 #include <dfu.h>
 #include <errno.h>
 #include <mtd/cfi_flash.h>
@@ -280,7 +281,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 "
index cc98668..ab0ce9e 100644 (file)
@@ -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;
index 6fa4505..84abdc7 100644 (file)
@@ -79,7 +79,7 @@ struct nand_internal_data {
 };
 
 struct ram_internal_data {
-       void            *start;
+       unsigned long   start;
        unsigned int    size;
 };