]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - tools/mxsboot.c
Merge branch 'u-boot-imx/master' into 'u-boot-arm/master'
[karo-tx-uboot.git] / tools / mxsboot.c
index 176753d2ce07078dc1fe053b70539ab9c45822bd..d92c39fec667448e0963c14dccbd72e8e5b572ce 100644 (file)
@@ -453,7 +453,7 @@ static int mx28_nand_write_firmware(struct mx28_nand_fcb *fcb, int infd,
 void usage(void)
 {
        printf(
-               "Usage: mx28image [ops] <type> <infile> <outfile>\n"
+               "Usage: mxsboot [ops] <type> <infile> <outfile>\n"
                "Augment BootStream file with a proper header for i.MX28 boot\n"
                "\n"
                "  <type>       type of image:\n"
@@ -551,7 +551,7 @@ static int mx28_create_sd_image(int infd, int outfd)
 
        fsize = lseek(infd, 0, SEEK_END);
        lseek(infd, 0, SEEK_SET);
-       size = fsize + 512;
+       size = fsize + 4 * 512;
 
        buf = malloc(size);
        if (!buf) {
@@ -559,7 +559,7 @@ static int mx28_create_sd_image(int infd, int outfd)
                goto err0;
        }
 
-       ret = read(infd, (uint8_t *)buf + 512, fsize);
+       ret = read(infd, (uint8_t *)buf + 4 * 512, fsize);
        if (ret != fsize) {
                ret = -1;
                goto err1;
@@ -574,8 +574,8 @@ static int mx28_create_sd_image(int infd, int outfd)
        cb->drv_info[0].chip_num = 0x0;
        cb->drv_info[0].drive_type = 0x0;
        cb->drv_info[0].tag = 0x1;
-       cb->drv_info[0].first_sector_number = sd_sector + 1;
-       cb->drv_info[0].sector_count = (size - 1) / 512;
+       cb->drv_info[0].first_sector_number = sd_sector + 4;
+       cb->drv_info[0].sector_count = (size - 4) / 512;
 
        wr_size = write(outfd, buf, size);
        if (wr_size != size) {
@@ -606,6 +606,9 @@ int parse_ops(int argc, char **argv)
        };
        int type;
 
+       if (argc < 4)
+               return -1;
+
        for (i = 1; i < argc; i++) {
                if (!strncmp(argv[i], "-w", 2))
                        type = PARAM_WRITE;