flash.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. /*
  2. * (C) Copyright 2001
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. /* #define DEBUG */
  24. #include <common.h>
  25. #include <mpc8xx.h>
  26. #if defined(CONFIG_ENV_IS_IN_FLASH)
  27. # ifndef CFG_ENV_ADDR
  28. # define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
  29. # endif
  30. # ifndef CFG_ENV_SIZE
  31. # define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
  32. # endif
  33. # ifndef CFG_ENV_SECT_SIZE
  34. # define CFG_ENV_SECT_SIZE CFG_ENV_SIZE
  35. # endif
  36. #endif
  37. /*---------------------------------------------------------------------*/
  38. flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
  39. /*-----------------------------------------------------------------------
  40. * Functions
  41. */
  42. static ulong flash_get_size (vu_long *addr, flash_info_t *info);
  43. static int write_data (flash_info_t *info, ulong dest, ulong data);
  44. #ifdef CFG_FLASH_USE_BUFFER_WRITE
  45. static int write_data_buf (flash_info_t * info, ulong dest, uchar * cp, int len);
  46. #endif
  47. static void flash_get_offsets (ulong base, flash_info_t *info);
  48. /*-----------------------------------------------------------------------
  49. */
  50. unsigned long flash_init (void)
  51. {
  52. volatile immap_t *immap = (immap_t *)CFG_IMMR;
  53. volatile memctl8xx_t *memctl = &immap->im_memctl;
  54. unsigned long size_b0, size_b1;
  55. int i;
  56. /* Init: no FLASHes known */
  57. for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
  58. flash_info[i].flash_id = FLASH_UNKNOWN;
  59. }
  60. /* Static FLASH Bank configuration here - FIXME XXX */
  61. debug ("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM);
  62. size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
  63. if (flash_info[0].flash_id == FLASH_UNKNOWN) {
  64. printf ("## Unknown FLASH on Bank 0: "
  65. "ID 0x%lx, Size = 0x%08lx = %ld MB\n",
  66. flash_info[0].flash_id,
  67. size_b0, size_b0<<20);
  68. }
  69. debug ("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM);
  70. size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
  71. debug ("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
  72. if (size_b1 > size_b0) {
  73. printf ("## ERROR: "
  74. "Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
  75. size_b1, size_b1<<20,
  76. size_b0, size_b0<<20
  77. );
  78. flash_info[0].flash_id = FLASH_UNKNOWN;
  79. flash_info[1].flash_id = FLASH_UNKNOWN;
  80. flash_info[0].sector_count = -1;
  81. flash_info[1].sector_count = -1;
  82. flash_info[0].size = 0;
  83. flash_info[1].size = 0;
  84. return (0);
  85. }
  86. debug ("## Before remap: "
  87. "BR0: 0x%08x OR0: 0x%08x "
  88. "BR1: 0x%08x OR1: 0x%08x\n",
  89. memctl->memc_br0, memctl->memc_or0,
  90. memctl->memc_br1, memctl->memc_or1);
  91. /* Remap FLASH according to real size */
  92. memctl->memc_or0 = (-size_b0 & 0xFFFF8000) | CFG_OR_TIMING_FLASH |
  93. OR_CSNT_SAM | OR_ACS_DIV1;
  94. memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) | BR_PS_32 | BR_V;
  95. debug ("## BR0: 0x%08x OR0: 0x%08x\n",
  96. memctl->memc_br0, memctl->memc_or0);
  97. /* Re-do sizing to get full correct info */
  98. size_b0 = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
  99. flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
  100. flash_info[0].size = size_b0;
  101. #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
  102. /* monitor protection ON by default */
  103. flash_protect(FLAG_PROTECT_SET,
  104. CFG_MONITOR_BASE,
  105. CFG_MONITOR_BASE+monitor_flash_len-1,
  106. &flash_info[0]);
  107. #endif
  108. #ifdef CONFIG_ENV_IS_IN_FLASH
  109. /* ENV protection ON by default */
  110. flash_protect(FLAG_PROTECT_SET,
  111. CFG_ENV_ADDR,
  112. CFG_ENV_ADDR+CFG_ENV_SECT_SIZE-1,
  113. &flash_info[0]);
  114. #endif
  115. if (size_b1) {
  116. memctl->memc_or1 = (-size_b1 & 0xFFFF8000) | CFG_OR_TIMING_FLASH |
  117. OR_CSNT_SAM | OR_ACS_DIV1;
  118. memctl->memc_br1 = ((CFG_FLASH_BASE + size_b0) & BR_BA_MSK) |
  119. BR_PS_32 | BR_V;
  120. debug ("## BR1: 0x%08x OR1: 0x%08x\n",
  121. memctl->memc_br1, memctl->memc_or1);
  122. /* Re-do sizing to get full correct info */
  123. size_b1 = flash_get_size((vu_long *)(CFG_FLASH_BASE + size_b0),
  124. &flash_info[1]);
  125. flash_info[1].size = size_b1;
  126. flash_get_offsets (CFG_FLASH_BASE + size_b0, &flash_info[1]);
  127. #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
  128. /* monitor protection ON by default */
  129. flash_protect(FLAG_PROTECT_SET,
  130. CFG_MONITOR_BASE,
  131. CFG_MONITOR_BASE+monitor_flash_len-1,
  132. &flash_info[1]);
  133. #endif
  134. #ifdef CONFIG_ENV_IS_IN_FLASH
  135. /* ENV protection ON by default */
  136. flash_protect(FLAG_PROTECT_SET,
  137. CFG_ENV_ADDR,
  138. CFG_ENV_ADDR+CFG_ENV_SECT_SIZE-1,
  139. &flash_info[1]);
  140. #endif
  141. } else {
  142. memctl->memc_br1 = 0; /* invalidate bank */
  143. memctl->memc_or1 = 0; /* invalidate bank */
  144. debug ("## DISABLE BR1: 0x%08x OR1: 0x%08x\n",
  145. memctl->memc_br1, memctl->memc_or1);
  146. flash_info[1].flash_id = FLASH_UNKNOWN;
  147. flash_info[1].sector_count = -1;
  148. flash_info[1].size = 0;
  149. }
  150. debug ("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
  151. return (size_b0 + size_b1);
  152. }
  153. /*-----------------------------------------------------------------------
  154. */
  155. static void flash_get_offsets (ulong base, flash_info_t *info)
  156. {
  157. int i;
  158. if (info->flash_id == FLASH_UNKNOWN) {
  159. return;
  160. }
  161. switch (info->flash_id & FLASH_VENDMASK) {
  162. case FLASH_MAN_INTEL:
  163. for (i = 0; i < info->sector_count; i++) {
  164. info->start[i] = base;
  165. base += 0x00020000 * 2; /* 128k * 2 chips per bank */
  166. }
  167. return;
  168. default:
  169. printf ("Don't know sector ofsets for flash type 0x%lx\n",
  170. info->flash_id);
  171. return;
  172. }
  173. }
  174. /*-----------------------------------------------------------------------
  175. */
  176. void flash_print_info (flash_info_t *info)
  177. {
  178. int i;
  179. if (info->flash_id == FLASH_UNKNOWN) {
  180. printf ("missing or unknown FLASH type\n");
  181. return;
  182. }
  183. switch (info->flash_id & FLASH_VENDMASK) {
  184. case FLASH_MAN_AMD: printf ("AMD "); break;
  185. case FLASH_MAN_FUJ: printf ("Fujitsu "); break;
  186. case FLASH_MAN_SST: printf ("SST "); break;
  187. case FLASH_MAN_STM: printf ("STM "); break;
  188. case FLASH_MAN_INTEL: printf ("Intel "); break;
  189. case FLASH_MAN_MT: printf ("MT "); break;
  190. default: printf ("Unknown Vendor "); break;
  191. }
  192. switch (info->flash_id & FLASH_TYPEMASK) {
  193. case FLASH_28F320J3A: printf ("28F320J3A (32Mbit = 128K x 32)\n");
  194. break;
  195. case FLASH_28F640J3A: printf ("28F640J3A (64Mbit = 128K x 64)\n");
  196. break;
  197. case FLASH_28F128J3A: printf ("28F128J3A (128Mbit = 128K x 128)\n");
  198. break;
  199. default: printf ("Unknown Chip Type\n");
  200. break;
  201. }
  202. if (info->size >= (1 << 20)) {
  203. i = 20;
  204. } else {
  205. i = 10;
  206. }
  207. printf (" Size: %ld %cB in %d Sectors\n",
  208. info->size >> i,
  209. (i == 20) ? 'M' : 'k',
  210. info->sector_count);
  211. printf (" Sector Start Addresses:");
  212. for (i=0; i<info->sector_count; ++i) {
  213. if ((i % 5) == 0)
  214. printf ("\n ");
  215. printf (" %08lX%s",
  216. info->start[i],
  217. info->protect[i] ? " (RO)" : " "
  218. );
  219. }
  220. printf ("\n");
  221. return;
  222. }
  223. /*-----------------------------------------------------------------------
  224. */
  225. /*-----------------------------------------------------------------------
  226. */
  227. /*
  228. * The following code cannot be run from FLASH!
  229. */
  230. static ulong flash_get_size (vu_long *addr, flash_info_t *info)
  231. {
  232. ulong value;
  233. /* Read Manufacturer ID */
  234. addr[0] = 0x00900090;
  235. value = addr[0];
  236. debug ("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value);
  237. switch (value) {
  238. case AMD_MANUFACT:
  239. info->flash_id = FLASH_MAN_AMD;
  240. break;
  241. case FUJ_MANUFACT:
  242. info->flash_id = FLASH_MAN_FUJ;
  243. break;
  244. case SST_MANUFACT:
  245. info->flash_id = FLASH_MAN_SST;
  246. break;
  247. case STM_MANUFACT:
  248. info->flash_id = FLASH_MAN_STM;
  249. break;
  250. case INTEL_MANUFACT:
  251. info->flash_id = FLASH_MAN_INTEL;
  252. break;
  253. default:
  254. info->flash_id = FLASH_UNKNOWN;
  255. info->sector_count = 0;
  256. info->size = 0;
  257. addr[0] = 0x00FF00FF; /* restore read mode */
  258. return (0); /* no or unknown flash */
  259. }
  260. value = addr[1]; /* device ID */
  261. debug ("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value);
  262. switch (value) {
  263. case INTEL_ID_28F320J3A:
  264. info->flash_id += FLASH_28F320J3A;
  265. info->sector_count = 32;
  266. info->size = 0x00400000 * 2;
  267. break; /* => 8 MB */
  268. case INTEL_ID_28F640J3A:
  269. info->flash_id += FLASH_28F640J3A;
  270. info->sector_count = 64;
  271. info->size = 0x00800000 * 2;
  272. break; /* => 16 MB */
  273. case INTEL_ID_28F128J3A:
  274. info->flash_id += FLASH_28F128J3A;
  275. info->sector_count = 128;
  276. info->size = 0x01000000 * 2;
  277. break; /* => 32 MB */
  278. default:
  279. info->flash_id = FLASH_UNKNOWN;
  280. addr[0] = 0x00FF00FF; /* restore read mode */
  281. return (0); /* => no or unknown flash */
  282. }
  283. if (info->sector_count > CFG_MAX_FLASH_SECT) {
  284. printf ("** ERROR: sector count %d > max (%d) **\n",
  285. info->sector_count, CFG_MAX_FLASH_SECT);
  286. info->sector_count = CFG_MAX_FLASH_SECT;
  287. }
  288. addr[0] = 0x00FF00FF; /* restore read mode */
  289. return (info->size);
  290. }
  291. /*-----------------------------------------------------------------------
  292. */
  293. int flash_erase (flash_info_t *info, int s_first, int s_last)
  294. {
  295. int flag, prot, sect;
  296. ulong start, now, last;
  297. debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
  298. if ((s_first < 0) || (s_first > s_last)) {
  299. if (info->flash_id == FLASH_UNKNOWN) {
  300. printf ("- missing\n");
  301. } else {
  302. printf ("- no sectors to erase\n");
  303. }
  304. return 1;
  305. }
  306. if ((info->flash_id & FLASH_VENDMASK) != FLASH_MAN_INTEL) {
  307. printf ("Can erase only Intel flash types - aborted\n");
  308. return 1;
  309. }
  310. prot = 0;
  311. for (sect=s_first; sect<=s_last; ++sect) {
  312. if (info->protect[sect]) {
  313. prot++;
  314. }
  315. }
  316. if (prot) {
  317. printf ("- Warning: %d protected sectors will not be erased!\n",
  318. prot);
  319. } else {
  320. printf ("\n");
  321. }
  322. start = get_timer (0);
  323. last = start;
  324. /* Start erase on unprotected sectors */
  325. for (sect = s_first; sect<=s_last; sect++) {
  326. if (info->protect[sect] == 0) { /* not protected */
  327. vu_long *addr = (vu_long *)(info->start[sect]);
  328. unsigned long status;
  329. /* Disable interrupts which might cause a timeout here */
  330. flag = disable_interrupts();
  331. *addr = 0x00600060; /* clear lock bit setup */
  332. *addr = 0x00D000D0; /* clear lock bit confirm */
  333. udelay (1000);
  334. /* This takes awfully long - up to 50 ms and more */
  335. while (((status = *addr) & 0x00800080) != 0x00800080) {
  336. if ((now=get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
  337. printf ("Timeout\n");
  338. *addr = 0x00FF00FF; /* reset to read mode */
  339. return 1;
  340. }
  341. /* show that we're waiting */
  342. if ((now - last) > 1000) { /* every second */
  343. putc ('.');
  344. last = now;
  345. }
  346. udelay (1000); /* to trigger the watchdog */
  347. }
  348. *addr = 0x00500050; /* clear status register */
  349. *addr = 0x00200020; /* erase setup */
  350. *addr = 0x00D000D0; /* erase confirm */
  351. /* re-enable interrupts if necessary */
  352. if (flag)
  353. enable_interrupts();
  354. /* wait at least 80us - let's wait 1 ms */
  355. udelay (1000);
  356. while (((status = *addr) & 0x00800080) != 0x00800080) {
  357. if ((now=get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
  358. printf ("Timeout\n");
  359. *addr = 0x00B000B0; /* suspend erase */
  360. *addr = 0x00FF00FF; /* reset to read mode */
  361. return 1;
  362. }
  363. /* show that we're waiting */
  364. if ((now - last) > 1000) { /* every second */
  365. putc ('.');
  366. last = now;
  367. }
  368. udelay (1000); /* to trigger the watchdog */
  369. }
  370. *addr = 0x00FF00FF; /* reset to read mode */
  371. }
  372. }
  373. printf (" done\n");
  374. return 0;
  375. }
  376. /*-----------------------------------------------------------------------
  377. * Copy memory to flash, returns:
  378. * 0 - OK
  379. * 1 - write timeout
  380. * 2 - Flash not erased
  381. * 4 - Flash not identified
  382. */
  383. #define FLASH_WIDTH 4 /* flash bus width in bytes */
  384. int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
  385. {
  386. ulong cp, wp, data;
  387. int i, l, rc;
  388. if (info->flash_id == FLASH_UNKNOWN) {
  389. return 4;
  390. }
  391. wp = (addr & ~(FLASH_WIDTH-1)); /* get lower FLASH_WIDTH aligned address */
  392. /*
  393. * handle unaligned start bytes
  394. */
  395. if ((l = addr - wp) != 0) {
  396. data = 0;
  397. for (i=0, cp=wp; i<l; ++i, ++cp) {
  398. data = (data << 8) | (*(uchar *)cp);
  399. }
  400. for (; i<FLASH_WIDTH && cnt>0; ++i) {
  401. data = (data << 8) | *src++;
  402. --cnt;
  403. ++cp;
  404. }
  405. for (; cnt==0 && i<FLASH_WIDTH; ++i, ++cp) {
  406. data = (data << 8) | (*(uchar *)cp);
  407. }
  408. if ((rc = write_data(info, wp, data)) != 0) {
  409. return (rc);
  410. }
  411. wp += FLASH_WIDTH;
  412. }
  413. /*
  414. * handle FLASH_WIDTH aligned part
  415. */
  416. #ifdef CFG_FLASH_USE_BUFFER_WRITE
  417. while(cnt >= FLASH_WIDTH) {
  418. i = CFG_FLASH_BUFFER_SIZE > cnt ?
  419. (cnt & ~(FLASH_WIDTH - 1)) : CFG_FLASH_BUFFER_SIZE;
  420. if((rc = write_data_buf(info, wp, src,i)) != 0)
  421. return rc;
  422. wp += i;
  423. src += i;
  424. cnt -=i;
  425. }
  426. #else
  427. while (cnt >= FLASH_WIDTH) {
  428. data = 0;
  429. for (i=0; i<FLASH_WIDTH; ++i) {
  430. data = (data << 8) | *src++;
  431. }
  432. if ((rc = write_data(info, wp, data)) != 0) {
  433. return (rc);
  434. }
  435. wp += FLASH_WIDTH;
  436. cnt -= FLASH_WIDTH;
  437. }
  438. #endif /* CFG_FLASH_USE_BUFFER_WRITE */
  439. if (cnt == 0) {
  440. return (0);
  441. }
  442. /*
  443. * handle unaligned tail bytes
  444. */
  445. data = 0;
  446. for (i=0, cp=wp; i<FLASH_WIDTH && cnt>0; ++i, ++cp) {
  447. data = (data << 8) | *src++;
  448. --cnt;
  449. }
  450. for (; i<FLASH_WIDTH; ++i, ++cp) {
  451. data = (data << 8) | (*(uchar *)cp);
  452. }
  453. return (write_data(info, wp, data));
  454. }
  455. /*-----------------------------------------------------------------------
  456. * Check flash status, returns:
  457. * 0 - OK
  458. * 1 - timeout
  459. */
  460. static int flash_status_check(vu_long *addr, ulong tout, char * prompt)
  461. {
  462. ulong status;
  463. ulong start;
  464. /* Wait for command completion */
  465. start = get_timer (0);
  466. while(((status = *addr) & 0x00800080) != 0x00800080) {
  467. if (get_timer(start) > tout) {
  468. printf("Flash %s timeout at address %p\n", prompt, addr);
  469. *addr = 0x00FF00FF; /* restore read mode */
  470. return (1);
  471. }
  472. }
  473. return 0;
  474. }
  475. /*-----------------------------------------------------------------------
  476. * Write a word to Flash, returns:
  477. * 0 - OK
  478. * 1 - write timeout
  479. * 2 - Flash not erased
  480. */
  481. static int write_data (flash_info_t *info, ulong dest, ulong data)
  482. {
  483. vu_long *addr = (vu_long *)dest;
  484. int flag;
  485. /* Check if Flash is (sufficiently) erased */
  486. if ((*addr & data) != data) {
  487. return (2);
  488. }
  489. /* Disable interrupts which might cause a timeout here */
  490. flag = disable_interrupts();
  491. *addr = 0x00400040; /* write setup */
  492. *addr = data;
  493. /* re-enable interrupts if necessary */
  494. if (flag)
  495. enable_interrupts();
  496. if (flash_status_check(addr, CFG_FLASH_WRITE_TOUT, "write") != 0) {
  497. return (1);
  498. }
  499. *addr = 0x00FF00FF; /* restore read mode */
  500. return (0);
  501. }
  502. #ifdef CFG_FLASH_USE_BUFFER_WRITE
  503. /*-----------------------------------------------------------------------
  504. * Write a buffer to Flash, returns:
  505. * 0 - OK
  506. * 1 - write timeout
  507. */
  508. static int write_data_buf(flash_info_t * info, ulong dest, uchar * cp, int len)
  509. {
  510. vu_long *addr = (vu_long *)dest;
  511. int sector;
  512. int cnt;
  513. int retcode;
  514. vu_long * src = (vu_long *)cp;
  515. vu_long * dst = (vu_long *)dest;
  516. /* find sector */
  517. for(sector = info->sector_count - 1; sector >= 0; sector--) {
  518. if(dest >= info->start[sector])
  519. break;
  520. }
  521. *addr = 0x00500050; /* clear status */
  522. *addr = 0x00e800e8; /* write buffer */
  523. if((retcode = flash_status_check(addr, CFG_FLASH_BUFFER_WRITE_TOUT,
  524. "write to buffer")) == 0) {
  525. cnt = len / FLASH_WIDTH;
  526. *addr = (cnt-1) | ((cnt-1) << 16);
  527. while(cnt-- > 0) {
  528. *dst++ = *src++;
  529. }
  530. *addr = 0x00d000d0; /* write buffer confirm */
  531. retcode = flash_status_check(addr, CFG_FLASH_BUFFER_WRITE_TOUT,
  532. "buffer write");
  533. }
  534. *addr = 0x00FF00FF; /* restore read mode */
  535. *addr = 0x00500050; /* clear status */
  536. return retcode;
  537. }
  538. #endif /* CFG_USE_FLASH_BUFFER_WRITE */
  539. /*-----------------------------------------------------------------------
  540. */