*/
#include <common.h>
#include <command.h>
-#include <cmd_boot.h>
#include <flash.h>
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
extern flash_info_t flash_info[]; /* info for FLASH chips */
bank = simple_strtoul(str, &ep, 10);
if (ep == str || *ep != '\0' ||
- bank < 1 || bank > CFG_MAX_FLASH_BANKS ||
+ bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS ||
(fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN)
return -1;
ulong bank;
if (argc == 1) { /* print info for all FLASH banks */
- for (bank=0; bank <CFG_MAX_FLASH_BANKS; ++bank) {
- mon_printf ("\nBank # %ld: ", bank+1);
+ for (bank=0; bank <CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
+ printf ("\nBank # %ld: ", bank+1);
flash_print_info (&flash_info[bank]);
}
}
bank = simple_strtoul(argv[1], NULL, 16);
- if ((bank < 1) || (bank > CFG_MAX_FLASH_BANKS)) {
- mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
- CFG_MAX_FLASH_BANKS);
+ if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
+ printf ("Only FLASH Banks # 1 ... # %d supported\n",
+ CONFIG_SYS_MAX_FLASH_BANKS);
return 1;
}
- mon_printf ("\nBank # %ld: ", bank);
+ printf ("\nBank # %ld: ", bank);
flash_print_info (&flash_info[bank-1]);
return 0;
}
int rcode = 0;
if (argc < 2) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
if (strcmp(argv[1], "all") == 0) {
- for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
- mon_printf ("Erase Flash Bank # %ld ", bank);
+ 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);
}
if ((n = abbrev_spec(argv[1], &info, §_first, §_last)) != 0) {
if (n < 0) {
- mon_printf("Bad sector specification\n");
+ printf("Bad sector specification\n");
return 1;
}
- mon_printf ("Erase Flash Sectors %d-%d in Bank # %d ",
+ 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) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ 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)) {
- mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
- CFG_MAX_FLASH_BANKS);
+ if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
+ printf ("Only FLASH Banks # 1 ... # %d supported\n",
+ CONFIG_SYS_MAX_FLASH_BANKS);
return 1;
}
- mon_printf ("Erase Flash Bank # %ld ", bank);
+ printf ("Erase Flash Bank # %ld ", bank);
info = &flash_info[bank-1];
rcode = flash_erase (info, 0, info->sector_count-1);
return rcode;
addr_last = simple_strtoul(argv[2], NULL, 16);
if (addr_first >= addr_last) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
- mon_printf ("Erase Flash from 0x%08lx to 0x%08lx ", addr_first, addr_last);
+ printf ("Erase Flash from 0x%08lx to 0x%08lx ", addr_first, addr_last);
rcode = flash_sect_erase(addr_first, addr_last);
return rcode;
}
erased = 0;
- for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) {
+ for (bank=0,info = &flash_info[0]; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank, ++info) {
ulong b_end;
int sect;
}
}
if (erased) {
- // mon_printf ("Erased %d sectors\n", erased);
+ /* printf ("Erased %d sectors\n", erased); */
} else {
- mon_printf ("Error: start and/or end address"
+ printf ("Error: start and/or end address"
" not on sector boundary\n");
rcode = 1;
}
int rcode = 0;
if (argc < 3) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
else if (strcmp(argv[1], "on") == 0)
p = 1;
else {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
if (strcmp(argv[2], "all") == 0) {
- for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
+ for (bank=1; bank<=CONFIG_SYS_MAX_FLASH_BANKS; ++bank) {
info = &flash_info[bank-1];
if (info->flash_id == FLASH_UNKNOWN) {
continue;
}
- //mon_printf ("%sProtect Flash Bank # %ld\n",
- // p ? "" : "Un-", bank);
+ /*printf ("%sProtect Flash Bank # %ld\n", */
+ /* p ? "" : "Un-", bank); */
for (i=0; i<info->sector_count; ++i) {
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (flash_real_protect(info, i, p))
rcode = 1;
putc ('.');
#else
info->protect[i] = p;
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
}
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (!rcode) puts (" done\n");
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
return rcode;
}
if ((n = abbrev_spec(argv[2], &info, §_first, §_last)) != 0) {
if (n < 0) {
- mon_printf("Bad sector specification\n");
+ printf("Bad sector specification\n");
return 1;
}
- //mon_printf("%sProtect Flash Sectors %d-%d in Bank # %d\n",
- // p ? "" : "Un-", sect_first, sect_last,
- // (info-flash_info)+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 defined(CONFIG_SYS_FLASH_PROTECTION)
if (flash_real_protect(info, i, p))
rcode = 1;
putc ('.');
#else
info->protect[i] = p;
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (!rcode) puts (" done\n");
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
return rcode;
}
if (argc != 4) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ 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)) {
- mon_printf ("Only FLASH Banks # 1 ... # %d supported\n",
- CFG_MAX_FLASH_BANKS);
+ if ((bank < 1) || (bank > CONFIG_SYS_MAX_FLASH_BANKS)) {
+ printf ("Only FLASH Banks # 1 ... # %d supported\n",
+ CONFIG_SYS_MAX_FLASH_BANKS);
return 1;
}
- mon_printf ("%sProtect Flash Bank # %ld\n",
+ printf ("%sProtect Flash Bank # %ld\n",
p ? "" : "Un-", bank);
info = &flash_info[bank-1];
if (info->flash_id == FLASH_UNKNOWN) {
- mon_printf ("missing or unknown FLASH type\n");
+ printf ("missing or unknown FLASH type\n");
return 1;
}
for (i=0; i<info->sector_count; ++i) {
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (flash_real_protect(info, i, p))
rcode = 1;
putc ('.');
#else
info->protect[i] = p;
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (!rcode) puts (" done\n");
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
return rcode;
}
addr_last = simple_strtoul(argv[3], NULL, 16);
if (addr_first >= addr_last) {
- mon_printf ("Usage:\n%s\n", cmdtp->usage);
+ printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
rcode = flash_sect_protect (p, addr_first, addr_last);
protected = 0;
- for (bank=0,info=&flash_info[0]; bank < CFG_MAX_FLASH_BANKS; ++bank, ++info) {
+ for (bank=0,info = &flash_info[0]; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank, ++info) {
ulong b_end;
int sect;
if (s_first>=0 && s_first<=s_last) {
protected += s_last - s_first + 1;
for (i=s_first; i<=s_last; ++i) {
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (flash_real_protect(info, i, p))
rcode = 1;
putc ('.');
#else
info->protect[i] = p;
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
}
-#if defined(CFG_FLASH_PROTECTION)
+#if defined(CONFIG_SYS_FLASH_PROTECTION)
if (!rcode) putc ('\n');
-#endif /* CFG_FLASH_PROTECTION */
+#endif /* CONFIG_SYS_FLASH_PROTECTION */
}
if (protected) {
- // mon_printf ("%sProtected %d sectors\n",
- // p ? "" : "Un-", protected);
+ /* printf ("%sProtected %d sectors\n", */
+ /* p ? "" : "Un-", protected); */
} else {
- mon_printf ("Error: start and/or end address"
+ printf ("Error: start and/or end address"
" not on sector boundary\n");
rcode = 1;
}
return rcode;
}
-#endif /* CFG_CMD_FLASH */
+#endif