xyzModem.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. // SPDX-License-Identifier: eCos-2.0
  2. /*
  3. *==========================================================================
  4. *
  5. * xyzModem.c
  6. *
  7. * RedBoot stream handler for xyzModem protocol
  8. *
  9. *==========================================================================
  10. *#####DESCRIPTIONBEGIN####
  11. *
  12. * Author(s): gthomas
  13. * Contributors: gthomas, tsmith, Yoshinori Sato
  14. * Date: 2000-07-14
  15. * Purpose:
  16. * Description:
  17. *
  18. * This code is part of RedBoot (tm).
  19. *
  20. *####DESCRIPTIONEND####
  21. *
  22. *==========================================================================
  23. */
  24. #include <common.h>
  25. #include <xyzModem.h>
  26. #include <stdarg.h>
  27. #include <crc.h>
  28. /* Assumption - run xyzModem protocol over the console port */
  29. /* Values magic to the protocol */
  30. #define SOH 0x01
  31. #define STX 0x02
  32. #define EOT 0x04
  33. #define ACK 0x06
  34. #define BSP 0x08
  35. #define NAK 0x15
  36. #define CAN 0x18
  37. #define EOF 0x1A /* ^Z for DOS officionados */
  38. /* Data & state local to the protocol */
  39. static struct
  40. {
  41. int *__chan;
  42. unsigned char pkt[1024], *bufp;
  43. unsigned char blk, cblk, crc1, crc2;
  44. unsigned char next_blk; /* Expected block */
  45. int len, mode, total_retries;
  46. int total_SOH, total_STX, total_CAN;
  47. bool crc_mode, at_eof, tx_ack;
  48. unsigned long file_length, read_length;
  49. } xyz;
  50. #define xyzModem_CHAR_TIMEOUT 2000 /* 2 seconds */
  51. #define xyzModem_MAX_RETRIES 20
  52. #define xyzModem_MAX_RETRIES_WITH_CRC 10
  53. #define xyzModem_CAN_COUNT 3 /* Wait for 3 CAN before quitting */
  54. typedef int cyg_int32;
  55. static int
  56. CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
  57. {
  58. ulong now = get_timer(0);
  59. while (!tstc ())
  60. {
  61. if (get_timer(now) > xyzModem_CHAR_TIMEOUT)
  62. break;
  63. }
  64. if (tstc ())
  65. {
  66. *c = getc ();
  67. return 1;
  68. }
  69. return 0;
  70. }
  71. static void
  72. CYGACC_COMM_IF_PUTC (char x, char y)
  73. {
  74. putc (y);
  75. }
  76. /* Validate a hex character */
  77. __inline__ static bool
  78. _is_hex (char c)
  79. {
  80. return (((c >= '0') && (c <= '9')) ||
  81. ((c >= 'A') && (c <= 'F')) || ((c >= 'a') && (c <= 'f')));
  82. }
  83. /* Convert a single hex nibble */
  84. __inline__ static int
  85. _from_hex (char c)
  86. {
  87. int ret = 0;
  88. if ((c >= '0') && (c <= '9'))
  89. {
  90. ret = (c - '0');
  91. }
  92. else if ((c >= 'a') && (c <= 'f'))
  93. {
  94. ret = (c - 'a' + 0x0a);
  95. }
  96. else if ((c >= 'A') && (c <= 'F'))
  97. {
  98. ret = (c - 'A' + 0x0A);
  99. }
  100. return ret;
  101. }
  102. /* Convert a character to lower case */
  103. __inline__ static char
  104. _tolower (char c)
  105. {
  106. if ((c >= 'A') && (c <= 'Z'))
  107. {
  108. c = (c - 'A') + 'a';
  109. }
  110. return c;
  111. }
  112. /* Parse (scan) a number */
  113. static bool
  114. parse_num (char *s, unsigned long *val, char **es, char *delim)
  115. {
  116. bool first = true;
  117. int radix = 10;
  118. char c;
  119. unsigned long result = 0;
  120. int digit;
  121. while (*s == ' ')
  122. s++;
  123. while (*s)
  124. {
  125. if (first && (s[0] == '0') && (_tolower (s[1]) == 'x'))
  126. {
  127. radix = 16;
  128. s += 2;
  129. }
  130. first = false;
  131. c = *s++;
  132. if (_is_hex (c) && ((digit = _from_hex (c)) < radix))
  133. {
  134. /* Valid digit */
  135. result = (result * radix) + digit;
  136. }
  137. else
  138. {
  139. if (delim != (char *) 0)
  140. {
  141. /* See if this character is one of the delimiters */
  142. char *dp = delim;
  143. while (*dp && (c != *dp))
  144. dp++;
  145. if (*dp)
  146. break; /* Found a good delimiter */
  147. }
  148. return false; /* Malformatted number */
  149. }
  150. }
  151. *val = result;
  152. if (es != (char **) 0)
  153. {
  154. *es = s;
  155. }
  156. return true;
  157. }
  158. #if defined(DEBUG) && !defined(CONFIG_USE_TINY_PRINTF)
  159. /*
  160. * Note: this debug setup works by storing the strings in a fixed buffer
  161. */
  162. static char zm_debug_buf[8192];
  163. static char *zm_out = zm_debug_buf;
  164. static char *zm_out_start = zm_debug_buf;
  165. static int
  166. zm_dprintf(char *fmt, ...)
  167. {
  168. int len;
  169. va_list args;
  170. va_start(args, fmt);
  171. len = diag_vsprintf(zm_out, fmt, args);
  172. va_end(args);
  173. zm_out += len;
  174. return len;
  175. }
  176. static void
  177. zm_flush (void)
  178. {
  179. zm_out = zm_out_start;
  180. }
  181. static void
  182. zm_dump_buf (void *buf, int len)
  183. {
  184. }
  185. static unsigned char zm_buf[2048];
  186. static unsigned char *zm_bp;
  187. static void
  188. zm_new (void)
  189. {
  190. zm_bp = zm_buf;
  191. }
  192. static void
  193. zm_save (unsigned char c)
  194. {
  195. *zm_bp++ = c;
  196. }
  197. static void
  198. zm_dump (int line)
  199. {
  200. zm_dprintf ("Packet at line: %d\n", line);
  201. zm_dump_buf (zm_buf, zm_bp - zm_buf);
  202. }
  203. #define ZM_DEBUG(x) x
  204. #else
  205. #define ZM_DEBUG(x)
  206. #endif
  207. /* Wait for the line to go idle */
  208. static void
  209. xyzModem_flush (void)
  210. {
  211. int res;
  212. char c;
  213. while (true)
  214. {
  215. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, &c);
  216. if (!res)
  217. return;
  218. }
  219. }
  220. static int
  221. xyzModem_get_hdr (void)
  222. {
  223. char c;
  224. int res;
  225. bool hdr_found = false;
  226. int i, can_total, hdr_chars;
  227. unsigned short cksum;
  228. ZM_DEBUG (zm_new ());
  229. /* Find the start of a header */
  230. can_total = 0;
  231. hdr_chars = 0;
  232. if (xyz.tx_ack)
  233. {
  234. CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK);
  235. xyz.tx_ack = false;
  236. }
  237. while (!hdr_found)
  238. {
  239. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, &c);
  240. ZM_DEBUG (zm_save (c));
  241. if (res)
  242. {
  243. hdr_chars++;
  244. switch (c)
  245. {
  246. case SOH:
  247. xyz.total_SOH++;
  248. case STX:
  249. if (c == STX)
  250. xyz.total_STX++;
  251. hdr_found = true;
  252. break;
  253. case CAN:
  254. xyz.total_CAN++;
  255. ZM_DEBUG (zm_dump (__LINE__));
  256. if (++can_total == xyzModem_CAN_COUNT)
  257. {
  258. return xyzModem_cancel;
  259. }
  260. else
  261. {
  262. /* Wait for multiple CAN to avoid early quits */
  263. break;
  264. }
  265. case EOT:
  266. /* EOT only supported if no noise */
  267. if (hdr_chars == 1)
  268. {
  269. CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK);
  270. ZM_DEBUG (zm_dprintf ("ACK on EOT #%d\n", __LINE__));
  271. ZM_DEBUG (zm_dump (__LINE__));
  272. return xyzModem_eof;
  273. }
  274. default:
  275. /* Ignore, waiting for start of header */
  276. ;
  277. }
  278. }
  279. else
  280. {
  281. /* Data stream timed out */
  282. xyzModem_flush (); /* Toss any current input */
  283. ZM_DEBUG (zm_dump (__LINE__));
  284. CYGACC_CALL_IF_DELAY_US ((cyg_int32) 250000);
  285. return xyzModem_timeout;
  286. }
  287. }
  288. /* Header found, now read the data */
  289. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, (char *) &xyz.blk);
  290. ZM_DEBUG (zm_save (xyz.blk));
  291. if (!res)
  292. {
  293. ZM_DEBUG (zm_dump (__LINE__));
  294. return xyzModem_timeout;
  295. }
  296. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, (char *) &xyz.cblk);
  297. ZM_DEBUG (zm_save (xyz.cblk));
  298. if (!res)
  299. {
  300. ZM_DEBUG (zm_dump (__LINE__));
  301. return xyzModem_timeout;
  302. }
  303. xyz.len = (c == SOH) ? 128 : 1024;
  304. xyz.bufp = xyz.pkt;
  305. for (i = 0; i < xyz.len; i++)
  306. {
  307. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, &c);
  308. ZM_DEBUG (zm_save (c));
  309. if (res)
  310. {
  311. xyz.pkt[i] = c;
  312. }
  313. else
  314. {
  315. ZM_DEBUG (zm_dump (__LINE__));
  316. return xyzModem_timeout;
  317. }
  318. }
  319. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, (char *) &xyz.crc1);
  320. ZM_DEBUG (zm_save (xyz.crc1));
  321. if (!res)
  322. {
  323. ZM_DEBUG (zm_dump (__LINE__));
  324. return xyzModem_timeout;
  325. }
  326. if (xyz.crc_mode)
  327. {
  328. res = CYGACC_COMM_IF_GETC_TIMEOUT (*xyz.__chan, (char *) &xyz.crc2);
  329. ZM_DEBUG (zm_save (xyz.crc2));
  330. if (!res)
  331. {
  332. ZM_DEBUG (zm_dump (__LINE__));
  333. return xyzModem_timeout;
  334. }
  335. }
  336. ZM_DEBUG (zm_dump (__LINE__));
  337. /* Validate the message */
  338. if ((xyz.blk ^ xyz.cblk) != (unsigned char) 0xFF)
  339. {
  340. ZM_DEBUG (zm_dprintf
  341. ("Framing error - blk: %x/%x/%x\n", xyz.blk, xyz.cblk,
  342. (xyz.blk ^ xyz.cblk)));
  343. ZM_DEBUG (zm_dump_buf (xyz.pkt, xyz.len));
  344. xyzModem_flush ();
  345. return xyzModem_frame;
  346. }
  347. /* Verify checksum/CRC */
  348. if (xyz.crc_mode)
  349. {
  350. cksum = crc16_ccitt(0, xyz.pkt, xyz.len);
  351. if (cksum != ((xyz.crc1 << 8) | xyz.crc2))
  352. {
  353. ZM_DEBUG (zm_dprintf ("CRC error - recvd: %02x%02x, computed: %x\n",
  354. xyz.crc1, xyz.crc2, cksum & 0xFFFF));
  355. return xyzModem_cksum;
  356. }
  357. }
  358. else
  359. {
  360. cksum = 0;
  361. for (i = 0; i < xyz.len; i++)
  362. {
  363. cksum += xyz.pkt[i];
  364. }
  365. if (xyz.crc1 != (cksum & 0xFF))
  366. {
  367. ZM_DEBUG (zm_dprintf
  368. ("Checksum error - recvd: %x, computed: %x\n", xyz.crc1,
  369. cksum & 0xFF));
  370. return xyzModem_cksum;
  371. }
  372. }
  373. /* If we get here, the message passes [structural] muster */
  374. return 0;
  375. }
  376. int
  377. xyzModem_stream_open (connection_info_t * info, int *err)
  378. {
  379. int stat = 0;
  380. int retries = xyzModem_MAX_RETRIES;
  381. int crc_retries = xyzModem_MAX_RETRIES_WITH_CRC;
  382. /* ZM_DEBUG(zm_out = zm_out_start); */
  383. #ifdef xyzModem_zmodem
  384. if (info->mode == xyzModem_zmodem)
  385. {
  386. *err = xyzModem_noZmodem;
  387. return -1;
  388. }
  389. #endif
  390. /* TODO: CHECK ! */
  391. int dummy = 0;
  392. xyz.__chan = &dummy;
  393. xyz.len = 0;
  394. xyz.crc_mode = true;
  395. xyz.at_eof = false;
  396. xyz.tx_ack = false;
  397. xyz.mode = info->mode;
  398. xyz.total_retries = 0;
  399. xyz.total_SOH = 0;
  400. xyz.total_STX = 0;
  401. xyz.total_CAN = 0;
  402. xyz.read_length = 0;
  403. xyz.file_length = 0;
  404. CYGACC_COMM_IF_PUTC (*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
  405. if (xyz.mode == xyzModem_xmodem)
  406. {
  407. /* X-modem doesn't have an information header - exit here */
  408. xyz.next_blk = 1;
  409. return 0;
  410. }
  411. while (retries-- > 0)
  412. {
  413. stat = xyzModem_get_hdr ();
  414. if (stat == 0)
  415. {
  416. /* Y-modem file information header */
  417. if (xyz.blk == 0)
  418. {
  419. /* skip filename */
  420. while (*xyz.bufp++);
  421. /* get the length */
  422. parse_num ((char *) xyz.bufp, &xyz.file_length, NULL, " ");
  423. /* The rest of the file name data block quietly discarded */
  424. xyz.tx_ack = true;
  425. }
  426. xyz.next_blk = 1;
  427. xyz.len = 0;
  428. return 0;
  429. }
  430. else if (stat == xyzModem_timeout)
  431. {
  432. if (--crc_retries <= 0)
  433. xyz.crc_mode = false;
  434. CYGACC_CALL_IF_DELAY_US (5 * 100000); /* Extra delay for startup */
  435. CYGACC_COMM_IF_PUTC (*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
  436. xyz.total_retries++;
  437. ZM_DEBUG (zm_dprintf ("NAK (%d)\n", __LINE__));
  438. }
  439. if (stat == xyzModem_cancel)
  440. {
  441. break;
  442. }
  443. }
  444. *err = stat;
  445. ZM_DEBUG (zm_flush ());
  446. return -1;
  447. }
  448. int
  449. xyzModem_stream_read (char *buf, int size, int *err)
  450. {
  451. int stat, total, len;
  452. int retries;
  453. total = 0;
  454. stat = xyzModem_cancel;
  455. /* Try and get 'size' bytes into the buffer */
  456. while (!xyz.at_eof && (size > 0))
  457. {
  458. if (xyz.len == 0)
  459. {
  460. retries = xyzModem_MAX_RETRIES;
  461. while (retries-- > 0)
  462. {
  463. stat = xyzModem_get_hdr ();
  464. if (stat == 0)
  465. {
  466. if (xyz.blk == xyz.next_blk)
  467. {
  468. xyz.tx_ack = true;
  469. ZM_DEBUG (zm_dprintf
  470. ("ACK block %d (%d)\n", xyz.blk, __LINE__));
  471. xyz.next_blk = (xyz.next_blk + 1) & 0xFF;
  472. if (xyz.mode == xyzModem_xmodem || xyz.file_length == 0)
  473. {
  474. /* Data blocks can be padded with ^Z (EOF) characters */
  475. /* This code tries to detect and remove them */
  476. if ((xyz.bufp[xyz.len - 1] == EOF) &&
  477. (xyz.bufp[xyz.len - 2] == EOF) &&
  478. (xyz.bufp[xyz.len - 3] == EOF))
  479. {
  480. while (xyz.len
  481. && (xyz.bufp[xyz.len - 1] == EOF))
  482. {
  483. xyz.len--;
  484. }
  485. }
  486. }
  487. /*
  488. * See if accumulated length exceeds that of the file.
  489. * If so, reduce size (i.e., cut out pad bytes)
  490. * Only do this for Y-modem (and Z-modem should it ever
  491. * be supported since it can fall back to Y-modem mode).
  492. */
  493. if (xyz.mode != xyzModem_xmodem && 0 != xyz.file_length)
  494. {
  495. xyz.read_length += xyz.len;
  496. if (xyz.read_length > xyz.file_length)
  497. {
  498. xyz.len -= (xyz.read_length - xyz.file_length);
  499. }
  500. }
  501. break;
  502. }
  503. else if (xyz.blk == ((xyz.next_blk - 1) & 0xFF))
  504. {
  505. /* Just re-ACK this so sender will get on with it */
  506. CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK);
  507. continue; /* Need new header */
  508. }
  509. else
  510. {
  511. stat = xyzModem_sequence;
  512. }
  513. }
  514. if (stat == xyzModem_cancel)
  515. {
  516. break;
  517. }
  518. if (stat == xyzModem_eof)
  519. {
  520. CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK);
  521. ZM_DEBUG (zm_dprintf ("ACK (%d)\n", __LINE__));
  522. if (xyz.mode == xyzModem_ymodem)
  523. {
  524. CYGACC_COMM_IF_PUTC (*xyz.__chan,
  525. (xyz.crc_mode ? 'C' : NAK));
  526. xyz.total_retries++;
  527. ZM_DEBUG (zm_dprintf ("Reading Final Header\n"));
  528. stat = xyzModem_get_hdr ();
  529. CYGACC_COMM_IF_PUTC (*xyz.__chan, ACK);
  530. ZM_DEBUG (zm_dprintf ("FINAL ACK (%d)\n", __LINE__));
  531. }
  532. xyz.at_eof = true;
  533. break;
  534. }
  535. CYGACC_COMM_IF_PUTC (*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
  536. xyz.total_retries++;
  537. ZM_DEBUG (zm_dprintf ("NAK (%d)\n", __LINE__));
  538. }
  539. if (stat < 0)
  540. {
  541. *err = stat;
  542. xyz.len = -1;
  543. return total;
  544. }
  545. }
  546. /* Don't "read" data from the EOF protocol package */
  547. if (!xyz.at_eof)
  548. {
  549. len = xyz.len;
  550. if (size < len)
  551. len = size;
  552. memcpy (buf, xyz.bufp, len);
  553. size -= len;
  554. buf += len;
  555. total += len;
  556. xyz.len -= len;
  557. xyz.bufp += len;
  558. }
  559. }
  560. return total;
  561. }
  562. void
  563. xyzModem_stream_close (int *err)
  564. {
  565. diag_printf
  566. ("xyzModem - %s mode, %d(SOH)/%d(STX)/%d(CAN) packets, %d retries\n",
  567. xyz.crc_mode ? "CRC" : "Cksum", xyz.total_SOH, xyz.total_STX,
  568. xyz.total_CAN, xyz.total_retries);
  569. ZM_DEBUG (zm_flush ());
  570. }
  571. /* Need to be able to clean out the input buffer, so have to take the */
  572. /* getc */
  573. void
  574. xyzModem_stream_terminate (bool abort, int (*getc) (void))
  575. {
  576. int c;
  577. if (abort)
  578. {
  579. ZM_DEBUG (zm_dprintf ("!!!! TRANSFER ABORT !!!!\n"));
  580. switch (xyz.mode)
  581. {
  582. case xyzModem_xmodem:
  583. case xyzModem_ymodem:
  584. /* The X/YMODEM Spec seems to suggest that multiple CAN followed by an equal */
  585. /* number of Backspaces is a friendly way to get the other end to abort. */
  586. CYGACC_COMM_IF_PUTC (*xyz.__chan, CAN);
  587. CYGACC_COMM_IF_PUTC (*xyz.__chan, CAN);
  588. CYGACC_COMM_IF_PUTC (*xyz.__chan, CAN);
  589. CYGACC_COMM_IF_PUTC (*xyz.__chan, CAN);
  590. CYGACC_COMM_IF_PUTC (*xyz.__chan, BSP);
  591. CYGACC_COMM_IF_PUTC (*xyz.__chan, BSP);
  592. CYGACC_COMM_IF_PUTC (*xyz.__chan, BSP);
  593. CYGACC_COMM_IF_PUTC (*xyz.__chan, BSP);
  594. /* Now consume the rest of what's waiting on the line. */
  595. ZM_DEBUG (zm_dprintf ("Flushing serial line.\n"));
  596. xyzModem_flush ();
  597. xyz.at_eof = true;
  598. break;
  599. #ifdef xyzModem_zmodem
  600. case xyzModem_zmodem:
  601. /* Might support it some day I suppose. */
  602. #endif
  603. break;
  604. }
  605. }
  606. else
  607. {
  608. ZM_DEBUG (zm_dprintf ("Engaging cleanup mode...\n"));
  609. /*
  610. * Consume any trailing crap left in the inbuffer from
  611. * previous received blocks. Since very few files are an exact multiple
  612. * of the transfer block size, there will almost always be some gunk here.
  613. * If we don't eat it now, RedBoot will think the user typed it.
  614. */
  615. ZM_DEBUG (zm_dprintf ("Trailing gunk:\n"));
  616. while ((c = (*getc) ()) > -1)
  617. ;
  618. ZM_DEBUG (zm_dprintf ("\n"));
  619. /*
  620. * Make a small delay to give terminal programs like minicom
  621. * time to get control again after their file transfer program
  622. * exits.
  623. */
  624. CYGACC_CALL_IF_DELAY_US ((cyg_int32) 250000);
  625. }
  626. }
  627. char *
  628. xyzModem_error (int err)
  629. {
  630. switch (err)
  631. {
  632. case xyzModem_access:
  633. return "Can't access file";
  634. break;
  635. case xyzModem_noZmodem:
  636. return "Sorry, zModem not available yet";
  637. break;
  638. case xyzModem_timeout:
  639. return "Timed out";
  640. break;
  641. case xyzModem_eof:
  642. return "End of file";
  643. break;
  644. case xyzModem_cancel:
  645. return "Cancelled";
  646. break;
  647. case xyzModem_frame:
  648. return "Invalid framing";
  649. break;
  650. case xyzModem_cksum:
  651. return "CRC/checksum error";
  652. break;
  653. case xyzModem_sequence:
  654. return "Block sequence error";
  655. break;
  656. default:
  657. return "Unknown error";
  658. break;
  659. }
  660. }
  661. /*
  662. * RedBoot interface
  663. */