From owner-freebsd-usb@FreeBSD.ORG Mon Sep 21 18:14:01 2009 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3F59106568B; Mon, 21 Sep 2009 18:14:01 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe11.swipnet.se [212.247.155.65]) by mx1.freebsd.org (Postfix) with ESMTP id 08F8F8FC1C; Mon, 21 Sep 2009 18:14:00 +0000 (UTC) X-Cloudmark-Score: 0.000000 [] X-Cloudmark-Analysis: v=1.0 c=1 a=6U-Pe18MTAwA:10 a=MnI1ikcADjEx7bvsp0jZvQ==:17 a=-CGS2k2TXTb61kRWAFMA:9 a=uFOVGaHZlF09kYd-Lx0A:7 a=xaFwmV-oBsW-Wt2FdJ1TNLcRku8A:4 Received: from [188.126.201.140] (account mc467741@c2i.net HELO laptop.adsl.tele2.no) by mailfe11.swip.net (CommuniGate Pro SMTP 5.2.13) with ESMTPA id 1138936927; Mon, 21 Sep 2009 20:13:59 +0200 From: Hans Petter Selasky To: "Pierre-Luc Drouin" Date: Mon, 21 Sep 2009 20:14:35 +0200 User-Agent: KMail/1.11.4 (FreeBSD/9.0-CURRENT; KDE/4.2.4; i386; ; ) References: <4AB6DA79.7050209@pldrouin.net> <200909211932.37015.hselasky@c2i.net> <4AB7BD4D.4020703@pldrouin.net> In-Reply-To: <4AB7BD4D.4020703@pldrouin.net> X-Face: (%:6u[ldzJ`0qjD7sCkfdMmD*RxpOwEEQ+KWt[{J#x6ow~JO:,zwp.(t; @Aq :4:&nFCgDb8[3oIeTb^'",;u{5{}C9>"PuY\)!=#\u9SSM-nz8+SR~B\!qBv MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909212014.36874.hselasky@c2i.net> Cc: ed@freebsd.org, freebsd-usb@freebsd.org Subject: Re: usb/138659: uftdi driver broken in RELENG_8/CURRENT X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Sep 2009 18:14:02 -0000 On Monday 21 September 2009 19:52:13 Pierre-Luc Drouin wrote: > Hans Petter Selasky wrote: > > On Monday 21 September 2009 19:29:10 Pierre-Luc Drouin wrote: > >> Hans Petter Selasky wrote: > >>> On Monday 21 September 2009 03:44:25 Pierre-Luc Drouin wrote: > >>>> Hi, > >>>> > >>>> I am also having troubles with the uftdi driver on 8.0-BETA4. > >>>> I am trying to use a fan controller (mCubed bigNG) that uses a FT232BL > >>>> chip and it does not seem to be responding on FreeBSD 8.0 while the > >>>> same code works perfectly on Linux (I have not tried the code on > >>>> RELENG_7 yet but I could install it if necessary). > >>>> > >>>> Here is the very simple code I am using for testing: > >>>> #include > >>>> #include > >>>> #include > >>>> #include > >>>> #include > >>>> > >>>> int main(); > >>>> > >>>> #define DEV "/dev/ttyU0" > >>>> > >>>> #define TBAN_SER_SOURCE1 0x05 /* Primary source */ > >>>> #define TBAN_SER_SOURCE2 0x06 /* Alternative source (miniNG...) > >>>> */ > >>>> > >>>> #define TBAN_SER_REQUEST 0x36 > >>>> > >>>> int main() > >>>> { > >>>> int fd; > >>>> int result; > >>>> struct termios oldtio, newtio; > >>>> unsigned char buf[285]; > >>>> > >>>> printf("Opening device\n"); > >>>> fd=open(DEV, O_RDWR | O_NOCTTY); > >>>> > >>>> if(fd<0) { > >>>> perror(DEV); > >>>> return 1; > >>>> } > >>>> > >>>> result=tcgetattr(fd,&oldtio); > >>>> if(result<0) { > >>>> perror("tcgetattr"); > >>>> return 1; > >>>> } > >>>> > >>>> memcpy(&newtio,&oldtio,sizeof(struct termios)); > >>>> newtio.c_cflag = B19200 > >>>> > >>>> | CRTSCTS > >>>> | CS8 > >>>> | CREAD; > >>>> > >>>> newtio.c_iflag = IGNPAR; > >>>> newtio.c_oflag = 0; > >>>> newtio.c_lflag = 0; > >>>> newtio.c_cc[VMIN] = 1; > >>>> newtio.c_cc[VTIME] = 0; > >>>> > >>>> result=tcflush(fd, TCIFLUSH); > >>>> if(result<0) { > >>>> perror("tcflush"); > >>>> return 1; > >>>> } > >>>> > >>>> result=tcsetattr(fd,TCSANOW,&newtio); > >>>> if(result<0) { > >>>> perror("tcsetattr"); > >>>> return 1; > >>>> } > >>>> > >>>> sleep(1); > >>>> > >>>> printf("Performing initial query\n"); > >>>> buf[0]=TBAN_SER_SOURCE1; > >>>> buf[1]=TBAN_SER_REQUEST; > >>>> > >>>> printf("Requesting status\n"); > >>>> result=write(fd,buf,2); > >>>> if(result<0) { > >>>> perror("write"); > >>>> return 1; > >>>> } > >>>> > >>>> sleep(1); > >>>> > >>>> printf("Reading status\n"); > >>>> result=read(fd,buf,32); > >>>> if(result<0) { > >>>> perror("read"); > >>>> return 1; > >>>> } > >>>> > >>>> result=tcsetattr(fd,TCSANOW,&oldtio); > >>>> if(result<0) { > >>>> perror("tcsetattr"); > >>>> return 1; > >>>> } > >>>> > >>>> result=close(fd); > >>>> if(result<0) { > >>>> perror("close"); > >>>> return 1; > >>>> } > >>>> return 0; > >>>> } > >>>> > >>>> It hangs while reading independently of the number of bits I am > >>>> reading. > >>>> > >>>> Here is the output from dmesg when I load the uftdi module: > >>>> Sep 20 21:31:31 ldaemon kernel: uftdi0: on usbus6 > >>>> Sep 20 21:31:31 ldaemon kernel: ucom_attach_tty:317: tp = > >>>> 0xffffff001f12b400, unit = 0 Sep 20 21:31:31 ldaemon kernel: > >>>> ucom_attach_tty:346: ttycreate: U0 Sep 20 21:31:34 ldaemon root: > >>>> Unknown USB device: vendor 0x051d product 0x0002 bus uhub0 > >>>> > >>>> Here is the output in /var/log/messages when I enable the debug output > >>>> for ucom and uftdi: Sep 20 21:33:30 ldaemon kernel: ucom_open:554: tp > >>>> = 0xffffff001f12b400 Sep 20 21:33:30 ldaemon kernel: ucom_dtr:827: > >>>> onoff = 1 Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: > >>>> on=0x01, off=0x00 Sep 20 21:33:30 ldaemon kernel: ucom_rts:838: onoff > >>>> = 1 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_break:816: onoff = 0 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x00, off=0x04 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_status_change:901: > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_param:950: sc = > >>>> 0xffffff001f12ac58 Sep 20 21:33:30 ldaemon kernel: > >>>> uftdi_pre_param:653: > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_dtr:827: onoff = 1 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x01, off=0x00 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_rts:838: onoff = 1 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_cfg_open:520: > >>>> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_open:354: > >>>> Sep 20 21:33:30 ldaemon kernel: uftdi_read_callback:459: status change > >>>> msr=0xf0 (0x00) lsr=0x60 (0x00) Sep 20 21:33:30 ldaemon kernel: > >>>> ucom_status_change:901: > >>>> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_get_status:705: msr=0xf0 > >>>> lsr=0x60 Sep 20 21:33:30 ldaemon kernel: ucom_cfg_status_change:887: > >>>> DCD changed to 1 Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_param:672: > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x402c7413 Sep > >>>> 20 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 Sep 20 > >>>> 21:33:30 ldaemon kernel: ucom_ioctl:653: cmd = 0x802c7414 Sep 20 > >>>> 21:33:30 ldaemon kernel: ucom_param:950: sc = 0xffffff001f12ac58 Sep > >>>> 20 21:33:30 ldaemon kernel: uftdi_pre_param:653: > >>>> Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_get_status:705: msr=0xf0 > >>>> lsr=0x60 Sep 20 21:33:30 ldaemon kernel: uftdi_cfg_param:672: > >>>> Sep 20 21:33:30 ldaemon kernel: ucom_get_data:1064: cnt=0 > >>>> Sep 20 21:33:31 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 > >>>> Sep 20 21:33:32 ldaemon kernel: ucom_outwakeup:1009: sc = > >>>> 0xffffff001f12ac58 Sep 20 21:33:32 ldaemon kernel: ucom_get_data:1064: > >>>> cnt=2 > >>>> Sep 20 21:33:32 ldaemon kernel: ucom_get_data:1064: cnt=0 > >>>> > >>>> I really need to get this working so I am ready to test things as much > >>>> as I can... > >>> > >>> Hi, > >>> > >>> You need to set raw mode for the TTY device I think. Maybe Ed can give > >>> you the function name you need to call to do that? > >>> > >>> --HPS > >> > >> Do I need to do something like that? > >> ioctl(fileno(stdin), TIOCGETP, &tty_org); > >> tty = tty_org; > >> > >> /* set terminal to raw mode ... */ > >> tty.sg_flags |= CRMOD; > >> tty.sg_flags &= ~ECHO; > >> tty.sg_flags &= ~XTABS; > >> tty.sg_flags |= RAW; > >> > >> Thanks! > >> Pierre-Luc Drouin > > > > Hi, > > > > You need to call this function: > > > > void > > cfmakeraw(struct termios *t); > > > > --HPS > > Hi, > > it still does not work. I have added the line > cfmakeraw(&newtio); > > just before the call to tcflush and I get the following output in > /var/log/messages: > Sep 21 13:38:46 ldaemon kernel: ucom_open:554: tp = 0xffffff001f12b400 > Sep 21 13:38:46 ldaemon kernel: ucom_dtr:827: onoff = 1 > Sep 21 13:38:46 ldaemon kernel: ucom_line_state:799: on=0x01, off=0x00 > Sep 21 13:38:46 ldaemon kernel: ucom_rts:838: onoff = 1 > Sep 21 13:38:46 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > Sep 21 13:38:46 ldaemon kernel: ucom_break:816: onoff = 0 > Sep 21 13:38:46 ldaemon kernel: ucom_line_state:799: on=0x00, off=0x04 > Sep 21 13:38:46 ldaemon kernel: ucom_status_change:901: > Sep 21 13:38:46 ldaemon kernel: ucom_param:950: sc = 0xffffff001f12ac58 > Sep 21 13:38:46 ldaemon kernel: uftdi_pre_param:653: > Sep 21 13:38:46 ldaemon kernel: ucom_dtr:827: onoff = 1 > Sep 21 13:38:46 ldaemon kernel: ucom_line_state:799: on=0x01, off=0x00 > Sep 21 13:38:46 ldaemon kernel: ucom_rts:838: onoff = 1 > Sep 21 13:38:46 ldaemon kernel: ucom_line_state:799: on=0x02, off=0x00 > Sep 21 13:38:46 ldaemon kernel: ucom_cfg_open:520: > Sep 21 13:38:46 ldaemon kernel: uftdi_cfg_open:354: > uftdi_cfg_get_status:705: msr=0xf0 lsr=0x60 > Sep 21 13:38:46 ldaemon kernel: ucom_cfg_status_change:887: DCD changed to > 1 Sep 21 13:38:46 ldaemon kernel: uftdi_cfg_param:672: > Sep 21 13:38:46 ldaemon kernel: ucom_ioctl:653: cmd = 0x402c7413 > Sep 21 13:38:46 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 > Sep 21 13:38:46 ldaemon kernel: ucom_ioctl:653: cmd = 0x802c7414 > Sep 21 13:38:46 ldaemon kernel: ucom_param:950: sc = 0xffffff001f12ac58 > Sep 21 13:38:46 ldaemon kernel: uftdi_pre_param:653: > Sep 21 13:38:46 ldaemon kernel: uftdi_cfg_param:672: > Sep 21 13:38:46 ldaemon kernel: ucom_get_data:1064: cnt=0 > Sep 21 13:38:47 ldaemon kernel: ucom_ioctl:653: cmd = 0x80047410 > Sep 21 13:38:48 ldaemon kernel: ucom_outwakeup:1009: sc = > 0xffffff001f12ac58 Sep 21 13:38:48 ldaemon kernel: ucom_get_data:1064: > cnt=2 > Sep 21 13:38:48 ldaemon kernel: ucom_get_data:1064: cnt=0 > Can you try adding a delay after setting the baud rate? --HPS