Skip to contentSkip to conversation

TI BTS for hciattach

PATCH In review Todd Blumer 2 participants 2 messages Jun 17, 2005 – Jun 18, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 TI BTS for hciattach

This proposed patch implements the TI BTS (Bluetooth script) mechanism. I have attached the diff and new files to be built along with hciattach. I have also attached a sample BTS file (the one that goes along with the BRF6150 plus firmware, as found in the iPAQ hx4700). The code is a bit chatty (prints BTS comment lines), but provides feedback as to what is being done with the chip. Comments / Suggestions welcome. Example usage:

hciattach -S /etc/bluetooth/TIInit_3.2.26.bts ttyS1 texas

Sample output (comments come from bts file):

TI module LMP version : 0x02
TI module LMP sub-version : 0x0d1a
Loading BTS script version 1
#--------------------------------------------------------------------------------
# Description : Initilization for BRF6150 2.11 ROM Device #

#               The following software update is required to be
#               executed after power up or reset of the BRF6150 v2.11 device
#               for optimal performance and enhancement of the RF.

#
#
# Script Ver : 2.26c
#
# Compatablity: BRF6150 2.11 ROM Device
#
# Last Updated: 25.3.2004
#
# Notes : For usage on BRF6150 v2.11 ROM device only (FW version
2.0.26)!
#
#--------------------------------------------------------------------------------
#LC Pole trim bits [9:7=011]
# DETECTOR Update
# Set MLSE THRESHOLD to -68 dBm
#MLSE Match filter coef
# MLSE Ideal values
#AFC T2 Coefficients
#ANRITSU Power Control
BTS changing baud rate to 921600, flow control to 1
Bluetooth: HCI UART driver ver 2.1
Bluetooth: HCI H4 protocol initialized
Bluetooth: HCI BCSP protocol initialized

--
Todd Blumer
SDG Systems, LLC

Index: Makefile.am
===================================================================
RCS file: /cvsroot/bluez/utils/tools/Makefile.am,v retrieving revision 1.29

Makefile.am +3 -0
diff -u -r1.29 Makefile.am
@@ -24,6 +24,9 @@
 
 noinst_PROGRAMS = hcisecfilter ppporc pskey bccmd
 
+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
 

Index: hciattach.c
===================================================================
RCS file: /cvsroot/bluez/utils/tools/hciattach.c,v retrieving revision 1.29

hciattach.c +134 -5

196 lines not on this page · raw message

/*
* 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 <stdio.h>
#include <stdlib.h>
#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);
    }
}

/*
* 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 */

maintainer
#1 lore raw

Hi Todd,

Quoted 6 lines

This proposed patch implements the TI BTS (Bluetooth script) mechanism. I have attached the diff and new files to be built along with hciattach. I have also attached a sample BTS file (the one that goes along with the BRF6150 plus firmware, as found in the iPAQ hx4700). The code is a bit chatty (prints BTS comment lines), but provides feedback as to what is being done with the chip. Comments / Suggestions welcome.

is it possible to get a development kit with the BRF6150 from TI? I like to test this new code.

Do we get the full specification of BTS? I think we need to rewrite some parts of the TI code. I don't like the coding style and parts of it look too much like crappy Windows code.

Regards

Marcel

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel