diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gpt.c | 13 | ||||
-rw-r--r-- | cmd/ubi.c | 38 | ||||
-rw-r--r-- | cmd/usb.c | 3 |
3 files changed, 40 insertions, 14 deletions
@@ -181,6 +181,7 @@ static int set_gpt_info(struct blk_desc *dev_desc, disk_partition_t *parts; int errno = 0; uint64_t size_ll, start_ll; + lbaint_t offset = 0; debug("%s: lba num: 0x%x %d\n", __func__, (unsigned int)dev_desc->lba, (unsigned int)dev_desc->lba); @@ -296,8 +297,14 @@ static int set_gpt_info(struct blk_desc *dev_desc, } if (extract_env(val, &p)) p = val; - size_ll = ustrtoull(p, &p, 0); - parts[i].size = lldiv(size_ll, dev_desc->blksz); + if ((strcmp(p, "-") == 0)) { + /* remove first usable lba and last block */ + parts[i].size = dev_desc->lba - 34 - 1 - offset; + } else { + size_ll = ustrtoull(p, &p, 0); + parts[i].size = lldiv(size_ll, dev_desc->blksz); + } + free(val); /* start address */ @@ -310,6 +317,8 @@ static int set_gpt_info(struct blk_desc *dev_desc, free(val); } + offset += parts[i].size + parts[i].start; + /* bootable */ if (found_key(tok, "bootable")) parts[i].bootable = 1; @@ -443,14 +443,8 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev, return 0; } -int ubi_part(char *part_name, const char *vid_header_offset) +int ubi_detach(void) { - int err = 0; - char mtd_dev[16]; - struct mtd_device *dev; - struct part_info *part; - u8 pnum; - if (mtdparts_init() != 0) { printf("Error initializing mtdparts!\n"); return 1; @@ -466,17 +460,28 @@ int ubi_part(char *part_name, const char *vid_header_offset) cmd_ubifs_umount(); #endif - /* todo: get dev number for NAND... */ - ubi_dev.nr = 0; - /* * Call ubi_exit() before re-initializing the UBI subsystem */ if (ubi_initialized) { ubi_exit(); del_mtd_partitions(ubi_dev.mtd_info); + ubi_initialized = 0; } + ubi_dev.selected = 0; + return 0; +} + +int ubi_part(char *part_name, const char *vid_header_offset) +{ + int err = 0; + char mtd_dev[16]; + struct mtd_device *dev; + struct part_info *part; + u8 pnum; + + ubi_detach(); /* * Search the mtd device number where this partition * is located @@ -517,6 +522,15 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; + + if (strcmp(argv[1], "detach") == 0) { + if (argc < 2) + return CMD_RET_USAGE; + + return ubi_detach(); + } + + if (strcmp(argv[1], "part") == 0) { const char *vid_header_offset = NULL; @@ -661,7 +675,9 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( ubi, 6, 1, do_ubi, "ubi commands", - "part [part] [offset]\n" + "detach" + " - detach ubi from a mtd partition\n" + "ubi part [part] [offset]\n" " - Show or set current partition (with optional VID" " header offset)\n" "ubi info [l[ayout]]" @@ -800,7 +800,8 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int dev = (int)simple_strtoul(argv[2], NULL, 10); printf("\nUSB device %d: ", dev); stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, dev); - if (stor_dev == NULL) { + if ((stor_dev == NULL) || + (stor_dev->if_type == IF_TYPE_UNKNOWN)) { printf("unknown device\n"); return 1; } |