karo: tx28: fix bugs in 'romupdate' command
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 30 Jun 2016 13:41:36 +0000 (15:41 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 30 Jun 2016 13:41:36 +0000 (15:41 +0200)
board/karo/tx28/flash.c

index af9bb72..6539b24 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2014 Lothar Waßmann <LW@KARO-electronics.de>
+ * Copyright (C) 2011-2016 Lothar Waßmann <LW@KARO-electronics.de>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -354,9 +354,9 @@ static int tx28_prog_uboot(void *addr, int start_block, int skip,
        nand_erase_options_t erase_opts = { 0, };
        size_t actual;
        size_t prg_length = max_len - skip * mtd->erasesize;
-       int prg_start = (start_block + skip) * mtd->erasesize;
+       int prg_start = start_block * mtd->erasesize;
 
-       erase_opts.offset = start_block * mtd->erasesize;
+       erase_opts.offset = (start_block - skip) * mtd->erasesize;
        erase_opts.length = max_len;
        erase_opts.quiet = 1;
 
@@ -673,7 +673,7 @@ int do_update(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 
        printf("Programming redundant U-Boot image to block %lu @ %08llx\n",
                fw2_start_block, (u64)fw2_start_block * mtd->erasesize);
-       ret = tx28_prog_uboot(addr, fw2_start_block, fw2_skip, fw_num_blocks,
+       ret = tx28_prog_uboot(addr, fw2_start_block, fw2_skip, size,
                        max_len2);
 out:
        free(buf);