void do_flerase(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); return; } if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; flash_erase (info, 0, info->sector_count-1); } return; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { printf("Bad sector specification\n"); return; } printf ("Erase Flash Sectors %d-%d in Bank # %d ", sect_first, sect_last, (info-flash_info)+1); flash_erase(info, sect_first, sect_last); return; } if (argc != 3) { printf ("Usage:\n%s\n", cmdtp->usage); return; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return; } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; flash_erase (info, 0, info->sector_count-1); return; } addr_first = simple_strtoul(argv[1], NULL, 16); addr_last = simple_strtoul(argv[2], NULL, 16); if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return; } printf ("Erase Flash from 0x%08lx to 0x%08lx ", addr_first, addr_last); flash_sect_erase(addr_first, addr_last); }
int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { #ifndef CONFIG_SYS_NO_FLASH flash_info_t *info; ulong bank; int i, n, sect_first, sect_last; #endif /* CONFIG_SYS_NO_FLASH */ #if !defined(CONFIG_SYS_NO_FLASH) || defined(CONFIG_HAS_DATAFLASH) ulong addr_first, addr_last; #endif #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif #ifdef CONFIG_HAS_DATAFLASH int status; #endif int p; int rcode = 0; if (argc < 3) { cmd_usage(cmdtp); return 1; } if (strcmp(argv[1], "off") == 0) { p = 0; } else if (strcmp(argv[1], "on") == 0) { p = 1; } else { cmd_usage(cmdtp); return 1; } #ifdef CONFIG_HAS_DATAFLASH if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) { addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); if (addr_dataflash(addr_first) && addr_dataflash(addr_last)) { status = dataflash_real_protect(p,addr_first,addr_last); if (status < 0){ puts ("Bad DataFlash sector specification\n"); return 1; } printf("%sProtect %d DataFlash Sectors\n", p ? "" : "Un-", status); return 0; } } #endif #ifndef CONFIG_SYS_NO_FLASH if (strcmp(argv[2], "all") == 0) { for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { continue; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); for (i=0; i<info->sector_count; ++i) { #if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CONFIG_SYS_FLASH_PROTECTION */ } #if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CONFIG_SYS_FLASH_PROTECTION */ } return rcode; } if ((n = abbrev_spec(argv[2], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf("%sProtect Flash Sectors %d-%d in Bank # %zu\n", p ? "" : "Un-", sect_first, sect_last, (info-flash_info)+1); for (i = sect_first; i <= sect_last; i++) { #if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CONFIG_SYS_FLASH_PROTECTION */ } #if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CONFIG_SYS_FLASH_PROTECTION */ return rcode; } #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS) /* protect on/off <part-id> */ if ((argc == 3) && (mtd_id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[2], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf ("%sProtect Flash Partition %s, " "bank %ld, 0x%08lx - 0x%08lx\n", p ? "" : "Un", argv[1], bank, addr_first, addr_last); rcode = flash_sect_protect (p, addr_first, addr_last); return rcode; } printf("cannot %sprotect, not a NOR device\n", p ? "" : "un"); return 1; } } #endif if (argc != 4) { cmd_usage(cmdtp); return 1; } if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CONFIG_SYS_MAX_FLASH_BANKS); return 1; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { puts ("missing or unknown FLASH type\n"); return 1; } for (i=0; i<info->sector_count; ++i) { #if defined(CONFIG_SYS_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CONFIG_SYS_FLASH_PROTECTION */ } #if defined(CONFIG_SYS_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CONFIG_SYS_FLASH_PROTECTION */ return rcode; } if (addr_spec(argv[2], argv[3], &addr_first, &addr_last) < 0){ printf("Bad address format\n"); return 1; } if (addr_first >= addr_last) { cmd_usage(cmdtp); return 1; } rcode = flash_sect_protect (p, addr_first, addr_last); #endif /* CONFIG_SYS_NO_FLASH */ return rcode; }
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { #ifndef CONFIG_SYS_NO_FLASH flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif int rcode = 0; if (argc < 2) { cmd_usage(cmdtp); return 1; } if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); } return rcode; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf ("Erase Flash Sectors %d-%d in Bank # %zu ", sect_first, sect_last, (info-flash_info)+1); rcode = flash_erase(info, sect_first, sect_last); return rcode; } #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS) /* erase <part-id> - erase partition */ if ((argc == 2) && (mtd_id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf ("Erase Flash Partition %s, " "bank %ld, 0x%08lx - 0x%08lx ", argv[1], bank, addr_first, addr_last); rcode = flash_sect_erase(addr_first, addr_last); return rcode; } printf("cannot erase, not a NOR device\n"); return 1; } } #endif if (argc != 3) { cmd_usage(cmdtp); return 1; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CONFIG_SYS_MAX_FLASH_BANKS); return 1; } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); return rcode; } if (addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0){ printf ("Bad address format\n"); return 1; } if (addr_first >= addr_last) { cmd_usage(cmdtp); return 1; } rcode = flash_sect_erase(addr_first, addr_last); return rcode; #else return 0; #endif /* CONFIG_SYS_NO_FLASH */ }
void do_protect(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int i, p, n, sect_first, sect_last; if (argc < 3) { printf ("Usage:\n%s\n", cmdtp->usage); return; } if (strcmp(argv[1], "off") == 0) p = 0; else if (strcmp(argv[1], "on") == 0) p = 1; else { printf ("Usage:\n%s\n", cmdtp->usage); return; } if (strcmp(argv[2], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { continue; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); for (i=0; i<info->sector_count; ++i) { if ((info->flash_id & FLASH_TYPEMASK)==FLASH_INT640B) { flash_protect_sector(info, i, p); } else { protect_sector(info, i, p); } } } return; } if ((n = abbrev_spec(argv[2], &info, §_first, §_last)) != 0) { if (n < 0) { printf("Bad sector specification\n"); return; } printf("%sProtect Flash Sectors %d-%d in Bank # %d\n", p ? "" : "Un-", sect_first, sect_last, (info-flash_info)+1); for (i = sect_first; i <= sect_last; i++) { if ((info->flash_id & FLASH_TYPEMASK)==FLASH_INT640B) { flash_protect_sector(info, i, p); } else { protect_sector(info, i, p); } } return; } if (argc != 4) { printf ("Usage:\n%s\n", cmdtp->usage); return; } if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { printf ("missing or unknown FLASH type\n"); return; } for (i=0; i<info->sector_count; ++i) { if ((info->flash_id & FLASH_TYPEMASK)==FLASH_INT640B) { flash_protect_sector(info, i, p); } else { protect_sector(info, i, p); } } return; } addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return; } flash_sect_protect (p, addr_first, addr_last); }
int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int i, p, n, sect_first, sect_last; int rcode = 0; #ifdef CONFIG_HAS_DATAFLASH int status; #endif if (argc < 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "off") == 0) { p = 0; } else if (strcmp(argv[1], "on") == 0) { p = 1; } else { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } #ifdef CONFIG_HAS_DATAFLASH if ((strcmp(argv[2], "all") != 0) && (strcmp(argv[2], "bank") != 0)) { addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); if (addr_dataflash(addr_first) && addr_dataflash(addr_last)) { status = dataflash_real_protect(p,addr_first,addr_last); if (status < 0){ puts ("Bad DataFlash sector specification\n"); return 1; } printf("%sProtect %d DataFlash Sectors\n", p ? "" : "Un-", status); return 0; } } #endif if (strcmp(argv[2], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { continue; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); for (i=0; i<info->sector_count; ++i) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ return rcode; } if ((n = abbrev_spec(argv[2], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf("%sProtect Flash Sectors %d-%d in Bank # %d\n", p ? "" : "Un-", sect_first, sect_last, (info-flash_info)+1); for (i = sect_first; i <= sect_last; i++) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ return rcode; } if (argc != 4) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[2], "bank") == 0) { bank = simple_strtoul(argv[3], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf ("%sProtect Flash Bank # %ld\n", p ? "" : "Un-", bank); info = &flash_info[bank-1]; if (info->flash_id == FLASH_UNKNOWN) { puts ("missing or unknown FLASH type\n"); return 1; } for (i=0; i<info->sector_count; ++i) { #if defined(CFG_FLASH_PROTECTION) if (flash_real_protect(info, i, p)) rcode = 1; putc ('.'); #else info->protect[i] = p; #endif /* CFG_FLASH_PROTECTION */ } #if defined(CFG_FLASH_PROTECTION) if (!rcode) puts (" done\n"); #endif /* CFG_FLASH_PROTECTION */ return rcode; } addr_first = simple_strtoul(argv[2], NULL, 16); addr_last = simple_strtoul(argv[3], NULL, 16); if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } rcode = flash_sect_protect (p, addr_first, addr_last); return rcode; }
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; int rcode = 0; if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "linux") == 0) { printf("\n Erase linux kernel block !!\n"); printf("From 0x%X To 0x%X\n", CFG_KERN_ADDR, CFG_KERN_ADDR + flash_info[0].size - (CFG_BOOTLOADER_SIZE + CFG_CONFIG_SIZE + CFG_FACTORY_SIZE) -1); rcode = flash_sect_erase(CFG_KERN_ADDR, CFG_KERN_ADDR + flash_info[0].size -(CFG_BOOTLOADER_SIZE + CFG_CONFIG_SIZE + CFG_FACTORY_SIZE) -1); return rcode; } else if (strcmp(argv[1], "uboot") == 0) { printf("\n Erase u-boot block !!\n"); printf("From 0x%X To 0x%X\n", CFG_FLASH_BASE, CFG_FLASH_BASE + CFG_BOOTLOADER_SIZE - 1); rcode = flash_sect_erase(CFG_FLASH_BASE, CFG_FLASH_BASE + CFG_BOOTLOADER_SIZE - 1); return rcode; } else if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ,info->sector_count = %d", bank,info->sector_count-1); info = &flash_info[bank-1]; rcode = erase_all_chip (info, 0, info->sector_count-1); } return rcode; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf ("Erase Flash Sectors %d-%d in Bank # %d ", sect_first, sect_last, (info-flash_info)+1); rcode = flash_erase(info, sect_first, sect_last); return rcode; } if (argc != 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); return rcode; } addr_first = simple_strtoul(argv[1], NULL, 16); addr_last = simple_strtoul(argv[2], NULL, 16); if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } rcode = flash_sect_erase(addr_first, addr_last); return rcode; }
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif int rcode = 0; int jffs2erase = 0; if (argc < 2) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } // Special JFFS2 erase which will write a JFFS2 "clean" header after the erase if('j' == argv[0][0]) { jffs2erase = 1; } if (strcmp(argv[1], "all") == 0) { for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) { printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); if(jffs2erase) jffs2_write_header(info, 0, info->sector_count-1); } return rcode; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { puts ("Bad sector specification\n"); return 1; } printf ("Erase Flash Sectors %d-%d in Bank # %d ", sect_first, sect_last, (info-flash_info)+1); rcode = flash_erase(info, sect_first, sect_last); if(jffs2erase) jffs2_write_header(info, sect_first, sect_last); return rcode; } #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) /* erase <part-id> - erase partition */ if ((argc == 2) && (id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf ("Erase Flash Parition %s, " "bank %d, 0x%08lx - 0x%08lx ", argv[1], bank, addr_first, addr_last); rcode = flash_sect_erase(addr_first, addr_last); return rcode; } printf("cannot erase, not a NOR device\n"); return 1; } } #endif if (argc != 3) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf ("Only FLASH Banks # 1 ... # %d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf ("Erase Flash Bank # %ld ", bank); info = &flash_info[bank-1]; rcode = flash_erase (info, 0, info->sector_count-1); if(jffs2erase) jffs2_write_header(info, 0, info->sector_count-1); return rcode; } if (addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0){ printf ("Bad address format\n"); return 1; } if (addr_first >= addr_last) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } if (jffs2erase) { printf ("Usage:\n%s\n", cmdtp->usage); return 1; } rcode = flash_sect_erase(addr_first, addr_last); return rcode; }
int do_flerase(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { flash_info_t *info; ulong bank, addr_first, addr_last; int n, sect_first, sect_last; #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) struct mtd_device *dev; struct part_info *part; u8 dev_type, dev_num, pnum; #endif int rcode = 0; if (argc < 2) { #ifdef CFG_LONGHELP if(cmdtp->help != NULL) { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->help); } else { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); } #else printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); #endif return 1; } // erase whole flash? if (strcmp(argv[1], "all") == 0) { for (bank = 1; bank <= CFG_MAX_FLASH_BANKS; ++bank) { printf("Erase flash bank #%ld ", bank); info = &flash_info[bank - 1]; rcode = flash_erase(info, 0, info->sector_count - 1); } return rcode; } if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) { if (n < 0) { puts("## Error: bad sector spec\n"); return 1; } printf("Erase flash sectors %d-%d in bank #%d ", sect_first, sect_last, (info - flash_info) + 1); rcode = flash_erase(info, sect_first, sect_last); return rcode; } #if (CONFIG_COMMANDS & CFG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE) /* erase <part-id> - erase partition */ if ((argc == 2) && (id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) { mtdparts_init(); if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) { if (dev->id->type == MTD_DEV_TYPE_NOR) { bank = dev->id->num; info = &flash_info[bank]; addr_first = part->offset + info->start[0]; addr_last = addr_first + part->size - 1; printf("Erase flash parition %s, bank %d, 0x%08lx - 0x%08lx ", argv[1], bank, addr_first, addr_last); rcode = flash_sect_erase(addr_first, addr_last); return rcode; } printf("## Error: cannot erase, not a NOR device\n"); return 1; } } #endif if (argc != 3) { #ifdef CFG_LONGHELP if(cmdtp->help != NULL) { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->help); } else { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); } #else printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); #endif return 1; } if (strcmp(argv[1], "bank") == 0) { bank = simple_strtoul(argv[2], NULL, 16); if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) { printf("## Error: only flash banks #1...#%d supported\n", CFG_MAX_FLASH_BANKS); return 1; } printf("Erase flash bank #%ld ", bank); info = &flash_info[bank - 1]; rcode = flash_erase(info, 0, info->sector_count - 1); return rcode; } if (addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0) { printf("## Error: bad address format\n"); return 1; } if (addr_first >= addr_last) { #ifdef CFG_LONGHELP if(cmdtp->help != NULL) { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->help); } else { printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); } #else printf("Usage:\n%s %s\n", cmdtp->name, cmdtp->usage); #endif return 1; } rcode = flash_sect_erase(addr_first, addr_last); return rcode; }