flash.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. /*
  7. * FLASH support
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <log.h>
  12. #include <uuid.h>
  13. #if defined(CONFIG_CMD_MTDPARTS)
  14. #include <jffs2/jffs2.h>
  15. /* partition handling routines */
  16. int mtdparts_init(void);
  17. int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
  18. int find_dev_and_part(const char *id, struct mtd_device **dev,
  19. u8 *part_num, struct part_info **part);
  20. #endif
  21. #ifdef CONFIG_MTD_NOR_FLASH
  22. #include <flash.h>
  23. #include <mtd/cfi_flash.h>
  24. /*
  25. * The user interface starts numbering for Flash banks with 1
  26. * for historical reasons.
  27. */
  28. /*
  29. * this routine looks for an abbreviated flash range specification.
  30. * the syntax is B:SF[-SL], where B is the bank number, SF is the first
  31. * sector to erase, and SL is the last sector to erase (defaults to SF).
  32. * bank numbers start at 1 to be consistent with other specs, sector numbers
  33. * start at zero.
  34. *
  35. * returns: 1 - correct spec; *pinfo, *psf and *psl are
  36. * set appropriately
  37. * 0 - doesn't look like an abbreviated spec
  38. * -1 - looks like an abbreviated spec, but got
  39. * a parsing error, a number out of range,
  40. * or an invalid flash bank.
  41. */
  42. static int
  43. abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl)
  44. {
  45. flash_info_t *fp;
  46. int bank, first, last;
  47. char *p, *ep;
  48. p = strchr(str, ':');
  49. if (!p)
  50. return 0;
  51. *p++ = '\0';
  52. bank = dectoul(str, &ep);
  53. if (ep == str || *ep != '\0' ||
  54. bank < 1 || bank > CFI_FLASH_BANKS)
  55. return -1;
  56. fp = &flash_info[bank - 1];
  57. if (fp->flash_id == FLASH_UNKNOWN)
  58. return -1;
  59. str = p;
  60. p = strchr(str, '-');
  61. if (p)
  62. *p++ = '\0';
  63. first = dectoul(str, &ep);
  64. if (ep == str || *ep != '\0' || first >= fp->sector_count)
  65. return -1;
  66. if (p) {
  67. last = dectoul(p, &ep);
  68. if (ep == p || *ep != '\0' ||
  69. last < first || last >= fp->sector_count)
  70. return -1;
  71. } else {
  72. last = first;
  73. }
  74. *pinfo = fp;
  75. *psf = first;
  76. *psl = last;
  77. return 1;
  78. }
  79. /*
  80. * Take *addr in Flash and adjust it to fall on the end of its sector
  81. */
  82. int flash_sect_roundb(ulong *addr)
  83. {
  84. flash_info_t *info;
  85. ulong bank, sector_end_addr;
  86. char found;
  87. int i;
  88. /* find the end addr of the sector where the *addr is */
  89. found = 0;
  90. for (bank = 0; bank < CFI_FLASH_BANKS && !found; ++bank) {
  91. info = &flash_info[bank];
  92. for (i = 0; i < info->sector_count && !found; ++i) {
  93. /* get the end address of the sector */
  94. if (i == info->sector_count - 1) {
  95. sector_end_addr = info->start[0] +
  96. info->size - 1;
  97. } else {
  98. sector_end_addr = info->start[i + 1] - 1;
  99. }
  100. if (*addr <= sector_end_addr && *addr >= info->start[i]) {
  101. found = 1;
  102. /* adjust *addr if necessary */
  103. if (*addr < sector_end_addr)
  104. *addr = sector_end_addr;
  105. } /* sector */
  106. } /* bank */
  107. }
  108. if (!found) {
  109. /* error, address not in flash */
  110. printf("Error: end address (0x%08lx) not in flash!\n", *addr);
  111. return 1;
  112. }
  113. return 0;
  114. }
  115. /*
  116. * This function computes the start and end addresses for both
  117. * erase and protect commands. The range of the addresses on which
  118. * either of the commands is to operate can be given in two forms:
  119. * 1. <cmd> start end - operate on <'start', 'end')
  120. * 2. <cmd> start +length - operate on <'start', start + length)
  121. * If the second form is used and the end address doesn't fall on the
  122. * sector boundary, than it will be adjusted to the next sector boundary.
  123. * If it isn't in the flash, the function will fail (return -1).
  124. * Input:
  125. * arg1, arg2: address specification (i.e. both command arguments)
  126. * Output:
  127. * addr_first, addr_last: computed address range
  128. * Return:
  129. * 1: success
  130. * -1: failure (bad format, bad address).
  131. */
  132. static int
  133. addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last)
  134. {
  135. char *ep;
  136. char len_used; /* indicates if the "start +length" form used */
  137. *addr_first = hextoul(arg1, &ep);
  138. if (ep == arg1 || *ep != '\0')
  139. return -1;
  140. len_used = 0;
  141. if (arg2 && *arg2 == '+') {
  142. len_used = 1;
  143. ++arg2;
  144. }
  145. *addr_last = hextoul(arg2, &ep);
  146. if (ep == arg2 || *ep != '\0')
  147. return -1;
  148. if (len_used) {
  149. /*
  150. * *addr_last has the length, compute correct *addr_last
  151. * XXX watch out for the integer overflow! Right now it is
  152. * checked for in both the callers.
  153. */
  154. *addr_last = *addr_first + *addr_last - 1;
  155. /*
  156. * It may happen that *addr_last doesn't fall on the sector
  157. * boundary. We want to round such an address to the next
  158. * sector boundary, so that the commands don't fail later on.
  159. */
  160. if (flash_sect_roundb(addr_last) > 0)
  161. return -1;
  162. } /* "start +length" from used */
  163. return 1;
  164. }
  165. static int
  166. flash_fill_sect_ranges(ulong addr_first, ulong addr_last,
  167. int *s_first, int *s_last,
  168. int *s_count)
  169. {
  170. flash_info_t *info;
  171. ulong bank;
  172. int rcode = 0;
  173. *s_count = 0;
  174. for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) {
  175. s_first[bank] = -1; /* first sector to erase */
  176. s_last[bank] = -1; /* last sector to erase */
  177. }
  178. for (bank = 0, info = &flash_info[0];
  179. (bank < CFI_FLASH_BANKS) && (addr_first <= addr_last);
  180. ++bank, ++info) {
  181. ulong b_end;
  182. int sect;
  183. short s_end;
  184. if (info->flash_id == FLASH_UNKNOWN)
  185. continue;
  186. b_end = info->start[0] + info->size - 1; /* bank end addr */
  187. s_end = info->sector_count - 1; /* last sector */
  188. for (sect = 0; sect < info->sector_count; ++sect) {
  189. ulong end; /* last address in current sect */
  190. end = (sect == s_end) ? b_end : info->start[sect + 1] - 1;
  191. if (addr_first > end)
  192. continue;
  193. if (addr_last < info->start[sect])
  194. continue;
  195. if (addr_first == info->start[sect])
  196. s_first[bank] = sect;
  197. if (addr_last == end)
  198. s_last[bank] = sect;
  199. }
  200. if (s_first[bank] >= 0) {
  201. if (s_last[bank] < 0) {
  202. if (addr_last > b_end) {
  203. s_last[bank] = s_end;
  204. } else {
  205. puts("Error: end address not on sector boundary\n");
  206. rcode = 1;
  207. break;
  208. }
  209. }
  210. if (s_last[bank] < s_first[bank]) {
  211. puts("Error: end sector precedes start sector\n");
  212. rcode = 1;
  213. break;
  214. }
  215. sect = s_last[bank];
  216. addr_first = (sect == s_end) ? b_end + 1 : info->start[sect + 1];
  217. (*s_count) += s_last[bank] - s_first[bank] + 1;
  218. } else if (addr_first >= info->start[0] && addr_first < b_end) {
  219. puts("Error: start address not on sector boundary\n");
  220. rcode = 1;
  221. break;
  222. } else if (s_last[bank] >= 0) {
  223. puts("Error: cannot span across banks when they are"
  224. " mapped in reverse order\n");
  225. rcode = 1;
  226. break;
  227. }
  228. }
  229. return rcode;
  230. }
  231. #endif /* CONFIG_MTD_NOR_FLASH */
  232. static int do_flinfo(struct cmd_tbl *cmdtp, int flag, int argc,
  233. char *const argv[])
  234. {
  235. #ifdef CONFIG_MTD_NOR_FLASH
  236. ulong bank;
  237. #endif
  238. #ifdef CONFIG_MTD_NOR_FLASH
  239. if (argc == 1) { /* print info for all FLASH banks */
  240. for (bank = 0; bank < CFI_FLASH_BANKS; ++bank) {
  241. printf("\nBank # %ld: ", bank + 1);
  242. flash_print_info(&flash_info[bank]);
  243. }
  244. return 0;
  245. }
  246. bank = hextoul(argv[1], NULL);
  247. if (bank < 1 || bank > CFI_FLASH_BANKS) {
  248. printf("Only FLASH Banks # 1 ... # %d supported\n",
  249. CFI_FLASH_BANKS);
  250. return 1;
  251. }
  252. printf("\nBank # %ld: ", bank);
  253. flash_print_info(&flash_info[bank - 1]);
  254. #endif /* CONFIG_MTD_NOR_FLASH */
  255. return 0;
  256. }
  257. static int do_flerase(struct cmd_tbl *cmdtp, int flag, int argc,
  258. char *const argv[])
  259. {
  260. #ifdef CONFIG_MTD_NOR_FLASH
  261. flash_info_t *info = NULL;
  262. ulong bank, addr_first, addr_last;
  263. int n, sect_first = 0, sect_last = 0;
  264. #if defined(CONFIG_CMD_MTDPARTS)
  265. struct mtd_device *dev;
  266. struct part_info *part;
  267. u8 dev_type, dev_num, pnum;
  268. #endif
  269. int rcode = 0;
  270. if (argc < 2)
  271. return CMD_RET_USAGE;
  272. if (strcmp(argv[1], "all") == 0) {
  273. for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) {
  274. printf("Erase Flash Bank # %ld ", bank);
  275. info = &flash_info[bank - 1];
  276. rcode = flash_erase(info, 0, info->sector_count - 1);
  277. }
  278. return rcode;
  279. }
  280. n = abbrev_spec(argv[1], &info, &sect_first, &sect_last);
  281. if (n) {
  282. if (n < 0) {
  283. puts("Bad sector specification\n");
  284. return 1;
  285. }
  286. printf("Erase Flash Sectors %d-%d in Bank # %zu ",
  287. sect_first, sect_last, (info - flash_info) + 1);
  288. rcode = flash_erase(info, sect_first, sect_last);
  289. return rcode;
  290. }
  291. #if defined(CONFIG_CMD_MTDPARTS)
  292. /* erase <part-id> - erase partition */
  293. if (argc == 2 && mtd_id_parse(argv[1], NULL, &dev_type, &dev_num) == 0) {
  294. mtdparts_init();
  295. if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) {
  296. if (dev->id->type == MTD_DEV_TYPE_NOR) {
  297. bank = dev->id->num;
  298. info = &flash_info[bank];
  299. addr_first = part->offset + info->start[0];
  300. addr_last = addr_first + part->size - 1;
  301. printf("Erase Flash Partition %s, bank %ld, 0x%08lx - 0x%08lx ",
  302. argv[1], bank, addr_first,
  303. addr_last);
  304. rcode = flash_sect_erase(addr_first, addr_last);
  305. return rcode;
  306. }
  307. printf("cannot erase, not a NOR device\n");
  308. return 1;
  309. }
  310. }
  311. #endif
  312. if (argc != 3)
  313. return CMD_RET_USAGE;
  314. if (strcmp(argv[1], "bank") == 0) {
  315. bank = hextoul(argv[2], NULL);
  316. if (bank < 1 || bank > CFI_FLASH_BANKS) {
  317. printf("Only FLASH Banks # 1 ... # %d supported\n",
  318. CFI_FLASH_BANKS);
  319. return 1;
  320. }
  321. printf("Erase Flash Bank # %ld ", bank);
  322. info = &flash_info[bank - 1];
  323. rcode = flash_erase(info, 0, info->sector_count - 1);
  324. return rcode;
  325. }
  326. if (addr_spec(argv[1], argv[2], &addr_first, &addr_last) < 0) {
  327. printf("Bad address format\n");
  328. return 1;
  329. }
  330. if (addr_first >= addr_last)
  331. return CMD_RET_USAGE;
  332. rcode = flash_sect_erase(addr_first, addr_last);
  333. return rcode;
  334. #else
  335. return 0;
  336. #endif /* CONFIG_MTD_NOR_FLASH */
  337. }
  338. #ifdef CONFIG_MTD_NOR_FLASH
  339. int flash_sect_erase(ulong addr_first, ulong addr_last)
  340. {
  341. flash_info_t *info;
  342. ulong bank;
  343. int s_first[CFI_FLASH_BANKS], s_last[CFI_FLASH_BANKS];
  344. int erased = 0;
  345. int planned;
  346. int rcode = 0;
  347. rcode = flash_fill_sect_ranges(addr_first, addr_last, s_first, s_last, &planned);
  348. if (planned && rcode == 0) {
  349. for (bank = 0, info = &flash_info[0];
  350. bank < CFI_FLASH_BANKS && rcode == 0;
  351. ++bank, ++info) {
  352. if (s_first[bank] >= 0) {
  353. erased += s_last[bank] - s_first[bank] + 1;
  354. debug("Erase Flash from 0x%08lx to 0x%08lx in Bank # %ld ",
  355. info->start[s_first[bank]],
  356. (s_last[bank] == info->sector_count) ?
  357. info->start[0] + info->size - 1 :
  358. info->start[s_last[bank] + 1] - 1,
  359. bank + 1);
  360. rcode = flash_erase(info, s_first[bank],
  361. s_last[bank]);
  362. }
  363. }
  364. if (rcode == 0)
  365. printf("Erased %d sectors\n", erased);
  366. } else if (rcode == 0) {
  367. puts("Error: start and/or end address not on sector boundary\n");
  368. rcode = 1;
  369. }
  370. return rcode;
  371. }
  372. #endif /* CONFIG_MTD_NOR_FLASH */
  373. static int do_protect(struct cmd_tbl *cmdtp, int flag, int argc,
  374. char *const argv[])
  375. {
  376. int rcode = 0;
  377. #ifdef CONFIG_MTD_NOR_FLASH
  378. flash_info_t *info = NULL;
  379. ulong bank;
  380. int i, n, sect_first = 0, sect_last = 0;
  381. #if defined(CONFIG_CMD_MTDPARTS)
  382. struct mtd_device *dev;
  383. struct part_info *part;
  384. u8 dev_type, dev_num, pnum;
  385. #endif
  386. #endif /* CONFIG_MTD_NOR_FLASH */
  387. #if defined(CONFIG_MTD_NOR_FLASH)
  388. int p;
  389. ulong addr_first, addr_last;
  390. #endif
  391. if (argc < 3)
  392. return CMD_RET_USAGE;
  393. #if defined(CONFIG_MTD_NOR_FLASH)
  394. if (strcmp(argv[1], "off") == 0)
  395. p = 0;
  396. else if (strcmp(argv[1], "on") == 0)
  397. p = 1;
  398. else
  399. return CMD_RET_USAGE;
  400. #endif
  401. #ifdef CONFIG_MTD_NOR_FLASH
  402. if (strcmp(argv[2], "all") == 0) {
  403. for (bank = 1; bank <= CFI_FLASH_BANKS; ++bank) {
  404. info = &flash_info[bank - 1];
  405. if (info->flash_id == FLASH_UNKNOWN)
  406. continue;
  407. printf("%sProtect Flash Bank # %ld\n",
  408. p ? "" : "Un-", bank);
  409. for (i = 0; i < info->sector_count; ++i) {
  410. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  411. if (flash_real_protect(info, i, p))
  412. rcode = 1;
  413. putc('.');
  414. #else
  415. info->protect[i] = p;
  416. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  417. }
  418. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  419. if (!rcode)
  420. puts(" done\n");
  421. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  422. }
  423. return rcode;
  424. }
  425. n = abbrev_spec(argv[2], &info, &sect_first, &sect_last);
  426. if (n) {
  427. if (n < 0) {
  428. puts("Bad sector specification\n");
  429. return 1;
  430. }
  431. printf("%sProtect Flash Sectors %d-%d in Bank # %zu\n",
  432. p ? "" : "Un-", sect_first, sect_last,
  433. (info - flash_info) + 1);
  434. for (i = sect_first; i <= sect_last; i++) {
  435. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  436. if (flash_real_protect(info, i, p))
  437. rcode = 1;
  438. putc('.');
  439. #else
  440. info->protect[i] = p;
  441. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  442. }
  443. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  444. if (!rcode)
  445. puts(" done\n");
  446. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  447. return rcode;
  448. }
  449. #if defined(CONFIG_CMD_MTDPARTS)
  450. /* protect on/off <part-id> */
  451. if (argc == 3 && mtd_id_parse(argv[2], NULL, &dev_type, &dev_num) == 0) {
  452. mtdparts_init();
  453. if (find_dev_and_part(argv[2], &dev, &pnum, &part) == 0) {
  454. if (dev->id->type == MTD_DEV_TYPE_NOR) {
  455. bank = dev->id->num;
  456. info = &flash_info[bank];
  457. addr_first = part->offset + info->start[0];
  458. addr_last = addr_first + part->size - 1;
  459. printf("%sProtect Flash Partition %s, "
  460. "bank %ld, 0x%08lx - 0x%08lx\n",
  461. p ? "" : "Un", argv[1],
  462. bank, addr_first, addr_last);
  463. rcode = flash_sect_protect(p, addr_first,
  464. addr_last);
  465. return rcode;
  466. }
  467. printf("cannot %sprotect, not a NOR device\n",
  468. p ? "" : "un");
  469. return 1;
  470. }
  471. }
  472. #endif
  473. if (argc != 4)
  474. return CMD_RET_USAGE;
  475. if (strcmp(argv[2], "bank") == 0) {
  476. bank = hextoul(argv[3], NULL);
  477. if (bank < 1 || bank > CFI_FLASH_BANKS) {
  478. printf("Only FLASH Banks # 1 ... # %d supported\n",
  479. CFI_FLASH_BANKS);
  480. return 1;
  481. }
  482. printf("%sProtect Flash Bank # %ld\n",
  483. p ? "" : "Un-", bank);
  484. info = &flash_info[bank - 1];
  485. if (info->flash_id == FLASH_UNKNOWN) {
  486. puts("missing or unknown FLASH type\n");
  487. return 1;
  488. }
  489. for (i = 0; i < info->sector_count; ++i) {
  490. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  491. if (flash_real_protect(info, i, p))
  492. rcode = 1;
  493. putc('.');
  494. #else
  495. info->protect[i] = p;
  496. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  497. }
  498. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  499. if (!rcode)
  500. puts(" done\n");
  501. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  502. return rcode;
  503. }
  504. if (addr_spec(argv[2], argv[3], &addr_first, &addr_last) < 0) {
  505. printf("Bad address format\n");
  506. return 1;
  507. }
  508. if (addr_first >= addr_last)
  509. return CMD_RET_USAGE;
  510. rcode = flash_sect_protect(p, addr_first, addr_last);
  511. #endif /* CONFIG_MTD_NOR_FLASH */
  512. return rcode;
  513. }
  514. #ifdef CONFIG_MTD_NOR_FLASH
  515. int flash_sect_protect(int p, ulong addr_first, ulong addr_last)
  516. {
  517. flash_info_t *info;
  518. ulong bank;
  519. int s_first[CFI_FLASH_BANKS], s_last[CFI_FLASH_BANKS];
  520. int protected, i;
  521. int planned;
  522. int rcode;
  523. rcode = flash_fill_sect_ranges(addr_first, addr_last, s_first, s_last, &planned);
  524. protected = 0;
  525. if (planned && rcode == 0) {
  526. for (bank = 0, info = &flash_info[0];
  527. bank < CFI_FLASH_BANKS; ++bank, ++info) {
  528. if (info->flash_id == FLASH_UNKNOWN)
  529. continue;
  530. if (s_first[bank] >= 0 && s_first[bank] <= s_last[bank]) {
  531. debug("%sProtecting sectors %d..%d in bank %ld\n",
  532. p ? "" : "Un-", s_first[bank],
  533. s_last[bank], bank + 1);
  534. protected += s_last[bank] - s_first[bank] + 1;
  535. for (i = s_first[bank]; i <= s_last[bank]; ++i) {
  536. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  537. if (flash_real_protect(info, i, p))
  538. rcode = 1;
  539. putc('.');
  540. #else
  541. info->protect[i] = p;
  542. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  543. }
  544. }
  545. }
  546. #if defined(CONFIG_SYS_FLASH_PROTECTION)
  547. puts(" done\n");
  548. #endif /* CONFIG_SYS_FLASH_PROTECTION */
  549. printf("%sProtected %d sectors\n",
  550. p ? "" : "Un-", protected);
  551. } else if (rcode == 0) {
  552. puts("Error: start and/or end address not on sector boundary\n");
  553. rcode = 1;
  554. }
  555. return rcode;
  556. }
  557. #endif /* CONFIG_MTD_NOR_FLASH */
  558. /**************************************************/
  559. #if defined(CONFIG_CMD_MTDPARTS)
  560. # define TMP_ERASE "erase <part-id>\n - erase partition\n"
  561. # define TMP_PROT_ON "protect on <part-id>\n - protect partition\n"
  562. # define TMP_PROT_OFF "protect off <part-id>\n - make partition writable\n"
  563. #else
  564. # define TMP_ERASE /* empty */
  565. # define TMP_PROT_ON /* empty */
  566. # define TMP_PROT_OFF /* empty */
  567. #endif
  568. U_BOOT_CMD(
  569. flinfo, 2, 1, do_flinfo,
  570. "print FLASH memory information",
  571. "\n - print information for all FLASH memory banks\n"
  572. "flinfo N\n - print information for FLASH memory bank # N"
  573. );
  574. U_BOOT_CMD(
  575. erase, 3, 0, do_flerase,
  576. "erase FLASH memory",
  577. "start end\n"
  578. " - erase FLASH from addr 'start' to addr 'end'\n"
  579. "erase start +len\n"
  580. " - erase FLASH from addr 'start' to the end of sect w/addr 'start'+'len'-1\n"
  581. "erase N:SF[-SL]\n - erase sectors SF-SL in FLASH bank # N\n"
  582. "erase bank N\n - erase FLASH bank # N\n"
  583. TMP_ERASE
  584. "erase all\n - erase all FLASH banks"
  585. );
  586. U_BOOT_CMD(
  587. protect, 4, 0, do_protect,
  588. "enable or disable FLASH write protection",
  589. "on start end\n"
  590. " - protect FLASH from addr 'start' to addr 'end'\n"
  591. "protect on start +len\n"
  592. " - protect FLASH from addr 'start' to end of sect w/addr 'start'+'len'-1\n"
  593. "protect on N:SF[-SL]\n"
  594. " - protect sectors SF-SL in FLASH bank # N\n"
  595. "protect on bank N\n - protect FLASH bank # N\n"
  596. TMP_PROT_ON
  597. "protect on all\n - protect all FLASH banks\n"
  598. "protect off start end\n"
  599. " - make FLASH from addr 'start' to addr 'end' writable\n"
  600. "protect off start +len\n"
  601. " - make FLASH from addr 'start' to end of sect w/addr 'start'+'len'-1 wrtable\n"
  602. "protect off N:SF[-SL]\n"
  603. " - make sectors SF-SL writable in FLASH bank # N\n"
  604. "protect off bank N\n - make FLASH bank # N writable\n"
  605. TMP_PROT_OFF
  606. "protect off all\n - make all FLASH banks writable"
  607. );
  608. #undef TMP_ERASE
  609. #undef TMP_PROT_ON
  610. #undef TMP_PROT_OFF