xyzModem.c 15 KB

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