summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPhilippe Reynes <philippe.reynes@softathome.com>2019-12-02 17:33:22 +0100
committerTom Rini <trini@konsulko.com>2019-12-05 10:28:38 -0500
commit787f10a9d2553f89e382e7ed09c2cf6b3b1d70cf (patch)
tree79be3853b128c75dc47a7ec4f7edd76dba5078f8 /cmd
parentae0d12f8df7b6fe6f04f567e1dc9d5b760a394d1 (diff)
downloadu-boot-787f10a9d2553f89e382e7ed09c2cf6b3b1d70cf.tar.gz
u-boot-787f10a9d2553f89e382e7ed09c2cf6b3b1d70cf.tar.bz2
u-boot-787f10a9d2553f89e382e7ed09c2cf6b3b1d70cf.zip
cmd: cp: add missing map_sysmem
The command cp fails on sandbox because the address is used directly. To fix this issue, we call the function map_sysmem to translate the address. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mem.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/cmd/mem.c b/cmd/mem.c
index 545534b1fc..4ec450b050 100644
--- a/cmd/mem.c
+++ b/cmd/mem.c
@@ -303,6 +303,7 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
ulong addr, dest, count;
+ void *src, *dst;
int size;
if (argc != 4)
@@ -326,25 +327,34 @@ static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
+ src = map_sysmem(addr, count * size);
+ dst = map_sysmem(dest, count * size);
+
#ifdef CONFIG_MTD_NOR_FLASH
/* check if we are copying to Flash */
- if (addr2info(dest) != NULL) {
+ if (addr2info((ulong)dst)) {
int rc;
puts ("Copy to Flash... ");
- rc = flash_write ((char *)addr, dest, count*size);
+ rc = flash_write((char *)src, (ulong)dst, count * size);
if (rc != 0) {
flash_perror (rc);
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return (1);
}
puts ("done\n");
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return 0;
}
#endif
- memcpy((void *)dest, (void *)addr, count * size);
+ memcpy(dst, src, count * size);
+ unmap_sysmem(src);
+ unmap_sysmem(dst);
return 0;
}