CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: nat Date: Sun Sep 3 22:54:12 UTC 2017 Modified Files: src/usr.sbin/btattach: init_bcm43xx.c Log Message: Fix copyright error. Ok plunky@. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/btattach/init_bcm43xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_bcm43xx.c diff -u src/usr.sbin/btattach/init_bcm43xx.c:1.4 src/usr.sbin/btattach/init_bcm43xx.c:1.5 --- src/usr.sbin/btattach/init_bcm43xx.c:1.4 Mon Aug 14 05:28:23 2017 +++ src/usr.sbin/btattach/init_bcm43xx.c Sun Sep 3 22:54:12 2017 @@ -1,7 +1,7 @@ -/* $NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $ */ +/* $NetBSD: init_bcm43xx.c,v 1.5 2017/09/03 22:54:12 nat Exp $ */ /*- - * Copyright (c) 2017 Iain Hibbert + * Copyright (c) 2017 Nathanial Sloss* All rights reserved. * * Copyright (c) 2008 Iain Hibbert @@ -34,7 +34,7 @@ */ #include -__RCSID("$NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $"); +__RCSID("$NetBSD: init_bcm43xx.c,v 1.5 2017/09/03 22:54:12 nat Exp $"); #include
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: nat Date: Mon Aug 14 05:28:23 UTC 2017 Modified Files: src/usr.sbin/btattach: init_bcm43xx.c Log Message: Set controller clock based on baud rate. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/init_bcm43xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_bcm43xx.c diff -u src/usr.sbin/btattach/init_bcm43xx.c:1.3 src/usr.sbin/btattach/init_bcm43xx.c:1.4 --- src/usr.sbin/btattach/init_bcm43xx.c:1.3 Thu Aug 10 20:43:12 2017 +++ src/usr.sbin/btattach/init_bcm43xx.c Mon Aug 14 05:28:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $ */ +/* $NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $ */ /*- * Copyright (c) 2017 Iain Hibbert @@ -34,7 +34,7 @@ */ #include -__RCSID("$NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $"); +__RCSID("$NetBSD: init_bcm43xx.c,v 1.4 2017/08/14 05:28:23 nat Exp $"); #include @@ -56,11 +56,17 @@ __RCSID("$NetBSD: init_bcm43xx.c,v 1.3 2 #define HCI_CMD_BCM43XX_SET_BDADDR \ HCI_OPCODE(HCI_OGF_VENDOR, 0x006) +#define HCI_CMD_BCM43XX_SET_CLOCK \ + HCI_OPCODE(HCI_OGF_VENDOR, 0x045) + #define HCI_CMD_43XXFWDN \ HCI_OPCODE(HCI_OGF_VENDOR, 0x02e) #define HCI_CMD_GET_LOCAL_NAME 0x0c14 +#define BCM43XX_CLK_48 1 +#define BCM43XX_CLK_24 2 + static int bcm43xx_get_local_name(int fd, char *name, size_t namelen) { @@ -85,7 +91,7 @@ bcm43xx_get_local_name(int fd, char *nam void init_bcm43xx(int fd, unsigned int speed) { - uint8_t rate[6]; + uint8_t rate[6], clock; uint8_t fw_buf[1024]; int fwfd, fw_len; uint8_t resp[7]; @@ -134,6 +140,14 @@ init_bcm43xx(int fd, unsigned int speed) uart_recv_cc(fd, HCI_CMD_RESET, , sizeof(resp)); /* assume it succeeded? */ + if (speed >= 300) + clock = BCM43XX_CLK_48; + else + clock = BCM43XX_CLK_24; + + uart_send_cmd(fd, HCI_CMD_BCM43XX_SET_CLOCK, , sizeof(clock)); + uart_recv_cc(fd, HCI_CMD_BCM43XX_SET_CLOCK, , sizeof(resp)); + rate[2] = speed; rate[3] = speed >> 8; rate[4] = speed >> 16;
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: wiz Date: Sun Aug 13 18:34:03 UTC 2017 Modified Files: src/usr.sbin/btattach: btattach.8 Log Message: Indent to avoid line breaks in tag; give tag width in table; use Nm to refer to hciattach because we'll probably never have hciattach(8). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/btattach/btattach.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.8 diff -u src/usr.sbin/btattach/btattach.8:1.9 src/usr.sbin/btattach/btattach.8:1.10 --- src/usr.sbin/btattach/btattach.8:1.9 Fri Aug 11 11:54:08 2017 +++ src/usr.sbin/btattach/btattach.8 Sun Aug 13 18:34:03 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: btattach.8,v 1.9 2017/08/11 11:54:08 jmcneill Exp $ +.\" $NetBSD: btattach.8,v 1.10 2017/08/13 18:34:03 wiz Exp $ .\" .\" Copyright (c) 2007 KIYOHARA Takashi .\" All rights reserved. @@ -55,7 +55,7 @@ given device before activating the line discipline. .Pp Supported types are: -.Bl -tag -compact -width ericssonxx -offset indent +.Bl -tag -compact -width 15n -offset indent .It Cm bcm2035 Broadcom BCM2035 .It Cm bcm43xx @@ -122,7 +122,7 @@ packet from HCI, or .Xr btuart 4 , if there is no response. .Sh FILES -.Bl -tag -compact +.Bl -tag -compact -width 20n .It Pa /var/run/btattach- Ns Bro tty Brc Ns .pid .El .Sh SEE ALSO @@ -134,7 +134,7 @@ if there is no response. The .Nm program was written with reference to -.Xr hciattach 8 +.Nm hciattach as provided with the BlueZ tools for Linux and first appeared in .Nx 5.0 . .Sh AUTHORS
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: jmcneill Date: Fri Aug 11 11:54:08 UTC 2017 Modified Files: src/usr.sbin/btattach: btattach.8 btattach.c Log Message: Make the "bcm43xx" type use H4 transport and add a new "bcm43xx-3wire" type for use with H5 transport. The naming of the types here matches those used in a series of BlueZ patches from the Raspberry Pi foundation. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/btattach/btattach.8 cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/btattach/btattach.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.8 diff -u src/usr.sbin/btattach/btattach.8:1.8 src/usr.sbin/btattach/btattach.8:1.9 --- src/usr.sbin/btattach/btattach.8:1.8 Tue Mar 18 18:20:46 2014 +++ src/usr.sbin/btattach/btattach.8 Fri Aug 11 11:54:08 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: btattach.8,v 1.8 2014/03/18 18:20:46 riastradh Exp $ +.\" $NetBSD: btattach.8,v 1.9 2017/08/11 11:54:08 jmcneill Exp $ .\" .\" Copyright (c) 2007 KIYOHARA Takashi .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd March 9, 2010 +.Dd August 11, 2017 .Dt BTATTACH 8 .Os .Sh NAME @@ -58,6 +58,10 @@ Supported types are: .Bl -tag -compact -width ericssonxx -offset indent .It Cm bcm2035 Broadcom BCM2035 +.It Cm bcm43xx +Broadcom BCM43xx +.It Cm bcm43xx-3wire +Broadcom BCM43xx (3-wire) .It Cm bcsp Generic BCSP (BlueCore Serial Protocol) .It Cm bgb2xx Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.14 src/usr.sbin/btattach/btattach.c:1.15 --- src/usr.sbin/btattach/btattach.c:1.14 Thu Aug 10 13:34:29 2017 +++ src/usr.sbin/btattach/btattach.c Fri Aug 11 11:54:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.14 2017/08/10 13:34:29 nat Exp $ */ +/* $NetBSD: btattach.c,v 1.15 2017/08/11 11:54:08 jmcneill Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved."); -__RCSID("$NetBSD: btattach.c,v 1.14 2017/08/10 13:34:29 nat Exp $"); +__RCSID("$NetBSD: btattach.c,v 1.15 2017/08/11 11:54:08 jmcneill Exp $"); #include #include @@ -63,12 +63,19 @@ static const struct devtype types[] = { }, { .name = "bcm43xx", - .line = "bth5", + .line = "btuart", .descr = "Broadcom BCM43xx", .init = _bcm43xx, .speed = B115200, }, { + .name = "bcm43xx-3wire", + .line = "bth5", + .descr = "Broadcom BCM43xx (3-wire)", + .init = _bcm43xx, + .speed = B115200, +}, +{ .name = "bcsp", .line = "bcsp", .descr = "Generic BlueCore Serial Protocol",
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: jmcneill Date: Thu Aug 10 20:43:12 UTC 2017 Modified Files: src/usr.sbin/btattach: Makefile init_bcm43xx.c Added Files: src/usr.sbin/btattach: firmload.c firmload.h Log Message: Derive the firmware name from the device's local name instead of hard-coding BCM4340A1. Search hw.firmware.path for the firmware image instead of loading it from the current directory. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/Makefile cvs rdiff -u -r0 -r1.1 src/usr.sbin/btattach/firmload.c \ src/usr.sbin/btattach/firmload.h cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/btattach/init_bcm43xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/Makefile diff -u src/usr.sbin/btattach/Makefile:1.3 src/usr.sbin/btattach/Makefile:1.4 --- src/usr.sbin/btattach/Makefile:1.3 Thu Aug 10 13:34:29 2017 +++ src/usr.sbin/btattach/Makefile Thu Aug 10 20:43:12 2017 @@ -1,10 +1,10 @@ -# $NetBSD: Makefile,v 1.3 2017/08/10 13:34:29 nat Exp $ +# $NetBSD: Makefile,v 1.4 2017/08/10 20:43:12 jmcneill Exp $ PROG= btattach MAN= btattach.8 -SRCS= btattach.c init_bcm2035.c init_bgb2xx.c init_csr.c init_digi.c \ - init_ericsson.c init_st.c init_stlc2500.c init_swave.c init_unistone.c \ - init_bcm43xx.c +SRCS= btattach.c firmload.c init_bcm2035.c init_bcm43xx.c init_bgb2xx.c \ + init_csr.c init_digi.c init_ericsson.c init_st.c init_stlc2500.c \ + init_swave.c init_unistone.c DPADD+= ${LIBBLUETOOTH} ${LIBUTIL} LDADD+= -lbluetooth -lutil Index: src/usr.sbin/btattach/init_bcm43xx.c diff -u src/usr.sbin/btattach/init_bcm43xx.c:1.2 src/usr.sbin/btattach/init_bcm43xx.c:1.3 --- src/usr.sbin/btattach/init_bcm43xx.c:1.2 Thu Aug 10 18:45:20 2017 +++ src/usr.sbin/btattach/init_bcm43xx.c Thu Aug 10 20:43:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: init_bcm43xx.c,v 1.2 2017/08/10 18:45:20 jakllsch Exp $ */ +/* $NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $ */ /*- * Copyright (c) 2017 Iain Hibbert @@ -34,7 +34,9 @@ */ #include -__RCSID("$NetBSD: init_bcm43xx.c,v 1.2 2017/08/10 18:45:20 jakllsch Exp $"); +__RCSID("$NetBSD: init_bcm43xx.c,v 1.3 2017/08/10 20:43:12 jmcneill Exp $"); + +#include #include #include @@ -46,6 +48,7 @@ __RCSID("$NetBSD: init_bcm43xx.c,v 1.2 2 #include #include "btattach.h" +#include "firmload.h" #define HCI_CMD_BCM43XX_SET_UART_BAUD_RATE \ HCI_OPCODE(HCI_OGF_VENDOR, 0x018) @@ -56,25 +59,57 @@ __RCSID("$NetBSD: init_bcm43xx.c,v 1.2 2 #define HCI_CMD_43XXFWDN \ HCI_OPCODE(HCI_OGF_VENDOR, 0x02e) +#define HCI_CMD_GET_LOCAL_NAME 0x0c14 + +static int +bcm43xx_get_local_name(int fd, char *name, size_t namelen) +{ + char buf[256]; + size_t len; + + memset(buf, 0, sizeof(buf)); + + uart_send_cmd(fd, HCI_CMD_GET_LOCAL_NAME, NULL, 0); + len = uart_recv_cc(fd, HCI_CMD_GET_LOCAL_NAME, buf, sizeof(buf)); + if (len == 0) + return EIO; + + strlcpy(name, [1], MIN(len - 1, namelen)); + + if (strlen(name) == 0) + return EIO; + + return 0; +} + void init_bcm43xx(int fd, unsigned int speed) { uint8_t rate[6]; uint8_t fw_buf[1024]; - char fw[] = "./BCM43430A1.hcd"; int fwfd, fw_len; uint8_t resp[7]; uint16_t fw_cmd; + char local_name[256]; + char fw[260]; memset(rate, 0, sizeof(rate)); + memset(local_name, 0, sizeof(local_name)); uart_send_cmd(fd, HCI_CMD_RESET, NULL, 0); uart_recv_cc(fd, HCI_CMD_RESET, , sizeof(resp)); /* assume it succeeded? */ - fwfd = open(fw, O_RDONLY); + if (bcm43xx_get_local_name(fd, local_name, sizeof(local_name)) != 0) { + fprintf(stderr, "Couldn't read local name\n"); + return; + } + snprintf(fw, sizeof(fw), "%s.hcd", local_name); + + fwfd = firmware_open("bcm43xx", fw); if (fwfd < 0) { - fprintf(stderr, "Unable to open firmware: %s\n", fw); + fprintf(stderr, "Unable to open firmware bcm43xx/%s: %s\n", + fw, strerror(errno)); return; } Added files: Index: src/usr.sbin/btattach/firmload.c diff -u /dev/null src/usr.sbin/btattach/firmload.c:1.1 --- /dev/null Thu Aug 10 20:43:12 2017 +++ src/usr.sbin/btattach/firmload.c Thu Aug 10 20:43:12 2017 @@ -0,0 +1,84 @@ +/* $NetBSD: firmload.c,v 1.1 2017/08/10 20:43:12 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared McNeill+ * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES,
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: jakllsch Date: Thu Aug 10 18:45:20 UTC 2017 Modified Files: src/usr.sbin/btattach: init_bcm43xx.c Log Message: remove currently-unused variables that trip up the build To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/btattach/init_bcm43xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_bcm43xx.c diff -u src/usr.sbin/btattach/init_bcm43xx.c:1.1 src/usr.sbin/btattach/init_bcm43xx.c:1.2 --- src/usr.sbin/btattach/init_bcm43xx.c:1.1 Thu Aug 10 13:34:29 2017 +++ src/usr.sbin/btattach/init_bcm43xx.c Thu Aug 10 18:45:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: init_bcm43xx.c,v 1.1 2017/08/10 13:34:29 nat Exp $ */ +/* $NetBSD: init_bcm43xx.c,v 1.2 2017/08/10 18:45:20 jakllsch Exp $ */ /*- * Copyright (c) 2017 Iain Hibbert @@ -34,7 +34,7 @@ */ #include -__RCSID("$NetBSD: init_bcm43xx.c,v 1.1 2017/08/10 13:34:29 nat Exp $"); +__RCSID("$NetBSD: init_bcm43xx.c,v 1.2 2017/08/10 18:45:20 jakllsch Exp $"); #include #include @@ -62,9 +62,8 @@ init_bcm43xx(int fd, unsigned int speed) uint8_t rate[6]; uint8_t fw_buf[1024]; char fw[] = "./BCM43430A1.hcd"; - int nr, fwfd, fw_len; + int fwfd, fw_len; uint8_t resp[7]; - uint8_t name[20]; uint16_t fw_cmd; memset(rate, 0, sizeof(rate));
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: nat Date: Thu Aug 10 13:34:29 UTC 2017 Modified Files: src/usr.sbin/btattach: Makefile btattach.c btattach.h Added Files: src/usr.sbin/btattach: init_bcm43xx.c Log Message: Add support for bcm 43xx devices using the btuart h5 protocol. Currently It will only load 1 firmware image for rpi3. To use change to the directory containing the firmware BCM4340A1.hcd. Then issue: btattach -FPi 115200 bcm43xx /dev/ttydevice 921600. Then you can use the bluetooth device btfive0. This enables the embedded bluetooth controller on rpi3. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/btattach/Makefile cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/btattach/btattach.c cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/btattach.h cvs rdiff -u -r0 -r1.1 src/usr.sbin/btattach/init_bcm43xx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/Makefile diff -u src/usr.sbin/btattach/Makefile:1.2 src/usr.sbin/btattach/Makefile:1.3 --- src/usr.sbin/btattach/Makefile:1.2 Sun Dec 6 12:55:46 2009 +++ src/usr.sbin/btattach/Makefile Thu Aug 10 13:34:29 2017 @@ -1,9 +1,10 @@ -# $NetBSD: Makefile,v 1.2 2009/12/06 12:55:46 kiyohara Exp $ +# $NetBSD: Makefile,v 1.3 2017/08/10 13:34:29 nat Exp $ PROG= btattach MAN= btattach.8 SRCS= btattach.c init_bcm2035.c init_bgb2xx.c init_csr.c init_digi.c \ - init_ericsson.c init_st.c init_stlc2500.c init_swave.c init_unistone.c + init_ericsson.c init_st.c init_stlc2500.c init_swave.c init_unistone.c \ + init_bcm43xx.c DPADD+= ${LIBBLUETOOTH} ${LIBUTIL} LDADD+= -lbluetooth -lutil Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.13 src/usr.sbin/btattach/btattach.c:1.14 --- src/usr.sbin/btattach/btattach.c:1.13 Tue Jun 16 23:04:14 2015 +++ src/usr.sbin/btattach/btattach.c Thu Aug 10 13:34:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.13 2015/06/16 23:04:14 christos Exp $ */ +/* $NetBSD: btattach.c,v 1.14 2017/08/10 13:34:29 nat Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved."); -__RCSID("$NetBSD: btattach.c,v 1.13 2015/06/16 23:04:14 christos Exp $"); +__RCSID("$NetBSD: btattach.c,v 1.14 2017/08/10 13:34:29 nat Exp $"); #include #include @@ -62,6 +62,13 @@ static const struct devtype types[] = { .speed = B115200, }, { + .name = "bcm43xx", + .line = "bth5", + .descr = "Broadcom BCM43xx", + .init = _bcm43xx, + .speed = B115200, +}, +{ .name = "bcsp", .line = "bcsp", .descr = "Generic BlueCore Serial Protocol", Index: src/usr.sbin/btattach/btattach.h diff -u src/usr.sbin/btattach/btattach.h:1.3 src/usr.sbin/btattach/btattach.h:1.4 --- src/usr.sbin/btattach/btattach.h:1.3 Sun Dec 6 12:55:46 2009 +++ src/usr.sbin/btattach/btattach.h Thu Aug 10 13:34:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.h,v 1.3 2009/12/06 12:55:46 kiyohara Exp $ */ +/* $NetBSD: btattach.h,v 1.4 2017/08/10 13:34:29 nat Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -40,6 +40,7 @@ struct devtype { }; devinit_t init_bcm2035; +devinit_t init_bcm43xx; devinit_t init_bgb2xx; devinit_t init_csr; devinit_t init_digi; Added files: Index: src/usr.sbin/btattach/init_bcm43xx.c diff -u /dev/null src/usr.sbin/btattach/init_bcm43xx.c:1.1 --- /dev/null Thu Aug 10 13:34:29 2017 +++ src/usr.sbin/btattach/init_bcm43xx.c Thu Aug 10 13:34:29 2017 @@ -0,0 +1,110 @@ +/* $NetBSD: init_bcm43xx.c,v 1.1 2017/08/10 13:34:29 nat Exp $ */ + +/*- + * Copyright (c) 2017 Iain Hibbert + * All rights reserved. + * + * Copyright (c) 2008 Iain Hibbert + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE,
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: christos Date: Tue Jun 16 23:54:58 UTC 2015 Modified Files: src/usr.sbin/btattach: init_unistone.c Log Message: a couple more stray \n To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/btattach/init_unistone.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_unistone.c diff -u src/usr.sbin/btattach/init_unistone.c:1.2 src/usr.sbin/btattach/init_unistone.c:1.3 --- src/usr.sbin/btattach/init_unistone.c:1.2 Tue Jun 16 19:04:14 2015 +++ src/usr.sbin/btattach/init_unistone.c Tue Jun 16 19:54:58 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: init_unistone.c,v 1.2 2015/06/16 23:04:14 christos Exp $ */ +/* $NetBSD: init_unistone.c,v 1.3 2015/06/16 23:54:58 christos Exp $ */ /* * Copyright (c) 2009 KIYOHARA Takashi * All rights reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: init_unistone.c,v 1.2 2015/06/16 23:04:14 christos Exp $); +__RCSID($NetBSD: init_unistone.c,v 1.3 2015/06/16 23:54:58 christos Exp $); #include bluetooth.h #include err.h @@ -106,7 +106,7 @@ init_unistone(int fd, unsigned int speed if (n != sizeof(cs) || cs.status != 0x00 || cs.opcode != HCI_CMD_INFINEON_SET_UART_BAUDRATE) - errx(EXIT_FAILURE, Set_UART_Baudrate failed\n); + errx(EXIT_FAILURE, Set_UART_Baudrate failed); if (cfsetspeed(tio, speed) != 0 || tcsetattr(fd, TCSANOW, tio) != 0) @@ -116,7 +116,7 @@ init_unistone(int fd, unsigned int speed if (n != sizeof(v) || v[0] != 0x12 || v[1] != 0x00) - errx(EXIT_FAILURE, Set_UART_Baudrate not complete\n); + errx(EXIT_FAILURE, Set_UART_Baudrate not complete); infineon_manufacturer_mode(fd, 0); }
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: joerg Date: Sat Aug 27 22:17:53 UTC 2011 Modified Files: src/usr.sbin/btattach: btattach.c Log Message: Mark types as static and usage as dead. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/btattach/btattach.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.11 src/usr.sbin/btattach/btattach.c:1.12 --- src/usr.sbin/btattach/btattach.c:1.11 Tue Mar 9 02:01:51 2010 +++ src/usr.sbin/btattach/btattach.c Sat Aug 27 22:17:53 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.11 2010/03/09 02:01:51 kiyohara Exp $ */ +/* $NetBSD: btattach.c,v 1.12 2011/08/27 22:17:53 joerg Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.); -__RCSID($NetBSD: btattach.c,v 1.11 2010/03/09 02:01:51 kiyohara Exp $); +__RCSID($NetBSD: btattach.c,v 1.12 2011/08/27 22:17:53 joerg Exp $); #include sys/ioctl.h #include sys/param.h @@ -47,13 +47,13 @@ #include btattach.h static void sighandler(int); -static void usage(void); +__dead static void usage(void); static void test(const char *, tcflag_t, tcflag_t); static int sigcount = 0; /* signals received */ static int opt_debug = 0; /* global? */ -const struct devtype types[] = { +static const struct devtype types[] = { { .name = bcm2035, .line = btuart,
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: wiz Date: Thu Apr 28 16:23:41 UTC 2011 Modified Files: src/usr.sbin/btattach: btattach.8 Log Message: Fix a typo. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/btattach/btattach.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.8 diff -u src/usr.sbin/btattach/btattach.8:1.5 src/usr.sbin/btattach/btattach.8:1.6 --- src/usr.sbin/btattach/btattach.8:1.5 Tue Mar 9 10:54:01 2010 +++ src/usr.sbin/btattach/btattach.8 Thu Apr 28 16:23:41 2011 @@ -1,4 +1,4 @@ -.\ $NetBSD: btattach.8,v 1.5 2010/03/09 10:54:01 wiz Exp $ +.\ $NetBSD: btattach.8,v 1.6 2011/04/28 16:23:41 wiz Exp $ .\ .\ Copyright (c) 2007 KIYOHARA Takashi .\ All rights reserved. @@ -65,7 +65,7 @@ .It Cm btuart Generic UART (this is the default) .It Cm csr -Cambridge Silicon Radio Casira serial adaptor, or +Cambridge Silicon Radio Casira serial adapter, or Brainboxes serial dongle (BL642) .It Cm ericsson Ericsson based modules
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: plunky Date: Wed Feb 17 09:49:41 UTC 2010 Modified Files: src/usr.sbin/btattach: btattach.c Log Message: sort entries in structure clarify init name type for CSR modules To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/btattach/btattach.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.5 src/usr.sbin/btattach/btattach.c:1.6 --- src/usr.sbin/btattach/btattach.c:1.5 Sun Dec 6 12:55:46 2009 +++ src/usr.sbin/btattach/btattach.c Wed Feb 17 09:49:41 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.5 2009/12/06 12:55:46 kiyohara Exp $ */ +/* $NetBSD: btattach.c,v 1.6 2010/02/17 09:49:41 plunky Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.); -__RCSID($NetBSD: btattach.c,v 1.5 2009/12/06 12:55:46 kiyohara Exp $); +__RCSID($NetBSD: btattach.c,v 1.6 2010/02/17 09:49:41 plunky Exp $); #include sys/ioctl.h #include sys/param.h @@ -54,13 +54,6 @@ const struct devtype types[] = { { - .name = bcsp, - .line = bcsp, - .descr = Generic BlueCore Serial Protocol, - .cflag = CRTSCTS, - .speed = B57600, -}, -{ .name = bcm2035, .line = btuart, .descr = Broadcom BCM2035, @@ -68,6 +61,13 @@ .speed = B115200, }, { + .name = bcsp, + .line = bcsp, + .descr = Generic BlueCore Serial Protocol, + .cflag = CRTSCTS, + .speed = B57600, +}, +{ .name = bgb2xx, .line = btuart, .descr = Philips BGB2xx module, @@ -83,7 +83,7 @@ { .name = csr, .line = btuart, - .descr = CSR Casira serial adaptor, + .descr = Cambridge Silicon Radio based modules (not BCSP), .init = init_csr, .cflag = CRTSCTS, .speed = B57600,
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: kiyohara Date: Sun Dec 6 12:29:48 UTC 2009 Modified Files: src/usr.sbin/btattach: init_csr.c Log Message: Fix comment. CSR use BlueCore command. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/btattach/init_csr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_csr.c diff -u src/usr.sbin/btattach/init_csr.c:1.1 src/usr.sbin/btattach/init_csr.c:1.2 --- src/usr.sbin/btattach/init_csr.c:1.1 Tue Apr 15 11:17:48 2008 +++ src/usr.sbin/btattach/init_csr.c Sun Dec 6 12:29:48 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: init_csr.c,v 1.1 2008/04/15 11:17:48 plunky Exp $ */ +/* $NetBSD: init_csr.c,v 1.2 2009/12/06 12:29:48 kiyohara Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: init_csr.c,v 1.1 2008/04/15 11:17:48 plunky Exp $); +__RCSID($NetBSD: init_csr.c,v 1.2 2009/12/06 12:29:48 kiyohara Exp $); #include bluetooth.h #include errno.h @@ -84,7 +84,7 @@ { struct bccmd cmd; - /* setup BCSP command packet */ + /* setup BlueCore command packet */ memset(cmd, 0, sizeof(cmd)); cmd.chanid = CSR_BCCMD_LAST | CSR_BCCMD_FIRST | BCSP_CHANNEL_BCCMD;
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: kiyohara Date: Sun Dec 6 12:31:07 UTC 2009 Modified Files: src/usr.sbin/btattach: init_stlc2500.c Log Message: Check return values. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/btattach/init_stlc2500.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/init_stlc2500.c diff -u src/usr.sbin/btattach/init_stlc2500.c:1.1 src/usr.sbin/btattach/init_stlc2500.c:1.2 --- src/usr.sbin/btattach/init_stlc2500.c:1.1 Tue Apr 15 11:17:48 2008 +++ src/usr.sbin/btattach/init_stlc2500.c Sun Dec 6 12:31:07 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: init_stlc2500.c,v 1.1 2008/04/15 11:17:48 plunky Exp $ */ +/* $NetBSD: init_stlc2500.c,v 1.2 2009/12/06 12:31:07 kiyohara Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: init_stlc2500.c,v 1.1 2008/04/15 11:17:48 plunky Exp $); +__RCSID($NetBSD: init_stlc2500.c,v 1.2 2009/12/06 12:31:07 kiyohara Exp $); #include bluetooth.h #include err.h @@ -113,9 +113,10 @@ /* STLC2500 has an ericsson core */ init_ericsson(fd, speed); - tcgetattr(fd, tio); - cfsetspeed(tio, speed); - tcsetattr(fd, TCSANOW, tio); + if (tcgetattr(fd, tio) != 0 || + cfsetspeed(tio, speed) != 0 || + tcsetattr(fd, TCSANOW, tio) != 0) + err(EXIT_FAILURE, can't change baud rate); uart_send_cmd(fd, HCI_CMD_READ_LOCAL_VER, NULL, 0); n = uart_recv_cc(fd, HCI_CMD_READ_LOCAL_VER, rp, sizeof(rp));
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: kiyohara Date: Sun Dec 6 12:47:37 UTC 2009 Modified Files: src/usr.sbin/btattach: btattach.c Log Message: Fix some bugs. 1. Remove O_NDELAY. Please block it. Or read() returns EAGAIN. 2. We want data size. header already read. 3. Call errx(). errno(2) unspecified at now. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/btattach/btattach.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.3 src/usr.sbin/btattach/btattach.c:1.4 --- src/usr.sbin/btattach/btattach.c:1.3 Wed Apr 15 00:32:23 2009 +++ src/usr.sbin/btattach/btattach.c Sun Dec 6 12:47:37 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.3 2009/04/15 00:32:23 lukem Exp $ */ +/* $NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.); -__RCSID($NetBSD: btattach.c,v 1.3 2009/04/15 00:32:23 lukem Exp $); +__RCSID($NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $); #include sys/ioctl.h #include sys/param.h @@ -211,7 +211,7 @@ init_speed = (type-speed ? type-speed : speed); /* open tty */ - if ((fd = open(argv[0], O_RDWR | O_NDELAY | O_EXLOCK, 0)) 0) + if ((fd = open(argv[0], O_RDWR | O_EXLOCK, 0)) 0) err(EXIT_FAILURE, %s, argv[0]); /* setup tty */ @@ -388,27 +388,24 @@ switch(type) { case HCI_EVENT_PKT: (void)uart_getc(fd, iov, ioc, count); /* event */ - want = sizeof(hci_event_hdr_t); - want += uart_getc(fd, iov, ioc, count); + want = uart_getc(fd, iov, ioc, count); break; case HCI_ACL_DATA_PKT: (void)uart_getc(fd, iov, ioc, count); /* handle LSB */ (void)uart_getc(fd, iov, ioc, count); /* handle MSB */ - want = sizeof(hci_acldata_hdr_t); - want += uart_getc(fd, iov, ioc, count); /* LSB */ - want += uart_getc(fd, iov, ioc, count) 8; /* MSB */ + want = uart_getc(fd, iov, ioc, count) | /* LSB */ + uart_getc(fd, iov, ioc, count) 8; /* MSB */ break; case HCI_SCO_DATA_PKT: (void)uart_getc(fd, iov, ioc, count); /* handle LSB */ (void)uart_getc(fd, iov, ioc, count); /* handle MSB */ - want = sizeof(hci_scodata_hdr_t); - want += uart_getc(fd, iov, ioc, count); + want = uart_getc(fd, iov, ioc, count); break; default: /* out of sync? */ - err(EXIT_FAILURE, unknown packet type 0x%2.2x, type); + errx(EXIT_FAILURE, unknown packet type 0x%2.2x\n, type); } while (want-- 0)
CVS commit: src/usr.sbin/btattach
Module Name:src Committed By: kiyohara Date: Sun Dec 6 12:55:46 UTC 2009 Modified Files: src/usr.sbin/btattach: Makefile btattach.c btattach.h Added Files: src/usr.sbin/btattach: init_unistone.c Log Message: Support Infineon UniStone (PBA31308). from Gumstix's bluez-utils-hciattach-pba31308.patch. tested on Gumstix verdex-pro. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/btattach/Makefile cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/btattach/btattach.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/btattach/btattach.h cvs rdiff -u -r0 -r1.1 src/usr.sbin/btattach/init_unistone.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/btattach/Makefile diff -u src/usr.sbin/btattach/Makefile:1.1 src/usr.sbin/btattach/Makefile:1.2 --- src/usr.sbin/btattach/Makefile:1.1 Tue Apr 15 11:17:48 2008 +++ src/usr.sbin/btattach/Makefile Sun Dec 6 12:55:46 2009 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.1 2008/04/15 11:17:48 plunky Exp $ +# $NetBSD: Makefile,v 1.2 2009/12/06 12:55:46 kiyohara Exp $ PROG= btattach MAN= btattach.8 SRCS= btattach.c init_bcm2035.c init_bgb2xx.c init_csr.c init_digi.c \ - init_ericsson.c init_st.c init_stlc2500.c init_swave.c + init_ericsson.c init_st.c init_stlc2500.c init_swave.c init_unistone.c DPADD+= ${LIBBLUETOOTH} ${LIBUTIL} LDADD+= -lbluetooth -lutil Index: src/usr.sbin/btattach/btattach.c diff -u src/usr.sbin/btattach/btattach.c:1.4 src/usr.sbin/btattach/btattach.c:1.5 --- src/usr.sbin/btattach/btattach.c:1.4 Sun Dec 6 12:47:37 2009 +++ src/usr.sbin/btattach/btattach.c Sun Dec 6 12:55:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $ */ +/* $NetBSD: btattach.c,v 1.5 2009/12/06 12:55:46 kiyohara Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -27,7 +27,7 @@ #include sys/cdefs.h __COPYRIGHT(@(#) Copyright (c) 2008 Iain Hibbert. All rights reserved.); -__RCSID($NetBSD: btattach.c,v 1.4 2009/12/06 12:47:37 kiyohara Exp $); +__RCSID($NetBSD: btattach.c,v 1.5 2009/12/06 12:55:46 kiyohara Exp $); #include sys/ioctl.h #include sys/param.h @@ -134,6 +134,14 @@ .cflag = CRTSCTS, .speed = B115200, }, +{ + .name = unistone, + .line = btuart, + .descr = Infineon UniStone, + .init = init_unistone, + .cflag = CRTSCTS, + .speed = B115200, +}, }; int Index: src/usr.sbin/btattach/btattach.h diff -u src/usr.sbin/btattach/btattach.h:1.2 src/usr.sbin/btattach/btattach.h:1.3 --- src/usr.sbin/btattach/btattach.h:1.2 Wed Apr 15 00:32:23 2009 +++ src/usr.sbin/btattach/btattach.h Sun Dec 6 12:55:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: btattach.h,v 1.2 2009/04/15 00:32:23 lukem Exp $ */ +/* $NetBSD: btattach.h,v 1.3 2009/12/06 12:55:46 kiyohara Exp $ */ /*- * Copyright (c) 2008 Iain Hibbert @@ -47,6 +47,7 @@ devinit_t init_st; devinit_t init_stlc2500; devinit_t init_swave; +devinit_t init_unistone; void uart_send_cmd(int, uint16_t, void *, size_t); size_t uart_recv_ev(int, uint8_t, void *, size_t); Added files: Index: src/usr.sbin/btattach/init_unistone.c diff -u /dev/null src/usr.sbin/btattach/init_unistone.c:1.1 --- /dev/null Sun Dec 6 12:55:46 2009 +++ src/usr.sbin/btattach/init_unistone.c Sun Dec 6 12:55:46 2009 @@ -0,0 +1,122 @@ +/* $NetBSD: init_unistone.c,v 1.1 2009/12/06 12:55:46 kiyohara Exp $ */ +/* + * Copyright (c) 2009 KIYOHARA Takashi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/* + * init information in this file gleaned from hciattach(8) + * command from Gumstix's patch for BlueZ. + */ + +#include sys/cdefs.h +__RCSID($NetBSD: init_unistone.c,v 1.1 2009/12/06 12:55:46 kiyohara Exp $); + +#include bluetooth.h