public inbox for ecos-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug 1001392] New: Generic 16x5x driver misses Rx timeout condition on LPC1765
@ 2011-11-24 14:41 bugzilla-daemon
  2012-02-07 10:18 ` [Bug 1001392] " bugzilla-daemon
  0 siblings, 1 reply; 3+ messages in thread
From: bugzilla-daemon @ 2011-11-24 14:41 UTC (permalink / raw)
  To: unassigned

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001392

           Summary: Generic 16x5x driver misses Rx timeout condition on
                    LPC1765
           Product: eCos
           Version: 3.0
          Platform: All
        OS/Version: Other
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: low
         Component: Serial
        AssignedTo: unassigned@bugs.ecos.sourceware.org
        ReportedBy: bernard.fouche@kuantic.com
                CC: ecos-bugs@ecos.sourceware.org
             Class: Advice Request


Hello.

I've found an issue with the generic 16x5x serial driver while working
with a NXP LPC1765. The situation is the following: I'm doing the
usual program/flash/debug cycle. I work with eCos from CVS.

In some circumstances, I halt the target while there are pending
bytes in the Rx FIFO of a channel of the serial controller.

Then I 'soft reset' (using OpenOCD) the target to rerun the software
(of after reflashing code). At that point the serial driver may fall
in a never ending loop there (from
devs/serial/generic/16x5x/current/src/ser_16x5x.c):

    SER_16X5X_READ_ISR(base, _isr);
    while ((_isr & ISR_nIP) == 0) {
        switch (_isr&0xE) {
        case ISR_Rx:
        case ISR_RxTO:
        {
            cyg_uint8 _lsr;
            unsigned char c;
            HAL_READ_UINT8(base+REG_lsr, _lsr);
            while(_lsr & LSR_RSR) {
                HAL_READ_UINT8(base+REG_rhr, c);
                (chan->callbacks->rcv_char)(chan, c);
                HAL_READ_UINT8(base+REG_lsr, _lsr);
            }
            break;
        }
     ... more code ...

The code above assumes that the timeout condition (case ISR_RxTO) implies that
(_lsr & LSR_RSR) is also true, while with the LPC1765, I'm able to get a
timeout but ( _lsr & LSR_RSR) is false.

Here is _isr (aka IIR: Interrupt Indication Register) (on LPC1765
there are 4 bytes between each register, hence the x4 multiplier):

#define REG_isr SER_REG(2)    // Interrupt status register
#define REG_lsr SER_REG(5)    // Line status register

(gdb) printf "0x%08X=%X\n",base+(4*2),*(base+(4*2))
0x4009C008=CC

The lower byte (0x0C) shows:

- interrupt flag set (bit 0 value is 0)
- Character Time-out Indicator (bits 1-3: 110)

Here is _lsr:

(gdb) printf "0x%08X=%X\n",base+(4*5),*(base+(4*5))
0x4009C014=60

Bit 0 is zero: no character is ready for reading...

However emptying the Rx FIFO will reset the timeout condition.

If I manually read the data register...

(gdb) printf "0x%08X=%X\n",base+(4*0),*(base+(4*0))
0x4009C000=0

then the timeout condition is removed:

(gdb) printf "0x%08X=%X\n",base+(4*2),*(base+(4*2))
0x4009C008=C1

There are many different chips based on the 16550 design, with many
different bugs. It's difficult to know if this is a MCU bug or a
'feature' since I found no datasheet, whatever the manufacturer, explicitely
stating that a rx timeout condition must also raise bit 0 of LSR.

The proposed fix is very simple, just change de while() loop to a
do()while loop, to always read at least a byte from the FIFO :

    while ((_isr & ISR_nIP) == 0) {
        switch (_isr&0xE) {
        case ISR_Rx:
        case ISR_RxTO:
        {
            cyg_uint8 _lsr;
            unsigned char c;
            do{
                HAL_READ_UINT8(base+REG_rhr, c);
                (chan->callbacks->rcv_char)(chan, c);
                HAL_READ_UINT8(base+REG_lsr, _lsr);
            }
            while(_lsr & LSR_RSR);
            break;
        }

It's even a bit quicker if a single byte is in the FIFO because _lsr is updated
only once.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug 1001392] Generic 16x5x driver misses Rx timeout condition on LPC1765
  2011-11-24 14:41 [Bug 1001392] New: Generic 16x5x driver misses Rx timeout condition on LPC1765 bugzilla-daemon
@ 2012-02-07 10:18 ` bugzilla-daemon
  0 siblings, 0 replies; 3+ messages in thread
From: bugzilla-daemon @ 2012-02-07 10:18 UTC (permalink / raw)
  To: unassigned

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001392

Bernard Fouché <bernard.fouche@kuantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Bernard Fouché <bernard.fouche@kuantic.com> 2012-02-07 10:18:29 GMT ---
Wrong diagnostic (and wrong fix, LSR must always be read before RHR).

The bug is at init time: init routine clears FIFO but do not clear Overrun
Error by reading RHR (the only way to remove the Overrun Error as stated in
NS/TI 16550D datasheet): bug isn't a LPC17XX specific bug because of this.

New bug description and patch in bug #1001475.

*** This bug has been marked as a duplicate of bug 1001475 ***

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
>From ecos-bugs-return-8779-listarch-ecos-bugs=sources.redhat.com@sourceware.org Tue Feb 07 10:18:54 2012
Return-Path: <ecos-bugs-return-8779-listarch-ecos-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-ecos-bugs@sources.redhat.com
Received: (qmail 11856 invoked by alias); 7 Feb 2012 10:18:52 -0000
Received: (qmail 11831 invoked by uid 22791); 7 Feb 2012 10:18:51 -0000
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0
	tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197)
    by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Feb 2012 10:18:35 +0000
Received: from localhost (hagrid.ecoscentric.com [127.0.0.1])
	by mail.ecoscentric.com (Postfix) with ESMTP id CDC972F78009
	for <ecos-bugs@ecos.sourceware.org>; Tue,  7 Feb 2012 10:18:34 +0000 (GMT)
Received: from mail.ecoscentric.com ([127.0.0.1])
	by localhost (hagrid.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 7sC50Nm0tqPE; Tue,  7 Feb 2012 10:18:34 +0000 (GMT)
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: ecos-bugs@ecos.sourceware.org
Subject: [Bug 1001475] Generic 16x5x driver do not clear overrun error at
 boot
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: eCos
X-Bugzilla-Component: Serial
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bernard.fouche@kuantic.com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: low
X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
In-Reply-To: <bug-1001475-13@http.bugs.ecos.sourceware.org/>
References: <bug-1001475-13@http.bugs.ecos.sourceware.org/>
X-Bugzilla-URL: http://bugs.ecos.sourceware.org/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Date: Tue, 07 Feb 2012 10:18:00 -0000
Message-Id: <20120207101833.738632F7800A@mail.ecoscentric.com>
Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <ecos-bugs.sourceware.org>
List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org>
List-Post: <mailto:ecos-bugs@sourceware.org>
List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: ecos-bugs-owner@sourceware.org
Delivered-To: mailing list ecos-bugs@sourceware.org
X-SW-Source: 2012/txt/msg00208.txt.bz2
Content-length: 465

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001475

--- Comment #1 from Bernard Fouché <bernard.fouche@kuantic.com> 2012-02-07 10:18:29 GMT ---
*** Bug 1001392 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
>From ecos-bugs-return-8780-listarch-ecos-bugs=sources.redhat.com@sourceware.org Tue Feb 07 10:18:55 2012
Return-Path: <ecos-bugs-return-8780-listarch-ecos-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-ecos-bugs@sources.redhat.com
Received: (qmail 11934 invoked by alias); 7 Feb 2012 10:18:53 -0000
Received: (qmail 11863 invoked by uid 22791); 7 Feb 2012 10:18:52 -0000
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0
	tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197)
    by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Feb 2012 10:18:35 +0000
Received: by mail.ecoscentric.com (Postfix, from userid 48)
	id BFFE92F78008; Tue,  7 Feb 2012 10:18:34 +0000 (GMT)
X-Original-To: unassigned@bugs.ecos.sourceware.org
Delivered-To: unassigned@bugs.ecos.sourceware.org
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: unassigned@bugs.ecos.sourceware.org
Subject: [Bug 1001475] Generic 16x5x driver do not clear overrun error at
 boot
X-Bugzilla-Reason: AssignedTo
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: eCos
X-Bugzilla-Component: Serial
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bernard.fouche@kuantic.com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: low
X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields:
In-Reply-To: <bug-1001475-777@http.bugs.ecos.sourceware.org/>
References: <bug-1001475-777@http.bugs.ecos.sourceware.org/>
X-Bugzilla-URL: http://bugs.ecos.sourceware.org/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Date: Tue, 07 Feb 2012 10:18:00 -0000
Message-Id: <20120207101833.3E45C2F78009@mail.ecoscentric.com>
Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <ecos-bugs.sourceware.org>
List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org>
List-Post: <mailto:ecos-bugs@sourceware.org>
List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: ecos-bugs-owner@sourceware.org
Delivered-To: mailing list ecos-bugs@sourceware.org
X-SW-Source: 2012/txt/msg00209.txt.bz2
Content-length: 463

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001475

--- Comment #1 from Bernard Fouché <bernard.fouche@kuantic.com> 2012-02-07 10:18:29 GMT ---
*** Bug 1001392 has been marked as a duplicate of this bug. ***

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
>From ecos-bugs-return-8777-listarch-ecos-bugs=sources.redhat.com@sourceware.org Tue Feb 07 10:18:48 2012
Return-Path: <ecos-bugs-return-8777-listarch-ecos-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-ecos-bugs@sources.redhat.com
Received: (qmail 11764 invoked by alias); 7 Feb 2012 10:18:47 -0000
Received: (qmail 11756 invoked by uid 22791); 7 Feb 2012 10:18:47 -0000
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0
	tests=AWL,BAYES_00
X-Spam-Check-By: sourceware.org
Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197)
    by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Feb 2012 10:18:35 +0000
Received: from localhost (hagrid.ecoscentric.com [127.0.0.1])
	by mail.ecoscentric.com (Postfix) with ESMTP id 1D4972F7800C
	for <ecos-bugs@ecos.sourceware.org>; Tue,  7 Feb 2012 10:18:34 +0000 (GMT)
Received: from mail.ecoscentric.com ([127.0.0.1])
	by localhost (hagrid.ecoscentric.com [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id hoFXctZbHmcL; Tue,  7 Feb 2012 10:18:33 +0000 (GMT)
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: ecos-bugs@ecos.sourceware.org
Subject: [Bug 1001392] Generic 16x5x driver misses Rx timeout condition on
 LPC1765
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: eCos
X-Bugzilla-Component: Serial
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: bernard.fouche@kuantic.com
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: low
X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Status Resolution
In-Reply-To: <bug-1001392-13@http.bugs.ecos.sourceware.org/>
References: <bug-1001392-13@http.bugs.ecos.sourceware.org/>
X-Bugzilla-URL: http://bugs.ecos.sourceware.org/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Date: Tue, 07 Feb 2012 10:18:00 -0000
Message-Id: <20120207101832.EE3A02F78008@mail.ecoscentric.com>
Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <ecos-bugs.sourceware.org>
List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org>
List-Post: <mailto:ecos-bugs@sourceware.org>
List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: ecos-bugs-owner@sourceware.org
Delivered-To: mailing list ecos-bugs@sourceware.org
X-SW-Source: 2012/txt/msg00206.txt.bz2
Content-length: 1119

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001392

Bernard Fouché <bernard.fouche@kuantic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Bernard Fouché <bernard.fouche@kuantic.com> 2012-02-07 10:18:29 GMT ---
Wrong diagnostic (and wrong fix, LSR must always be read before RHR).

The bug is at init time: init routine clears FIFO but do not clear Overrun
Error by reading RHR (the only way to remove the Overrun Error as stated in
NS/TI 16550D datasheet): bug isn't a LPC17XX specific bug because of this.

New bug description and patch in bug #1001475.

*** This bug has been marked as a duplicate of bug 1001475 ***

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
>From ecos-bugs-return-8781-listarch-ecos-bugs=sources.redhat.com@sourceware.org Tue Feb 07 19:26:42 2012
Return-Path: <ecos-bugs-return-8781-listarch-ecos-bugs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-ecos-bugs@sources.redhat.com
Received: (qmail 12513 invoked by alias); 7 Feb 2012 19:26:40 -0000
Received: (qmail 12493 invoked by uid 22791); 7 Feb 2012 19:26:39 -0000
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0
	tests=AWL,BAYES_00,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Received: from hagrid.ecoscentric.com (HELO mail.ecoscentric.com) (212.13.207.197)
    by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Feb 2012 19:26:23 +0000
Received: by mail.ecoscentric.com (Postfix, from userid 48)
	id 31BA22F78004; Tue,  7 Feb 2012 19:26:22 +0000 (GMT)
X-Original-To: unassigned@bugs.ecos.sourceware.org
Delivered-To: unassigned@bugs.ecos.sourceware.org
From: bugzilla-daemon@bugs.ecos.sourceware.org
To: unassigned@bugs.ecos.sourceware.org
Subject: [Bug 1001450] Kinetis HAL and driver upgrade
X-Bugzilla-Reason: AssignedTo
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: eCos
X-Bugzilla-Component: Patches and contributions
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: ilijak@siva.com.mk
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: low
X-Bugzilla-Assigned-To: unassigned@bugs.ecos.sourceware.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Changed-Fields: Attachment #1504 is obsolete
In-Reply-To: <bug-1001450-777@http.bugs.ecos.sourceware.org/>
References: <bug-1001450-777@http.bugs.ecos.sourceware.org/>
X-Bugzilla-URL: http://bugs.ecos.sourceware.org/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
Date: Tue, 07 Feb 2012 19:26:00 -0000
Message-Id: <20120207192616.08ED02F78006@mail.ecoscentric.com>
Mailing-List: contact ecos-bugs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <ecos-bugs.sourceware.org>
List-Subscribe: <mailto:ecos-bugs-subscribe@sourceware.org>
List-Post: <mailto:ecos-bugs@sourceware.org>
List-Help: <mailto:ecos-bugs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: ecos-bugs-owner@sourceware.org
Delivered-To: mailing list ecos-bugs@sourceware.org
X-SW-Source: 2012/txt/msg00210.txt.bz2
Content-length: 812

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id\x1001450

Ilija Kocho <ilijak@siva.com.mk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #1504|0                           |1
        is obsolete|                            |

--- Comment #12 from Ilija Kocho <ilijak@siva.com.mk> 2012-02-07 19:26:12 GMT ---
Created an attachment (id\x1553)
 --> (http://bugs.ecos.sourceware.org/attachment.cgi?id\x1553)
Ethernet driver Freescale ENET - Add Redboot ESA support 120206

--
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug 1001392] New: Generic 16x5x driver misses Rx timeout condition on LPC1765
@ 2011-11-24 14:41 bugzilla-daemon
  0 siblings, 0 replies; 3+ messages in thread
From: bugzilla-daemon @ 2011-11-24 14:41 UTC (permalink / raw)
  To: ecos-bugs

Please do not reply to this email. Use the web interface provided at:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001392

           Summary: Generic 16x5x driver misses Rx timeout condition on
                    LPC1765
           Product: eCos
           Version: 3.0
          Platform: All
        OS/Version: Other
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: low
         Component: Serial
        AssignedTo: unassigned@bugs.ecos.sourceware.org
        ReportedBy: bernard.fouche@kuantic.com
                CC: ecos-bugs@ecos.sourceware.org
             Class: Advice Request


Hello.

I've found an issue with the generic 16x5x serial driver while working
with a NXP LPC1765. The situation is the following: I'm doing the
usual program/flash/debug cycle. I work with eCos from CVS.

In some circumstances, I halt the target while there are pending
bytes in the Rx FIFO of a channel of the serial controller.

Then I 'soft reset' (using OpenOCD) the target to rerun the software
(of after reflashing code). At that point the serial driver may fall
in a never ending loop there (from
devs/serial/generic/16x5x/current/src/ser_16x5x.c):

    SER_16X5X_READ_ISR(base, _isr);
    while ((_isr & ISR_nIP) == 0) {
        switch (_isr&0xE) {
        case ISR_Rx:
        case ISR_RxTO:
        {
            cyg_uint8 _lsr;
            unsigned char c;
            HAL_READ_UINT8(base+REG_lsr, _lsr);
            while(_lsr & LSR_RSR) {
                HAL_READ_UINT8(base+REG_rhr, c);
                (chan->callbacks->rcv_char)(chan, c);
                HAL_READ_UINT8(base+REG_lsr, _lsr);
            }
            break;
        }
     ... more code ...

The code above assumes that the timeout condition (case ISR_RxTO) implies that
(_lsr & LSR_RSR) is also true, while with the LPC1765, I'm able to get a
timeout but ( _lsr & LSR_RSR) is false.

Here is _isr (aka IIR: Interrupt Indication Register) (on LPC1765
there are 4 bytes between each register, hence the x4 multiplier):

#define REG_isr SER_REG(2)    // Interrupt status register
#define REG_lsr SER_REG(5)    // Line status register

(gdb) printf "0x%08X=%X\n",base+(4*2),*(base+(4*2))
0x4009C008=CC

The lower byte (0x0C) shows:

- interrupt flag set (bit 0 value is 0)
- Character Time-out Indicator (bits 1-3: 110)

Here is _lsr:

(gdb) printf "0x%08X=%X\n",base+(4*5),*(base+(4*5))
0x4009C014=60

Bit 0 is zero: no character is ready for reading...

However emptying the Rx FIFO will reset the timeout condition.

If I manually read the data register...

(gdb) printf "0x%08X=%X\n",base+(4*0),*(base+(4*0))
0x4009C000=0

then the timeout condition is removed:

(gdb) printf "0x%08X=%X\n",base+(4*2),*(base+(4*2))
0x4009C008=C1

There are many different chips based on the 16550 design, with many
different bugs. It's difficult to know if this is a MCU bug or a
'feature' since I found no datasheet, whatever the manufacturer, explicitely
stating that a rx timeout condition must also raise bit 0 of LSR.

The proposed fix is very simple, just change de while() loop to a
do()while loop, to always read at least a byte from the FIFO :

    while ((_isr & ISR_nIP) == 0) {
        switch (_isr&0xE) {
        case ISR_Rx:
        case ISR_RxTO:
        {
            cyg_uint8 _lsr;
            unsigned char c;
            do{
                HAL_READ_UINT8(base+REG_rhr, c);
                (chan->callbacks->rcv_char)(chan, c);
                HAL_READ_UINT8(base+REG_lsr, _lsr);
            }
            while(_lsr & LSR_RSR);
            break;
        }

It's even a bit quicker if a single byte is in the FIFO because _lsr is updated
only once.

-- 
Configure bugmail: http://bugs.ecos.sourceware.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-02-07 10:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-24 14:41 [Bug 1001392] New: Generic 16x5x driver misses Rx timeout condition on LPC1765 bugzilla-daemon
2012-02-07 10:18 ` [Bug 1001392] " bugzilla-daemon
  -- strict thread matches above, loose matches on Subject: below --
2011-11-24 14:41 [Bug 1001392] New: " bugzilla-daemon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).