1 /*****************************************************************************
5 ** Description: Download a patchram files for the HCD format
7 ** Copyright (c) 2000-2009, Broadcom Corp., All Rights Reserved.
8 ******************************************************************************/
12 #include <sys/types.h>
20 #include <sys/termios.h>
21 #include <sys/ioctl.h>
26 #define HCI_UART_BCSP 1
27 #define HCI_UART_3WIRE 2
28 #define HCI_UART_H4DS 3
30 #define HCIUARTSETPROTO _IOW('U', 200, int)
31 #define HCIUARTGETPROTO _IOR('U', 201, int)
32 #define HCIUARTGETDEVICE _IOR('U', 202, int)
34 /* Pre baudrate change for fast download */
35 #define HIGH_SPEED_PATCHRAM_DOWNLOAD TRUE
37 /* Host Stack Idle Threshold */
38 #define HCILP_IDLE_THRESHOLD 0x01
40 /* Host Controller Idle Threshold */
41 #define HCILP_HC_IDLE_THRESHOLD 0x01
43 /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
44 #define HCILP_BT_WAKE_POLARITY 1
46 /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
47 #define HCILP_HOST_WAKE_POLARITY 1
50 #define BCM_DISABLE_RF_PWRCTRL FALSE
55 #define RELEASE_DATE "2011.02.07"
58 typedef unsigned char UINT8;
59 typedef unsigned short UINT16;
60 typedef unsigned long UINT32;
61 typedef signed long INT32;
62 typedef signed char INT8;
63 typedef signed short INT16;
64 typedef unsigned char BOOLEAN;
69 #define BD_ADDR_LEN 6 /* Device address length */
70 typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */
74 #define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)
75 #define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)
76 #define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10)
77 #define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)
78 #define HCI_GRP_STATUS_PARAMS (0x05 << 10)
79 #define HCI_GRP_TESTING_CMDS (0x06 << 10)
80 #define HCI_GRP_L2CAP_CMDS (0x07 << 10)
81 #define HCI_GRP_L2CAP_HCI_EVTS (0x08 << 10)
82 #define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10)
85 #define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
86 #define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
87 #define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
88 #define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
90 #define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
91 #define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
93 #define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
95 #define HCI_BRCM_SUPER_PEEK_POKE (0x000A | HCI_GRP_VENDOR_SPECIFIC)
96 #define VSC_WRITE_BD_ADDR (0x0001 | HCI_GRP_VENDOR_SPECIFIC)
97 #define VSC_HCI_CMD_SET_LOC_FEATURES_CMD (0x000B | HCI_GRP_VENDOR_SPECIFIC)
98 #define HCI_BRCM_UPDATE_BAUDRATE_CMD (0x0018 | HCI_GRP_VENDOR_SPECIFIC)
99 #define HCI_BRCM_WRITE_SCO_PCM_INT_PARAM (0x001C | HCI_GRP_VENDOR_SPECIFIC)
100 #define VSC_WRITE_PCM_DATA_FORMAT_PARAM (0x001E | HCI_GRP_VENDOR_SPECIFIC)
101 #define HCI_BRCM_WRITE_SLEEP_MODE (0x0027 | HCI_GRP_VENDOR_SPECIFIC)
102 #define HCI_BRCM_DOWNLOAD_MINI_DRV (0x002E | HCI_GRP_VENDOR_SPECIFIC)
103 #define VSC_WRITE_UART_CLOCK_SETTING (0x0045 | HCI_GRP_VENDOR_SPECIFIC)
106 #define VOICE_SETTING_MU_LAW_MD 0x0100
107 #define VOICE_SETTING_LINEAR_MD 0x0060
109 #define HCI_ARM_MEM_PEEK 0x04
110 #define HCI_ARM_MEM_POKE 0x05
112 #define BTUI_MAX_STRING_LENGTH_PER_LINE 255
113 #define HCI_BRCM_WRITE_SLEEP_MODE_LENGTH 10
115 #define HCI_BRCM_UPDATE_BAUD_RATE_ENCODED_LENGTH 0x02
116 #define HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH 0x06
118 #define VSC_WRITE_UART_CLOCK_SETTING_LEN 1
120 /* print string with time stamp */
121 #define TDEBUG0(m) if(debug_mode) {print_time();fprintf(stderr,m);}
122 #define TDEBUG1(m,n1) if(debug_mode) {print_time();fprintf(stderr,m,n1);}
123 #define TDEBUG2(m,n1,n2) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2);}
124 #define TDEBUG3(m,n1,n2,n3) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3);}
125 #define TDEBUG4(m,n1,n2,n3,n4) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4);}
126 #define TDEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5);}
127 #define TDEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {print_time();fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
129 /* print just string */
130 #define DEBUG0(m) if(debug_mode) {fprintf(stderr,m);}
131 #define DEBUG1(m,n1) if(debug_mode) {fprintf(stderr,m,n1);}
132 #define DEBUG2(m,n1,n2) if(debug_mode) {fprintf(stderr,m,n1,n2);}
133 #define DEBUG3(m,n1,n2,n3) if(debug_mode) {fprintf(stderr,m,n1,n2,n3);}
134 #define DEBUG4(m,n1,n2,n3,n4) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4);}
135 #define DEBUG5(m,n1,n2,n3,n4,n5) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5);}
136 #define DEBUG6(m,n1,n2,n3,n4,n5,n6) if(debug_mode) {fprintf(stderr,m,n1,n2,n3,n4,n5,n6);}
139 #define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;}
140 #define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;}
141 #define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;}
143 #define ROTATE_BD_ADDR(p1, p2) \
155 UINT8 vsc_for_pcm_config[5] = {0x00, 0x00, 0x03, 0x03, 0x00};
157 Byte1 -- 0 for MSb first
158 Byte2 -- 0 Fill value
159 Byte3 -- 1 Fill option (0:0's, 1:1's , 2:Signed, 3:Programmable)
160 Byte4 -- 1 Number of fill bits
161 Byte5 -- 1 Right justified (0 for left justified)
164 UINT8 vsc_for_sco_pcm[5] = {0x00, 0x01, 0x00, 0x01, 0x01};
166 Neverland : PCM, 256, short, master ,master
167 Volance : PCM, 256, short, master ,master
169 Byte1 -- 0 for PCM 1 for UART or USB
170 Byte2 -- 0 : 128, 1: 256, 2:512, 3:1024, 4:2048 Khz
171 Byte3 -- 0 for short frame sync 1 for long frame sync
172 Byte4 -- 0 Clock direction 0 for same as sync 1 for opposite direction
173 Byte5 -- 0 for slave 1 for master
176 int fd; /* HCI handle */
178 BOOLEAN debug_mode = FALSE; /* Debug Mode Enable */
180 unsigned char buffer[1024];
182 struct termios termios;
184 void ChangeBaudRate(UINT32 baudrate);
187 void exit_err(UINT8 err)
189 #if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
190 ChangeBaudRate(115200);
195 void print_time(void)
201 rs = clock_gettime(CLOCK_REALTIME,&tp);
202 fprintf(stderr, "[%04d : %06d]\n", tp.tv_sec, tp.tv_nsec/1000);
207 void dump(unsigned char *out, int len)
211 for (i = 0; i < len; i++)
217 DEBUG1( "%02x ", out[i]);
222 UINT8 SendCommand(UINT16 opcode, UINT8 param_len, UINT8 *p_param_buf)
224 UINT8 pbuf[255] = {0,};
229 pbuf[1] = (UINT8)(opcode);
230 pbuf[2] = (UINT8)(opcode >>8);
233 for (i=0; i<param_len; i++)
235 pbuf[i+4] = *p_param_buf++;
238 DEBUG1( "Send %d",param_len+4);
240 dump(pbuf, param_len+4);
242 ret = write(fd, pbuf, param_len+4);
249 void expired(int sig)
251 static UINT8 count = 0;
252 DEBUG0( "expired try again\n");
253 SendCommand(HCI_RESET, 0, NULL);
259 fprintf(stderr, "[ERR] HCI reset time expired\n");
264 void read_event(int fd, unsigned char *buffer)
270 while ((count = read(fd, &buffer[i], len)) < len)
279 while ((count = read(fd, &buffer[i], len)) < len)
288 DEBUG1( "\nreceived %d", count);
293 INT32 filesize (char *name)
299 flag = stat (name,&buf);
307 void DisplayProgress(int total, int val)
310 #define PROGRESS_NUM 20
314 char text[PROGRESS_NUM+2]={0,};
317 text[PROGRESS_NUM+1]=']';
318 p=(val*PROGRESS_NUM)/total;
320 for ( i=1; i<=p; i++)
325 for ( i=p+1; i<=PROGRESS_NUM; i++)
331 for ( i=0; i<=(PROGRESS_NUM+1); i++)
333 fprintf(stderr, "%c",text[i]);
336 if( p >= PROGRESS_NUM)
337 fprintf(stderr, " %6d/%6d\n",val,total);
339 fprintf(stderr, " %6d/%6d\r",val,total);
342 fprintf(stderr, " %6d/%6d\n",val,total);
344 fprintf(stderr, " %6d/%6d\r",val,total);
348 UINT8 DownloadPatchram( char *patchram1 )
358 DEBUG1( "\n%s\n", patchram1);
361 DEBUG0( "HCI reset\n");
362 SendCommand(HCI_RESET, 0, NULL);
364 read_event(fd, buffer);
367 #if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
368 ChangeBaudRate(921600);
371 strcpy(prm, patchram1);
373 fprintf(stderr, "Download Start\n");
375 if ((pFile = fopen(prm, "r")) == NULL)
377 fprintf(stderr, "file %s could not be opened, error %d\n", prm, errno);
380 FileSize = filesize(prm);
382 SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
383 read_event(fd, buffer);
387 while (fread(&buffer[1], sizeof(UINT8), 3 ,pFile))
393 ret = fread(&buffer[4],sizeof(UINT8),len, pFile);
397 ret = write(fd, buffer, len + 4);
401 /* dispaly progress*/
402 SentSize += (len + 3);
403 DisplayProgress(FileSize,SentSize);
404 /* dispaly progress*/
406 read_event(fd, buffer);
411 usleep(100000); /*100ms delay */
413 tcflush(fd, TCIOFLUSH);
414 tcgetattr(fd, &termios);
416 termios.c_cflag |= CRTSCTS;
417 tcsetattr(fd, TCSANOW, &termios);
418 tcflush(fd, TCIOFLUSH);
419 tcsetattr(fd, TCSANOW, &termios);
420 tcflush(fd, TCIOFLUSH);
421 tcflush(fd, TCIOFLUSH);
422 cfsetospeed(&termios, B115200);
423 cfsetispeed(&termios, B115200);
424 tcsetattr(fd, TCSANOW, &termios);
426 /* Send HCI_RESET Command and process event */
427 DEBUG0( "HCI reset\n");
428 SendCommand(HCI_RESET, 0, NULL);
430 read_event(fd, buffer);
432 fprintf(stderr,"Download Complete\n");
437 void SetScanEnable(void)
441 /* 0x00: No scan enabled */
442 /* 0x01: Inquiry scan enabled | Page scan disabled */
443 /* 0x02: Inquiry scan disabled | Page scan enabled */
444 /* 0x03: Inquiry scan enabled | Page scan enabled */
447 SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
448 read_event(fd, buffer);
453 fprintf(stderr,"Write Audio parameter\n");
455 DEBUG5( "vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
456 vsc_for_sco_pcm[1],vsc_for_sco_pcm[2],
457 vsc_for_sco_pcm[3],vsc_for_sco_pcm[4]);
459 SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5, (UINT8 *)vsc_for_sco_pcm);
460 read_event(fd, buffer);
462 DEBUG5( "vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
463 vsc_for_pcm_config[1], vsc_for_pcm_config[2],
464 vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
466 SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5, (UINT8 *)vsc_for_pcm_config);
467 read_event(fd, buffer);
470 void SetPcmConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
472 vsc_for_pcm_config[0] = p0;
473 vsc_for_pcm_config[1] = p1;
474 vsc_for_pcm_config[2] = p2;
475 vsc_for_pcm_config[3] = p3;
476 vsc_for_pcm_config[4] = p4;
479 void SetScoConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
481 vsc_for_sco_pcm[0] = p0;
482 vsc_for_sco_pcm[1] = p1;
483 vsc_for_sco_pcm[2] = p2;
484 vsc_for_sco_pcm[3] = p3;
485 vsc_for_sco_pcm[4] = p4;
488 void HCILP_Enable(BOOLEAN on)
490 fprintf(stderr,"Set Low Power mode %d\n",on);
491 UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
492 0x01, /* Sleep Mode algorithm 1 */
493 HCILP_IDLE_THRESHOLD, /* Host Idle Treshold in 300ms */
494 HCILP_HC_IDLE_THRESHOLD, /* Host Controller Idle Treshold in 300ms */ /* this should be less than scan interval.*/
495 HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High*/
496 HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
497 0x01, /* Allow host Sleep during SCO */
498 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1,*/
499 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
500 0x00, /* NA to Mode 1 */
501 0x00, /* NA to Mode 1 */
513 SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH, (UINT8 *)data);
514 read_event(fd, buffer);
517 UINT32 uart_speed(UINT32 Speed)
546 void ChangeBaudRate(UINT32 baudrate)
548 UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
549 UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
550 UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
562 /* Write UART Clock setting of 24MHz */
563 DEBUG0( "Change UART_CLOCK 24Mhz\n");
564 SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_24);
565 read_event(fd, buffer);
570 /* Write UART Clock setting of 48MHz */
571 DEBUG0( "Change UART_CLOCK 48Mh\nz");
572 SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_48);
573 read_event(fd, buffer);
577 fprintf(stderr,"Not Support baudrate = %ld\n", baudrate);
582 hci_data[2] = baudrate & 0xFF;
583 hci_data[3] = (baudrate >> 8) & 0xFF;
584 hci_data[4] = (baudrate >> 16) & 0xFF;
585 hci_data[5] = (baudrate >> 24) & 0xFF;
587 DEBUG1( "Change Baudrate %ld\n",baudrate);
589 SendCommand( HCI_BRCM_UPDATE_BAUDRATE_CMD, HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH, (UINT8 *)hci_data);
590 read_event(fd, buffer);
593 tcflush(fd, TCIOFLUSH);
594 tcgetattr(fd, &termios);
596 termios.c_cflag |= CRTSCTS;
597 tcsetattr(fd, TCSANOW, &termios);
598 tcflush(fd, TCIOFLUSH);
599 tcsetattr(fd, TCSANOW, &termios);
600 tcflush(fd, TCIOFLUSH);
601 tcflush(fd, TCIOFLUSH);
602 cfsetospeed(&termios, uart_speed(baudrate));
603 cfsetispeed(&termios, uart_speed(baudrate));
604 tcsetattr(fd, TCSANOW, &termios);
608 void EnableTestMode(void)
610 UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
612 /* bt sleep disable */
615 /* Enable both Inquiry & Page Scans */
618 /* Set Event Filter: Enable Auto Connect */
619 SendCommand( HCI_SET_EVENT_FILTER, 0x03, (UINT8 *)filter_data);
620 read_event(fd, buffer);
622 /* Enable Device under test */
623 SendCommand( HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
624 read_event(fd, buffer);
626 fprintf(stderr,"Enable Device Under Test\n");
629 void SetLocalFeatures(void)
633 DEBUG0("Read Local Feature\n");
634 SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
635 read_event(fd, buffer);
639 #if (BCM_DISABLE_RF_PWRCTRL == TRUE)
640 fprintf(stderr,"Remove Power Control\n");
641 data[2] &= 0xFB; /* Power contrel */
643 DEBUG0("Write Local Feature\n");
644 SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *)data);
645 read_event(fd, buffer);
651 int proto = HCI_UART_H4;
653 if (ioctl(fd, TIOCSETD, &i) < 0)
655 fprintf(stderr, "Can't set line discipline\n");
659 if (ioctl(fd, HCIUARTSETPROTO, proto) < 0)
661 fprintf(stderr, "Can't set hci protocol\n");
664 fprintf(stderr, "Done setting line discpline\n");
668 void print_usage( void )
670 fprintf(stderr,"\n");
671 fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
672 fprintf(stderr,"\n");
673 fprintf(stderr," Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
674 fprintf(stderr," -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
675 fprintf(stderr," -BAUD Set Baudrate EX) -BAUD=3000000\n");
676 fprintf(stderr," -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
677 fprintf(stderr," -SCO Enable SCO/PCM config EX) -SCO\n");
678 fprintf(stderr," -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
679 fprintf(stderr," -LP Enable Low power EX) -LP\n");
680 fprintf(stderr," -FEATURE Set local Feature EX) -FEATURE\n");
681 fprintf(stderr," -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
682 fprintf(stderr," -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
683 fprintf(stderr," -DEBUG Debug message EX) -DEBUG\n");
684 fprintf(stderr,"\n");
687 int main(int argc, char *argv[])
698 fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
702 if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1)
704 fprintf(stderr, "port %s could not be opened, error %d\n", argv[1], errno);
708 tcflush(fd, TCIOFLUSH);
709 tcgetattr(fd, &termios);
711 termios.c_cflag |= CRTSCTS;
712 tcsetattr(fd, TCSANOW, &termios);
713 tcflush(fd, TCIOFLUSH);
714 tcsetattr(fd, TCSANOW, &termios);
715 tcflush(fd, TCIOFLUSH);
716 tcflush(fd, TCIOFLUSH);
717 cfsetospeed(&termios, B115200);
718 cfsetispeed(&termios, B115200);
719 tcsetattr(fd, TCSANOW, &termios);
721 signal(SIGALRM, expired);
723 for( i=2; i<argc; i++ )
727 if( strstr(ptr,"-DEBUG") )
730 DEBUG0("DEBUG On\n");
735 for( i=2; i<argc; i++ )
742 fprintf(stderr,"[%d] %s\n", i-1, ptr);
744 if( strstr(ptr,"-FILE=") )
750 strncpy(prm_name,ptr, 127);
751 DownloadPatchram( prm_name );
754 else if( strstr(ptr,"-BAUD=") )
759 baudrate = atoi(ptr);
761 ChangeBaudRate(baudrate);
763 else if( strstr(ptr,"-ADDR=") )
765 char *bdaddr_filename;
768 int bdaddr[10]; /* Displayed BD Address */
770 BD_ADDR local_addr; /* BD Address for write */
774 if( sscanf(ptr,"%02X:%02X:%02X:%02X:%02X:%02X",&bdaddr[0],&bdaddr[1],&bdaddr[2],&bdaddr[3],&bdaddr[4],&bdaddr[5]) != 6 )
776 fprintf(stderr,"-ADDR: Parameter error");
779 bte_write_bdaddr(bdaddr);
782 bdaddr_filename = ptr;
786 pFile = fopen(bdaddr_filename, "r");
791 char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
793 if ((fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile))!= NULL)
794 sscanf(text,"%02x%02x",&bdaddr[0],&bdaddr[1]);
796 if ((fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile)) != NULL)
797 sscanf(text,"%02x",&bdaddr[2]);
799 if ((fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile)) != NULL)
800 sscanf(text,"%02x%02x%02x",&bdaddr[3],&bdaddr[4],&bdaddr[5]);
802 fprintf(stderr,"Writing B/D Address = %02X:%02X:%02X:%02X:%02X:%02X\n",bdaddr[0],bdaddr[1],bdaddr[2],bdaddr[3],bdaddr[4],bdaddr[5]);
804 ROTATE_BD_ADDR(local_addr,bdaddr);
806 SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN, (UINT8 *)local_addr);
807 read_event(fd, buffer);
811 fprintf(stderr, "-ADDR: file open fail\n");
816 else if( strstr(ptr,"-SCO") )
821 else if( strstr(ptr,"-SETSCO=") )
826 if( sscanf(ptr,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&value[0],&value[1],&value[2],&value[3],&value[4],
827 &value[5],&value[6],&value[7],&value[8],&value[9]) != 10 )
829 DEBUG0("PCM / SCO configuration value err\n");
830 DEBUG0("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
834 SetScoConf( value[0],value[1],value[2],value[3],value[4] );
835 SetPcmConf( value[5],value[6],value[7],value[8],value[9] );
838 else if( strstr(ptr,"-LP") )
842 else if( strstr(ptr,"-DUT") )
846 else if( strstr(ptr,"-FEATURE") )
850 else if( strstr(ptr,"-ATTACH") )
858 else if( strstr(ptr,"-DEBUG") )
864 fprintf(stderr,"Invalid parameter(s)!\n");
869 fprintf(stderr, "EXIT\n");