2 * (C) Copyright 2000-2004
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
25 * Serial up- and download support
34 DECLARE_GLOBAL_DATA_PTR;
36 #if (CONFIG_COMMANDS & CFG_CMD_LOADS)
37 static ulong load_serial (ulong offset);
38 static ulong load_serial_ymodem (ulong offset);
39 static int read_record (char *buf, ulong len);
40 # if (CONFIG_COMMANDS & CFG_CMD_SAVES)
41 static int save_serial (ulong offset, ulong size);
42 static int write_record (char *buf);
43 # endif /* CFG_CMD_SAVES */
45 static int do_echo = 1;
46 #endif /* CFG_CMD_LOADS */
48 /* -------------------------------------------------------------------- */
50 #if (CONFIG_COMMANDS & CFG_CMD_LOADS)
51 int do_load_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
58 #ifdef CFG_LOADS_BAUD_CHANGE
59 int load_baudrate, current_baudrate;
61 load_baudrate = current_baudrate = gd->baudrate;
64 if (((env_echo = getenv("loads_echo")) != NULL) && (*env_echo == '1')) {
70 #ifdef CFG_LOADS_BAUD_CHANGE
72 offset = simple_strtoul(argv[1], NULL, 16);
75 load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
77 /* default to current baudrate */
78 if (load_baudrate == 0)
79 load_baudrate = current_baudrate;
81 if (load_baudrate != current_baudrate) {
82 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
85 gd->baudrate = load_baudrate;
93 #else /* ! CFG_LOADS_BAUD_CHANGE */
95 offset = simple_strtoul(argv[1], NULL, 16);
97 #endif /* CFG_LOADS_BAUD_CHANGE */
99 printf ("## Ready for S-Record download ...\n");
101 addr = load_serial (offset);
104 * Gather any trailing characters (for instance, the ^D which
105 * is sent by 'cu' after sending a file), and give the
106 * box some time (100 * 1 ms)
108 for (i=0; i<100; ++i) {
116 printf ("## S-Record download aborted\n");
119 printf ("## Start Addr = 0x%08lX\n", addr);
123 #ifdef CFG_LOADS_BAUD_CHANGE
124 if (load_baudrate != current_baudrate) {
125 printf ("## Switch baudrate to %d bps and press ESC ...\n",
128 gd->baudrate = current_baudrate;
132 if (getc() == 0x1B) /* ESC */
141 load_serial (ulong offset)
143 char record[SREC_MAXRECLEN + 1]; /* buffer for one S-Record */
144 char binbuf[SREC_MAXBINLEN]; /* buffer for binary data */
145 int binlen; /* no. of data bytes in S-Rec. */
146 int type; /* return code for record type */
147 ulong addr; /* load address from S-Record */
148 ulong size; /* number of bytes transferred */
151 ulong start_addr = ~0;
155 while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {
156 type = srec_decode (record, &binlen, &addr, binbuf);
159 return (~0); /* Invalid S-Record */
166 store_addr = addr + offset;
168 if (addr2info(store_addr)) {
171 rc = flash_write((char *)binbuf,store_addr,binlen);
179 memcpy ((char *)(store_addr), binbuf, binlen);
181 if ((store_addr) < start_addr)
182 start_addr = store_addr;
183 if ((store_addr + binlen - 1) > end_addr)
184 end_addr = store_addr + binlen - 1;
190 size = end_addr - start_addr + 1;
192 "## First Load Addr = 0x%08lX\n"
193 "## Last Load Addr = 0x%08lX\n"
194 "## Total Size = 0x%08lX = %ld Bytes\n",
195 start_addr, end_addr, size, size
197 flush_cache (start_addr, size);
198 sprintf(buf, "%lX", size);
199 setenv("filesize", buf);
206 if (!do_echo) { /* print a '.' every 100 lines */
207 if ((++line_count % 100) == 0)
212 return (~0); /* Download aborted */
216 read_record (char *buf, ulong len)
221 --len; /* always leave room for terminating '\0' byte */
223 for (p=buf; p < buf+len; ++p) {
224 c = getc(); /* read character */
226 putc (c); /* ... and echo it */
234 case 0x03: /* ^C - Control C */
240 /* Check for the console hangup (if any different from serial) */
241 if (gd->jt[XF_getc] != getc) {
248 /* line too long - truncate */
253 #if (CONFIG_COMMANDS & CFG_CMD_SAVES)
255 int do_save_serial (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
259 #ifdef CFG_LOADS_BAUD_CHANGE
260 int save_baudrate, current_baudrate;
262 save_baudrate = current_baudrate = gd->baudrate;
266 offset = simple_strtoul(argv[1], NULL, 16);
268 #ifdef CFG_LOADS_BAUD_CHANGE
270 size = simple_strtoul(argv[2], NULL, 16);
273 save_baudrate = (int)simple_strtoul(argv[3], NULL, 10);
275 /* default to current baudrate */
276 if (save_baudrate == 0)
277 save_baudrate = current_baudrate;
279 if (save_baudrate != current_baudrate) {
280 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
283 gd->baudrate = save_baudrate;
291 #else /* ! CFG_LOADS_BAUD_CHANGE */
293 size = simple_strtoul(argv[2], NULL, 16);
295 #endif /* CFG_LOADS_BAUD_CHANGE */
297 printf ("## Ready for S-Record upload, press ENTER to proceed ...\n");
302 if(save_serial (offset, size)) {
303 printf ("## S-Record upload aborted\n");
305 printf ("## S-Record upload complete\n");
307 #ifdef CFG_LOADS_BAUD_CHANGE
308 if (save_baudrate != current_baudrate) {
309 printf ("## Switch baudrate to %d bps and press ESC ...\n",
310 (int)current_baudrate);
312 gd->baudrate = current_baudrate;
316 if (getc() == 0x1B) /* ESC */
324 #define SREC3_START "S0030000FC\n"
325 #define SREC3_FORMAT "S3%02X%08lX%s%02X\n"
326 #define SREC3_END "S70500000000FA\n"
327 #define SREC_BYTES_PER_RECORD 16
329 static int save_serial (ulong address, ulong count)
331 int i, c, reclen, checksum, length;
332 char *hex = "0123456789ABCDEF";
333 char record[2*SREC_BYTES_PER_RECORD+16]; /* buffer for one S-Record */
334 char data[2*SREC_BYTES_PER_RECORD+1]; /* buffer for hex data */
339 if(write_record(SREC3_START)) /* write the header */
342 if(count) { /* collect hex data in the buffer */
343 c = *(volatile uchar*)(address + reclen); /* get one byte */
344 checksum += c; /* accumulate checksum */
345 data[2*reclen] = hex[(c>>4)&0x0f];
346 data[2*reclen+1] = hex[c & 0x0f];
347 data[2*reclen+2] = '\0';
351 if(reclen == SREC_BYTES_PER_RECORD || count == 0) {
352 /* enough data collected for one record: dump it */
353 if(reclen) { /* build & write a data record: */
354 /* address + data + checksum */
355 length = 4 + reclen + 1;
357 /* accumulate length bytes into checksum */
358 for(i = 0; i < 2; i++)
359 checksum += (length >> (8*i)) & 0xff;
361 /* accumulate address bytes into checksum: */
362 for(i = 0; i < 4; i++)
363 checksum += (address >> (8*i)) & 0xff;
365 /* make proper checksum byte: */
366 checksum = ~checksum & 0xff;
368 /* output one record: */
369 sprintf(record, SREC3_FORMAT, length, address, data, checksum);
370 if(write_record(record))
373 address += reclen; /* increment address */
379 if(write_record(SREC3_END)) /* write the final record */
385 write_record (char *buf)
392 /* Check for the console hangup (if any different from serial) */
399 # endif /* CFG_CMD_SAVES */
401 #endif /* CFG_CMD_LOADS */
404 #if (CONFIG_COMMANDS & CFG_CMD_LOADB) /* loadb command (load binary) included */
408 #define START_CHAR 0x01
409 #define ETX_CHAR 0x03
410 #define END_CHAR 0x0D
412 #define K_ESCAPE 0x23
413 #define SEND_TYPE 'S'
414 #define DATA_TYPE 'D'
416 #define NACK_TYPE 'N'
417 #define BREAK_TYPE 'B'
418 #define tochar(x) ((char) (((x) + SPACE) & 0xff))
419 #define untochar(x) ((int) (((x) - SPACE) & 0xff))
421 extern int os_data_count;
422 extern int os_data_header[8];
424 static void set_kerm_bin_mode(unsigned long *);
425 static int k_recv(void);
426 static ulong load_serial_bin (ulong offset);
429 char his_eol; /* character he needs at end of packet */
430 int his_pad_count; /* number of pad chars he needs */
431 char his_pad_char; /* pad chars he needs */
432 char his_quote; /* quote chars he'll use */
434 int do_load_serial_bin (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
438 int load_baudrate, current_baudrate;
442 /* pre-set offset from CFG_LOAD_ADDR */
443 offset = CFG_LOAD_ADDR;
445 /* pre-set offset from $loadaddr */
446 if ((s = getenv("loadaddr")) != NULL) {
447 offset = simple_strtoul(s, NULL, 16);
450 load_baudrate = current_baudrate = gd->baudrate;
453 offset = simple_strtoul(argv[1], NULL, 16);
456 load_baudrate = (int)simple_strtoul(argv[2], NULL, 10);
458 /* default to current baudrate */
459 if (load_baudrate == 0)
460 load_baudrate = current_baudrate;
463 if (load_baudrate != current_baudrate) {
464 printf ("## Switch baudrate to %d bps and press ENTER ...\n",
467 gd->baudrate = load_baudrate;
476 if (strcmp(argv[0],"loady")==0) {
477 printf ("## Ready for binary (ymodem) download "
478 "to 0x%08lX at %d bps...\n",
482 addr = load_serial_ymodem (offset);
486 printf ("## Ready for binary (kermit) download "
487 "to 0x%08lX at %d bps...\n",
490 addr = load_serial_bin (offset);
494 printf ("## Binary (kermit) download aborted\n");
497 printf ("## Start Addr = 0x%08lX\n", addr);
501 if (load_baudrate != current_baudrate) {
502 printf ("## Switch baudrate to %d bps and press ESC ...\n",
505 gd->baudrate = current_baudrate;
509 if (getc() == 0x1B) /* ESC */
514 #ifdef CONFIG_AUTOSCRIPT
518 if (((s = getenv("autoscript")) != NULL) && (strcmp(s,"yes") == 0)) {
519 printf("Running autoscript at addr 0x%08lX ...\n", load_addr);
520 rcode = autoscript (load_addr);
528 static ulong load_serial_bin (ulong offset)
533 set_kerm_bin_mode ((ulong *) offset);
537 * Gather any trailing characters (for instance, the ^D which
538 * is sent by 'cu' after sending a file), and give the
539 * box some time (100 * 1 ms)
541 for (i=0; i<100; ++i) {
548 flush_cache (offset, size);
550 printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
551 sprintf(buf, "%X", size);
552 setenv("filesize", buf);
559 int count = his_pad_count;
565 /* converts escaped kermit char to binary char */
566 char ktrans (char in)
568 if ((in & 0x60) == 0x40) {
569 return (char) (in & ~0x40);
570 } else if ((in & 0x7f) == 0x3f) {
571 return (char) (in | 0x40);
576 int chk1 (char *buffer)
583 return (int) ((total + ((total >> 6) & 0x03)) & 0x3f);
586 void s1_sendpacket (char *packet)
595 void send_ack (int n)
602 a_b[4] = tochar (chk1 (&a_b[1]));
608 void send_nack (int n)
615 a_b[4] = tochar (chk1 (&a_b[1]));
622 /* os_data_* takes an OS Open image and puts it into memory, and
623 puts the boot header in an array named os_data_header
625 if image is binary, no header is stored in os_data_header.
627 void (*os_data_init) (void);
628 void (*os_data_char) (char new_char);
629 static int os_data_state, os_data_state_saved;
631 static int os_data_count_saved;
632 static char *os_data_addr, *os_data_addr_saved;
633 static char *bin_start_address;
634 int os_data_header[8];
635 static void bin_data_init (void)
639 os_data_addr = bin_start_address;
641 static void os_data_save (void)
643 os_data_state_saved = os_data_state;
644 os_data_count_saved = os_data_count;
645 os_data_addr_saved = os_data_addr;
647 static void os_data_restore (void)
649 os_data_state = os_data_state_saved;
650 os_data_count = os_data_count_saved;
651 os_data_addr = os_data_addr_saved;
653 static void bin_data_char (char new_char)
655 switch (os_data_state) {
657 *os_data_addr++ = new_char;
662 static void set_kerm_bin_mode (unsigned long *addr)
664 bin_start_address = (char *) addr;
665 os_data_init = bin_data_init;
666 os_data_char = bin_data_char;
670 /* k_data_* simply handles the kermit escape translations */
671 static int k_data_escape, k_data_escape_saved;
672 void k_data_init (void)
677 void k_data_save (void)
679 k_data_escape_saved = k_data_escape;
682 void k_data_restore (void)
684 k_data_escape = k_data_escape_saved;
687 void k_data_char (char new_char)
690 /* last char was escape - translate this character */
691 os_data_char (ktrans (new_char));
694 if (new_char == his_quote) {
695 /* this char is escape - remember */
698 /* otherwise send this char as-is */
699 os_data_char (new_char);
704 #define SEND_DATA_SIZE 20
705 char send_parms[SEND_DATA_SIZE];
708 /* handle_send_packet interprits the protocol info and builds and
709 sends an appropriate ack for what we can do */
710 void handle_send_packet (int n)
715 /* initialize some protocol parameters */
716 his_eol = END_CHAR; /* default end of line character */
719 his_quote = K_ESCAPE;
721 /* ignore last character if it filled the buffer */
722 if (send_ptr == &send_parms[SEND_DATA_SIZE - 1])
724 bytes = send_ptr - send_parms; /* how many bytes we'll process */
728 /* handle MAXL - max length */
729 /* ignore what he says - most I'll take (here) is 94 */
730 a_b[++length] = tochar (94);
733 /* handle TIME - time you should wait for my packets */
734 /* ignore what he says - don't wait for my ack longer than 1 second */
735 a_b[++length] = tochar (1);
738 /* handle NPAD - number of pad chars I need */
739 /* remember what he says - I need none */
740 his_pad_count = untochar (send_parms[2]);
741 a_b[++length] = tochar (0);
744 /* handle PADC - pad chars I need */
745 /* remember what he says - I need none */
746 his_pad_char = ktrans (send_parms[3]);
747 a_b[++length] = 0x40; /* He should ignore this */
750 /* handle EOL - end of line he needs */
751 /* remember what he says - I need CR */
752 his_eol = untochar (send_parms[4]);
753 a_b[++length] = tochar (END_CHAR);
756 /* handle QCTL - quote control char he'll use */
757 /* remember what he says - I'll use '#' */
758 his_quote = send_parms[5];
762 /* handle QBIN - 8-th bit prefixing */
763 /* ignore what he says - I refuse */
767 /* handle CHKT - the clock check type */
768 /* ignore what he says - I do type 1 (for now) */
772 /* handle REPT - the repeat prefix */
773 /* ignore what he says - I refuse (for now) */
777 /* handle CAPAS - the capabilities mask */
778 /* ignore what he says - I only do long packets - I don't do windows */
779 a_b[++length] = tochar (2); /* only long packets */
780 a_b[++length] = tochar (0); /* no windows */
781 a_b[++length] = tochar (94); /* large packet msb */
782 a_b[++length] = tochar (94); /* large packet lsb */
786 a_b[1] = tochar (length);
789 a_b[++length] = '\0';
790 a_b[length] = tochar (chk1 (&a_b[1]));
791 a_b[++length] = his_eol;
792 a_b[++length] = '\0';
796 /* k_recv receives a OS Open image file over kermit line */
797 static int k_recv (void)
800 char k_state, k_state_saved;
808 /* initialize some protocol parameters */
809 his_eol = END_CHAR; /* default end of line character */
812 his_quote = K_ESCAPE;
814 /* initialize the k_recv and k_data state machine */
818 k_state_saved = k_state;
820 n = 0; /* just to get rid of a warning */
823 /* expect this "type" sequence (but don't check):
828 B: break transmission
831 /* enter main loop */
833 /* set the send packet pointer to begining of send packet parms */
834 send_ptr = send_parms;
836 /* With each packet, start summing the bytes starting with the length.
837 Save the current sequence number.
838 Note the type of the packet.
839 If a character less than SPACE (0x20) is received - error.
843 /* OLD CODE, Prior to checking sequence numbers */
844 /* first have all state machines save current states */
845 k_state_saved = k_state;
850 /* wait for the starting character or ^C */
853 case START_CHAR: /* start packet */
855 case ETX_CHAR: /* ^C waiting for packet */
862 /* get length of packet */
865 if ((new_char & 0xE0) == 0)
867 sum += new_char & 0xff;
868 length = untochar (new_char);
869 /* get sequence number */
871 if ((new_char & 0xE0) == 0)
873 sum += new_char & 0xff;
874 n = untochar (new_char);
877 /* NEW CODE - check sequence numbers for retried packets */
878 /* Note - this new code assumes that the sequence number is correctly
879 * received. Handling an invalid sequence number adds another layer
880 * of complexity that may not be needed - yet! At this time, I'm hoping
881 * that I don't need to buffer the incoming data packets and can write
882 * the data into memory in real time.
885 /* same sequence number, restore the previous state */
886 k_state = k_state_saved;
889 /* new sequence number, checkpoint the download */
891 k_state_saved = k_state;
896 /* get packet type */
898 if ((new_char & 0xE0) == 0)
900 sum += new_char & 0xff;
903 /* check for extended length */
905 /* (length byte was 0, decremented twice) */
906 /* get the two length bytes */
908 if ((new_char & 0xE0) == 0)
910 sum += new_char & 0xff;
911 len_hi = untochar (new_char);
913 if ((new_char & 0xE0) == 0)
915 sum += new_char & 0xff;
916 len_lo = untochar (new_char);
917 length = len_hi * 95 + len_lo;
918 /* check header checksum */
920 if ((new_char & 0xE0) == 0)
922 if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
924 sum += new_char & 0xff;
925 /* --length; */ /* new length includes only data and block check to come */
927 /* bring in rest of packet */
930 if ((new_char & 0xE0) == 0)
932 sum += new_char & 0xff;
934 if (k_state == DATA_TYPE) {
935 /* pass on the data if this is a data packet */
936 k_data_char (new_char);
937 } else if (k_state == SEND_TYPE) {
938 /* save send pack in buffer as is */
939 *send_ptr++ = new_char;
940 /* if too much data, back off the pointer */
941 if (send_ptr >= &send_parms[SEND_DATA_SIZE])
945 /* get and validate checksum character */
947 if ((new_char & 0xE0) == 0)
949 if (new_char != tochar ((sum + ((sum >> 6) & 0x03)) & 0x3f))
953 if (new_char != END_CHAR) {
955 /* restore state machines */
956 k_state = k_state_saved;
958 /* send a negative acknowledge packet in */
960 } else if (k_state == SEND_TYPE) {
961 /* crack the protocol parms, build an appropriate ack packet */
962 handle_send_packet (n);
964 /* send simple acknowledge packet in */
966 /* quit if end of transmission */
967 if (k_state == BREAK_TYPE)
972 return ((ulong) os_data_addr - (ulong) bin_start_address);
975 static int getcxmodem(void) {
980 static ulong load_serial_ymodem (ulong offset)
986 connection_info_t info;
987 char ymodemBuf[1024];
988 ulong store_addr = ~0;
992 info.mode=xyzModem_ymodem;
993 res=xyzModem_stream_open(&info, &err);
996 while ((res=xyzModem_stream_read(ymodemBuf, 1024, &err)) > 0 ){
997 store_addr = addr + offset;
1000 #ifndef CFG_NO_FLASH
1001 if (addr2info(store_addr)) {
1004 rc = flash_write((char *)ymodemBuf,store_addr,res);
1012 memcpy ((char *)(store_addr), ymodemBuf, res);
1018 printf ("%s\n",xyzModem_error(err));
1021 xyzModem_stream_close(&err);
1022 xyzModem_stream_terminate(false,&getcxmodem);
1025 flush_cache (offset, size);
1027 printf("## Total Size = 0x%08x = %d Bytes\n", size, size);
1028 sprintf(buf, "%X", size);
1029 setenv("filesize", buf);
1034 #endif /* CFG_CMD_LOADB */
1036 /* -------------------------------------------------------------------- */
1038 #if (CONFIG_COMMANDS & CFG_CMD_LOADS)
1040 #ifdef CFG_LOADS_BAUD_CHANGE
1042 loads, 3, 0, do_load_serial,
1043 "loads - load S-Record file over serial line\n",
1044 "[ off ] [ baud ]\n"
1045 " - load S-Record file over serial line"
1046 " with offset 'off' and baudrate 'baud'\n"
1049 #else /* ! CFG_LOADS_BAUD_CHANGE */
1051 loads, 2, 0, do_load_serial,
1052 "loads - load S-Record file over serial line\n",
1054 " - load S-Record file over serial line with offset 'off'\n"
1056 #endif /* CFG_LOADS_BAUD_CHANGE */
1059 * SAVES always requires LOADS support, but not vice versa
1063 #if (CONFIG_COMMANDS & CFG_CMD_SAVES)
1064 #ifdef CFG_LOADS_BAUD_CHANGE
1066 saves, 4, 0, do_save_serial,
1067 "saves - save S-Record file over serial line\n",
1068 "[ off ] [size] [ baud ]\n"
1069 " - save S-Record file over serial line"
1070 " with offset 'off', size 'size' and baudrate 'baud'\n"
1072 #else /* ! CFG_LOADS_BAUD_CHANGE */
1074 saves, 3, 0, do_save_serial,
1075 "saves - save S-Record file over serial line\n",
1077 " - save S-Record file over serial line with offset 'off' and size 'size'\n"
1079 #endif /* CFG_LOADS_BAUD_CHANGE */
1080 #endif /* CFG_CMD_SAVES */
1081 #endif /* CFG_CMD_LOADS */
1084 #if (CONFIG_COMMANDS & CFG_CMD_LOADB)
1086 loadb, 3, 0, do_load_serial_bin,
1087 "loadb - load binary file over serial line (kermit mode)\n",
1088 "[ off ] [ baud ]\n"
1089 " - load binary file over serial line"
1090 " with offset 'off' and baudrate 'baud'\n"
1094 loady, 3, 0, do_load_serial_bin,
1095 "loady - load binary file over serial line (ymodem mode)\n",
1096 "[ off ] [ baud ]\n"
1097 " - load binary file over serial line"
1098 " with offset 'off' and baudrate 'baud'\n"
1101 #endif /* CFG_CMD_LOADB */
1103 /* -------------------------------------------------------------------- */
1105 #if (CONFIG_COMMANDS & CFG_CMD_HWFLOW)
1106 int do_hwflow (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
1108 extern int hwflow_onoff(int);
1111 if (strcmp(argv[1], "off") == 0)
1114 if (strcmp(argv[1], "on") == 0)
1117 printf("Usage: %s\n", cmdtp->usage);
1119 printf("RTS/CTS hardware flow control: %s\n", hwflow_onoff(0) ? "on" : "off");
1123 /* -------------------------------------------------------------------- */
1126 hwflow, 2, 0, do_hwflow,
1127 "hwflow - turn the harwdare flow control on/off\n",
1128 "[on|off]\n - change RTS/CTS hardware flow control over serial line\n"
1131 #endif /* CFG_CMD_HWFLOW */