common: command: Fix manual relocation for repeatable command
authorMichal Simek <michal.simek@xilinx.com>
Mon, 21 Oct 2019 10:54:20 +0000 (12:54 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 24 Oct 2019 11:37:03 +0000 (13:37 +0200)
All platforms which are using MANUAL_RELOC are jumping back to origin
location when repeatable command is called. The reason is that cmd_rep link
is not updated properly. Issue can be reproduced by rewriting origin
U-Boot location through (for example) file download by tftp command.

Fixes: 80a48dd47e3b ("common: command: Rework the 'cmd is repeatable' logic")
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
common/command.c

index 4b887a267fb6d82d3cd827fe1558cf0b087a5c54..ceca992510762d1b2cea8df922f8d5310cfb1ce0 100644 (file)
@@ -496,6 +496,11 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size)
        for (i = 0; i < size; i++) {
                ulong addr;
 
+               addr = (ulong)(cmdtp->cmd_rep) + gd->reloc_off;
+               cmdtp->cmd_rep =
+                       (int (*)(struct cmd_tbl_s *, int, int,
+                                char * const [], int *))addr;
+
                addr = (ulong)(cmdtp->cmd) + gd->reloc_off;
 #ifdef DEBUG_COMMANDS
                printf("Command \"%s\": 0x%08lx => 0x%08lx\n",