1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-29 22:41:17 +02:00

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>
This commit is contained in:
Philippe Reynes
2019-12-02 17:33:22 +01:00
committed by Tom Rini
parent ae0d12f8df
commit 787f10a9d2

View File

@@ -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[]) static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{ {
ulong addr, dest, count; ulong addr, dest, count;
void *src, *dst;
int size; int size;
if (argc != 4) 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; return 1;
} }
src = map_sysmem(addr, count * size);
dst = map_sysmem(dest, count * size);
#ifdef CONFIG_MTD_NOR_FLASH #ifdef CONFIG_MTD_NOR_FLASH
/* check if we are copying to Flash */ /* check if we are copying to Flash */
if (addr2info(dest) != NULL) { if (addr2info((ulong)dst)) {
int rc; int rc;
puts ("Copy to Flash... "); puts ("Copy to Flash... ");
rc = flash_write ((char *)addr, dest, count*size); rc = flash_write((char *)src, (ulong)dst, count * size);
if (rc != 0) { if (rc != 0) {
flash_perror (rc); flash_perror (rc);
unmap_sysmem(src);
unmap_sysmem(dst);
return (1); return (1);
} }
puts ("done\n"); puts ("done\n");
unmap_sysmem(src);
unmap_sysmem(dst);
return 0; return 0;
} }
#endif #endif
memcpy((void *)dest, (void *)addr, count * size); memcpy(dst, src, count * size);
unmap_sysmem(src);
unmap_sysmem(dst);
return 0; return 0;
} }