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,};
228 pbuf[1] = (UINT8)(opcode);
229 pbuf[2] = (UINT8)(opcode >>8);
232 for (i=0; i<param_len; i++)
234 pbuf[i+4] = *p_param_buf++;
237 DEBUG1( "Send %d",param_len+4);
239 dump(pbuf, param_len+4);
241 if (write(fd, pbuf, param_len+4) < 0)
242 DEBUG0("Fail to write pbuf");
247 void expired(int sig)
249 static UINT8 count = 0;
250 DEBUG0( "expired try again\n");
251 SendCommand(HCI_RESET, 0, NULL);
257 fprintf(stderr, "[ERR] HCI reset time expired\n");
262 void read_event(int fd, unsigned char *buffer)
268 while ((count = read(fd, &buffer[i], len)) < len)
277 while ((count = read(fd, &buffer[i], len)) < len)
286 DEBUG1( "\nreceived %d", count);
291 INT32 filesize (char *name)
297 flag = stat (name,&buf);
305 void DisplayProgress(int total, int val)
308 #define PROGRESS_NUM 20
312 char text[PROGRESS_NUM+2]={0,};
315 text[PROGRESS_NUM+1]=']';
316 p=(val*PROGRESS_NUM)/total;
318 for ( i=1; i<=p; i++)
323 for ( i=p+1; i<=PROGRESS_NUM; i++)
329 for ( i=0; i<=(PROGRESS_NUM+1); i++)
331 fprintf(stderr, "%c",text[i]);
334 if( p >= PROGRESS_NUM)
335 fprintf(stderr, " %6d/%6d\n",val,total);
337 fprintf(stderr, " %6d/%6d\r",val,total);
340 fprintf(stderr, " %6d/%6d\n",val,total);
342 fprintf(stderr, " %6d/%6d\r",val,total);
346 UINT8 DownloadPatchram( char *patchram1 )
356 DEBUG1( "\n%s\n", patchram1);
359 DEBUG0( "HCI reset\n");
360 SendCommand(HCI_RESET, 0, NULL);
362 read_event(fd, buffer);
365 #if ( HIGH_SPEED_PATCHRAM_DOWNLOAD == TRUE )
366 ChangeBaudRate(921600);
369 strcpy(prm, patchram1);
371 fprintf(stderr, "Download Start\n");
373 if ((pFile = fopen(prm, "r")) == NULL)
375 fprintf(stderr, "file %s could not be opened, error %d\n", prm, errno);
378 FileSize = filesize(prm);
380 SendCommand(HCI_BRCM_DOWNLOAD_MINI_DRV, 0, NULL);
381 read_event(fd, buffer);
385 while (fread(&buffer[1], sizeof(UINT8), 3 ,pFile))
391 size = fread(&buffer[4], sizeof(UINT8), len, pFile);
392 fprintf(stderr, "fread size: %d\n", (int) size);
394 size = write(fd, buffer, len + 4);
395 fprintf(stderr, "write size: %d\n", (int) size);
397 /* dispaly progress*/
398 SentSize += (len + 3);
399 DisplayProgress(FileSize,SentSize);
400 /* dispaly progress*/
402 read_event(fd, buffer);
407 usleep(100000); /*100ms delay */
409 tcflush(fd, TCIOFLUSH);
410 tcgetattr(fd, &termios);
412 termios.c_cflag |= CRTSCTS;
413 tcsetattr(fd, TCSANOW, &termios);
414 tcflush(fd, TCIOFLUSH);
415 tcsetattr(fd, TCSANOW, &termios);
416 tcflush(fd, TCIOFLUSH);
417 tcflush(fd, TCIOFLUSH);
418 cfsetospeed(&termios, B115200);
419 cfsetispeed(&termios, B115200);
420 tcsetattr(fd, TCSANOW, &termios);
422 /* Send HCI_RESET Command and process event */
423 DEBUG0( "HCI reset\n");
424 SendCommand(HCI_RESET, 0, NULL);
426 read_event(fd, buffer);
428 fprintf(stderr,"Download Complete\n");
433 void SetScanEnable(void)
437 /* 0x00: No scan enabled */
438 /* 0x01: Inquiry scan enabled | Page scan disabled */
439 /* 0x02: Inquiry scan disabled | Page scan enabled */
440 /* 0x03: Inquiry scan enabled | Page scan enabled */
443 SendCommand(HCI_WRITE_SCAN_ENABLE, 1, &scan_data[0]);
444 read_event(fd, buffer);
449 fprintf(stderr,"Write Audio parameter\n");
451 DEBUG5( "vsc_for_sco_pcm = {%d,%d,%d,%d,%d}\n", vsc_for_sco_pcm[0],
452 vsc_for_sco_pcm[1],vsc_for_sco_pcm[2],
453 vsc_for_sco_pcm[3],vsc_for_sco_pcm[4]);
455 SendCommand(HCI_BRCM_WRITE_SCO_PCM_INT_PARAM, 5, (UINT8 *)vsc_for_sco_pcm);
456 read_event(fd, buffer);
458 DEBUG5( "vsc_for_pcm_config = {%d,%d,%d,%d,%d}\n", vsc_for_pcm_config[0],
459 vsc_for_pcm_config[1], vsc_for_pcm_config[2],
460 vsc_for_pcm_config[3], vsc_for_pcm_config[4]);
462 SendCommand(VSC_WRITE_PCM_DATA_FORMAT_PARAM, 5, (UINT8 *)vsc_for_pcm_config);
463 read_event(fd, buffer);
466 void SetPcmConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
468 vsc_for_pcm_config[0] = p0;
469 vsc_for_pcm_config[1] = p1;
470 vsc_for_pcm_config[2] = p2;
471 vsc_for_pcm_config[3] = p3;
472 vsc_for_pcm_config[4] = p4;
475 void SetScoConf( UINT8 p0, UINT8 p1, UINT8 p2, UINT8 p3, UINT8 p4 )
477 vsc_for_sco_pcm[0] = p0;
478 vsc_for_sco_pcm[1] = p1;
479 vsc_for_sco_pcm[2] = p2;
480 vsc_for_sco_pcm[3] = p3;
481 vsc_for_sco_pcm[4] = p4;
484 void HCILP_Enable(BOOLEAN on)
486 fprintf(stderr,"Set Low Power mode %d\n",on);
487 UINT8 data[HCI_BRCM_WRITE_SLEEP_MODE_LENGTH] = {
488 0x01, /* Sleep Mode algorithm 1 */
489 HCILP_IDLE_THRESHOLD, /* Host Idle Treshold in 300ms */
490 HCILP_HC_IDLE_THRESHOLD, /* Host Controller Idle Treshold in 300ms */ /* this should be less than scan interval.*/
491 HCILP_BT_WAKE_POLARITY, /* BT_WAKE Polarity - 0=Active Low, 1= Active High*/
492 HCILP_HOST_WAKE_POLARITY, /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
493 0x01, /* Allow host Sleep during SCO */
494 0x01, /* Combine Sleep Mode and LPM - The device will not sleep in mode 0 if this flag is set to 1,*/
495 0x00, /* UART_TXD Tri-State : 0x00 = Do not tri-state UART_TXD in sleep mode */
496 0x00, /* NA to Mode 1 */
497 0x00, /* NA to Mode 1 */
509 SendCommand(HCI_BRCM_WRITE_SLEEP_MODE, HCI_BRCM_WRITE_SLEEP_MODE_LENGTH, (UINT8 *)data);
510 read_event(fd, buffer);
513 UINT32 uart_speed(UINT32 Speed)
542 void ChangeBaudRate(UINT32 baudrate)
544 UINT8 hci_data[HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
545 UINT8 uart_clock_24 = 0x2; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
546 UINT8 uart_clock_48 = 0x1; /* 0x1 - UART Clock 48MHz, 0x2 - UART Clock 24MHz */
558 /* Write UART Clock setting of 24MHz */
559 DEBUG0( "Change UART_CLOCK 24Mhz\n");
560 SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_24);
561 read_event(fd, buffer);
566 /* Write UART Clock setting of 48MHz */
567 DEBUG0( "Change UART_CLOCK 48Mh\nz");
568 SendCommand( VSC_WRITE_UART_CLOCK_SETTING, VSC_WRITE_UART_CLOCK_SETTING_LEN, (UINT8 *)&uart_clock_48);
569 read_event(fd, buffer);
573 fprintf(stderr,"Not Support baudrate = %ld\n", baudrate);
578 hci_data[2] = baudrate & 0xFF;
579 hci_data[3] = (baudrate >> 8) & 0xFF;
580 hci_data[4] = (baudrate >> 16) & 0xFF;
581 hci_data[5] = (baudrate >> 24) & 0xFF;
583 DEBUG1( "Change Baudrate %ld\n",baudrate);
585 SendCommand( HCI_BRCM_UPDATE_BAUDRATE_CMD, HCI_BRCM_UPDATE_BAUD_RATE_UNENCODED_LENGTH, (UINT8 *)hci_data);
586 read_event(fd, buffer);
589 tcflush(fd, TCIOFLUSH);
590 tcgetattr(fd, &termios);
592 termios.c_cflag |= CRTSCTS;
593 tcsetattr(fd, TCSANOW, &termios);
594 tcflush(fd, TCIOFLUSH);
595 tcsetattr(fd, TCSANOW, &termios);
596 tcflush(fd, TCIOFLUSH);
597 tcflush(fd, TCIOFLUSH);
598 cfsetospeed(&termios, uart_speed(baudrate));
599 cfsetispeed(&termios, uart_speed(baudrate));
600 tcsetattr(fd, TCSANOW, &termios);
604 void EnableTestMode(void)
606 UINT8 filter_data[] = { 0x02, 0x00, 0x02 };
608 /* bt sleep disable */
611 /* Enable both Inquiry & Page Scans */
614 /* Set Event Filter: Enable Auto Connect */
615 SendCommand( HCI_SET_EVENT_FILTER, 0x03, (UINT8 *)filter_data);
616 read_event(fd, buffer);
618 /* Enable Device under test */
619 SendCommand( HCI_ENABLE_DEV_UNDER_TEST_MODE, 0x0, NULL);
620 read_event(fd, buffer);
622 fprintf(stderr,"Enable Device Under Test\n");
625 void SetLocalFeatures(void)
629 DEBUG0("Read Local Feature\n");
630 SendCommand(HCI_READ_LOCAL_FEATURES, 0, NULL);
631 read_event(fd, buffer);
635 #if (BCM_DISABLE_RF_PWRCTRL == TRUE)
636 fprintf(stderr,"Remove Power Control\n");
637 data[2] &= 0xFB; /* Power contrel */
639 DEBUG0("Write Local Feature\n");
640 SendCommand(VSC_HCI_CMD_SET_LOC_FEATURES_CMD, 0x08, (UINT8 *)data);
641 read_event(fd, buffer);
647 int proto = HCI_UART_H4;
649 if (ioctl(fd, TIOCSETD, &i) < 0)
651 fprintf(stderr, "Can't set line discipline\n");
655 if (ioctl(fd, HCIUARTSETPROTO, proto) < 0)
657 fprintf(stderr, "Can't set hci protocol\n");
660 fprintf(stderr, "Done setting line discpline\n");
664 void print_usage( void )
666 fprintf(stderr,"\n");
667 fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
668 fprintf(stderr,"\n");
669 fprintf(stderr," Usage: bcmtool <tty Device> <command> [command parameter],....\n\n");
670 fprintf(stderr," -FILE Patchram file name EX) -FILE=BCM43xx_xxx.hcd\n");
671 fprintf(stderr," -BAUD Set Baudrate EX) -BAUD=3000000\n");
672 fprintf(stderr," -ADDR BD addr file name EX) -ADDR=.bdaddr\n");
673 fprintf(stderr," -SCO Enable SCO/PCM config EX) -SCO\n");
674 fprintf(stderr," -SETSCO SCO/PCM values verify EX) -SETSCO=0,1,0,1,1,0,0,3,3,0\n");
675 fprintf(stderr," -LP Enable Low power EX) -LP\n");
676 fprintf(stderr," -FEATURE Set local Feature EX) -FEATURE\n");
677 fprintf(stderr," -DUT Enable DUT mode(do not use with -LP) EX) -DUT\n");
678 fprintf(stderr," -ATTACH Attach BT controller to BlueZ stack EX) -ATTACH\n");
679 fprintf(stderr," -DEBUG Debug message EX) -DEBUG\n");
680 fprintf(stderr,"\n");
683 int main(int argc, char *argv[])
694 fprintf(stderr,"BRCM BT tool for Linux release %s\n",RELEASE_DATE);
698 if ((fd = open(argv[1], O_RDWR | O_NOCTTY)) == -1)
700 fprintf(stderr, "port %s could not be opened, error %d\n", argv[1], errno);
704 tcflush(fd, TCIOFLUSH);
705 tcgetattr(fd, &termios);
707 termios.c_cflag |= CRTSCTS;
708 tcsetattr(fd, TCSANOW, &termios);
709 tcflush(fd, TCIOFLUSH);
710 tcsetattr(fd, TCSANOW, &termios);
711 tcflush(fd, TCIOFLUSH);
712 tcflush(fd, TCIOFLUSH);
713 cfsetospeed(&termios, B115200);
714 cfsetispeed(&termios, B115200);
715 tcsetattr(fd, TCSANOW, &termios);
717 signal(SIGALRM, expired);
719 for( i=2; i<argc; i++ )
723 if( strstr(ptr,"-DEBUG") )
726 DEBUG0("DEBUG On\n");
731 for( i=2; i<argc; i++ )
738 fprintf(stderr,"[%d] %s\n", i-1, ptr);
740 if( strstr(ptr,"-FILE=") )
746 strncpy(prm_name,ptr, 127);
747 DownloadPatchram( prm_name );
750 else if( strstr(ptr,"-BAUD=") )
755 baudrate = atoi(ptr);
757 ChangeBaudRate(baudrate);
759 else if( strstr(ptr,"-ADDR=") )
761 char *bdaddr_filename;
764 int bdaddr[10]; /* Displayed BD Address */
766 BD_ADDR local_addr; /* BD Address for write */
770 if( sscanf(ptr,"%02X:%02X:%02X:%02X:%02X:%02X",&bdaddr[0],&bdaddr[1],&bdaddr[2],&bdaddr[3],&bdaddr[4],&bdaddr[5]) != 6 )
772 fprintf(stderr,"-ADDR: Parameter error");
775 bte_write_bdaddr(bdaddr);
778 bdaddr_filename = ptr;
782 pFile = fopen(bdaddr_filename, "r");
787 char text[BTUI_MAX_STRING_LENGTH_PER_LINE];
789 if (!fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile))
790 fprintf(stderr, "fail to fgets");
791 sscanf(text,"%02x%02x",&bdaddr[0],&bdaddr[1]);
793 if (!fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile))
794 fprintf(stderr, "fail to fgets");
795 sscanf(text,"%02x",&bdaddr[2]);
797 if (!fgets(text, BTUI_MAX_STRING_LENGTH_PER_LINE, pFile))
798 fprintf(stderr, "fail to fgets");
799 sscanf(text,"%02x%02x%02x",&bdaddr[3],&bdaddr[4],&bdaddr[5]);
801 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]);
803 ROTATE_BD_ADDR(local_addr,bdaddr);
805 SendCommand(VSC_WRITE_BD_ADDR, BD_ADDR_LEN, (UINT8 *)local_addr);
806 read_event(fd, buffer);
810 fprintf(stderr, "-ADDR: file open fail\n");
815 else if( strstr(ptr,"-SCO") )
820 else if( strstr(ptr,"-SETSCO=") )
825 if( sscanf(ptr,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",&value[0],&value[1],&value[2],&value[3],&value[4],
826 &value[5],&value[6],&value[7],&value[8],&value[9]) != 10 )
828 DEBUG0("PCM / SCO configuration value err\n");
829 DEBUG0("SCO_Routing,PCM_Interface_Rate,Frame_Type,Sync_Mode,Clock_Mode,LSB_First,Fill_bits,Fill_Method,Fill_Num,Right_Justify\n");
833 SetScoConf( value[0],value[1],value[2],value[3],value[4] );
834 SetPcmConf( value[5],value[6],value[7],value[8],value[9] );
837 else if( strstr(ptr,"-LP") )
841 else if( strstr(ptr,"-DUT") )
845 else if( strstr(ptr,"-FEATURE") )
849 else if( strstr(ptr,"-ATTACH") )
857 else if( strstr(ptr,"-DEBUG") )
863 fprintf(stderr,"Invalid parameter(s)!\n");
868 fprintf(stderr, "EXIT\n");