xyzModem.c 15 KB

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