From 0c6c41d4c7f5d8744f55829871001516f03bf20f Mon Sep 17 00:00:00 2001 From: Todd Blumer Date: Tue, 4 Jul 2006 14:20:01 +0200 Subject: [PATCH] bluez-utils: apply hciattach-ti-bts.patch (required for bluetooth to work on hx4700) Signed-off-by: Rene Wagner --- .../packages/bluez/bluez-utils-2.21.inc | 48 -- .../packages/bluez/bluez-utils-dbus_2.21.bb | 2 +- .../packages/bluez/bluez-utils-nodbus_2.21.bb | 2 +- .../packages/bluez/bluez-utils.inc | 5 +- .../bluez/files/hciattach-ti-bts.patch | 489 ++++++++++++++++++ 5 files changed, 495 insertions(+), 51 deletions(-) delete mode 100644 org.handhelds.familiar/packages/bluez/bluez-utils-2.21.inc create mode 100644 org.handhelds.familiar/packages/bluez/files/hciattach-ti-bts.patch diff --git a/org.handhelds.familiar/packages/bluez/bluez-utils-2.21.inc b/org.handhelds.familiar/packages/bluez/bluez-utils-2.21.inc deleted file mode 100644 index d4d1bdc..0000000 --- a/org.handhelds.familiar/packages/bluez/bluez-utils-2.21.inc +++ /dev/null @@ -1,48 +0,0 @@ -DESCRIPTION = "Linux Bluetooth Stack Userland Utilities." -SECTION = "console" -PRIORITY = "optional" -DEPENDS = "bluez-libs-${PV} pcmcia-cs" -RPROVIDES_${PN} = "bluez-pan bluez-sdp bluez-utils" -LICENSE = "GPL" -PR = "r0" - -SRC_URI = "http://bluez.sourceforge.net/download/bluez-utils-${PV}.tar.gz \ - file://base.patch;patch=1 \ - file://blueboxes.patch;patch=1 \ - file://hcid.conf \ - file://bluetooth.default \ - file://bluetooth.conf " - -# Almost all serial CF cards w/ manfid 0x0000,0x0000 seem to use the bcs protocol -# Let's default to that instead of 'any' and see if we break something with that -SRC_URI_append_familiar = " file://default-manfid-0x0-to-bcps.patch;patch=1" -SRC_URI_append_openzaurus = " file://default-manfid-0x0-to-bcps.patch;patch=1" - -S = "${WORKDIR}/bluez-utils-${PV}" - -EXTRA_OECONF = "--with-bluez-libs=${STAGING_LIBDIR} --with-bluez-includes=${STAGING_INCDIR} \ - --enable-pcmcia --enable-initscripts --enable-bcm203x" - -inherit autotools update-rc.d - -INITSCRIPT_NAME = "bluetooth" -INITSCRIPT_PARAMS = "defaults 23 19" - -do_install_append() { - install -d ${D}${base_sbindir} ${D}${base_bindir}/ - mv ${D}${sbindir}/* ${D}${base_sbindir}/ - mv ${D}${bindir}/* ${D}${base_bindir}/ - rmdir ${D}${bindir} ${D}${sbindir} - chmod u+s ${D}${base_sbindir}/hciattach ${D}${base_sbindir}/hciconfig - chmod 755 ${D}${sysconfdir}/pcmcia/bluetooth - install -m 0644 ${WORKDIR}/hcid.conf ${D}${sysconfdir}/bluetooth/ - install -m 0644 ${WORKDIR}/bluetooth.default ${D}${sysconfdir}/default/bluetooth - cat ${WORKDIR}/bluetooth.conf >> ${D}${sysconfdir}/pcmcia/bluetooth.conf -} - -CONFFILES_${PN} = "${sysconfdir}/bluetooth/hcid.conf ${sysconfdir}/bluetooth/rfcomm.conf \ - ${sysconfdir}/bluetooth/pin ${sysconfdir}/default/bluetooth" - -PACKAGES =+ "${PN}-ciptool ${PN}-bluepin" -FILES_${PN}-ciptool = "/bin/ciptool" -FILES_${PN}-bluepin = "/bin/bluepin" diff --git a/org.handhelds.familiar/packages/bluez/bluez-utils-dbus_2.21.bb b/org.handhelds.familiar/packages/bluez/bluez-utils-dbus_2.21.bb index 61a0ff5..c0696ef 100644 --- a/org.handhelds.familiar/packages/bluez/bluez-utils-dbus_2.21.bb +++ b/org.handhelds.familiar/packages/bluez/bluez-utils-dbus_2.21.bb @@ -1,6 +1,6 @@ include bluez-utils.inc -PR = "r6" +PR = "r7" DEPENDS += "dbus" SRC_URI += "file://dbus.patch;patch=1 \ diff --git a/org.handhelds.familiar/packages/bluez/bluez-utils-nodbus_2.21.bb b/org.handhelds.familiar/packages/bluez/bluez-utils-nodbus_2.21.bb index 13cb31e..aea692f 100644 --- a/org.handhelds.familiar/packages/bluez/bluez-utils-nodbus_2.21.bb +++ b/org.handhelds.familiar/packages/bluez/bluez-utils-nodbus_2.21.bb @@ -1,5 +1,5 @@ include bluez-utils.inc -PR = "r4" +PR = "r5" EXTRA_OECONF += "--without-dbus" diff --git a/org.handhelds.familiar/packages/bluez/bluez-utils.inc b/org.handhelds.familiar/packages/bluez/bluez-utils.inc index c68df7b..f35e54b 100644 --- a/org.handhelds.familiar/packages/bluez/bluez-utils.inc +++ b/org.handhelds.familiar/packages/bluez/bluez-utils.inc @@ -8,6 +8,7 @@ LICENSE = "GPL" SRC_URI = "http://bluez.sourceforge.net/download/bluez-utils-${PV}.tar.gz \ file://base.patch;patch=1 \ file://blueboxes.patch;patch=1 \ + file://hciattach-ti-bts.patch;patch=1 \ file://hcid.conf \ file://bluetooth.default \ file://bluetooth.conf \ @@ -34,6 +35,8 @@ do_compile_prepend() { do_install_append() { install -d ${D}${base_sbindir} ${D}${base_bindir}/ ${D}${sysconfdir}/apm/event.d/ + install -d ${D}${base_sbindir} ${D}${base_bindir}/ ${D}${sysconfdir}/apm/scripts.d/ + install -d ${D}${base_sbindir} ${D}${base_bindir}/ ${D}${sysconfdir}/apm/resume.d/ mv ${D}${sbindir}/* ${D}${base_sbindir}/ mv ${D}${bindir}/* ${D}${base_bindir}/ rmdir ${D}${bindir} ${D}${sbindir} @@ -42,7 +45,7 @@ do_install_append() { install -m 0644 ${WORKDIR}/hcid.conf ${D}${sysconfdir}/bluetooth/ install -m 0644 ${WORKDIR}/bluetooth.default ${D}${sysconfdir}/default/bluetooth cat ${WORKDIR}/bluetooth.conf >> ${D}${sysconfdir}/pcmcia/bluetooth.conf - install -m 0755 ${WORKDIR}/02dtl1_cs.sh ${D}${sysconfdir}/apm/event.d/ + install -m 0755 ${WORKDIR}/02dtl1_cs.sh ${D}${sysconfdir}/apm/event.d/02dtl1_cs } CONFFILES_${PN} = "${sysconfdir}/bluetooth/hcid.conf ${sysconfdir}/bluetooth/rfcomm.conf \ diff --git a/org.handhelds.familiar/packages/bluez/files/hciattach-ti-bts.patch b/org.handhelds.familiar/packages/bluez/files/hciattach-ti-bts.patch new file mode 100644 index 0000000..069b11b --- /dev/null +++ b/org.handhelds.familiar/packages/bluez/files/hciattach-ti-bts.patch @@ -0,0 +1,489 @@ +--- bluez-utils-2.21/tools/hciattach.c.orig 2005-07-03 17:19:51.000000000 -0400 ++++ bluez-utils-2.21/tools/hciattach.c 2006-03-20 13:52:41.008742344 -0500 +@@ -62,6 +62,8 @@ + #define HCI_UART_3WIRE 2 + #define HCI_UART_H4DS 3 + ++#include "ti_bts.h" ++ + struct uart_t { + char *type; + int m_id; +@@ -71,6 +73,7 @@ + int speed; + int flags; + int (*init) (int fd, struct uart_t *u, struct termios *ti); ++ char *bts; /* bluetooth script */ + }; + + #define FLOW_CTL 0x0001 +@@ -246,6 +249,114 @@ + return 0; + } + ++static int brf6150(int fd, struct uart_t *u, struct termios *ti) ++{ ++ bts_t *bfp; ++ int i; ++ unsigned long vers; ++ unsigned char actionbuf[256]; ++ unsigned char resp[128]; /* Response */ ++ unsigned long count; ++ unsigned short atype; ++ ++ if (u->bts == NULL) /* no script, ignore */ ++ return 0; ++ ++ bfp = bts_load_script( u->bts, &vers ); ++ if (bfp == NULL) ++ return -1; ++ ++ fprintf( stderr, "Loading BTS script version %lu\n", vers ); ++ ++ while ((count = bts_next_action( bfp, actionbuf, ++ sizeof actionbuf - 1, &atype )) != 0) { ++ if (atype == ACTION_REMARKS) { ++ if (actionbuf[0] != 0) ++ fprintf( stderr, "%s\n", actionbuf ); ++ } ++ else if (atype == ACTION_SEND_COMMAND) { ++#if 0 ++ fprintf( stderr, "ACTION_SEND_COMMAND: ", (int)atype ); ++ for (i=0; idata[i] ); ++ } ++ fprintf( stderr, "\n" ); ++#endif ++ usleep(wait->msec); /* seems they give usec, not msec */ ++ /* Read reply. */ ++ if ((count = read_hci_event(fd, resp, sizeof resp)) < 0) { ++ perror("Failed to read TI command response"); ++ return -1; ++ } ++ if (count < wait->size) { ++ fprintf( stderr, "TI command response is short."); ++ } ++ for (i=0; isize; i++) { ++ if (i == 3) continue; /* ignore */ ++ if (resp[i] != wait->data[i]) { ++ fprintf( stderr, "TI command response does not match expected result.\n" ); ++ } ++ } ++ } ++ else if (atype == ACTION_SERIAL_PORT_PARAMETERS) { ++ action_serial_t *sercmd = (action_serial_t *)actionbuf; ++ ++ /* Set actual baudrate */ ++ fprintf( stderr, ++ "BTS changing baud rate to %u, flow control to %u\n", ++ sercmd->baud, sercmd->flow_control ); ++ ++ tcflush(fd, TCIOFLUSH); ++ ++ if (sercmd->flow_control) ++ ti->c_cflag |= CRTSCTS; ++ else ++ ti->c_cflag &= ~CRTSCTS; ++ if (tcsetattr(fd, TCSANOW, ti) < 0) { ++ perror("Can't set port settings"); ++ return -1; ++ } ++ ++ u->speed = sercmd->baud; ++ ++ tcflush(fd, TCIOFLUSH); ++ if (set_speed(fd, ti, sercmd->baud) < 0) { ++ perror("Can't set baud rate"); ++ return -1; ++ } ++ } ++ else if (atype == ACTION_DELAY) { ++ action_delay_t *delay = (action_delay_t *)actionbuf; ++ usleep(delay->msec); /* seems they give usec, not msec */ ++ } ++ else { ++ fprintf( stderr, "BTS action type = %d: ", (int)atype ); ++ for (i=0; i> 2) == 3) { ++ int err; ++ nanosleep(&tm, NULL); ++ ++ /* BRF6150 */ ++ if ((err=brf6150( fd, u, ti )) != 0) { ++ fprintf( stderr, "TI script failed (err=%d)\n", ++ err ); ++ return -1; ++ } ++ } + + nanosleep(&tm, NULL); + return 0; +@@ -957,7 +1079,7 @@ + { + printf("hciattach - HCI UART driver initialization utility\n"); + printf("Usage:\n"); +- printf("\thciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] [speed] [flow|noflow]\n"); ++ printf("\thciattach [-n] [-p] [-b] [-t timeout] [-s initial_speed] [-S bts-script] [speed] [flow|noflow]\n"); + printf("\thciattach -l\n"); + } + +@@ -974,11 +1096,12 @@ + pid_t pid; + struct sigaction sa; + char dev[20]; ++ char *bts = NULL; + + detach = 1; + printpid = 0; + +- while ((opt=getopt(argc, argv, "bnpt:s:l")) != EOF) { ++ while ((opt=getopt(argc, argv, "bnpt:s:S:l")) != EOF) { + switch(opt) { + case 'b': + send_break = 1; +@@ -1000,6 +1123,10 @@ + init_speed = atoi(optarg); + break; + ++ case 'S': ++ bts = optarg; ++ break; ++ + case 'l': + for (i = 0; uart[i].type; i++) { + printf("%-10s0x%04x,0x%04x\n", uart[i].type, +@@ -1071,6 +1198,8 @@ + if (init_speed) + u->init_speed = init_speed; + ++ u->bts = bts; ++ + memset(&sa, 0, sizeof(sa)); + sa.sa_flags = SA_NOCLDSTOP; + sa.sa_handler = sig_alarm; +--- bluez-utils-2.24/tools/Makefile.am.orig 2005-12-03 07:22:16.000000000 +0100 ++++ bluez-utils-2.24/tools/Makefile.am 2006-01-22 13:53:59.000000000 +0100 +@@ -37,6 +37,9 @@ + + noinst_PROGRAMS = hcisecfilter ppporc + ++hciattach_SOURCES = hciattach.c ti_bts.h ti_bts.c ++hciattach_LDADD = @BLUEZ_LIBS@ ++ + hciconfig_SOURCES = hciconfig.c csr.h csr.c + hciconfig_LDADD = @BLUEZ_LIBS@ $(top_builddir)/common/libtextfile.a + +--- bluez-utils-2.24/tools/ti_bts.h.orig 2006-01-22 13:56:38.000000000 +0100 ++++ bluez-utils-2.24/tools/ti_bts.h 2006-01-22 13:53:59.000000000 +0100 +@@ -0,0 +1,116 @@ ++/* ++ * Copyright (c) 2005 Texas Instruments, Inc. ++ * Ported by SDG Systems, LLC ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation; ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. ++ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY ++ * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ * ++ * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, ++ * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS ++ * SOFTWARE IS DISCLAIMED. ++ * ++ */ ++ ++#ifndef BT_SCRIPT_H ++#define BT_SCRIPT_H ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++/* ++ * Define the interface of Bluetooth Script ++ */ ++ ++typedef void bts_t; ++ ++ ++#define ACTION_SEND_COMMAND 1 /* Send out raw data (as is) */ ++#define ACTION_WAIT_EVENT 2 /* Wait for data */ ++#define ACTION_SERIAL_PORT_PARAMETERS 3 ++#define ACTION_DELAY 4 ++#define ACTION_RUN_SCRIPT 5 ++#define ACTION_REMARKS 6 ++ ++/* ++ * Structure for ACTION_SEND_COMMAND ++ */ ++typedef struct tagCActionCommand ++{ ++ unsigned char data[1]; /* Data to send */ ++} action_command_t; ++ ++/* ++ * Structure for ACTION_WAIT_EVENT ++ */ ++typedef struct tagCActionWaitEvent ++{ ++ unsigned long msec; /* in milliseconds */ ++ unsigned long size; ++ unsigned char data[1]; /* Data to wait for */ ++} action_wait_t; ++ ++ ++/* ++ * Structure for ACTION_SERIAL_PORT_PARAMETERS ++ */ ++typedef struct tagCActionSerialPortParameters ++{ ++ unsigned long baud; ++ unsigned long flow_control; ++} action_serial_t; ++ ++/* Flow Control Type */ ++#define FCT_NONE 0 ++#define FCT_HARDWARE 1 ++ ++#define DONT_CHANGE 0xFFFFFFFF /* For both baud rate and flow control */ ++ ++ ++/* ++ * Structure for ACTION_DELAY ++ */ ++typedef struct tagCActionDelay ++{ ++ unsigned long msec; /* in milliseconds */ ++} action_delay_t; ++ ++/* ++ * Structure for ACTION_RUN_SCRIPT ++ */ ++typedef struct tagCActionRunScript ++{ ++ char filename[1]; ++} action_run_t; ++ ++/* ++ * Structure for ACTION_REMARKS ++ */ ++typedef struct tagCActionRemarks ++{ ++ char m_szRemarks[1]; ++} action_remarks_t; ++ ++ ++const char *cis_create_filename(const unsigned char* cmdparms); ++bts_t * bts_load_script(const char* fname, unsigned long* version); ++unsigned long bts_next_action(const bts_t* bts_fp, unsigned char* action_buf, ++ unsigned long nMaxSize, unsigned short* ptype); ++void bts_unload_script(bts_t* bts_fp); ++ ++#ifdef __cplusplus ++}; ++#endif ++ ++#endif /* BT_SCRIPT_H */ ++ +--- bluez-utils-2.24/tools/ti_bts.c.orig 2006-01-22 13:56:36.000000000 +0100 ++++ bluez-utils-2.24/tools/ti_bts.c 2006-01-22 13:56:31.000000000 +0100 +@@ -0,0 +1,149 @@ ++/* ++ * Copyright (c) 2005 Texas Instruments, Inc. ++ * Ported by SDG Systems, LLC ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation; ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. ++ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY ++ * CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES ++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ++ * ++ * ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, ++ * COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS ++ * SOFTWARE IS DISCLAIMED. ++ * ++ */ ++ ++ ++#include ++#include ++#include "ti_bts.h" ++ ++#ifndef MAKEWORD ++#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) | ((unsigned short)((unsigned char)(b))) << 8)) ++#endif ++ ++#define TI_MANUFACTURER_ID 13 ++ ++/* ++ * Common Init Script specific ++ */ ++const char * ++cis_create_filename(const unsigned char* cmdparms) ++{ ++ static char bts_file[50]; ++ ++ /* Check for TI's id */ ++ unsigned short manfid = MAKEWORD(cmdparms[8], cmdparms[9]); ++ ++ if (TI_MANUFACTURER_ID == manfid) { ++ unsigned short version = MAKEWORD(cmdparms[10], cmdparms[11]); ++ ++ unsigned short chip = (version & 0x7C00) >> 10; ++ unsigned short min_ver = (version & 0x007F); ++ unsigned short maj_ver = (version & 0x0380) >> 7; ++ ++ if (0 != (version & 0x8000)) { ++ maj_ver |= 0x0008; ++ } ++ ++ sprintf( bts_file, "TIInit_%d.%d.%d.bts", ++ (int)chip, (int)maj_ver, (int)min_ver); ++ ++ return &bts_file[0]; ++ } ++ return NULL; ++} ++ ++typedef struct tagCHeader ++{ ++ unsigned long magic; ++ unsigned long version; ++ unsigned char future[24]; ++} cheader_t; ++ ++ ++/* The value 0x42535442 stands for (in ASCII) BTSB */ ++/* which is Bluetooth Script Binary */ ++#define FILE_HEADER_MAGIC 0x42535442 ++ ++ ++bts_t * ++bts_load_script(const char* fname, unsigned long* version) ++{ ++ bts_t* bts = NULL; ++ FILE* fp = fopen(fname, "rb"); ++ ++ if (NULL != fp) { ++ /* Read header */ ++ cheader_t header; ++ ++ /* Read header */ ++ if (1 == fread(&header, sizeof(header), 1, fp)) { ++ /* Check magic number for correctness */ ++ if (header.magic == FILE_HEADER_MAGIC) { ++ /* If user wants the version number */ ++ if (NULL != version) { ++ *version = header.version; ++ } ++ bts = (bts_t*)fp; ++ } ++ } ++ /* If failed reading the file, close it */ ++ if (NULL == bts) { ++ fclose(fp); ++ } ++ } ++ return bts; ++} ++ ++unsigned long ++bts_next_action(const bts_t* bts_fp, unsigned char* action_buf, ++ unsigned long nMaxSize, unsigned short* ptype) ++{ ++ unsigned long bytes = 0; ++ FILE* fp = (FILE*)bts_fp; ++ unsigned char action_hdr[4]; ++ ++ if (bts_fp == NULL) ++ return 0; ++ ++ /* Each Action has the following: */ ++ /* UINT16 type of this action */ ++ /* UINT16 size of rest */ ++ /* BYTE[] action buffer (for HCI, includes the type byte e.g. 1 for hci command) */ ++ ++ if (1 == fread(&action_hdr[0], sizeof(action_hdr), 1, fp)) { ++ unsigned short type = *(unsigned short*)&action_hdr[0]; ++ unsigned short size = *(unsigned short*)&action_hdr[2]; ++ ++ if (size <= nMaxSize) { ++ int nread = fread(action_buf, sizeof(action_buf[0]), size, fp); ++ ++ if (nread == size) { ++ *ptype = type; ++ bytes = (unsigned long)size; ++ } ++ } ++ } ++ ++ return bytes; ++} ++ ++void ++bts_unload_script(bts_t* bts_fp) ++{ ++ FILE* fp = (FILE*)bts_fp; ++ ++ if (NULL != fp) { ++ fclose(fp); ++ } ++} ++ -- 2.41.0